Merged revisions 3089-3138 from 1.7 branch. Full merge, all changes from 1.7 beta phase up to now are included.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3139 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2010-01-08 11:46:38 +00:00
parent 9b3f9590f0
commit 0ca3ba3744
93 changed files with 1752 additions and 489 deletions

View File

@ -1,5 +1,7 @@
Changes in 1.7
- ITimer no longer stops when started twice
- Add hasType to IGUIElement as a dynamic_cast substitute.
- Add another parameter to IGUISkin::draw3DWindowBackground to allow getting the client area without actually drawing
@ -28,7 +30,7 @@ Changes in 1.7
- Add OBJ_TEXTURE_PATH and B3D_TEXTURE_PATH to SceneParameters to allow setting texture-paths for obj and b3d.
- Irrlicht keeps now filenames additionaly to the internally used names, thereby fixing some problems with uppercase-filenames on Linux.
- Irrlicht keeps now filenames additionally to the internally used names, thereby fixing some problems with uppercase-filenames on Linux.
- Bugfix: Mousewheel no longer sends EMIE_MOUSE_WHEEL messages twice on Linux.
@ -58,7 +60,7 @@ Changes in 1.7
- Double and triple click events now for each mouse-button. Old events for that got removed.
- Fix adding archives twice, which caused multiple archives of the same name and type covering each other. This one required a texture name change from using backslashes to slahes under Windows.
- Fix adding archives twice, which caused multiple archives of the same name and type covering each other. This one required a texture name change from using backslashes to slashes under Windows.
- Give access to texture mipmaps. You can provide custom mipmap textures upon generation, regeneration, and locking.
Make sure the provided data is large enough and covers all miplevels. Also the returned pointer (from lock) will only cover the smaller data of the mipmap level dimension chosen (level 0 is the original texture).
@ -69,7 +71,7 @@ Changes in 1.7
- windows show now active/inactive state
- remove unneed drop/grab calls found by manik_sheeri
- remove unneeded drop/grab calls found by manik_sheeri
- fix rounding problem in IGUIElements which have EGUIA_SCALE alignments.
@ -115,13 +117,13 @@ Changes in 1.7
- Bounding Box updates for skinned meshes fixed
- The current FPS for an animated scene node cn be queried now, added some variables to serialization
- The current FPS for an animated scene node can be queried now, added some variables to serialization
- Scrollbars fixed
- Fixed 2d vertex primitive method to correctly handle transparency
- Fullscreen handling has been ehanced for Windows, now proper resolution is restored on Alt-Tab etc.
- Fullscreen handling has been enhanced for Windows, now proper resolution is restored on Alt-Tab etc.
- Cameras can now be added to the scene node without automatically activating them
Clone method added
@ -147,6 +149,12 @@ Changes in 1.7
----------------
Changes in 1.6.1
- Fix pingpong for CSceneNodeAnimatorFlyStraight (found by gbox)
- Fix bug with IGUIEditBox where the cursor position is reset on text change.
- Make sure the window top-left corner on Windows is not negative on start so that Windows sytem-menu is always visible.
- Fix problem that the window did sometimes not get the keyboard focus in X11 in fullscreen. Add more debug output in case focus grabbing goes wrong.
- Fix screensize in videodriver when we didn't get the requested window size. This also prevents that gui-clicks are no longer synchronized with gui-drawing and elements can't be hit anymore.

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Version="9,00"
Name="14.Win32Window_vc9"
ProjectGUID="{772FBE05-D05A-467B-9842-BEC409EEA8D0}"
RootNamespace="Win32Window_vc9"
@ -72,7 +72,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib user32.lib gdi32.lib"
AdditionalDependencies="kernel32.lib user32.lib gdi32.lib opengl32.lib"
OutputFile="..\..\bin\Win32-VisualStudio\14.Win32Window.exe"
LinkIncremental="0"
SuppressStartupBanner="true"
@ -164,6 +164,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="opengl32.lib"
OutputFile="..\..\bin\Win32-VisualStudio\14.Win32Window.exe"
LinkIncremental="0"
SuppressStartupBanner="true"

View File

@ -0,0 +1,182 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="17.HelloWorld for Windows Mobile on PC"
ProjectGUID="{2A29B6B1-AFC4-46C7-9944-7052AAE66F7B}"
RootNamespace="My17HelloWorldforWindowsMobileonPC"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="..\..\bin\Win32-VisualStudio\17.HelloWorld_Mobile on PC.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
GenerateDebugInformation="true"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
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="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="..\..\bin\Win32-VisualStudio\17.HelloWorld_Mobile on PC.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<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>
<File
RelativePath=".\main.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -134,9 +134,9 @@ IrrlichtDevice *startup()
wchar_t buf[255];
GetModuleFileNameW ( 0, buf, 255 );
string<c16> base = buf;
io::path base = buf;
base = base.subString ( 0, base.findLast ( '\\' ) + 1 );
device->getFileSystem()->registerFileArchive ( base );
device->getFileSystem()->addFileArchive ( base );
}
#endif

View File

@ -128,7 +128,7 @@
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="0"
CallingConvention="1"
CallingConvention="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -73,7 +73,7 @@ VideoDriver, load an animated mesh from .md2 and a map from
.pk3. Because that's old stuff, I won't explain every step.
Just take care of the maps position.
*/
int main()
int main(int argc, char** argv)
{
video::E_DRIVER_TYPE driverType;

View File

@ -290,7 +290,7 @@ const SItemElement * getItemElement ( const stringc& key )
{
const SItemElement *item = Quake3ItemElement;
while ( item->key[0] )
while ( item->key )
{
if ( 0 == strcmp ( key.c_str(), item->key ) )
return item;

View File

@ -3,7 +3,7 @@
ProjectType="Visual C++"
Version="9.00"
Name="22.MaterialViewer_vc9"
ProjectGUID="{0914E5C8-5352-467B-8421-C9EB35BD5596}"
ProjectGUID="{4E6C2F8D-BA92-4C5B-96FD-72D4FE8BD7FA}"
RootNamespace="MaterialViewer_vc9"
TargetFrameworkVersion="131072"
>

View File

@ -123,12 +123,11 @@
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..\..\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="0"
BufferSecurityCheck="false"
ExceptionHandling="1"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="0"
CallingConvention="1"
CallingConvention="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -324,7 +324,7 @@ up a mesh from a heightmap, light it with a moving light, and allow
the user to navigate around it.
*/
int main()
int main(int argc, char* argv[])
{
// ask user for driver
video::E_DRIVER_TYPE driverType;

View File

@ -89,12 +89,54 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "16.Quake3MapShader_vc9", "1
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "18.SplitScreen_vc9", "18.SplitScreen\SplitScreen_vc9.vcproj", "{1AB9413E-4F53-42A3-8CB2-CB4BE22336D0}"
ProjectSection(ProjectDependencies) = postProject
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "19.MouseAndJoystick_vc9", "19.MouseAndJoystick\MouseAndJoystick_vc9.vcproj", "{FE853A36-E0D1-4AC5-A792-B643E70D2953}"
ProjectSection(ProjectDependencies) = postProject
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "20.ManagedLights_vc9", "20.ManagedLights\ManagedLights_vc9.vcproj", "{16007FE2-142B-47F8-93E1-519BA3F39E71}"
ProjectSection(ProjectDependencies) = postProject
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "21.Quake3Explorer_vc9", "21.Quake3Explorer\Quake3Explorer_vc9.vcproj", "{CDC4AAA9-72E1-4FFA-A04D-7EF59D8B97CD}"
ProjectSection(ProjectDependencies) = postProject
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "22.MaterialViewer_vc9", "22.MaterialViewer\MaterialViewer_vc9.vcproj", "{4E6C2F8D-BA92-4C5B-96FD-72D4FE8BD7FA}"
ProjectSection(ProjectDependencies) = postProject
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "23.SMeshHandling_vc9", "23.SMeshHandling\SMeshHandling_vc9.vcproj", "{6AEC2AA2-C9FF-4B7D-B07A-94A9D34B41D7}"
ProjectSection(ProjectDependencies) = postProject
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "17.HelloWorld for Windows Mobile on PC", "17.HelloWorld_Mobile\17. HelloWorld for Windows Mobile on PC_v9.vcproj", "{2A29B6B1-AFC4-46C7-9944-7052AAE66F7B}"
ProjectSection(ProjectDependencies) = postProject
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GUI Editor_v9", "..\tools\GUIEditor\GUI Editor_v9.vcproj", "{853A396E-C031-4C26-A716-5B4E176BE11D}"
ProjectSection(ProjectDependencies) = postProject
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Font Tool", "..\tools\IrrFontTool\newFontTool\irrFontTool_v9.vcproj", "{4D53E40F-37E3-42B1-8848-F4C6F8313A17}"
ProjectSection(ProjectDependencies) = postProject
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Mesh Converter", "..\tools\MeshConverter\MeshConverter_v9.vcproj", "{E72B637E-4AA6-46F3-885F-AC67B4B470ED}"
ProjectSection(ProjectDependencies) = postProject
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -164,8 +206,8 @@ Global
{78C9F424-523C-49AC-94B7-823AA4A26BF9}.Release|Win32.Build.0 = Release|Win32
{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 - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|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
{6F076455-D955-45D4-9C68-4AD4E45F2D47}.Debug|Win32.ActiveCfg = Debug|Win32
{6F076455-D955-45D4-9C68-4AD4E45F2D47}.Debug|Win32.Build.0 = Debug|Win32
{6F076455-D955-45D4-9C68-4AD4E45F2D47}.Release|Win32.ActiveCfg = Release|Win32
@ -190,6 +232,30 @@ Global
{CDC4AAA9-72E1-4FFA-A04D-7EF59D8B97CD}.Debug|Win32.Build.0 = Debug|Win32
{CDC4AAA9-72E1-4FFA-A04D-7EF59D8B97CD}.Release|Win32.ActiveCfg = Release|Win32
{CDC4AAA9-72E1-4FFA-A04D-7EF59D8B97CD}.Release|Win32.Build.0 = Release|Win32
{4E6C2F8D-BA92-4C5B-96FD-72D4FE8BD7FA}.Debug|Win32.ActiveCfg = Debug|Win32
{4E6C2F8D-BA92-4C5B-96FD-72D4FE8BD7FA}.Debug|Win32.Build.0 = Debug|Win32
{4E6C2F8D-BA92-4C5B-96FD-72D4FE8BD7FA}.Release|Win32.ActiveCfg = Release|Win32
{4E6C2F8D-BA92-4C5B-96FD-72D4FE8BD7FA}.Release|Win32.Build.0 = Release|Win32
{6AEC2AA2-C9FF-4B7D-B07A-94A9D34B41D7}.Debug|Win32.ActiveCfg = Debug|Win32
{6AEC2AA2-C9FF-4B7D-B07A-94A9D34B41D7}.Debug|Win32.Build.0 = Debug|Win32
{6AEC2AA2-C9FF-4B7D-B07A-94A9D34B41D7}.Release|Win32.ActiveCfg = Release|Win32
{6AEC2AA2-C9FF-4B7D-B07A-94A9D34B41D7}.Release|Win32.Build.0 = Release|Win32
{2A29B6B1-AFC4-46C7-9944-7052AAE66F7B}.Debug|Win32.ActiveCfg = Debug|Win32
{2A29B6B1-AFC4-46C7-9944-7052AAE66F7B}.Debug|Win32.Build.0 = Debug|Win32
{2A29B6B1-AFC4-46C7-9944-7052AAE66F7B}.Release|Win32.ActiveCfg = Release|Win32
{2A29B6B1-AFC4-46C7-9944-7052AAE66F7B}.Release|Win32.Build.0 = Release|Win32
{853A396E-C031-4C26-A716-5B4E176BE11D}.Debug|Win32.ActiveCfg = Debug|Win32
{853A396E-C031-4C26-A716-5B4E176BE11D}.Debug|Win32.Build.0 = Debug|Win32
{853A396E-C031-4C26-A716-5B4E176BE11D}.Release|Win32.ActiveCfg = Release|Win32
{853A396E-C031-4C26-A716-5B4E176BE11D}.Release|Win32.Build.0 = Release|Win32
{4D53E40F-37E3-42B1-8848-F4C6F8313A17}.Debug|Win32.ActiveCfg = Debug|Win32
{4D53E40F-37E3-42B1-8848-F4C6F8313A17}.Debug|Win32.Build.0 = Debug|Win32
{4D53E40F-37E3-42B1-8848-F4C6F8313A17}.Release|Win32.ActiveCfg = Release|Win32
{4D53E40F-37E3-42B1-8848-F4C6F8313A17}.Release|Win32.Build.0 = Release|Win32
{E72B637E-4AA6-46F3-885F-AC67B4B470ED}.Debug|Win32.ActiveCfg = Debug|Win32
{E72B637E-4AA6-46F3-885F-AC67B4B470ED}.Debug|Win32.Build.0 = Debug|Win32
{E72B637E-4AA6-46F3-885F-AC67B4B470ED}.Release|Win32.ActiveCfg = Release|Win32
{E72B637E-4AA6-46F3-885F-AC67B4B470ED}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Version="9,00"
Name="Demo_vc9"
ProjectGUID="{6F076455-D955-45D4-9C68-4AD4E45F2D47}"
TargetFrameworkVersion="131072"
@ -48,7 +48,8 @@
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
InlineFunctionExpansion="0"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="..\..\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
StringPooling="true"

View File

@ -25,10 +25,7 @@ namespace scene
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
EJUOR_CONTROL
};

View File

@ -35,7 +35,7 @@ public:
//! Create a pseudo-random mesh representing a hilly terrain.
/**
\param tileSize The size of each time.
\param tileSize The size of each tile.
\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.
@ -50,6 +50,23 @@ public:
const core::dimension2d<f32>& countHills,
const core::dimension2d<f32>& textureRepeatCount) const =0;
//! Create a simple rectangular textured plane mesh.
/**
\param tileSize The size of each tile.
\param tileCount The number of tiles in each dimension.
\param material The material to apply to the mesh.
\param textureRepeatCount The number of times to repeat the material texture along each dimension.
\return Generated mesh.
*/
IMesh* createPlaneMesh(
const core::dimension2d<f32>& tileSize,
const core::dimension2d<u32>& tileCount,
video::SMaterial* material,
const core::dimension2d<f32>& textureRepeatCount)
{
return createHillPlaneMesh(tileSize, tileCount, material, 0.f, core::dimension2df(), textureRepeatCount);
}
//! Create a terrain mesh from an image representing a heightfield.
/**
\param texture The texture to apply to the terrain.

View File

@ -782,7 +782,7 @@ namespace quake3
textures.clear();
core::stringc loadFile;
io::path loadFile;
for ( u32 i = 0; i!= stringList.size (); ++i )
{
video::ITexture* texture = 0;

View File

@ -100,7 +100,7 @@ namespace video
/** 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;
const u32 tmp = (alphaSource << 12) | (modulate << 8) | (srcFact << 4) | dstFact;
return FR(tmp);
}
@ -110,10 +110,10 @@ namespace video
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 ) );
alphaSource = (state & 0x0000F000) >> 12;
modulo = E_MODULATE_FUNC( ( state & 0x00000F00 ) >> 8 );
srcFact = E_BLEND_FACTOR ( ( state & 0x000000F0 ) >> 4 );
dstFact = E_BLEND_FACTOR ( ( state & 0x0000000F ) );
}
//! EMT_ONETEXTURE_BLEND: has BlendFactor Alphablending

View File

@ -43,23 +43,6 @@ class aabbox3d
// 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.
@ -85,6 +68,23 @@ class aabbox3d
MinEdge = initValue;
}
//! 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);
}
//! 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.
@ -101,8 +101,102 @@ class aabbox3d
if (z<MinEdge.Z) MinEdge.Z = z;
}
//! 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 (maximal distance of two points in the box)
/** \return Extent of the bounding box. */
vector3d<T> getExtent() const
{
return MaxEdge - MinEdge;
}
//! 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 );
}
//! 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);
}
//! 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);
}
//! 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.
/** d=0 returns other, d=1 returns this, all other values blend between
the two boxes.
\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));
}
//! Determines if a point is within this box.
/** \param p: Point to check.
/** Border is included (IS part of the 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
{
@ -111,8 +205,9 @@ class aabbox3d
p.Z >= MinEdge.Z && p.Z <= MaxEdge.Z);
}
//! Determines if a point is within this box and its borders.
/** \param p: Point to check.
//! Determines if a point is within this box and not its borders.
/** Border is excluded (NOT part of the box)!
\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
{
@ -121,15 +216,6 @@ class aabbox3d
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,
@ -139,6 +225,15 @@ class aabbox3d
return MinEdge >= other.MinEdge && MaxEdge <= other.MaxEdge;
}
//! 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);
}
//! Tests if the box intersects with a line
/** \param line: Line to test intersection with.
\return True if there is an intersection , else false. */
@ -154,8 +249,7 @@ class aabbox3d
\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>& linevect, T halflength) const
{
const vector3d<T> e = getExtent() * (T)0.5;
const vector3d<T> t = getCenter() - linemiddle;
@ -217,103 +311,6 @@ class aabbox3d
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;

View File

@ -84,15 +84,15 @@ public:
//! Constructor
string(const string<T>& other)
string(const string<T,TAlloc>& other)
: array(0), allocated(0), used(0)
{
*this = other;
}
//! Constructor from other string types
template <class B>
string(const string<B>& other)
template <class B, class A>
string(const string<B, A>& other)
: array(0), allocated(0), used(0)
{
*this = other;
@ -227,7 +227,7 @@ public:
//! Assignment operator
string<T>& operator=(const string<T>& other)
string<T,TAlloc>& operator=(const string<T,TAlloc>& other)
{
if (this == &other)
return *this;
@ -248,8 +248,8 @@ public:
}
//! Assignment operator for other string types
template <class B>
string<T>& operator=(const string<B>& other)
template <class B, class A>
string<T,TAlloc>& operator=(const string<B,A>& other)
{
*this = other.c_str();
return *this;
@ -258,7 +258,7 @@ public:
//! Assignment operator for strings, ascii and unicode
template <class B>
string<T>& operator=(const B* const c)
string<T,TAlloc>& operator=(const B* const c)
{
if (!c)
{
@ -304,9 +304,9 @@ public:
//! Append operator for other strings
string<T> operator+(const string<T>& other) const
string<T,TAlloc> operator+(const string<T,TAlloc>& other) const
{
string<T> str(*this);
string<T,TAlloc> str(*this);
str.append(other);
return str;
@ -315,9 +315,9 @@ public:
//! Append operator for strings, ascii and unicode
template <class B>
string<T> operator+(const B* const c) const
string<T,TAlloc> operator+(const B* const c) const
{
string<T> str(*this);
string<T,TAlloc> str(*this);
str.append(c);
return str;
@ -356,7 +356,7 @@ public:
//! Equality operator
bool operator ==(const string<T>& other) const
bool operator ==(const string<T,TAlloc>& other) const
{
for(u32 i=0; array[i] && other.array[i]; ++i)
if (array[i] != other.array[i])
@ -367,7 +367,7 @@ public:
//! Is smaller comparator
bool operator <(const string<T>& other) const
bool operator <(const string<T,TAlloc>& other) const
{
for(u32 i=0; array[i] && other.array[i]; ++i)
{
@ -388,7 +388,7 @@ public:
//! Inequality operator
bool operator !=(const string<T>& other) const
bool operator !=(const string<T,TAlloc>& other) const
{
return !(*this == other);
}
@ -430,7 +430,7 @@ public:
//! 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
bool equals_ignore_case(const string<T,TAlloc>& other) const
{
for(u32 i=0; array[i] && other[i]; ++i)
if (locale_lower( array[i]) != locale_lower(other[i]))
@ -443,7 +443,7 @@ public:
/** \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
bool equals_substring_ignore_case(const string<T,TAlloc>&other, const s32 sourcePos = 0 ) const
{
if ( (u32) sourcePos > used )
return false;
@ -460,7 +460,7 @@ public:
//! 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
bool lower_ignore_case(const string<T,TAlloc>& other) const
{
for(u32 i=0; array[i] && other.array[i]; ++i)
{
@ -477,7 +477,7 @@ public:
/** \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
bool equalsn(const string<T,TAlloc>& other, u32 n) const
{
u32 i;
for(i=0; array[i] && other[i] && i < n; ++i)
@ -553,7 +553,7 @@ public:
//! Appends a string to this string
/** \param other: String to append. */
void append(const string<T>& other)
void append(const string<T,TAlloc>& other)
{
--used;
u32 len = other.size()+1;
@ -571,7 +571,7 @@ public:
//! 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)
void append(const string<T,TAlloc>& other, u32 length)
{
if (other.size() < length)
{
@ -775,17 +775,17 @@ public:
//! Returns a substring
/** \param begin: Start of substring.
\param length: Length of substring. */
string<T> subString(u32 begin, s32 length) const
string<T,TAlloc> subString(u32 begin, s32 length) const
{
// if start after string
// or no proper substring length
if ((length <= 0) || (begin>=size()))
return string<T>("");
return string<T,TAlloc>("");
// clamp length to maximal value
if ((length+begin) > size())
length = size()-begin;
string<T> o;
string<T,TAlloc> o;
o.reserve(length+1);
for (s32 i=0; i<length; ++i)
@ -800,7 +800,7 @@ public:
//! Appends a character to this string
/** \param c Character to append. */
string<T>& operator += (T c)
string<T,TAlloc>& operator += (T c)
{
append(c);
return *this;
@ -809,7 +809,7 @@ public:
//! Appends a char string to this string
/** \param c Char string to append. */
string<T>& operator += (const T* const c)
string<T,TAlloc>& operator += (const T* const c)
{
append(c);
return *this;
@ -818,7 +818,7 @@ public:
//! Appends a string to this string
/** \param other String to append. */
string<T>& operator += (const string<T>& other)
string<T,TAlloc>& operator += (const string<T,TAlloc>& other)
{
append(other);
return *this;
@ -827,54 +827,54 @@ public:
//! Appends a string representation of a number to this string
/** \param i Number to append. */
string<T>& operator += (const int i)
string<T,TAlloc>& operator += (const int i)
{
append(string<T>(i));
append(string<T,TAlloc>(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)
string<T,TAlloc>& operator += (const unsigned int i)
{
append(string<T>(i));
append(string<T,TAlloc>(i));
return *this;
}
//! Appends a string representation of a number to this string
/** \param i Number to append. */
string<T>& operator += (const long i)
string<T,TAlloc>& operator += (const long i)
{
append(string<T>(i));
append(string<T,TAlloc>(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)
string<T,TAlloc>& operator += (const unsigned long& i)
{
append(string<T>(i));
append(string<T,TAlloc>(i));
return *this;
}
//! Appends a string representation of a number to this string
/** \param i Number to append. */
string<T>& operator += (const double i)
string<T,TAlloc>& operator += (const double i)
{
append(string<T>(i));
append(string<T,TAlloc>(i));
return *this;
}
//! Appends a string representation of a number to this string
/** \param i Number to append. */
string<T>& operator += (const float i)
string<T,TAlloc>& operator += (const float i)
{
append(string<T>(i));
append(string<T,TAlloc>(i));
return *this;
}
@ -913,7 +913,7 @@ public:
//! Removes a string from the string.
/** \param toRemove: String to remove. */
void remove(const string<T> toRemove)
void remove(const string<T,TAlloc> toRemove)
{
u32 size = toRemove.size();
u32 pos = 0;
@ -943,7 +943,7 @@ public:
//! Removes characters from a string.
/** \param characters: Characters to remove. */
void removeChars(const string<T> & characters)
void removeChars(const string<T,TAlloc> & characters)
{
u32 pos = 0;
u32 found = 0;
@ -974,7 +974,7 @@ public:
//! 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")
string<T,TAlloc>& trim(const string<T,TAlloc> & whitespace = " \t\n\r")
{
// find start and end of the substring without the specified characters
const s32 begin = findFirstCharNotInList(whitespace.c_str(), whitespace.used);
@ -1068,7 +1068,7 @@ public:
{
if ((!ignoreEmptyTokens || i - lastpos != 0) &&
!lastWasSeparator)
ret.push_back(string<T>(&array[lastpos], i - lastpos));
ret.push_back(string<T,TAlloc>(&array[lastpos], i - lastpos));
foundSeparator = true;
lastpos = (keepSeparators ? i : i + 1);
break;
@ -1077,7 +1077,7 @@ public:
lastWasSeparator = foundSeparator;
}
if ((used - 1) > lastpos)
ret.push_back(string<T>(&array[lastpos], (used - 1) - lastpos));
ret.push_back(string<T,TAlloc>(&array[lastpos], (used - 1) - lastpos));
return ret.size()-oldSize;
}

View File

@ -79,6 +79,9 @@ class quaternion
//! Sets new quaternion based on euler angles (radians)
inline quaternion& set(const core::vector3df& vec);
//! Sets new quaternion from other quaternion
inline quaternion& set(const core::quaternion& quat);
//! Normalizes the quaternion
inline quaternion& normalize();
@ -453,6 +456,12 @@ inline quaternion& quaternion::set(const core::vector3df& vec)
return set(vec.X, vec.Y, vec.Z);
}
// sets new quaternion based on other quaternion
inline quaternion& quaternion::set(const core::quaternion& quat)
{
return (*this=quat);
}
// normalizes the quaternion
inline quaternion& quaternion::normalize()
{

View File

@ -295,7 +295,7 @@ namespace core
return angle;
}
//! Get the spherical coordinate angles
//! Get the spherical coordinate angles
/** This returns Euler degrees for the point represented by
this vector. The calculation assumes the pole at (0,1,0) and
returns the angles in X and Y.
@ -317,7 +317,7 @@ namespace core
angle.X = (T)(acos(Y * core::reciprocal_squareroot(length)) * RADTODEG64);
}
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.
@ -377,6 +377,12 @@ namespace core
T Z;
};
//! partial specialization for integer vectors
// Implementor note: inline keyword needed due to template specialization for s32. Otherwise put specialization into a .cpp
template <>
inline vector3d<s32> vector3d<s32>::operator /(s32 val) const {return core::vector3d<s32>(X/val,Y/val,Z/val);}
template <>
inline vector3d<s32>& vector3d<s32>::operator /=(s32 val) {X/=val;Y/=val;Z/=val; return *this;}
//! Typedef for a f32 3d vector.
typedef vector3d<f32> vector3df;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 15 KiB

BIN
media/023shot.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 90 KiB

View File

@ -381,7 +381,7 @@ bool CAnimatedMeshMD3::loadModelFile( u32 modelIndex, io::IReadFile* file,
{
file->read( &skin, sizeof(skin) );
core::stringc name;
io::path name;
cutFilenameExtension ( name, skin.name );
name.replace ( '\\', '/' );
buf->Shader = name;

View File

@ -195,7 +195,7 @@ void CAnimatedMeshSceneNode::OnRegisterSceneNode()
}
}
IMesh * CAnimatedMeshSceneNode::getMeshForCurrentFrame(bool forceRecalcOfControlJoints)
IMesh * CAnimatedMeshSceneNode::getMeshForCurrentFrame()
{
if(Mesh->getMeshType() != EAMT_SKINNED)
{
@ -204,7 +204,7 @@ IMesh * CAnimatedMeshSceneNode::getMeshForCurrentFrame(bool forceRecalcOfControl
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.
// re-animate it every frame to ensure that this node gets the mesh that it needs.
CSkinnedMesh* skinnedMesh = reinterpret_cast<CSkinnedMesh*>(Mesh);
@ -246,7 +246,7 @@ void CAnimatedMeshSceneNode::OnAnimate(u32 timeMs)
if (Mesh)
{
scene::IMesh * mesh = getMeshForCurrentFrame( true );
scene::IMesh * mesh = getMeshForCurrentFrame();
if (mesh)
Box = mesh->getBoundingBox();
@ -271,7 +271,7 @@ void CAnimatedMeshSceneNode::render()
++PassCount;
scene::IMesh* m = getMeshForCurrentFrame( false );
scene::IMesh* m = getMeshForCurrentFrame();
if(m)
{

View File

@ -165,7 +165,7 @@ namespace scene
private:
//! Get a static mesh for the current frame of this animated mesh
IMesh* getMeshForCurrentFrame(bool forceRecalcOfControlJoints);
IMesh* getMeshForCurrentFrame();
void buildFrameNr(u32 timeMs);
void checkJoints();

View File

@ -554,24 +554,23 @@ bool CB3DMeshFileLoader::readChunkBONE(CSkinnedMesh::SJoint *inJoint)
{
while((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) // this chunk repeats
{
CSkinnedMesh::SWeight *weight=AnimatedMesh->addWeight(inJoint);
u32 globalVertexID;
f32 strength;
B3DFile->read(&globalVertexID, sizeof(globalVertexID));
B3DFile->read(&weight->strength, sizeof(weight->strength));
B3DFile->read(&strength, sizeof(strength));
#ifdef __BIG_ENDIAN__
globalVertexID = os::Byteswap::byteswap(globalVertexID);
weight->strength = os::Byteswap::byteswap(weight->strength);
strength = os::Byteswap::byteswap(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
else if (strength >0)
{
CSkinnedMesh::SWeight *weight=AnimatedMesh->addWeight(inJoint);
weight->strength=strength;
//Find the meshbuffer and Vertex index from the Global Vertex ID:
weight->vertex_id = AnimatedVertices_VertexID[globalVertexID];
weight->buffer_id = AnimatedVertices_BufferID[globalVertexID];
@ -596,6 +595,13 @@ bool CB3DMeshFileLoader::readChunkKEYS(CSkinnedMesh::SJoint *inJoint)
flags = os::Byteswap::byteswap(flags);
#endif
CSkinnedMesh::SPositionKey *oldPosKey=0;
core::vector3df oldPos[2];
CSkinnedMesh::SScaleKey *oldScaleKey=0;
core::vector3df oldScale[2];
CSkinnedMesh::SRotationKey *oldRotKey=0;
core::quaternion oldRot[2];
bool isFirst[3]={true};
while((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) //this chunk repeats
{
s32 frame;
@ -610,24 +616,104 @@ bool CB3DMeshFileLoader::readChunkKEYS(CSkinnedMesh::SJoint *inJoint)
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 ((oldPosKey!=0) && (oldPos[0]==oldPos[1]))
{
const core::vector3df pos(data[0], data[1], data[2]);
if (oldPos[1]==pos)
oldPosKey->frame = (f32)frame-1;
else
{
oldPos[0]=oldPos[1];
oldPosKey=AnimatedMesh->addPositionKey(inJoint);
oldPosKey->frame = (f32)frame-1;
oldPos[1].set(oldPosKey->position.set(pos));
}
}
else if (oldPosKey==0 && isFirst[0])
{
oldPosKey=AnimatedMesh->addPositionKey(inJoint);
oldPosKey->frame = (f32)frame-1;
oldPos[0].set(oldPosKey->position.set(data[0], data[1], data[2]));
oldPosKey=0;
isFirst[0]=false;
}
else
{
if (oldPosKey!=0)
oldPos[0]=oldPos[1];
oldPosKey=AnimatedMesh->addPositionKey(inJoint);
oldPosKey->frame = (f32)frame-1;
oldPos[1].set(oldPosKey->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 ((oldScaleKey!=0) && (oldScale[0]==oldScale[1]))
{
const core::vector3df scale(data[0], data[1], data[2]);
if (oldScale[1]==scale)
oldScaleKey->frame = (f32)frame-1;
else
{
oldScale[0]=oldScale[1];
oldScaleKey=AnimatedMesh->addScaleKey(inJoint);
oldScaleKey->frame = (f32)frame-1;
oldScale[1].set(oldScaleKey->scale.set(scale));
}
}
else if (oldScaleKey==0 && isFirst[1])
{
oldScaleKey=AnimatedMesh->addScaleKey(inJoint);
oldScaleKey->frame = (f32)frame-1;
oldScale[0].set(oldScaleKey->scale.set(data[0], data[1], data[2]));
oldScaleKey=0;
isFirst[1]=false;
}
else
{
if (oldScaleKey!=0)
oldScale[0]=oldScale[1];
oldScaleKey=AnimatedMesh->addScaleKey(inJoint);
oldScaleKey->frame = (f32)frame-1;
oldScale[1].set(oldScaleKey->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]);
if ((oldRotKey!=0) && (oldRot[0]==oldRot[1]))
{
// meant to be in this order since b3d stores W first
const core::quaternion rot(data[1], data[2], data[3], data[0]);
if (oldRot[1]==rot)
oldRotKey->frame = (f32)frame-1;
else
{
oldRot[0]=oldRot[1];
oldRotKey=AnimatedMesh->addRotationKey(inJoint);
oldRotKey->frame = (f32)frame-1;
oldRot[1].set(oldRotKey->rotation.set(data[1], data[2], data[3], data[0]));
}
}
else if (oldRotKey==0 && isFirst[2])
{
oldRotKey=AnimatedMesh->addRotationKey(inJoint);
oldRotKey->frame = (f32)frame-1;
// meant to be in this order since b3d stores W first
oldRot[0].set(oldRotKey->rotation.set(data[1], data[2], data[3], data[0]));
oldRotKey=0;
isFirst[2]=false;
}
else
{
if (oldRotKey!=0)
oldRot[0]=oldRot[1];
oldRotKey=AnimatedMesh->addRotationKey(inJoint);
oldRotKey->frame = (f32)frame-1;
// meant to be in this order since b3d stores W first
oldRot[1].set(oldRotKey->rotation.set(data[1], data[2], data[3], data[0]));
}
}
}
@ -859,6 +945,7 @@ bool CB3DMeshFileLoader::readChunkBRUS()
}
B3dMaterial.Material.DiffuseColor = video::SColorf(B3dMaterial.red, B3dMaterial.green, B3dMaterial.blue, B3dMaterial.alpha).toSColor();
B3dMaterial.Material.ColorMaterial=video::ECM_NONE;
//------ Material fx ------
@ -871,7 +958,7 @@ bool CB3DMeshFileLoader::readChunkBRUS()
B3dMaterial.Material.AmbientColor = B3dMaterial.Material.DiffuseColor;
if (B3dMaterial.fx & 2) //use vertex colors instead of brush color
B3dMaterial.Material.ColorMaterial=video::ECM_NONE;
B3dMaterial.Material.ColorMaterial=video::ECM_DIFFUSE_AND_AMBIENT;
if (B3dMaterial.fx & 4) //flatshaded
B3dMaterial.Material.GouraudShading = false;

View File

@ -1794,6 +1794,7 @@ void CD3D8Driver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChan
if (texture)
{
setTransform(ETS_TEXTURE_0, core::IdentityMatrix);
if (alphaChannel)
{
pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE );

View File

@ -2413,6 +2413,7 @@ void CD3D9Driver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChan
{
if (texture)
{
setTransform(ETS_TEXTURE_0, core::IdentityMatrix);
if (alphaChannel)
{
pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );

View File

@ -353,23 +353,25 @@ const io::path& CFileSystem::getWorkingDirectory()
else
{
#if defined(_IRR_WINDOWS_CE_PLATFORM_)
// does not need this
#elif defined(_IRR_WINDOWS_API_)
fschar_t tmp[_MAX_PATH];
#if defined(_IRR_WCHAR_FILESYSTEM )
wchar_t tmp[_MAX_PATH];
_wgetcwd(tmp, _MAX_PATH);
WorkingDirectory[FILESYSTEM_NATIVE] = tmp;
WorkingDirectory[FILESYSTEM_NATIVE].replace(L'\\', L'/');
#else
c8 tmp[_MAX_PATH];
_getcwd(tmp, _MAX_PATH);
WorkingDirectory[FILESYSTEM_NATIVE] = tmp;
WorkingDirectory[FILESYSTEM_NATIVE].replace('\\', '/');
#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
// 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;
@ -443,16 +445,16 @@ bool CFileSystem::changeWorkingDirectoryTo(const io::path& newDirectory)
io::path CFileSystem::getAbsolutePath(const io::path& filename) const
{
#if defined(_IRR_WINDOWS_API_) && !defined(_IRR_WINDOWS_CE_PLATFORM_)
#if defined(_IRR_WINDOWS_CE_PLATFORM_)
return filename;
#elif defined(_IRR_WINDOWS_API_)
fschar_t *p=0;
fschar_t fpath[_MAX_PATH];
#if defined(_IRR_WCHAR_FILESYSTEM )
wchar_t fpath[_MAX_PATH];
p = _wfullpath(fpath, filename.c_str(), _MAX_PATH);
core::stringw tmp(p);
tmp.replace(L'\\', L'/');
#else
c8 fpath[_MAX_PATH];
p = _fullpath(fpath, filename.c_str(), _MAX_PATH);
core::stringc tmp(p);
tmp.replace('\\', '/');
@ -465,22 +467,19 @@ io::path CFileSystem::getAbsolutePath(const io::path& filename) const
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
// content in fpath is unclear at this point
if (!fpath[0]) // seems like fpath wasn't altered, use our best guess
{
// at least remove a ./ prefix
if ('.'==filename[0] && '/'==filename[1])
return filename.subString(2, filename.size()-2);
else
return filename;
io::path tmp(filename);
return flattenFilename(tmp);
}
else
return io::path(fpath);
}
#endif
return io::path(p);
#else
return io::path(filename);
#endif
}
@ -532,7 +531,7 @@ io::path CFileSystem::getFileBasename(const io::path& filename, bool keepExtensi
}
//! flaten a path and file name for example: "/you/me/../." becomes "/you"
//! flatten 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('\\', '/');

View File

@ -807,9 +807,9 @@ void CGUIEditBox::draw()
mbegin = font->getDimension(s.c_str()).Width;
// deal with kerning
mbegin += font->getKerningWidth(
&((*txtLine)[realmbgn - startPos]),
realmbgn - startPos > 0 ? &((*txtLine)[realmbgn - startPos - 1]) : 0);
mbegin += font->getKerningWidth(
&((*txtLine)[realmbgn - startPos]),
realmbgn - startPos > 0 ? &((*txtLine)[realmbgn - startPos - 1]) : 0);
lineStartPos = realmbgn - startPos;
}
@ -854,7 +854,7 @@ void CGUIEditBox::draw()
startPos = BrokenTextPositions[cursorLine];
}
s = txtLine->subString(0,CursorPos-startPos);
charcursorpos = font->getDimension(s.c_str()).Width +
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)
@ -877,7 +877,8 @@ void CGUIEditBox::draw()
void CGUIEditBox::setText(const wchar_t* text)
{
Text = text;
CursorPos = 0;
if (u32(CursorPos) > Text.size())
CursorPos = Text.size();
HScrollPos = 0;
breakText();
}

View File

@ -441,7 +441,7 @@ void CGUIEnvironment::updateHoveredElement(core::position2d<s32> mousePos)
if (Hovered)
{
u32 now = os::Timer::getTime ();
u32 now = os::Timer::getTime();
if (Hovered != this)
Hovered->grab();
@ -458,7 +458,7 @@ void CGUIEnvironment::updateHoveredElement(core::position2d<s32> mousePos)
lastHovered->OnEvent(event);
}
if ( ToolTip.Element )
if (ToolTip.Element)
{
ToolTip.Element->remove();
ToolTip.Element->drop();
@ -479,7 +479,8 @@ void CGUIEnvironment::updateHoveredElement(core::position2d<s32> mousePos)
}
event.GUIEvent.Caller = Hovered;
event.GUIEvent.Caller = Hovered;
event.GUIEvent.Element = Hovered;
event.GUIEvent.EventType = EGET_ELEMENT_HOVERED;
Hovered->OnEvent(event);
}

View File

@ -110,7 +110,7 @@ IMesh* CGeometryCreator::createHillPlaneMesh(
vtx.Pos.set(sx - center.X, 0, sy - center.Y);
vtx.TCoords.set(tsx, 1.0f - tsy);
if (hillHeight != 0.0f)
if (core::isnotzero(hillHeight))
vtx.Pos.Y = sinf(vtx.Pos.X * countHills.Width * core::PI / center.X) *
cosf(vtx.Pos.Z * countHills.Height * core::PI / center.Y) *
hillHeight;
@ -158,6 +158,7 @@ IMesh* CGeometryCreator::createHillPlaneMesh(
buffer->Material = *material;
buffer->recalculateBoundingBox();
buffer->setHardwareMappingHint(EHM_STATIC);
SMesh* mesh = new SMesh();
mesh->addMeshBuffer(buffer);
@ -327,9 +328,11 @@ IMesh* CGeometryCreator::createArrowMesh(const u32 tesselationCylinder,
scene::IMeshBuffer* buffer = mesh2->getMeshBuffer(i);
for (u32 j=0; j<buffer->getVertexCount(); ++j)
buffer->getPosition(j).Y += cylinderHeight;
buffer->setDirty(EBT_VERTEX);
mesh->addMeshBuffer(buffer);
}
mesh2->drop();
mesh->setHardwareMappingHint(EHM_STATIC);
return mesh;
}
@ -494,6 +497,7 @@ IMesh* CGeometryCreator::createSphereMesh(f32 radius, u32 polyCountX, u32 polyCo
mesh->addMeshBuffer(buffer);
buffer->drop();
mesh->setHardwareMappingHint(EHM_STATIC);
mesh->recalculateBoundingBox();
return mesh;
}
@ -630,6 +634,7 @@ IMesh* CGeometryCreator::createCylinderMesh(f32 radius, f32 length,
buffer->recalculateBoundingBox();
SMesh* mesh = new SMesh();
mesh->addMeshBuffer(buffer);
mesh->setHardwareMappingHint(EHM_STATIC);
mesh->recalculateBoundingBox();
buffer->drop();
return mesh;
@ -722,6 +727,7 @@ IMesh* CGeometryCreator::createConeMesh(f32 radius, f32 length, u32 tesselation,
mesh->addMeshBuffer(buffer);
buffer->drop();
mesh->setHardwareMappingHint(EHM_STATIC);
mesh->recalculateBoundingBox();
return mesh;
}

View File

@ -559,6 +559,11 @@ CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params)
s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2;
s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2;
if ( windowLeft < 0 )
windowLeft = 0;
if ( windowTop < 0 )
windowTop = 0; // make sure window menus are in screen on creation
if (CreationParams.Fullscreen)
{
windowLeft = 0;
@ -576,6 +581,9 @@ CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params)
// fix ugly ATI driver bugs. Thanks to ariaci
MoveWindow(HWnd, windowLeft, windowTop, realWidth, realHeight, TRUE);
// make sure everything gets updated to the real sizes
Resized = true;
}
else if (CreationParams.WindowId)
{
@ -1292,21 +1300,28 @@ void CIrrDeviceWin32::pollJoysticks()
u32 joystick;
JOYINFOEX info;
info.dwSize = sizeof(info);
info.dwFlags = JOY_RETURNALL;
for(joystick = 0; joystick < ActiveJoysticks.size(); ++joystick)
{
// needs to be reset for each joystick
// request ALL values and POV as continuous if possible
info.dwSize = sizeof(info);
info.dwFlags = JOY_RETURNALL|JOY_RETURNPOVCTS;
const JOYCAPS & caps = ActiveJoysticks[joystick].Caps;
// if no POV is available don't ask for POV values
if (!(caps.wCaps & JOYCAPS_HASPOV))
info.dwFlags &= ~(JOY_RETURNPOV|JOY_RETURNPOVCTS);
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)
// set to undefined if no POV value was returned or the value
// is out of range
if (!(info.dwFlags & JOY_RETURNPOV) || (event.JoystickEvent.POV > 35900))
event.JoystickEvent.POV = 65535;
for(int axis = 0; axis < SEvent::SJoystickEvent::NUMBER_OF_AXES; ++axis)
@ -1402,12 +1417,12 @@ void CIrrDeviceWin32::clearSystemMessages()
void CIrrDeviceWin32::ReportLastWinApiError()
{
// (based on code from ovidiucucu from http://www.codeguru.com/forum/showthread.php?t=318721)
LPCTSTR pszCaption = "Windows SDK Error Report";
LPCTSTR pszCaption = __TEXT("Windows SDK Error Report");
DWORD dwError = GetLastError();
if(NOERROR == dwError)
{
MessageBox(NULL, "No error", pszCaption, MB_OK);
MessageBox(NULL, __TEXT("No error"), pszCaption, MB_OK);
}
else
{
@ -1425,12 +1440,12 @@ void CIrrDeviceWin32::ReportLastWinApiError()
NULL);
if(0 != dwCount)
{
MessageBox(NULL, (LPCSTR)pTextBuffer, pszCaption, MB_OK|MB_ICONERROR);
MessageBox(NULL, (LPCTSTR)pTextBuffer, pszCaption, MB_OK|MB_ICONERROR);
LocalFree(pTextBuffer);
}
else
{
MessageBox(NULL, "Unknown error", pszCaption, MB_OK|MB_ICONERROR);
MessageBox(NULL, __TEXT("Unknown error"), pszCaption, MB_OK|MB_ICONERROR);
}
}
}
@ -1438,4 +1453,3 @@ void CIrrDeviceWin32::ReportLastWinApiError()
} // end namespace
#endif // _IRR_COMPILE_WITH_WINDOWS_DEVICE_

View File

@ -5,17 +5,13 @@
#include "COSOperator.h"
#ifdef _IRR_WINDOWS_API_
#ifdef _IRR_XBOX_PLATFORM_
#else
#ifndef _IRR_XBOX_PLATFORM_
#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_
#ifndef _IRR_SOLARIS_PLATFORM_
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
@ -24,6 +20,9 @@
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_)
#include "CIrrDeviceLinux.h"
#endif
#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
#include "MacOSX/OSXClipboard.h"
#endif
namespace irr
{
@ -184,7 +183,7 @@ bool COSOperator::getSystemMemory(u32* Total, u32* Avail) const
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return true;
#elif defined(_IRR_POSIX_API_)
#elif defined(_IRR_POSIX_API_) && !defined(__FreeBSD__)
#if defined(_SC_PHYS_PAGES) && defined(_SC_AVPHYS_PAGES)
long ps = sysconf(_SC_PAGESIZE);
long pp = sysconf(_SC_PHYS_PAGES);

View File

@ -22,14 +22,15 @@ namespace scene
//! constructor
COctreeSceneNode::COctreeSceneNode(ISceneNode* parent, ISceneManager* mgr,
s32 id, s32 minimalPolysPerNode)
: IMeshSceneNode(parent, mgr, id), StdOctree(0), LightMapOctree(0), TangentsOctree(0),
MinimalPolysPerNode(minimalPolysPerNode), Mesh(0)
: IMeshSceneNode(parent, mgr, id), StdOctree(0), LightMapOctree(0),
TangentsOctree(0), VertexType((video::E_VERTEX_TYPE)-1),
MinimalPolysPerNode(minimalPolysPerNode), Mesh(0),
UseVBOs(OCTREE_USE_HARDWARE), UseVisibilityAndVBOs(OCTREE_USE_VISIBILITY),
BoxBased(OCTREE_BOX_BASED)
{
#ifdef _DEBUG
setDebugName("COctreeSceneNode");
#endif
vertexType = (video::E_VERTEX_TYPE)-1;
}
@ -88,7 +89,7 @@ void COctreeSceneNode::render()
{
video::IVideoDriver* driver = SceneManager->getVideoDriver();
if (vertexType == -1 || !driver)
if (VertexType == -1 || !driver)
return;
ICameraSceneNode* camera = SceneManager->getActiveCamera();
@ -110,19 +111,16 @@ void COctreeSceneNode::render()
frust.transform(invTrans);
}
#if defined ( OCTREE_BOX_BASED )
const core::aabbox3d<float> &box = frust.getBoundingBox();
#endif
switch(vertexType)
switch (VertexType)
{
case video::EVT_STANDARD:
{
#if defined ( OCTREE_BOX_BASED )
StdOctree->calculatePolys(box);
#else
StdOctree->calculatePolys(frust);
#endif
if (BoxBased)
StdOctree->calculatePolys(box);
else
StdOctree->calculatePolys(frust);
const Octree<video::S3DVertex>::SIndexData* d = StdOctree->getIndexData();
@ -167,11 +165,11 @@ void COctreeSceneNode::render()
break;
case video::EVT_2TCOORDS:
{
#if defined ( OCTREE_BOX_BASED )
LightMapOctree->calculatePolys(box);
#else
LightMapOctree->calculatePolys(frust);
#endif
if (BoxBased)
LightMapOctree->calculatePolys(box);
else
LightMapOctree->calculatePolys(frust);
const Octree<video::S3DVertex2TCoords>::SIndexData* d = LightMapOctree->getIndexData();
for (u32 i=0; i<Materials.size(); ++i)
@ -187,14 +185,27 @@ void COctreeSceneNode::render()
if (transparent == isTransparentPass)
{
driver->setMaterial(Materials[i]);
#if defined (OCTREE_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
if (UseVBOs)
{
if (UseVisibilityAndVBOs)
{
u16* oldPointer = LightMapMeshes[i].Indices.pointer();
const u32 oldSize = LightMapMeshes[i].Indices.size();
LightMapMeshes[i].Indices.set_free_when_destroyed(false);
LightMapMeshes[i].Indices.set_pointer(d[i].Indices, d[i].CurrentSize, false, false);
LightMapMeshes[i].setDirty(scene::EBT_INDEX);
driver->drawMeshBuffer ( &LightMapMeshes[i] );
LightMapMeshes[i].Indices.set_pointer(oldPointer, oldSize);
LightMapMeshes[i].setDirty(scene::EBT_INDEX);
}
else
driver->drawMeshBuffer ( &LightMapMeshes[i] );
}
else
driver->drawIndexedTriangleList(
&LightMapMeshes[i].Vertices[0],
LightMapMeshes[i].Vertices.size(),
d[i].Indices, d[i].CurrentSize / 3);
}
}
@ -220,11 +231,10 @@ void COctreeSceneNode::render()
break;
case video::EVT_TANGENTS:
{
#if defined ( OCTREE_BOX_BASED )
TangentsOctree->calculatePolys(box);
#else
TangentsOctree->calculatePolys(frust);
#endif
if (BoxBased)
TangentsOctree->calculatePolys(box);
else
TangentsOctree->calculatePolys(frust);
const Octree<video::S3DVertexTangents>::SIndexData* d = TangentsOctree->getIndexData();
@ -301,9 +311,9 @@ bool COctreeSceneNode::createTree(IMesh* mesh)
if (mesh->getMeshBufferCount())
{
vertexType = mesh->getMeshBuffer(0)->getVertexType();
VertexType = mesh->getMeshBuffer(0)->getVertexType();
switch(vertexType)
switch(VertexType)
{
case video::EVT_STANDARD:
{
@ -362,9 +372,13 @@ bool COctreeSceneNode::createTree(IMesh* mesh)
Octree<video::S3DVertex2TCoords>::SMeshChunk& nchunk = LightMapMeshes.getLast();
nchunk.MaterialId = Materials.size() - 1;
#if defined (OCTREE_USE_HARDWARE)
nchunk.setHardwareMappingHint ( b->getHardwareMappingHint_Vertex() );
#endif
if (UseVisibilityAndVBOs)
{
nchunk.setHardwareMappingHint(scene::EHM_STATIC, scene::EBT_VERTEX);
nchunk.setHardwareMappingHint(scene::EHM_DYNAMIC, scene::EBT_INDEX);
}
else
nchunk.setHardwareMappingHint(scene::EHM_STATIC);
u32 v;
nchunk.Vertices.reallocate(b->getVertexCount());

View File

@ -81,7 +81,7 @@ namespace scene
Octree<video::S3DVertexTangents>* TangentsOctree;
core::array< Octree<video::S3DVertexTangents>::SMeshChunk > TangentsMeshes;
video::E_VERTEX_TYPE vertexType;
video::E_VERTEX_TYPE VertexType;
core::array< video::SMaterial > Materials;
core::stringc MeshName;
@ -89,6 +89,12 @@ namespace scene
s32 PassCount;
IMesh * Mesh;
//! use VBOs for rendering where possible
bool UseVBOs;
//! use visibility information together with VBOs
bool UseVisibilityAndVBOs;
//! use bounding box or frustum for calculate polys
bool BoxBased;
};
} // end namespace scene

View File

@ -121,7 +121,7 @@ IAnimatedMesh* COgreMeshFileLoader::createMesh(io::IReadFile* file)
return 0;
ChunkData data;
readString(file, data, Version);
if ((Version != "[MeshSerializer_v1.30]") && (Version != "[MeshSerializer_v1.40]"))
if ((Version != "[MeshSerializer_v1.30]") && (Version != "[MeshSerializer_v1.40]") && (Version != "[MeshSerializer_v1.41]"))
return 0;
clearMeshes();
@ -366,6 +366,9 @@ bool COgreMeshFileLoader::readSubMesh(io::IReadFile* file, ChunkData& parent, Og
os::Printer::log("Read Submesh");
#endif
readString(file, parent, subMesh.Material);
#ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("using material", subMesh.Material);
#endif
readBool(file, parent, subMesh.SharedVertices);
s32 numIndices;
@ -781,29 +784,21 @@ void COgreMeshFileLoader::composeObject(void)
}
}
// currently not working correctly
for (u32 i=0; i<Skeleton.Animations.size(); ++i)
{
for (u32 j=0; j<Skeleton.Animations[i].Keyframes.size(); ++j)
{
#if 0
OgreKeyframe& frame = Skeleton.Animations[i].Keyframes[j];
#ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Time", core::stringc(frame.Time));
os::Printer::log("Position", core::stringc(frame.Position.X)+" "+core::stringc(frame.Position.Y)+" "+core::stringc(frame.Position.Z));
os::Printer::log("Rotation quat", core::stringc(frame.Orientation.W)+" "+core::stringc(frame.Orientation.X)+" "+core::stringc(frame.Orientation.Y)+" "+core::stringc(frame.Orientation.Z));
#endif
ISkinnedMesh::SJoint* keyjoint = m->getAllJoints()[frame.BoneID];
ISkinnedMesh::SPositionKey* poskey = m->addPositionKey(keyjoint);
poskey->frame=frame.Time;
poskey->frame=frame.Time*25;
poskey->position=keyjoint->LocalMatrix.getTranslation()+frame.Position;
ISkinnedMesh::SRotationKey* rotkey = m->addRotationKey(keyjoint);
rotkey->frame=frame.Time;
rotkey->rotation=frame.Orientation+core::quaternion(keyjoint->LocalMatrix);
rotkey->frame=frame.Time*25;
rotkey->rotation=core::quaternion(keyjoint->LocalMatrix)*frame.Orientation;
ISkinnedMesh::SScaleKey* scalekey = m->addScaleKey(keyjoint);
scalekey->frame=frame.Time;
scalekey->frame=frame.Time*25;
scalekey->scale=frame.Scale;
#endif
}
}
m->finalize();
@ -1155,7 +1150,13 @@ void COgreMeshFileLoader::readPass(io::IReadFile* file, OgreTechnique& technique
{
getMaterialToken(file, token);
} while (token != "}");
getMaterialToken(file, token);
}
else if (token=="shadow_caster_vertex_program_ref")
{
do
{
getMaterialToken(file, token);
} while (token != "}");
}
else if (token=="vertex_program_ref")
{
@ -1163,7 +1164,6 @@ void COgreMeshFileLoader::readPass(io::IReadFile* file, OgreTechnique& technique
{
getMaterialToken(file, token);
} while (token != "}");
getMaterialToken(file, token);
}
//fog_override, iteration, point_size_attenuation
//not considered yet!
@ -1407,8 +1407,8 @@ bool COgreMeshFileLoader::loadSkeleton(io::IReadFile* meshFile, const core::stri
OgreKeyframe& keyframe = Skeleton.Animations.getLast().Keyframes.getLast();
readFloat(file, data, &keyframe.Time);
keyframe.Time+=animationTotal;
readVector(file, data, keyframe.Position);
readQuaternion(file, data, keyframe.Orientation);
readVector(file, data, keyframe.Position);
if (data.read<data.header.length)
{
readVector(file, data, keyframe.Scale);

View File

@ -2860,6 +2860,7 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
setTransform(ETS_TEXTURE_0, core::IdentityMatrix);
if (alphaChannel)
{

View File

@ -450,6 +450,7 @@ void CParticleSystemSceneNode::doParticleSystem(u32 time)
for (u32 i=0; i<Particles.size();)
{
// erase is pretty expensive!
if (now > Particles[i].endTime)
Particles.erase(i);
else

View File

@ -1871,10 +1871,10 @@ void CQ3LevelMesh::loadTextures()
// load textures
Tex.set_used( NumTextures+1 );
const IShader * shader;
const IShader* shader;
core::stringc list;
core::stringc check;
io::path check;
tTexArray textureArray;
// pre-load shaders

View File

@ -10,7 +10,6 @@
#include "os.h"
#include "irrMath.h"
#include <float.h> // For FLT_MAX
namespace irr
{
@ -41,21 +40,22 @@ CSceneCollisionManager::~CSceneCollisionManager()
//! 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::position2d<s32>& pos, s32 idBitMask, bool noDebugObjects, scene::ISceneNode* root)
{
const core::line3d<f32> ln = getRayFromScreenCoordinates(pos, 0);
if ( ln.start == ln.end )
return 0;
return getSceneNodeFromRayBB(ln, idBitMask, bNoDebugObjects, root);
return getSceneNodeFromRayBB(ln, idBitMask, noDebugObjects, 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* CSceneCollisionManager::getSceneNodeFromRayBB(
const core::line3d<f32>& ray,
s32 idBitMask, bool noDebugObjects, scene::ISceneNode* root)
{
ISceneNode* best = 0;
f32 dist = FLT_MAX;
@ -63,7 +63,7 @@ ISceneNode* CSceneCollisionManager::getSceneNodeFromRayBB(const core::line3d<f32
core::line3d<f32> truncatableRay(ray);
getPickedNodeBB((root==0)?SceneManager->getRootSceneNode():root, truncatableRay,
idBitMask, bNoDebugObjects, dist, best);
idBitMask, noDebugObjects, dist, best);
return best;
}
@ -71,7 +71,7 @@ ISceneNode* CSceneCollisionManager::getSceneNodeFromRayBB(const core::line3d<f32
//! recursive method for going through all scene nodes
void CSceneCollisionManager::getPickedNodeBB(ISceneNode* root,
core::line3df& ray, s32 bits, bool bNoDebugObjects,
core::line3df& ray, s32 bits, bool noDebugObjects,
f32& outbestdistance, ISceneNode*& outbestnode)
{
const ISceneNodeList& children = root->getChildren();
@ -84,7 +84,7 @@ void CSceneCollisionManager::getPickedNodeBB(ISceneNode* root,
if (current->isVisible())
{
if((bNoDebugObjects ? !current->isDebugObject() : true) &&
if((noDebugObjects ? !current->isDebugObject() : true) &&
(bits==0 || (bits != 0 && (current->getID() & bits))))
{
// get world to object space transform
@ -103,10 +103,20 @@ void CSceneCollisionManager::getPickedNodeBB(ISceneNode* root,
// 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)
// use fast bbox intersection to find distance to hitpoint
// algorithm from Kay et al., code from gamedev.net
const core::vector3df dir = (objectRay.end-objectRay.start).normalize();
const core::vector3df minDist = (objectBox.MinEdge - objectRay.start)/dir;
const core::vector3df maxDist = (objectBox.MaxEdge - objectRay.start)/dir;
const core::vector3df realMin(core::min_(minDist.X, maxDist.X),core::min_(minDist.Y, maxDist.Y),core::min_(minDist.Z, maxDist.Z));
const core::vector3df realMax(core::max_(minDist.X, maxDist.X),core::max_(minDist.Y, maxDist.Y),core::max_(minDist.Z, maxDist.Z));
const f32 minmax = core::min_(realMax.X, realMax.Y, realMax.Z);
// nearest distance to intersection
const f32 maxmin = core::max_(realMin.X, realMin.Y, realMin.Z);
const f32 toIntersectionSq = (maxmin>0?maxmin*maxmin:minmax*minmax);
if (toIntersectionSq < outbestdistance)
{
outbestdistance = toIntersectionSq;
outbestnode = current;
@ -175,7 +185,7 @@ void CSceneCollisionManager::getPickedNodeBB(ISceneNode* root,
// 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.
// find the closest 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)) );
@ -189,7 +199,7 @@ void CSceneCollisionManager::getPickedNodeBB(ISceneNode* root,
// 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))
if (!(face & 0x01))
++face;
}
@ -205,7 +215,7 @@ void CSceneCollisionManager::getPickedNodeBB(ISceneNode* root,
}
// Only check the children if this node is visible.
getPickedNodeBB(current, ray, bits, bNoDebugObjects, outbestdistance, outbestnode);
getPickedNodeBB(current, ray, bits, noDebugObjects, outbestdistance, outbestnode);
}
}
}
@ -257,7 +267,7 @@ ISceneNode* CSceneCollisionManager::getSceneNodeAndCollisionPointFromRay(
void CSceneCollisionManager::getPickedNodeFromBBAndSelector(
ISceneNode * root,
const core::line3df & ray,
core::line3df & ray,
s32 bits,
bool noDebugObjects,
f32 & outBestDistanceSquared,
@ -305,6 +315,8 @@ void CSceneCollisionManager::getPickedNodeFromBBAndSelector(
outBestNode = current;
outBestCollisionPoint = candidateCollisionPoint;
outBestTriangle = candidateTriangle;
const core::vector3df rayVector = ray.getVector().normalize();
ray.end = ray.start + (rayVector * sqrtf(distanceSquared));
}
}
}
@ -319,7 +331,7 @@ void CSceneCollisionManager::getPickedNodeFromBBAndSelector(
//! 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)
ICameraSceneNode* camera, s32 idBitMask, bool noDebugObjects)
{
if (!camera)
return 0;
@ -329,7 +341,7 @@ ISceneNode* CSceneCollisionManager::getSceneNodeFromCameraBB(
end = start + ((end - start).normalize() * camera->getFarValue());
return getSceneNodeFromRayBB(core::line3d<f32>(start, end), idBitMask, bNoDebugObjects);
return getSceneNodeFromRayBB(core::line3d<f32>(start, end), idBitMask, noDebugObjects);
}

View File

@ -89,7 +89,7 @@ namespace scene
//! recursive method for going through all scene nodes
void getPickedNodeFromBBAndSelector(ISceneNode * root,
const core::line3df & ray,
core::line3df & ray,
s32 bits,
bool noDebugObjects,
f32 & outBestDistanceSquared,

View File

@ -42,21 +42,27 @@ void CSceneNodeAnimatorFlyStraight::animateNode(ISceneNode* node, u32 timeMs)
u32 t = (timeMs-StartTime);
core::vector3df pos = Start;
core::vector3df pos;
if (!Loop && t >= TimeForWay)
if (!Loop && !PingPong && t >= TimeForWay)
{
pos = End;
HasFinished = true;
}
else if (!Loop && PingPong && t >= TimeForWay * 2.f )
{
pos = Start;
HasFinished = true;
}
else
{
f32 phase = fmodf( (f32) t, (f32) TimeForWay );
core::vector3df rel = Vector * phase * TimeFactor;
const bool pong = PingPong && fmodf( (f32) t, (f32) TimeForWay*2.f ) >= TimeForWay;
if ( !PingPong || phase < TimeForWay * 0.5f )
if ( !pong )
{
pos += rel;
pos += Start + rel;
}
else
{

View File

@ -1254,17 +1254,13 @@ void CSkinnedMesh::recoverJointsFromMesh(core::array<IBoneSceneNode*> &JointChil
SJoint *joint=AllJoints[i];
node->setPosition( joint->LocalAnimatedMatrix.getTranslation() );
node->setRotation( joint->LocalAnimatedMatrix.getRotationDegrees() );
//node->setScale( joint->LocalAnimatedMatrix.getScale() );
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();
node->updateAbsolutePosition();
}
}
@ -1276,19 +1272,15 @@ void CSkinnedMesh::transferJointsToMesh(const core::array<IBoneSceneNode*> &Join
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->LocalAnimatedMatrix.setTranslation(node->getPosition());
joint->LocalAnimatedMatrix *= core::matrix4().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;
joint->GlobalSkinningSpace=(node->getSkinningSpace()==EBSS_GLOBAL);
}
//Remove cache, temp...
LastAnimatedFrame=-1;

View File

@ -126,6 +126,7 @@ void CSkyDomeSceneNode::generateMesh()
Buffer->Indices.push_back(0 + (VerticalResolution + 1)*k + j);
}
}
Buffer->setHardwareMappingHint(scene::EHM_STATIC);
}
@ -288,4 +289,3 @@ ISceneNode* CSkyDomeSceneNode::clone(ISceneNode* newParent, ISceneManager* newMa
} // namespace scene
} // namespace irr

View File

@ -490,6 +490,7 @@ IReadFile* CZipReader::createAndOpenFile(const io::path& filename)
return 0;
}
#ifdef _IRR_COMPILE_WITH_LZMA_
//! Used for LZMA decompression. The lib has no default memory management
namespace
{
@ -497,6 +498,7 @@ namespace
void SzFree(void *p, void *address) { p = p; free(address); }
ISzAlloc lzmaAlloc = { SzAlloc, SzFree };
}
#endif
//! opens a file by index
IReadFile* CZipReader::createAndOpenFile(u32 index)

View File

@ -807,6 +807,10 @@
RelativePath="..\..\include\aabbox3d.h"
>
</File>
<File
RelativePath="..\..\include\coreutil.h"
>
</File>
<File
RelativePath="..\..\include\dimension2d.h"
>
@ -1091,6 +1095,10 @@
RelativePath="..\..\include\IQ3LevelMesh.h"
>
</File>
<File
RelativePath="..\..\include\IQ3Shader.h"
>
</File>
<File
RelativePath="..\..\include\ISceneCollisionManager.h"
>

View File

@ -161,7 +161,7 @@ namespace irr
}
//! Returns the current position of the mouse cursor.
virtual core::position2d<s32> getPosition()
virtual const core::position2d<s32>& getPosition()
{
return CursorPos;
}

View File

@ -350,11 +350,14 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
{
firstLaunch = false;
[[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
[NSApp setDelegate:[[[AppDelegate alloc] initWithDevice:this] autorelease]];
[NSBundle loadNibNamed:@"MainMenu" owner:[NSApp delegate]];
[NSApp finishLaunching];
if(!CreationParams.WindowId) //load menus if standalone application
{
[[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]);
@ -415,9 +418,18 @@ void CIrrDeviceMacOSX::closeDevice()
{
if (CGLContext != NULL)
{
CGLSetCurrentContext(NULL);
CGLClearDrawable(CGLContext);
CGLDestroyContext(CGLContext);
if(CreationParams.WindowId)
{
[(NSOpenGLContext *)OGLContext clearDrawable];
[(NSOpenGLContext *)OGLContext release];
OGLContext = NULL;
}
else
{
CGLSetCurrentContext(NULL);
CGLClearDrawable(CGLContext);
CGLDestroyContext(CGLContext);
}
}
}
@ -448,8 +460,12 @@ bool CIrrDeviceMacOSX::createWindow()
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)
if(!CreationParams.WindowId) //create another window when WindowId is null
{
Window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,CreationParams.WindowSize.Width,CreationParams.WindowSize.Height) styleMask:NSTitledWindowMask+NSClosableWindowMask+NSResizableWindowMask backing:NSBackingStoreBuffered defer:FALSE];
}
if (Window != NULL || CreationParams.WindowId)
{
NSOpenGLPixelFormatAttribute windowattribs[] =
{
@ -535,12 +551,17 @@ bool CIrrDeviceMacOSX::createWindow()
if (OGLContext != NULL)
{
[Window center];
[Window setDelegate:[NSApp delegate]];
[OGLContext setView:[Window contentView]];
[Window setAcceptsMouseMovedEvents:TRUE];
[Window setIsVisible:TRUE];
[Window makeKeyAndOrderFront:nil];
if (!CreationParams.WindowId)
{
[Window center];
[Window setDelegate:[NSApp delegate]];
[OGLContext setView:[Window contentView]];
[Window setAcceptsMouseMovedEvents:TRUE];
[Window setIsVisible:TRUE];
[Window makeKeyAndOrderFront:nil];
}
else //use another window for drawing
[OGLContext setView:(NSView*)CreationParams.WindowId];
CGLContext = (CGLContextObj) [OGLContext CGLContextObj];
DeviceWidth = CreationParams.WindowSize.Width;
@ -605,7 +626,7 @@ bool CIrrDeviceMacOSX::createWindow()
if (result)
{
// fullscreen?
if (Window == NULL)
if (Window == NULL && !CreationParams.WindowId) //hide menus in fullscreen mode only
SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar);
CGLSetCurrentContext(CGLContext);
newSwapInterval = (CreationParams.Vsync) ? 1 : 0;
@ -625,8 +646,15 @@ void CIrrDeviceMacOSX::setResize(int width, int height)
[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));
if (Window)
{
NSRect driverFrame = [Window contentRectForFrameRect:[Window frame]];
getVideoDriver()->OnResize(core::dimension2d<u32>( (s32)driverFrame.size.width, (s32)driverFrame.size.height));
}
else
getVideoDriver()->OnResize(core::dimension2d<u32>( (s32)width, (s32)height));
if(CreationParams.WindowId && OGLContext)
[(NSOpenGLContext *)OGLContext update];
}
void CIrrDeviceMacOSX::createDriver()

View File

@ -55,7 +55,7 @@ LINKOBJ = $(IRRMESHOBJ) $(IRROBJ) $(IRRPARTICLEOBJ) $(IRRANIMOBJ) \
###############
#Compiler flags
CXXINCS = -I../../include -Izlib -Ijpeglib -Ilibpng
CPPFLAGS = $(CXXINCS) -DIRRLICHT_EXPORTS=1
CPPFLAGS += $(CXXINCS) -DIRRLICHT_EXPORTS=1
CXXFLAGS += -Wall -pipe -fno-exceptions -fno-rtti -fstrict-aliasing
ifndef NDEBUG
CXXFLAGS += -g -D_DEBUG
@ -65,7 +65,7 @@ endif
ifdef PROFILE
CXXFLAGS += -pg
endif
CFLAGS := -fexpensive-optimizations -O3 -DPNG_THREAD_UNSAFE_OK -DPNG_NO_MMX_CODE -DPNG_NO_MNG_FEATURES
CFLAGS := -O3 -fexpensive-optimizations -DPNG_THREAD_UNSAFE_OK -DPNG_NO_MMX_CODE -DPNG_NO_MNG_FEATURES
sharedlib sharedlib_osx: CXXFLAGS += -fPIC
sharedlib sharedlib_osx: CFLAGS += -fPIC
@ -103,20 +103,22 @@ sharedlib_win32 staticlib_win32: CPPFLAGS += -DIRR_COMPILE_WITH_DX9_DEV_PACK -D_
staticlib_win32: CPPFLAGS += -D_IRR_STATIC_LIB_
####################
# All target, builds Irrlicht as static lib (libIrrlicht.a) and copies it into /lib/Linux
# All target, builds Irrlicht as static lib (libIrrlicht.a) and copies it into lib/Linux
all linux: staticlib
# Builds Irrlicht as shared lib (libIrrlicht.so.versionNumber) and copies it into /lib/Linux
# Builds Irrlicht as shared lib (libIrrlicht.so.versionNumber) and copies it into lib/Linux
sharedlib: $(LINKOBJ)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -shared -Wl,-soname,$(SHARED_LIB).$(VERSION_MAJOR).$(VERSION_MINOR) -o $(SHARED_LIB).$(VERSION) $^ $(LDFLAGS)
mkdir -p $(LIB_PATH)
cp $(SHARED_LIB).$(VERSION) $(LIB_PATH)
# Builds Irrlicht as static lib (libIrrlicht.a)
$(STATIC_LIB): $(LINKOBJ)
$(AR) rs $@ $^
# Copies static lib into /lib/Linux
# Copies static lib into lib/Linux
staticlib staticlib_osx: $(STATIC_LIB)
mkdir -p $(LIB_PATH)
cp $^ $(LIB_PATH)
# Builds Irrlicht as dll (Irrlicht.dll) into ../../bin/Win32-gcc
@ -165,7 +167,7 @@ help:
@echo "Available targets for Irrlicht"
@echo " sharedlib: Build shared library Irrlicht.so for Linux"
@echo " staticlib: Build static library Irrlicht.a for Linux"
@echo " install: Copy shared library to /usr/lib"
@echo " install: Copy shared library to /usr/local/lib"
@echo ""
@echo " sharedlib_win32: Build shared library Irrlicht.dll for Windows"
@echo " staticlib_win32: Build static library Irrlicht.a for Windows"

View File

@ -14,9 +14,14 @@
/*!
Flags for Octree
*/
#define OCTREE_USE_HARDWARE // use meshbuffer for drawing, enables hardware acceleration
#define OCTREE_PARENTTEST // bypass full invisible/visible test
#define OCTREE_BOX_BASED // use bounding box or frustum for calculate polys
//! use meshbuffer for drawing, enables VBO usage
#define OCTREE_USE_HARDWARE true
//! use visibility information together with VBOs
#define OCTREE_USE_VISIBILITY false
//! use bounding box or frustum for calculate polys
#define OCTREE_BOX_BASED true
//! bypass full invisible/visible test
#define OCTREE_PARENTTEST
namespace irr
{
@ -29,7 +34,6 @@ class Octree
{
public:
#if defined (OCTREE_USE_HARDWARE)
struct SMeshChunk : public scene::CMeshBuffer<T>
{
SMeshChunk ()
@ -45,14 +49,6 @@ public:
s32 MaterialId;
};
#else
struct SMeshChunk
{
core::array<T> Vertices;
core::array<u16> Indices;
s32 MaterialId;
};
#endif
struct SIndexChunk
{

View File

@ -289,7 +289,7 @@ namespace os
//! returns if the timer currently is stopped
bool Timer::isStopped()
{
return VirtualTimerStopCounter != 0;
return VirtualTimerStopCounter < 0;
}
void Timer::initVirtualTimer()

55
tests/anti-aliasing.cpp Normal file
View File

@ -0,0 +1,55 @@
#include "testUtils.h"
using namespace irr;
static bool testLineRendering(video::E_DRIVER_TYPE type)
{
SIrrlichtCreationParameters params;
params.AntiAlias = 0;
params.Bits = 16;
params.WindowSize = core::dimension2d<u32>(160, 120);
params.DriverType = type;
IrrlichtDevice *device = createDeviceEx(params);
if (!device)
return true; // in case the driver type does not exist
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
scene::IAnimatedMesh* mesh = smgr->getMesh("../media/sydney.md2");
if (!mesh)
{
device->drop();
return false;
}
scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
if (node)
{
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("../media/sydney.bmp") );
}
smgr->addCameraSceneNode(0, core::vector3df(0,30,-40), core::vector3df(0,5,0));
driver->beginScene(true, true, video::SColor(255,100,101,140));
smgr->drawAll();
driver->draw3DBox(node->getBoundingBox(), video::SColor(0,255,0,0));
driver->draw2DLine(core::position2di(10,10), core::position2di(100,100), video::SColor(255,0,0,0));
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-lineAntiAliasing.png" );
device->drop();
return result;
}
bool antiAliasing()
{
bool result = testLineRendering(video::EDT_OPENGL);
result &= testLineRendering(video::EDT_DIRECT3D9);
return result;
}

View File

@ -11,7 +11,6 @@ using namespace io;
using namespace gui;
// Tests B3D animations.
/** Verify that two skinned animated mesh scene nodes can use different frames of the skinned mesh */
bool b3dAnimation(void)
{
// Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
@ -23,46 +22,68 @@ bool b3dAnimation(void)
IVideoDriver* driver = device->getVideoDriver();
ISceneManager * smgr = device->getSceneManager();
IAnimatedMesh* mesh = smgr->getMesh("../media/ninja.b3d");
ISkinnedMesh* mesh = (ISkinnedMesh*)smgr->getMesh("../media/ninja.b3d");
assert(mesh);
bool result = false;
if(mesh)
if (!mesh)
return false;
IAnimatedMeshSceneNode* node1 = smgr->addAnimatedMeshSceneNode(mesh);
assert(node1);
/** Verify that two skinned animated mesh scene nodes can use different frames of the skinned mesh */
if(node1)
{
IAnimatedMeshSceneNode* node1 = smgr->addAnimatedMeshSceneNode(mesh);
assert(node1);
if(node1)
{
node1->setPosition(vector3df(-3, -3, 10));
node1->setMaterialFlag(EMF_LIGHTING, false);
node1->setAnimationSpeed(0.f);
node1->setCurrentFrame(10.f);
node1->setDebugDataVisible(irr::scene::EDS_BBOX_BUFFERS);
}
IAnimatedMeshSceneNode* node2 = smgr->addAnimatedMeshSceneNode(mesh);
assert(node2);
if(node2)
{
node2->setPosition(vector3df(3, -3, 10));
node2->setMaterialFlag(EMF_LIGHTING, false);
node2->setAnimationSpeed(0.f);
node2->setCurrentFrame(62.f);
node2->setDebugDataVisible(irr::scene::EDS_BBOX_BUFFERS);
}
(void)smgr->addCameraSceneNode();
// Just jump to the last frame since that's all we're interested in.
device->run();
driver->beginScene(true, true, SColor(255, 60, 60, 60));
smgr->drawAll();
driver->endScene();
result = takeScreenshotAndCompareAgainstReference(driver, "-b3dAnimation.png");
node1->setPosition(vector3df(-3, -3, 10));
node1->setMaterialFlag(EMF_LIGHTING, false);
node1->setAnimationSpeed(0.f);
node1->setCurrentFrame(10.f);
node1->setDebugDataVisible(irr::scene::EDS_BBOX_BUFFERS);
}
IAnimatedMeshSceneNode* node2 = smgr->addAnimatedMeshSceneNode(mesh);
assert(node2);
if(node2)
{
node2->setPosition(vector3df(3, -3, 10));
node2->setMaterialFlag(EMF_LIGHTING, false);
node2->setAnimationSpeed(0.f);
node2->setCurrentFrame(62.f);
node2->setDebugDataVisible(irr::scene::EDS_BBOX_BUFFERS);
}
(void)smgr->addCameraSceneNode();
// Just jump to the last frame since that's all we're interested in.
device->run();
driver->beginScene(true, true, SColor(255, 60, 60, 60));
smgr->drawAll();
driver->endScene();
result = takeScreenshotAndCompareAgainstReference(driver, "-b3dAnimation.png");
if (node2)
node2->remove();
/** Now test if bones are correctly positioned. */
node1->setDebugDataVisible(scene::EDS_SKELETON);
node1->setPosition(vector3df(1, -5, 8));
node1->setRotation(core::vector3df(0,180,0));
node1->updateAbsolutePosition();
for (u32 i=0; i<node1->getJointCount(); ++i)
{
smgr->addCubeSceneNode(1.f,0,-1,node1->getJointNode(i)->getAbsolutePosition());
// smgr->addCubeSceneNode(1.f,node1->getJointNode(i));
}
// Simple render call
device->run();
driver->beginScene(true, true, SColor(255, 60, 60, 60));
smgr->drawAll();
driver->endScene();
result &= takeScreenshotAndCompareAgainstReference(driver, "-b3dJointPosition.png");
device->drop();
return result;

View File

@ -48,9 +48,9 @@ public:
}
void setNextExpectedCollision(ISceneNode* target,
const vector3df& expectedPoint,
const vector3df& expectedPosition,
bool consume)
const vector3df& expectedPoint,
const vector3df& expectedPosition,
bool consume)
{
ExpectedTarget = target;
ExpectedCollisionPoint = expectedPoint;
@ -195,4 +195,3 @@ bool collisionResponseAnimator(void)
return result;
}

44
tests/draw2DImage.cpp Normal file
View File

@ -0,0 +1,44 @@
#include "testUtils.h"
using namespace irr;
static bool testWithRenderTarget(video::E_DRIVER_TYPE driverType)
{
// create device
IrrlichtDevice *device = createDevice(driverType, core::dimension2d<u32>(160,120));
if (device == 0)
return false; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
video::ITexture* RenderTarget=driver->addRenderTargetTexture(core::dimension2d<u32>(64,64), "BASEMAP");
video::ITexture *Image=driver->getTexture("../media/water.jpg");
driver->beginScene(true, true, video::SColor(255,255,0,255));//Backbuffer background is pink
//draw the 256x256 water image on the rendertarget:
driver->setRenderTarget(RenderTarget,true,true,video::SColor(255,0,0,255));//Rendertarget background is blue
driver->draw2DImage(Image, core::position2d<s32>(0,0), core::recti(0,0,32,32));
driver->setRenderTarget(0);
//draw the rendertarget on screen:
//this should normally draw a 64x64 image containing a 32x32 image in the top left corner
driver->draw2DImage(RenderTarget, core::position2d<s32>(0,0));
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-draw2DImageRTT.png");
device->drop();
return result;
}
bool draw2DImage()
{
bool result = testWithRenderTarget(video::EDT_DIRECT3D9);
result &= testWithRenderTarget(video::EDT_OPENGL);
return result;
}

View File

@ -15,7 +15,7 @@ bool enumerateImageManipulators(void)
IVideoDriver* driver = device->getVideoDriver();
const char filenames[][8] =
const char* filenames[] =
{
"foo.bmp",
"foo.jpg",
@ -24,8 +24,20 @@ bool enumerateImageManipulators(void)
"foo.ppm",
"foo.psd",
"foo.tga",
"foo.wal"
// the following have no writers
"foo.wal",
"foo.pgm",
"foo.pbm",
"foo.rgb",
"foo.rgba",
"foo.sgi",
"foo.int",
"foo.inta",
"foo.bw"
};
// how many formats have loaders?
const u32 writersUntil = 7;
const u32 numberOfFilenames = sizeof(filenames) / sizeof(filenames[0]);
bool loaderForFilename[numberOfFilenames] = { false }; // and the rest get 0 == false
bool writerForFilename[numberOfFilenames] = { false }; // and the rest get 0 == false
@ -50,7 +62,6 @@ bool enumerateImageManipulators(void)
if(loader->isALoadableFileExtension(filenames[filename]))
{
loaderForFilename[filename] = true;
break;
}
}
}
@ -106,7 +117,7 @@ bool enumerateImageManipulators(void)
for(u32 filename = 0; filename < numberOfFilenames; ++filename)
{
// There's no writer for the .WAL file type.
if(!writerForFilename[filename] && 0 != strcmp(filenames[filename], "foo.wal"))
if(!writerForFilename[filename] && (filename<writersUntil))
{
logTestString("File type '%s' doesn't have a writer\n", filenames[filename]);
assert(false);

View File

@ -4,6 +4,35 @@ using namespace irr;
using namespace core;
using namespace io;
static bool testgetAbsoluteFilename(io::IFileSystem* fs)
{
bool result=true;
io::path apath = fs->getAbsolutePath("media");
io::path cwd = fs->getWorkingDirectory();
if (apath!=(cwd+"/media"))
{
logTestString("getAbsolutePath failed on existing dir %s\n", apath.c_str());
result = false;
}
apath = fs->getAbsolutePath("../media/");
core::deletePathFromPath(cwd, 1);
if (apath!=(cwd+"media/"))
{
logTestString("getAbsolutePath failed on dir with postfix / %s\n", apath.c_str());
result = false;
}
apath = fs->getAbsolutePath ("../nothere.txt"); // file does not exist
if (apath!=(cwd+"nothere.txt"))
{
logTestString("getAbsolutePath failed on non-existing file %s\n", apath.c_str());
result = false;
}
return result;
}
static bool testFlattenFilename(io::IFileSystem* fs)
{
bool result=true;
@ -92,7 +121,8 @@ bool filesystem(void)
// remove it again to not affect other tests
device->getFileSystem()->removeFileArchive( device->getFileSystem()->getFileArchiveCount() );
result |= testFlattenFilename(fs);
result &= testFlattenFilename(fs);
result &= testgetAbsoluteFilename(fs);
return result;
}

View File

@ -21,7 +21,7 @@ static bool testSelfAssignment()
return myArray.size() == 1;
}
// this will (did once) simply crash when wrong, so no return value
// this will (did once) crash when wrong due to deallocating memory twice, so no return value
static void crashTestFastAlloc()
{
core::array < VarArray, core::irrAllocatorFast<VarArray> > ArrayArray;

View File

@ -8,6 +8,13 @@
using namespace irr;
using namespace core;
static bool testSelfAssignment()
{
core::stringw myString(L"foo");
myString = myString;
return myString == core::stringw(L"foo");
}
static bool testSplit()
{
logTestString("Test stringw::split()\n");
@ -19,6 +26,21 @@ static bool testSplit()
return (parts1.getSize()==4) && (parts2.getSize()==5);
}
static bool testFastAlloc()
{
core::string<wchar_t, core::irrAllocatorFast<wchar_t> > FastString(L"abc");
core::string<wchar_t, core::irrAllocatorFast<wchar_t> > FastStringLong(L"longer");
FastString = L"test";
// cause a reallocation
FastString = FastStringLong;
// this test should either not compile or crash when the allocaters are messed up
return true;
}
// Test the functionality of irrString
/** Validation is done with asserts() against expected results. */
bool testIrrString(void)
@ -71,6 +93,12 @@ bool testIrrString(void)
myPath = "Some text"; // Only to avoid wrong optimizations
}
logTestString("Test self assignment\n");
allExpected &= testSelfAssignment();
logTestString("test fast alloc\n");
allExpected &= testFastAlloc();
if(allExpected)
logTestString("\nAll tests passed\n");
else

View File

@ -63,6 +63,7 @@ int main(int argumentCount, char * arguments[])
TEST(testDimension2d);
TEST(testVector2d);
TEST(testVector3d);
TEST(testaabbox3d);
// TODO: Needs to be fixed first
// TEST(testTriangle3d);
TEST(vectorPositionDimension2d);
@ -80,6 +81,7 @@ int main(int argumentCount, char * arguments[])
TEST(sceneCollisionManager);
TEST(sceneNodeAnimator);
TEST(meshLoaders);
TEST(testTimer);
// software drivers only
TEST(softwareDevice);
TEST(b3dAnimation);
@ -98,6 +100,8 @@ int main(int argumentCount, char * arguments[])
TEST(textureFeatures);
TEST(textureRenderStates);
TEST(transparentAlphaChannelRef);
TEST(antiAliasing);
TEST(draw2DImage);
// TODO: Needs to be fixed first.
// TEST(projectionMatrix);
// large scenes
@ -205,6 +209,11 @@ int main(int argumentCount, char * arguments[])
{
(void)fprintf(testsLastPassedAtFile, "Tests finished. %d test%s of %d passed.\n",
passed, 1 == passed ? "" : "s", numberOfTests);
#ifdef _DEBUG
(void)fprintf(testsLastPassedAtFile, "Compiled as DEBUG\n");
#else
(void)fprintf(testsLastPassedAtFile, "Compiled as RELEASE\n");
#endif
(void)fprintf(testsLastPassedAtFile, "Test suite pass at GMT %s\n", asctime(timeinfo));
(void)fclose(testsLastPassedAtFile);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -271,7 +271,7 @@ static bool getScaledPickedNodeBB(IrrlichtDevice * device,
else if(hit == farTarget)
logTestString("getSceneNodeFromRayBB() hit the far (scaled) target.\n");
else if(hit == middleTarget)
logTestString("getSceneNodeFromRayBB() hit the far (scaled) target.\n");
logTestString("getSceneNodeFromRayBB() hit the middle (scaled) target.\n");
assert(result);
@ -281,6 +281,100 @@ static bool getScaledPickedNodeBB(IrrlichtDevice * device,
}
// box intersection according to Kay et al., code from gamedev.net
static bool IntersectBox(const core::vector3df& origin, const core::vector3df& dir, const core::aabbox3df& box)
{
core::vector3df minDist = (box.MinEdge - origin)/dir;
core::vector3df maxDist = (box.MaxEdge - origin)/dir;
core::vector3df realMin(core::min_(minDist.X, maxDist.X),core::min_(minDist.Y, maxDist.Y),core::min_(minDist.Z, maxDist.Z));
core::vector3df realMax(core::max_(minDist.X, maxDist.X),core::max_(minDist.Y, maxDist.Y),core::max_(minDist.Z, maxDist.Z));
f32 minmax = core::min_(realMax.X, realMax.Y, realMax.Z);
// nearest distance to intersection
f32 maxmin = core::max_(realMin.X, realMin.Y, realMin.Z);
return (maxmin >=0 && minmax >= maxmin);
}
static bool checkBBoxIntersection(IrrlichtDevice * device,
ISceneManager * smgr)
{
video::IVideoDriver* driver = device->getVideoDriver();
// add camera
scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
camera->setPosition(core::vector3df(30, 30, 30));
camera->setTarget(core::vector3df(8.f, 8.f, 8.f));
camera->setID(0);
// add a cube to pick
scene::ISceneNode* cube = smgr->addCubeSceneNode(30, 0, -1, core::vector3df(0,0,0),core::vector3df(30,40,50));
bool result=true;
for (u32 round=0; round<2; ++round)
{
driver->beginScene(true, true, video::SColor(100, 50, 50, 100));
smgr->drawAll();
driver->endScene();
core::matrix4 invMat = cube->getAbsoluteTransformation();
invMat.makeInverse();
s32 hits=0;
u32 start = device->getTimer()->getRealTime();
for (u32 i=10; i<150; ++i)
{
for (u32 j=10; j<110; ++j)
{
const core::position2di pos(i, j);
// get the line used for picking
core::line3df ray = smgr->getSceneCollisionManager()->getRayFromScreenCoordinates(pos, camera);
invMat.transformVect(ray.start);
invMat.transformVect(ray.end);
hits += (cube->getBoundingBox().intersectsWithLine(ray)?1:0);
}
}
u32 duration = device->getTimer()->getRealTime()-start;
logTestString("bbox intersection checks %d hits (of 14000).\n", hits);
hits = -hits;
start = device->getTimer()->getRealTime();
for (u32 i=10; i<150; ++i)
{
for (u32 j=10; j<110; ++j)
{
const core::position2di pos(i, j);
// get the line used for picking
core::line3df ray = smgr->getSceneCollisionManager()->getRayFromScreenCoordinates(pos, camera);
invMat.transformVect(ray.start);
invMat.transformVect(ray.end);
hits += (IntersectBox(ray.start, (ray.end-ray.start).normalize(), cube->getBoundingBox())?1:0);
}
}
u32 duration2 = device->getTimer()->getRealTime()-start;
logTestString("bbox intersection resulted in %d misses at a speed of %d (old) compared to %d (new).\n", abs(hits), duration, duration2);
if (duration>(duration2*1.2f))
logTestString("Consider replacement of bbox intersection test.\n");
result &= (hits==0);
assert(result);
// second round without any hits, so check opposite direction
camera->setTarget(core::vector3df(80.f, 80.f, 80.f));
}
smgr->clear();
return (result);
}
static bool compareGetSceneNodeFromRayBBWithBBIntersectsWithLine(IrrlichtDevice * device,
ISceneManager * smgr,
ISceneCollisionManager * collMgr)
@ -299,15 +393,18 @@ static bool compareGetSceneNodeFromRayBBWithBBIntersectsWithLine(IrrlichtDevice
// add a cube to pick
scene::ISceneNode* cube = smgr->addCubeSceneNode(15);
driver->beginScene(true, true, video::SColor(100, 50, 50, 100));
smgr->drawAll();
driver->endScene();
core::matrix4 invMat = cube->getAbsoluteTransformation();
invMat.makeInverse();
bool result = true;
for (u32 i=68; i<82; ++i)
for (u32 i=76; i<82; ++i)
{
for (u32 j=56; j<64; ++j)
{
driver->beginScene(true, true, video::SColor(100, 50, 50, 100));
smgr->drawAll();
driver->endScene();
const core::position2di pos(i, j);
// get the line used for picking
@ -316,9 +413,6 @@ static bool compareGetSceneNodeFromRayBBWithBBIntersectsWithLine(IrrlichtDevice
// find a selected node
scene::ISceneNode* pick = smgr->getSceneCollisionManager()->getSceneNodeFromRayBB(ray, 1);
core::matrix4 invMat = cube->getAbsoluteTransformation();
invMat.makeInverse();
invMat.transformVect(ray.start);
invMat.transformVect(ray.end);
@ -357,10 +451,10 @@ bool sceneCollisionManager(void)
result &= getCollisionPoint_ignoreTriangleVertices(device, smgr, collMgr);
// TODO: Not yet going through
// result &= compareGetSceneNodeFromRayBBWithBBIntersectsWithLine(device, smgr, collMgr);
result &= checkBBoxIntersection(device, smgr);
result &= compareGetSceneNodeFromRayBBWithBBIntersectsWithLine(device, smgr, collMgr);
device->drop();
return result;
}

View File

@ -215,7 +215,7 @@ bool MemorySerialization(io::IFileSystem * fs )
// Serialization to/from an xml-file
bool XmlSerialization(io::IFileSystem * fs, video::IVideoDriver * driver )
{
const io::path XML_FILENAME("media/attributeSerialization.xml");
const io::path XML_FILENAME("results/attributeSerialization.xml");
SerializableMock origMock(false), copyMock;
origMock.set();
copyMock.reset();

View File

@ -38,10 +38,27 @@ bool testGeometryCreator(void)
0, -1, vector3df(-10, -20, 0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node = smgr->addMeshSceneNode(geom->createConeMesh(5.f, 10.f, 16), 0, -1, vector3df(-35, -20, 0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
node = smgr->addMeshSceneNode(geom->createCubeMesh(), 0, -1, vector3df(-20, -20, 0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
node = smgr->addMeshSceneNode(geom->createCylinderMesh(3, 10, 16), 0, -1, vector3df(0, -20, 10), core::vector3df(45,0,0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
node = smgr->addMeshSceneNode(geom->createSphereMesh(), 0, -1, vector3df(10, -15, 0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
node = smgr->addMeshSceneNode(geom->createVolumeLightMesh(), 0, -1, vector3df(20, -20, -10));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
node->setScale(core::vector3df(4.f,4.f,4.f));
bool result = false;
device->run();
if (driver->beginScene(true, true, video::SColor(0, 80, 80, 80)))

View File

@ -2,13 +2,6 @@
#ifndef _TEST_UTILS_H_
#define _TEST_UTILS_H_ 1
#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) || defined(_WIN32_WCE)
#define TESTING_ON_WINDOWS
#define DIR_SEP_STRING "\\"
#else
#define DIR_SEP_STRING "/"
#endif
#include "irrlicht.h"
#include <assert.h>

385
tests/testaabbox.cpp Normal file
View File

@ -0,0 +1,385 @@
// Copyright (C) 2008-2009 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
using namespace core;
// These tests are also only called for f32 and f64, due to conversion problems
// in the respective methods.
template<class T>
static bool checkCollisions()
{
aabbox3d<T> one(0,0,0,4,4,4);
aabbox3d<T> two(2,2,2,4,4,4);
if (two.getInterpolated(one, 1) != two)
{
logTestString("aabbox3d<T> interpolation wrong on 1\n");
return false;
}
if (two.getInterpolated(one, 0) != one)
{
logTestString("aabbox3d<T> interpolation wrong on 0\n");
return false;
}
aabbox3d<T> three(two.getInterpolated(one, 0.5f));
if (two == one)
{
logTestString("aabbox3d<T> interpolation wrong on 0.5 (right)\n");
return false;
}
if (two == three)
{
logTestString("aabbox3d<T> interpolation wrong on 0.5 (left)\n");
return false;
}
three.reset(aabbox3d<T>(2,2,2,5,5,5));
if (!two.isFullInside(one))
{
logTestString("small aabbox3d<T> is not fully inside\n");
return false;
}
if (three.isFullInside(one))
{
logTestString("large aabbox3d<T> is fully inside\n");
return false;
}
if (!two.intersectsWithBox(one))
{
logTestString("small aabbox3d<T> does not intersect\n");
return false;
}
if (!three.intersectsWithBox(one))
{
logTestString("large aabbox3d<T> does not intersect\n");
return false;
}
core::line3d<T> line(-2,-2,-2,2,2,2);
if (!one.intersectsWithLine(line))
{
logTestString("aabbox3d<T> does not intersect with line(1)\n");
return false;
}
line.end.set(2,2,10);
if (!one.intersectsWithLine(line))
{
logTestString("aabbox3d<T> does not intersect with line(2)\n");
return false;
}
line.end.set(0,2,10);
if (one.intersectsWithLine(line))
{
logTestString("aabbox3d<T> does intersect with line(3)\n");
return false;
}
return true;
}
template<class T>
static bool checkPoints()
{
aabbox3d<T> one(-1,-2,-3,2,2,2);
if (!one.isPointInside(core::vector3d<T>(-1,-2,-3)))
{
logTestString("isPointInside failed with min vertex\n");
return false;
}
if (!one.isPointInside(core::vector3d<T>(-1,2,-3)))
{
logTestString("isPointInside failed with other min vertex\n");
return false;
}
if (!one.isPointInside(core::vector3d<T>(2,-2,2)))
{
logTestString("isPointInside failed with other max vertex\n");
return false;
}
if (!one.isPointInside(core::vector3d<T>(2,2,2)))
{
logTestString("isPointInside failed with max vertex\n");
return false;
}
if (!one.isPointInside(core::vector3d<T>(0,0,0)))
{
logTestString("isPointInside failed with origin\n");
return false;
}
if (!one.isPointInside(core::vector3d<T>((T)1.2,-1,1)))
{
logTestString("isPointInside failed with random point inside\n");
return false;
}
if (one.isPointInside(core::vector3d<T>(-2,-2,-3)))
{
logTestString("isPointInside failed near min vertex\n");
return false;
}
if (one.isPointInside(core::vector3d<T>(2,3,2)))
{
logTestString("isPointInside failed near max vertex\n");
return false;
}
if (one.isPointInside(core::vector3d<T>(3,0,0)))
{
logTestString("isPointInside failed near origin\n");
return false;
}
if (one.isPointInside(core::vector3d<T>((T)10.2,-1,1)))
{
logTestString("isPointInside failed with random point outside\n");
return false;
}
if (one.isPointTotalInside(core::vector3d<T>(-1,-2,-3)))
{
logTestString("isPointTotalInside failed with min vertex\n");
return false;
}
if (one.isPointTotalInside(core::vector3d<T>(-1,2,-3)))
{
logTestString("isPointTotalInside failed with other min vertex\n");
return false;
}
if (one.isPointTotalInside(core::vector3d<T>(2,-2,2)))
{
logTestString("isPointTotalInside failed with other max vertex\n");
return false;
}
if (one.isPointTotalInside(core::vector3d<T>(2,2,2)))
{
logTestString("isPointTotalInside failed with max vertex\n");
return false;
}
if (!one.isPointTotalInside(core::vector3d<T>(0,0,0)))
{
logTestString("isPointTotalInside failed with origin\n");
return false;
}
if (!one.isPointTotalInside(core::vector3d<T>((T)1.2,-1,1)))
{
logTestString("isPointTotalInside failed with random point inside\n");
return false;
}
if (one.isPointTotalInside(core::vector3d<T>((T)10.2,-1,1)))
{
logTestString("isPointTotalInside failed with random point outside\n");
return false;
}
core::plane3d<T> plane(core::vector3d<T>(0,0,-1), -10);
if (one.classifyPlaneRelation(plane) != core::ISREL3D_BACK)
{
logTestString("box not behind\n");
return false;
}
plane.D=0;
if (one.classifyPlaneRelation(plane) != core::ISREL3D_CLIPPED)
{
logTestString("box not clipped\n");
return false;
}
plane.D=10;
if (one.classifyPlaneRelation(plane) != core::ISREL3D_FRONT)
{
logTestString("box not in front\n");
return false;
}
return true;
}
template <class T>
static bool doTests()
{
aabbox3d<T> empty;
aabbox3d<T> one(-1,-1,-1,1,1,1);
if (empty != one)
{
logTestString("default aabbox3d<T> wrong, or comparison failed\n");
return false;
}
if (empty.getCenter() != core::vector3d<T>(0,0,0))
{
logTestString("default aabbox3d<T> has wrong Center\n");
return false;
}
if (empty.getExtent() != core::vector3d<T>(2,2,2))
{
logTestString("default aabbox3d<T> has wrong Extent\n");
return false;
}
if (empty.isEmpty())
{
logTestString("default aabbox3d<T> is empty\n");
return false;
}
if (empty.getVolume() != 8)
{
logTestString("default aabbox3d<T> has wrong volume\n");
return false;
}
if (empty.getArea() != 24)
{
logTestString("default aabbox3d<T> has wrong area\n");
return false;
}
aabbox3d<T> two(core::vector3d<T>(-1,-1,-1),core::vector3d<T>(2,2,2));
if (empty == two)
{
logTestString("empty aabbox3d<T> too large, or comparison failed\n");
return false;
}
if (two.getCenter() != core::vector3d<T>((T)0.5,(T)0.5,(T)0.5))
{
logTestString("extended aabbox3d<T> has wrong Center\n");
return false;
}
if (two.getExtent() != core::vector3d<T>(3,3,3))
{
logTestString("extended aabbox3d<T> has wrong Extent\n");
return false;
}
if (two.isEmpty())
{
logTestString("extended aabbox3d<T> is empty\n");
return false;
}
if (two.getVolume() != 27)
{
logTestString("extended aabbox3d<T> has wrong volume\n");
return false;
}
if (two.getArea() != 54)
{
logTestString("extended aabbox3d<T> has wrong area\n");
return false;
}
one.reset(1,1,1);
if (one==empty)
{
logTestString("reset failed, or comparison failed\n");
return false;
}
if (one.getCenter() != core::vector3d<T>(1,1,1))
{
logTestString("singular aabbox3d<T> has wrong Center\n");
return false;
}
if (one.getExtent() != core::vector3d<T>(0,0,0))
{
logTestString("singular aabbox3d<T> has Extent\n");
return false;
}
if (!one.isEmpty())
{
logTestString("empty aabbox3d<T> is not empty\n");
return false;
}
if (one.getVolume() != 0)
{
logTestString("empty aabbox3d<T> has wrong volume\n");
return false;
}
if (one.getArea() != 0)
{
logTestString("empty aabbox3d<T> has wrong area\n");
return false;
}
one.addInternalPoint(core::vector3d<T>(-1,-1,-1));
if (one!=empty)
{
logTestString("addInternalPoint failed, creating default bbox\n");
return false;
}
one.reset(1,1,1);
one.reset(empty);
if (one!=empty)
{
logTestString("reset with bbox failed, creating default bbox\n");
return false;
}
one.addInternalPoint(core::vector3d<T>(2,2,2));
if (one != two)
{
logTestString("addInternalPoint for aabbox3d<T> failed.\n");
return false;
}
one.addInternalBox(empty);
if (one != two)
{
logTestString("addInternalBox with smaller box failed.\n");
return false;
}
one.addInternalBox(two);
if (one != two)
{
logTestString("addInternalBox with same box failed.\n");
return false;
}
one.addInternalPoint(-1,-2,-3);
two.addInternalPoint(-1,-2,-3);
empty.addInternalBox(one);
if (empty != two)
{
logTestString("addInternalBox with larger box failed\n");
return false;
}
if (one.getCenter() != core::vector3d<T>((T)0.5,0,(T)-0.5))
{
logTestString("large aabbox3d<T> has wrong Center\n");
return false;
}
if (one.getExtent() != core::vector3d<T>(3,4,5))
{
logTestString("large aabbox3d<T> has wrong Extent\n");
return false;
}
if (one.isEmpty())
{
logTestString("large aabbox3d<T> is empty\n");
return false;
}
if (one.getVolume() != 60)
{
logTestString("large aabbox3d<T> has wrong volume\n");
return false;
}
if (one.getArea() != 94)
{
logTestString("large aabbox3d<T> has wrong area\n");
return false;
}
if (!checkPoints<T>())
return false;
return true;
}
/** Test the functionality of aabbox3d<T>. */
bool testaabbox3d(void)
{
bool f32Success = doTests<f32>();
f32Success &= checkCollisions<f32>();
if(f32Success)
logTestString("aabbox3d<f32> tests passed\n\n");
else
logTestString("\n*** aabbox3d<f32> tests failed ***\n\n");
bool f64Success = doTests<f64>();
f64Success &= checkCollisions<f64>();
if(f64Success)
logTestString("aabbox3d<f64> tests passed\n\n");
else
logTestString("\n*** aabbox3d<f64> tests failed ***\n\n");
bool s32Success = doTests<s32>();
if(s32Success)
logTestString("aabbox3d<s32> tests passed\n\n");
else
logTestString("\n*** aabbox3d<s32> tests failed ***\n\n");
return f32Success && f64Success && s32Success;
}

View File

@ -1,3 +1,3 @@
Tests finished. 44 tests of 44 passed.
Test suite pass at GMT Mon Dec 28 10:51:50 2009
Tests finished. 36 tests of 36 passed.
Test suite pass at GMT Tue Dec 29 19:51:18 2009

View File

@ -2,6 +2,9 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tests", "tests_vc9.vcproj", "{2A1DE18B-F678-4A94-A996-E848E20B2983}"
ProjectSection(ProjectDependencies) = postProject
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "..\source\Irrlicht\Irrlicht9.0.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}"
EndProject

View File

@ -114,6 +114,7 @@
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\include"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
WarningLevel="3"
@ -170,6 +171,10 @@
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\anti-aliasing.cpp"
>
</File>
<File
RelativePath=".\archiveReader.cpp"
>
@ -194,6 +199,10 @@
RelativePath=".\disambiguateTextures.cpp"
>
</File>
<File
RelativePath=".\draw2DImage.cpp"
>
</File>
<File
RelativePath=".\drawPixel.cpp"
>
@ -310,6 +319,10 @@
RelativePath=".\terrainSceneNode.cpp"
>
</File>
<File
RelativePath=".\testaabbox.cpp"
>
</File>
<File
RelativePath=".\testDimension2d.cpp"
>
@ -342,6 +355,10 @@
RelativePath=".\textureRenderStates.cpp"
>
</File>
<File
RelativePath=".\timer.cpp"
>
</File>
<File
RelativePath=".\transparentAlphaChannelRef.cpp"
>

View File

@ -91,6 +91,53 @@ static bool renderAndRemove(E_DRIVER_TYPE driverType)
}
static bool testTextureMatrixInMixedScenes(video::E_DRIVER_TYPE driverType)
{
SIrrlichtCreationParameters cp;
cp.DriverType = driverType;
cp.WindowSize = dimension2du(160,120);
irr::IrrlichtDevice* device = createDeviceEx(cp);
if (!device)
return true;
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* sceneManager = device->getSceneManager();
gui::IGUIEnvironment* gui = device->getGUIEnvironment();
ICameraSceneNode* camera = sceneManager->addCameraSceneNode();
camera->setPosition(vector3df(0,10,0));
IGUIStaticText* stext = gui->addStaticText(L" ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 ",
rect<s32>(5,100,150,125),false,false,0,false);
stext->setBackgroundColor(SColor(255,128,0,0));
stext->setOverrideColor(SColor(255,255,255,255));
gui->addEditBox(L"Test edit box", rect<s32>(5,50,150,75));
gui->addCheckBox(true, rect<s32>(5, 20, 150, 45),0,-1,L"Test CheckBox");
video::SMaterial mat;
mat.MaterialType = EMT_SOLID;
mat.setFlag(EMF_LIGHTING, false);
// problem doesn't occur if the scale defaults: (1.f,1.f).
mat.getTextureMatrix(0).setTextureScale(2.0,2.0);
scene::IAnimatedMesh* pmesh = sceneManager->addHillPlaneMesh("testMesh",dimension2d<f32>(50,50),dimension2d<u32>(6,6),&mat);
sceneManager->addAnimatedMeshSceneNode(pmesh);
driver->beginScene(true, true, SColor(255,100,101,140));
sceneManager->drawAll();
gui->drawAll();
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-textureMatrixInMixedScenes.png", 100);
device->drop();
return result;
}
bool textureRenderStates(void)
{
bool passed = true;
@ -107,6 +154,12 @@ bool textureRenderStates(void)
passed &= renderAndRemove(EDT_DIRECT3D9);
passed &= renderAndRemove(EDT_DIRECT3D8);
passed &= testTextureMatrixInMixedScenes(EDT_OPENGL);
passed &= testTextureMatrixInMixedScenes(EDT_SOFTWARE);
passed &= testTextureMatrixInMixedScenes(EDT_BURNINGSVIDEO);
passed &= testTextureMatrixInMixedScenes(EDT_DIRECT3D9);
passed &= testTextureMatrixInMixedScenes(EDT_DIRECT3D8);
return passed;
}

47
tests/timer.cpp Normal file
View File

@ -0,0 +1,47 @@
#include "testUtils.h"
#include <irrlicht.h>
#include <assert.h>
using namespace irr;
using namespace core;
// Test the functionality of the Irrlicht timer
bool testTimer(void)
{
bool success = true;
IrrlichtDevice* device = createDevice(video::EDT_NULL);
if (!device)
return false;
ITimer* timer = device->getTimer();
// must be running at start
success &= !timer->isStopped();
// starting more often should not stop the timer
timer->start();
success &= !timer->isStopped();
// one stop should not stop the timer because it's started twice now
timer->stop();
success &= !timer->isStopped();
// another stop should really stop it
timer->stop();
success &= timer->isStopped();
// third stop - timer should still be stopped
timer->stop();
success &= timer->isStopped();
// should not start yet
timer->start();
success &= timer->isStopped();
// start again
timer->start();
success &= !timer->isStopped();
return success;
}

View File

@ -79,7 +79,7 @@ bool writeImageToFile(void)
}
buffer = new c8[BUFFER_SIZE];
writtenFilename = "results" DIR_SEP_STRING "Burning's Video-drawPixel.png";
writtenFilename = "results/Burning's Video-writeImageToFile.png";
memoryFile = device->getFileSystem()->createMemoryWriteFile(buffer, BUFFER_SIZE, writtenFilename, false);
if(!driver->writeImageToFile(screenshot, memoryFile))
{
@ -106,7 +106,7 @@ bool writeImageToFile(void)
writtenFile->drop();
writtenFile = 0;
referenceFilename = "media" DIR_SEP_STRING "Burning's Video-drawPixel.png";
referenceFilename = "media/Burning's Video-drawPixel.png";
if(!binaryCompareFiles(writtenFilename, referenceFilename))
{
logTestString("File written from memory is not the same as the reference file.\n");

View File

@ -3,7 +3,7 @@
ProjectType="Visual C++"
Version="9,00"
Name="Font Tool"
ProjectGUID="{853A396E-C031-4C26-A716-5B4E176BE11D}"
ProjectGUID="{4D53E40F-37E3-42B1-8848-F4C6F8313A17}"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
@ -120,12 +120,11 @@
/>
<Tool
Name="VCCLCompilerTool"
WholeProgramOptimization="true"
Optimization="2"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="../../../include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
@ -144,13 +143,13 @@
Name="VCLinkerTool"
AdditionalOptions=" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib glu32.lib opengl32.lib gdi32.lib"
OutputFile="../../../bin/Win32-visualstudio/FontTool.exe"
LinkIncremental="2"
LinkIncremental="0"
AdditionalLibraryDirectories="../../../lib/Win32-visualstudio"
GenerateDebugInformation="true"
GenerateDebugInformation="false"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
LinkTimeCodeGeneration="1"
LinkTimeCodeGeneration="0"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Version="9,00"
Name="Mesh Converter"
ProjectGUID="{853A396E-C031-4C26-A716-5B4E176BE11D}"
ProjectGUID="{E72B637E-4AA6-46F3-885F-AC67B4B470ED}"
RootNamespace="GUI Editor"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
@ -123,14 +123,12 @@
<Tool
Name="VCCLCompilerTool"
Optimization="3"
WholeProgramOptimization="true"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="..\..\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"