diff --git a/school/informatik/id3lib/id3lib-3.8.3.zip b/school/informatik/id3lib/id3lib-3.8.3.zip new file mode 100644 index 00000000..fb29c480 Binary files /dev/null and b/school/informatik/id3lib/id3lib-3.8.3.zip differ diff --git a/school/informatik/id3lib/id3lib-3.8.3binaries.zip b/school/informatik/id3lib/id3lib-3.8.3binaries.zip new file mode 100644 index 00000000..b37c6634 Binary files /dev/null and b/school/informatik/id3lib/id3lib-3.8.3binaries.zip differ diff --git a/school/informatik/id3lib/id3lib-doc-3.8.0pre1.tar.gz b/school/informatik/id3lib/id3lib-doc-3.8.0pre1.tar.gz new file mode 100644 index 00000000..61c3e65a Binary files /dev/null and b/school/informatik/id3lib/id3lib-doc-3.8.0pre1.tar.gz differ diff --git a/school/informatik/id3lib/id3tags-20000623.zip b/school/informatik/id3lib/id3tags-20000623.zip new file mode 100644 index 00000000..cd4bfba1 Binary files /dev/null and b/school/informatik/id3lib/id3tags-20000623.zip differ diff --git a/school/informatik/stringlist/stringlist.cpp b/school/informatik/stringlist/stringlist.cpp new file mode 100644 index 00000000..064163b7 --- /dev/null +++ b/school/informatik/stringlist/stringlist.cpp @@ -0,0 +1,76 @@ +#include "stringlist.h" + +// element am Endy anfügen +//string gelesenes_element; +//... +//dyn_array.push_back( gelesenes_element ); + +//Und so kannst du abschliessend auf alle Elems zugreifen: + + +//for( vector::iterator it=dyn_array.begin(); it!=dyn_array.end();++it) +//{ + //coord& elem = *it; + // ... +//} +//n = str_array.size() + +std::string* CStringList::getLine(int lineId) +{ + if(countLines() > lineId) return &std::string(""); + + return &(lines[lineId]); +} + +void CStringList::addLine(std::string *line) +{ + lines.push_back(*(line)); +} + +bool CStringList::delLine(int id) +{ + return true;//lines.erase(id); +} + +int CStringList::insertLine(int pos, std::string *line) +{ + //dummy + return 0; +} + +bool CStringList::loadFromFile(std::string *file) +{ + clear(); + + std::ifstream in(file->c_str()); // Open for reading + + std::string s; + + while(getline(in, s)) // Discards newline char + addLine(&s); + + return true; +} + +int CStringList::countLines() +{ + return int(lines.size()); +} + +int CStringList::countChars() +{ + int result = 0; + for(int i=0;i<=int(lines.size());i++) + { + result += (int)getLine(i)->length(); + } + + return result; +} + +void CStringList::clear() +{ + + lines.clear(); + +} \ No newline at end of file diff --git a/school/informatik/stringlist/stringlist.h b/school/informatik/stringlist/stringlist.h new file mode 100644 index 00000000..57edc7c3 --- /dev/null +++ b/school/informatik/stringlist/stringlist.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include +#include + +class CStringList +{ + std::vector lines; + +public: + + std::string* getLine(int lineId); + void addLine(std::string *line); + bool delLine(int id); + int insertLine(int pos, std::string *line); + bool loadFromFile(std::string *file); + int countLines(); + int countChars(); + void clear(); + +}; \ No newline at end of file diff --git a/school/informatik/typecasts/typecasts.cpp b/school/informatik/typecasts/typecasts.cpp new file mode 100644 index 00000000..4eb2b407 --- /dev/null +++ b/school/informatik/typecasts/typecasts.cpp @@ -0,0 +1,13 @@ +#include "typecasts.h" +#include + +std::string inttostr(int i) +{ + std::string s; + + std::stringstream sstr; + sstr << i; + sstr >> s; + + return s; +} \ No newline at end of file diff --git a/school/informatik/typecasts/typecasts.h b/school/informatik/typecasts/typecasts.h new file mode 100644 index 00000000..6420ba24 --- /dev/null +++ b/school/informatik/typecasts/typecasts.h @@ -0,0 +1,5 @@ +#pragma once + +#include + +std::string inttostr(int i); \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/bin/OIS.dll b/school/informatik/verkerhssimulation/bin/OIS.dll new file mode 100644 index 00000000..84b21610 Binary files /dev/null and b/school/informatik/verkerhssimulation/bin/OIS.dll differ diff --git a/school/informatik/verkerhssimulation/bin/Ogre.log b/school/informatik/verkerhssimulation/bin/Ogre.log new file mode 100644 index 00000000..b1b4ba96 --- /dev/null +++ b/school/informatik/verkerhssimulation/bin/Ogre.log @@ -0,0 +1,315 @@ +07:31:02: Creating resource group General +07:31:02: Creating resource group Internal +07:31:02: Creating resource group Autodetect +07:31:02: SceneManagerFactory for type 'DefaultSceneManager' registered. +07:31:02: Registering ResourceManager for type Material +07:31:02: Registering ResourceManager for type Mesh +07:31:02: Registering ResourceManager for type Skeleton +07:31:02: MovableObjectFactory for type 'ParticleSystem' registered. +07:31:02: OverlayElementFactory for type Panel registered. +07:31:02: OverlayElementFactory for type BorderPanel registered. +07:31:02: OverlayElementFactory for type TextArea registered. +07:31:02: Registering ResourceManager for type Font +07:31:02: ArchiveFactory for archive type FileSystem registered. +07:31:02: ArchiveFactory for archive type Zip registered. +07:31:02: FreeImage version: 3.9.2 +07:31:02: This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details +07:31:02: Supported formats: bmp,ico,jpg,jif,jpeg,jpe,jng,koa,iff,lbm,mng,pbm,pbm,pcd,pcx,pgm,pgm,png,ppm,ppm,ras,tga,targa,tif,tiff,wap,wbmp,wbm,psd,cut,xbm,xpm,gif,hdr,g3,sgi +07:31:02: DDS codec registering +07:31:02: Registering ResourceManager for type HighLevelGpuProgram +07:31:02: Registering ResourceManager for type Compositor +07:31:02: MovableObjectFactory for type 'Entity' registered. +07:31:02: MovableObjectFactory for type 'Light' registered. +07:31:02: MovableObjectFactory for type 'BillboardSet' registered. +07:31:02: MovableObjectFactory for type 'ManualObject' registered. +07:31:02: MovableObjectFactory for type 'BillboardChain' registered. +07:31:02: MovableObjectFactory for type 'RibbonTrail' registered. +07:31:02: Loading library Plugins\RenderSystem_Direct3D9 +07:31:02: Installing plugin: D3D9 RenderSystem +07:31:02: D3D9 : Direct3D9 Rendering Subsystem created. +07:31:02: D3D9: Driver Detection Starts +07:31:02: D3D9: Driver Detection Ends +07:31:02: Plugin successfully installed +07:31:02: Loading library Plugins\RenderSystem_GL +07:31:02: Installing plugin: GL RenderSystem +07:31:02: OpenGL Rendering Subsystem created. +07:31:03: Plugin successfully installed +07:31:03: Loading library Plugins\Plugin_ParticleFX +07:31:03: Installing plugin: ParticleFX +07:31:03: Particle Emitter Type 'Point' registered +07:31:03: Particle Emitter Type 'Box' registered +07:31:03: Particle Emitter Type 'Ellipsoid' registered +07:31:03: Particle Emitter Type 'Cylinder' registered +07:31:03: Particle Emitter Type 'Ring' registered +07:31:03: Particle Emitter Type 'HollowEllipsoid' registered +07:31:03: Particle Affector Type 'LinearForce' registered +07:31:03: Particle Affector Type 'ColourFader' registered +07:31:03: Particle Affector Type 'ColourFader2' registered +07:31:03: Particle Affector Type 'ColourImage' registered +07:31:03: Particle Affector Type 'ColourInterpolator' registered +07:31:03: Particle Affector Type 'Scaler' registered +07:31:03: Particle Affector Type 'Rotator' registered +07:31:03: Particle Affector Type 'DirectionRandomiser' registered +07:31:03: Particle Affector Type 'DeflectorPlane' registered +07:31:03: Plugin successfully installed +07:31:03: Loading library Plugins\Plugin_BSPSceneManager +07:31:03: Installing plugin: BSP Scene Manager +07:31:03: Plugin successfully installed +07:31:03: Loading library Plugins\Plugin_OctreeSceneManager +07:31:03: Installing plugin: Octree & Terrain Scene Manager +07:31:03: Plugin successfully installed +07:31:03: Loading library Plugins\Plugin_CgProgramManager +07:31:03: Installing plugin: Cg Program Manager +07:31:03: Plugin successfully installed +07:31:03: *-*-* OGRE Initialising +07:31:03: *-*-* Version 1.4.4 (Eihort) +07:31:03: Added resource location 'c:\Dokumente und Einstellungen\Rylon\Desktop\source\Verkerhssimulation M&U\media' of type 'FileSystem' to resource group 'General' +07:31:03: Added resource location 'c:\Dokumente und Einstellungen\Rylon\Desktop\source\Verkerhssimulation M&U\media\fonts' of type 'FileSystem' to resource group 'General' +07:31:03: Added resource location 'c:\Dokumente und Einstellungen\Rylon\Desktop\source\Verkerhssimulation M&U\media\materials\programs' of type 'FileSystem' to resource group 'General' +07:31:03: Added resource location 'c:\Dokumente und Einstellungen\Rylon\Desktop\source\Verkerhssimulation M&U\media\materials\scripts' of type 'FileSystem' to resource group 'General' +07:31:03: Added resource location 'c:\Dokumente und Einstellungen\Rylon\Desktop\source\Verkerhssimulation M&U\media\materials\textures' of type 'FileSystem' to resource group 'General' +07:31:03: Added resource location 'c:\Dokumente und Einstellungen\Rylon\Desktop\source\Verkerhssimulation M&U\media\models' of type 'FileSystem' to resource group 'General' +07:31:03: Added resource location 'c:\Dokumente und Einstellungen\Rylon\Desktop\source\Verkerhssimulation M&U\media\overlays' of type 'FileSystem' to resource group 'General' +07:31:03: Added resource location 'c:\Dokumente und Einstellungen\Rylon\Desktop\source\Verkerhssimulation M&U\media\particle' of type 'FileSystem' to resource group 'General' +07:31:03: Added resource location 'c:\Dokumente und Einstellungen\Rylon\Desktop\source\Verkerhssimulation M&U\media\gui' of type 'FileSystem' to resource group 'General' +07:31:03: Added resource location 'c:\Dokumente und Einstellungen\Rylon\Desktop\source\Verkerhssimulation M&U\media\DeferredShadingMedia' of type 'FileSystem' to resource group 'General' +07:31:03: Added resource location 'c:\Dokumente und Einstellungen\Rylon\Desktop\source\Verkerhssimulation M&U\media\packs\cubemap.zip' of type 'Zip' to resource group 'General' +07:31:03: Added resource location 'c:\Dokumente und Einstellungen\Rylon\Desktop\source\Verkerhssimulation M&U\media\packs\cubemapsJS.zip' of type 'Zip' to resource group 'General' +07:31:03: Added resource location 'c:\Dokumente und Einstellungen\Rylon\Desktop\source\Verkerhssimulation M&U\media\packs\dragon.zip' of type 'Zip' to resource group 'General' +07:31:03: Added resource location 'c:\Dokumente und Einstellungen\Rylon\Desktop\source\Verkerhssimulation M&U\media\packs\fresneldemo.zip' of type 'Zip' to resource group 'General' +07:31:03: Added resource location 'c:\Dokumente und Einstellungen\Rylon\Desktop\source\Verkerhssimulation M&U\media\packs\ogretestmap.zip' of type 'Zip' to resource group 'General' +07:31:03: Added resource location 'c:\Dokumente und Einstellungen\Rylon\Desktop\source\Verkerhssimulation M&U\media\packs\skybox.zip' of type 'Zip' to resource group 'General' +07:31:03: Added resource location 'c:\Dokumente und Einstellungen\Rylon\Desktop\source\Verkerhssimulation M&U\media\packs\OgreCore.zip' of type 'Zip' to resource group 'General' +07:31:03: D3D9 : RenderSystem Option: Allow NVPerfHUD = Yes +07:31:03: D3D9 : RenderSystem Option: Anti aliasing = None +07:31:03: D3D9 : RenderSystem Option: Floating-point mode = Fastest +07:31:03: D3D9 : RenderSystem Option: Full Screen = No +07:31:03: D3D9 : RenderSystem Option: Rendering Device = NVIDIA GeForce Go 6800 +07:31:03: D3D9 : RenderSystem Option: VSync = No +07:31:03: D3D9 : RenderSystem Option: Video Mode = 800 x 600 @ 32-bit colour +07:31:07: CPU Identifier & Features +07:31:07: ------------------------- +07:31:07: * CPU ID: GenuineIntel: Intel(R) Pentium(R) M processor 2.00GHz +07:31:07: * SSE: yes +07:31:07: * SSE2: yes +07:31:07: * SSE3: no +07:31:07: * MMX: yes +07:31:07: * MMXEXT: yes +07:31:07: * 3DNOW: no +07:31:07: * 3DNOWEXT: no +07:31:07: * CMOV: yes +07:31:07: * TSC: yes +07:31:07: * FPU: yes +07:31:07: * PRO: no +07:31:07: * HT: no +07:31:07: ------------------------- +07:31:07: D3D9 : Subsystem Initialising +07:31:07: D3D9RenderSystem::createRenderWindow "OGRE Render Window", 800x600 windowed miscParams: FSAA=0 FSAAQuality=0 colourDepth=32 useNVPerfHUD=true vsync=false +07:31:07: D3D9 : Created D3D9 Rendering Window 'OGRE Render Window' : 800x600, 32bpp +07:31:07: D3D9 : WARNING - disabling VSync in windowed mode can cause timing issues at lower frame rates, turn VSync on if you observe this problem. +07:31:07: Registering ResourceManager for type Texture +07:31:07: Registering ResourceManager for type GpuProgram +07:31:07: D3D9: Vertex texture format supported - PF_FLOAT32_RGB +07:31:07: D3D9: Vertex texture format supported - PF_FLOAT32_RGBA +07:31:07: D3D9: Vertex texture format supported - PF_FLOAT32_R +07:31:07: RenderSystem capabilities +07:31:07: ------------------------- +07:31:07: * Hardware generation of mipmaps: yes +07:31:07: * Texture blending: yes +07:31:07: * Anisotropic texture filtering: yes +07:31:07: * Dot product texture operation: yes +07:31:07: * Cube mapping: yes +07:31:07: * Hardware stencil buffer: yes +07:31:07: - Stencil depth: 8 +07:31:07: - Two sided stencil support: yes +07:31:07: - Wrap stencil values: yes +07:31:07: * Hardware vertex / index buffers: yes +07:31:07: * Vertex programs: yes +07:31:07: - Max vertex program version: vs_3_0 +07:31:07: * Fragment programs: yes +07:31:07: - Max fragment program version: ps_3_0 +07:31:07: * Texture Compression: yes +07:31:07: - DXT: yes +07:31:07: - VTC: no +07:31:07: * Scissor Rectangle: yes +07:31:07: * Hardware Occlusion Query: yes +07:31:07: * User clip planes: yes +07:31:07: * VET_UBYTE4 vertex element type: yes +07:31:07: * Infinite far plane projection: yes +07:31:07: * Hardware render-to-texture: yes +07:31:07: * Floating point textures: yes +07:31:07: * Non-power-of-two textures: yes +07:31:07: * Volume textures: yes +07:31:07: * Multiple Render Targets: 4 +07:31:07: * Point Sprites: yes +07:31:07: * Extended point parameters: yes +07:31:07: * Max Point Size: 8192 +07:31:07: * Vertex texture fetch: yes +07:31:07: - Max vertex textures: 4 +07:31:07: - Vertex textures shared: no +07:31:07: *************************************** +07:31:07: *** D3D9 : Subsystem Initialised OK *** +07:31:07: *************************************** +07:31:07: ResourceBackgroundQueue - threading disabled +07:31:07: Particle Renderer Type 'billboard' registered +07:31:07: SceneManagerFactory for type 'OctreeSceneManager' registered. +07:31:07: SceneManagerFactory for type 'TerrainSceneManager' registered. +07:31:07: SceneManagerFactory for type 'BspSceneManager' registered. +07:31:07: Registering ResourceManager for type BspLevel +07:31:07: TerrainSceneManager: Registered a new PageSource for type Heightmap +07:31:07: Parsing scripts for resource group Autodetect +07:31:07: Finished parsing scripts for resource group Autodetect +07:31:07: Parsing scripts for resource group General +07:31:08: Parsing script Examples.program +07:31:08: Parsing script StdQuad_vp.program +07:31:08: Parsing script deferred.glsl.program +07:31:08: Parsing script deferred.hlsl.program +07:31:08: Parsing script deferred_post_debug.glsl.program +07:31:08: Parsing script deferred_post_debug.hlsl.program +07:31:08: Parsing script deferred_post_minilight.glsl.program +07:31:08: Parsing script deferred_post_minilight.hlsl.program +07:31:08: OGRE EXCEPTION(2:InvalidParametersException): Parameter called lightSpecularColor does not exist. in GpuProgramParameters::_findNamedConstantDefinition at ..\src\OgreGpuProgram.cpp (line 883) +07:31:08: Error at line 29 of deferred_post_minilight.hlsl.program: Invalid param_named_auto attribute - Parameter called lightSpecularColor does not exist. +07:31:08: Parsing script deferred_post_multipass.glsl.program +07:31:08: Parsing script deferred_post_multipass.hlsl.program +07:31:08: Parsing script deferred_post_onepass.glsl.program +07:31:08: Parsing script deferred_post_onepass.hlsl.program +07:31:08: Parsing script BlackAndWhite.material +07:31:08: Parsing script Bloom.material +07:31:08: Parsing script DepthShadowmap.material +07:31:08: Parsing script DOF.material +07:31:08: Parsing script Embossed.material +07:31:08: Parsing script Example-DynTex.material +07:31:08: Parsing script Example-Water.material +07:31:08: Parsing script Example.material +07:31:09: Parsing script Examples-Advanced.material +07:31:09: Parsing script facial.material +07:31:09: Parsing script Glass.material +07:31:09: Parsing script hdr.material +07:31:09: Parsing script HeatVision.material +07:31:09: Parsing script Hurt.material +07:31:09: Parsing script instancing.material +07:31:10: Parsing script Invert.material +07:31:10: Parsing script Laplace.material +07:31:10: Parsing script MotionBlur.material +07:31:10: Parsing script Ocean.material +07:31:10: Parsing script OffsetMapping.material +07:31:10: Parsing script Ogre.material +07:31:10: Parsing script OldMovie.material +07:31:10: Parsing script OldTV.material +07:31:10: Parsing script Posterize.material +07:31:10: Parsing script RZR-002.material +07:31:10: Parsing script SharpenEdges.material +07:31:10: Parsing script smoke.material +07:31:10: Parsing script Tiling.material +07:31:10: Parsing script VarianceShadowmap.material +07:31:10: Parsing script deferred.material +07:31:10: Parsing script deferreddemo.material +07:31:10: Parsing script deferred_post_debug.material +07:31:10: Parsing script deferred_post_minilight.material +07:31:10: Parsing script deferred_post_multipass.material +07:31:10: Parsing script deferred_post_onepass.material +07:31:10: Parsing script RomanBath.material +07:31:10: Parsing script OgreCore.material +07:31:10: Parsing script OgreProfiler.material +07:31:10: Parsing script Examples.compositor +07:31:10: Parsing script sample.fontdef +07:31:10: Parsing script Ogre.fontdef +07:31:10: Parsing script emitted_emitter.particle +07:31:10: Parsing script Example-Water.particle +07:31:10: Parsing script Example.particle +07:31:10: Parsing script smoke.particle +07:31:10: Parsing script Compositor.overlay +07:31:10: Texture: New_Ogre_Border_Center.png: Loading 1 faces(PF_A8R8G8B8,256x128x1) with hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x128x1. +07:31:10: Texture: New_Ogre_Border.png: Loading 1 faces(PF_A8R8G8B8,256x256x1) with hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x256x1. +07:31:10: Font BlueHighwayusing texture size 512x512 +07:31:10: Info: Freetype returned null for character 127 in font BlueHighway +07:31:10: Info: Freetype returned null for character 128 in font BlueHighway +07:31:10: Info: Freetype returned null for character 129 in font BlueHighway +07:31:10: Info: Freetype returned null for character 130 in font BlueHighway +07:31:10: Info: Freetype returned null for character 131 in font BlueHighway +07:31:10: Info: Freetype returned null for character 132 in font BlueHighway +07:31:10: Info: Freetype returned null for character 133 in font BlueHighway +07:31:10: Info: Freetype returned null for character 134 in font BlueHighway +07:31:10: Info: Freetype returned null for character 135 in font BlueHighway +07:31:10: Info: Freetype returned null for character 136 in font BlueHighway +07:31:10: Info: Freetype returned null for character 137 in font BlueHighway +07:31:10: Info: Freetype returned null for character 138 in font BlueHighway +07:31:10: Info: Freetype returned null for character 139 in font BlueHighway +07:31:10: Info: Freetype returned null for character 140 in font BlueHighway +07:31:10: Info: Freetype returned null for character 141 in font BlueHighway +07:31:10: Info: Freetype returned null for character 142 in font BlueHighway +07:31:10: Info: Freetype returned null for character 143 in font BlueHighway +07:31:10: Info: Freetype returned null for character 144 in font BlueHighway +07:31:10: Info: Freetype returned null for character 145 in font BlueHighway +07:31:10: Info: Freetype returned null for character 146 in font BlueHighway +07:31:10: Info: Freetype returned null for character 147 in font BlueHighway +07:31:10: Info: Freetype returned null for character 148 in font BlueHighway +07:31:10: Info: Freetype returned null for character 149 in font BlueHighway +07:31:10: Info: Freetype returned null for character 150 in font BlueHighway +07:31:10: Info: Freetype returned null for character 151 in font BlueHighway +07:31:10: Info: Freetype returned null for character 152 in font BlueHighway +07:31:10: Info: Freetype returned null for character 153 in font BlueHighway +07:31:10: Info: Freetype returned null for character 154 in font BlueHighway +07:31:10: Info: Freetype returned null for character 155 in font BlueHighway +07:31:10: Info: Freetype returned null for character 156 in font BlueHighway +07:31:10: Info: Freetype returned null for character 157 in font BlueHighway +07:31:10: Info: Freetype returned null for character 158 in font BlueHighway +07:31:10: Info: Freetype returned null for character 159 in font BlueHighway +07:31:10: Info: Freetype returned null for character 160 in font BlueHighway +07:31:10: Texture: BlueHighwayTexture: Loading 1 faces(PF_BYTE_LA,512x512x1) with 0 generated mipmaps from Image. Internal format is PF_BYTE_LA,512x512x1. +07:31:10: Parsing script DP3.overlay +07:31:10: Parsing script Example-CubeMapping.overlay +07:31:10: Parsing script Example-DynTex.overlay +07:31:10: Parsing script Example-Water.overlay +07:31:10: Parsing script Shadows.overlay +07:31:10: Parsing script OgreDebugPanel.overlay +07:31:10: Texture: New_Ogre_Border_Break.png: Loading 1 faces(PF_A8R8G8B8,32x32x1) with hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,32x32x1. +07:31:10: Texture: ogretext.png: Loading 1 faces(PF_A8R8G8B8,256x128x1) with hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x128x1. +07:31:10: Parsing script OgreLoadingPanel.overlay +07:31:11: Finished parsing scripts for resource group General +07:31:11: Parsing scripts for resource group Internal +07:31:11: Finished parsing scripts for resource group Internal +07:31:11: Creating viewport on target 'OGRE Render Window', rendering from camera 'PlayerCam', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0 +07:31:11: Mesh: Loading ninja.mesh. +07:31:11: Skeleton: Loading ninja.skeleton +07:31:11: Texture: nskingr.jpg: Loading 1 faces(PF_R8G8B8,512x512x1) with hardware generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1. +07:31:11: Texture: BumpyMetal.jpg: Loading 1 faces(PF_R8G8B8,512x512x1) with hardware generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1. +07:31:11: TerrainSceneManager: Activated PageSource Heightmap +07:31:11: Texture: terrain_texture.jpg: Loading 1 faces(PF_R8G8B8,512x512x1) with hardware generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1. +07:31:11: Texture: terrain_detail.jpg: Loading 1 faces(PF_R8G8B8,256x256x1) with hardware generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1. +07:31:11: Texture: clouds.jpg: Loading 1 faces(PF_R8G8B8,256x256x1) with hardware generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1. +07:31:11: *** Initializing OIS *** +07:31:11: Texture: spot_shadow_fade.png: Loading 1 faces(PF_R8G8B8,128x128x1) with hardware generated mipmaps from Image. Internal format is PF_X8R8G8B8,128x128x1. +07:31:13: Unregistering ResourceManager for type BspLevel +07:31:13: *-*-* OGRE Shutdown +07:31:13: Unregistering ResourceManager for type Compositor +07:31:13: Unregistering ResourceManager for type Font +07:31:13: Unregistering ResourceManager for type Skeleton +07:31:13: Unregistering ResourceManager for type Mesh +07:31:13: Unregistering ResourceManager for type HighLevelGpuProgram +07:31:13: Uninstalling plugin: Cg Program Manager +07:31:13: Plugin successfully uninstalled +07:31:13: Unloading library Plugins\Plugin_CgProgramManager +07:31:13: Uninstalling plugin: Octree & Terrain Scene Manager +07:31:13: Plugin successfully uninstalled +07:31:13: Unloading library Plugins\Plugin_OctreeSceneManager +07:31:13: Uninstalling plugin: BSP Scene Manager +07:31:13: Plugin successfully uninstalled +07:31:13: Unloading library Plugins\Plugin_BSPSceneManager +07:31:13: Uninstalling plugin: ParticleFX +07:31:13: Plugin successfully uninstalled +07:31:13: Unloading library Plugins\Plugin_ParticleFX +07:31:13: Uninstalling plugin: GL RenderSystem +07:31:13: *** Stopping Win32GL Subsystem *** +07:31:13: Plugin successfully uninstalled +07:31:13: Unloading library Plugins\RenderSystem_GL +07:31:13: Uninstalling plugin: D3D9 RenderSystem +07:31:13: Render Target 'OGRE Render Window' Average FPS: 397.602 Best FPS: 397.602 Worst FPS: 397.602 +07:31:13: D3D9 : Shutting down cleanly. +07:31:13: Unregistering ResourceManager for type Texture +07:31:13: Unregistering ResourceManager for type GpuProgram +07:31:13: D3D9 : Direct3D9 Rendering Subsystem destroyed. +07:31:13: Plugin successfully uninstalled +07:31:13: Unloading library Plugins\RenderSystem_Direct3D9 +07:31:13: Unregistering ResourceManager for type Material diff --git a/school/informatik/verkerhssimulation/bin/OgreGUIRenderer.dll b/school/informatik/verkerhssimulation/bin/OgreGUIRenderer.dll new file mode 100644 index 00000000..d2896f27 Binary files /dev/null and b/school/informatik/verkerhssimulation/bin/OgreGUIRenderer.dll differ diff --git a/school/informatik/verkerhssimulation/bin/OgreMain.dll b/school/informatik/verkerhssimulation/bin/OgreMain.dll new file mode 100644 index 00000000..e213e070 Binary files /dev/null and b/school/informatik/verkerhssimulation/bin/OgreMain.dll differ diff --git a/school/informatik/verkerhssimulation/bin/OgreMain.dll.org b/school/informatik/verkerhssimulation/bin/OgreMain.dll.org new file mode 100644 index 00000000..eabcf5d5 Binary files /dev/null and b/school/informatik/verkerhssimulation/bin/OgreMain.dll.org differ diff --git a/school/informatik/verkerhssimulation/bin/Plugins.cfg b/school/informatik/verkerhssimulation/bin/Plugins.cfg new file mode 100644 index 00000000..95bb8c92 --- /dev/null +++ b/school/informatik/verkerhssimulation/bin/Plugins.cfg @@ -0,0 +1,14 @@ +# Defines plugins to load + +# Define plugin folder +PluginFolder=Plugins + +# Define plugins +Plugin=RenderSystem_Direct3D9 +Plugin=RenderSystem_GL +Plugin=Plugin_ParticleFX +Plugin=Plugin_BSPSceneManager +Plugin=Plugin_OctreeSceneManager +Plugin=Plugin_CgProgramManager + + diff --git a/school/informatik/verkerhssimulation/bin/Plugins/Plugin_BSPSceneManager.dll b/school/informatik/verkerhssimulation/bin/Plugins/Plugin_BSPSceneManager.dll new file mode 100644 index 00000000..31f214b7 Binary files /dev/null and b/school/informatik/verkerhssimulation/bin/Plugins/Plugin_BSPSceneManager.dll differ diff --git a/school/informatik/verkerhssimulation/bin/Plugins/Plugin_CgProgramManager.dll b/school/informatik/verkerhssimulation/bin/Plugins/Plugin_CgProgramManager.dll new file mode 100644 index 00000000..2b83c1e2 Binary files /dev/null and b/school/informatik/verkerhssimulation/bin/Plugins/Plugin_CgProgramManager.dll differ diff --git a/school/informatik/verkerhssimulation/bin/Plugins/Plugin_OctreeSceneManager.dll b/school/informatik/verkerhssimulation/bin/Plugins/Plugin_OctreeSceneManager.dll new file mode 100644 index 00000000..8122770e Binary files /dev/null and b/school/informatik/verkerhssimulation/bin/Plugins/Plugin_OctreeSceneManager.dll differ diff --git a/school/informatik/verkerhssimulation/bin/Plugins/Plugin_ParticleFX.dll b/school/informatik/verkerhssimulation/bin/Plugins/Plugin_ParticleFX.dll new file mode 100644 index 00000000..9fce5540 Binary files /dev/null and b/school/informatik/verkerhssimulation/bin/Plugins/Plugin_ParticleFX.dll differ diff --git a/school/informatik/verkerhssimulation/bin/Plugins/RenderSystem_Direct3D9.dll b/school/informatik/verkerhssimulation/bin/Plugins/RenderSystem_Direct3D9.dll new file mode 100644 index 00000000..bb4f078c Binary files /dev/null and b/school/informatik/verkerhssimulation/bin/Plugins/RenderSystem_Direct3D9.dll differ diff --git a/school/informatik/verkerhssimulation/bin/Plugins/RenderSystem_GL.dll b/school/informatik/verkerhssimulation/bin/Plugins/RenderSystem_GL.dll new file mode 100644 index 00000000..239fe8f2 Binary files /dev/null and b/school/informatik/verkerhssimulation/bin/Plugins/RenderSystem_GL.dll differ diff --git a/school/informatik/verkerhssimulation/bin/Verkehrssimulation.exe b/school/informatik/verkerhssimulation/bin/Verkehrssimulation.exe new file mode 100644 index 00000000..7b12621e Binary files /dev/null and b/school/informatik/verkerhssimulation/bin/Verkehrssimulation.exe differ diff --git a/school/informatik/verkerhssimulation/bin/cg.dll b/school/informatik/verkerhssimulation/bin/cg.dll new file mode 100644 index 00000000..67df3529 Binary files /dev/null and b/school/informatik/verkerhssimulation/bin/cg.dll differ diff --git a/school/informatik/verkerhssimulation/bin/ogre.cfg b/school/informatik/verkerhssimulation/bin/ogre.cfg new file mode 100644 index 00000000..b31dce70 --- /dev/null +++ b/school/informatik/verkerhssimulation/bin/ogre.cfg @@ -0,0 +1,19 @@ +Render System=Direct3D9 Rendering Subsystem + +[Direct3D9 Rendering Subsystem] +Allow NVPerfHUD=Yes +Anti aliasing=None +Floating-point mode=Fastest +Full Screen=No +Rendering Device=NVIDIA GeForce Go 6800 +VSync=No +Video Mode=800 x 600 @ 32-bit colour + +[OpenGL Rendering Subsystem] +Colour Depth=32 +Display Frequency=N/A +FSAA=0 +Full Screen=No +RTT Preferred Mode=FBO +VSync=Yes +Video Mode=1024 x 768 diff --git a/school/informatik/verkerhssimulation/bin/resources.cfg b/school/informatik/verkerhssimulation/bin/resources.cfg new file mode 100644 index 00000000..88a66b4f --- /dev/null +++ b/school/informatik/verkerhssimulation/bin/resources.cfg @@ -0,0 +1,24 @@ +# Resource locations to be added to the 'boostrap' path +# This also contains the minimum you need to use the Ogre example framework +# [Bootstrap] +# Zip=..\media\packs\OgreCore.zip + +# Resource locations to be added to the default path +[General] +FileSystem=..\media +FileSystem=..\media\fonts +FileSystem=..\media\materials\programs +FileSystem=..\media\materials\scripts +FileSystem=..\media\materials\textures +FileSystem=..\media\models +FileSystem=..\media\overlays +FileSystem=..\media\particle +FileSystem=..\media\gui +FileSystem=..\media\DeferredShadingMedia +Zip=..\media\packs\cubemap.zip +Zip=..\media\packs\cubemapsJS.zip +Zip=..\media\packs\dragon.zip +Zip=..\media\packs\fresneldemo.zip +Zip=..\media\packs\ogretestmap.zip +Zip=..\media\packs\skybox.zip +Zip=..\media\packs\OgreCore.zip \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/bin/test.bat b/school/informatik/verkerhssimulation/bin/test.bat new file mode 100644 index 00000000..814d1350 --- /dev/null +++ b/school/informatik/verkerhssimulation/bin/test.bat @@ -0,0 +1,2 @@ +Verkehrssimulation.exe +pause \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/doc/cmd-line cmds.txt b/school/informatik/verkerhssimulation/doc/cmd-line cmds.txt new file mode 100644 index 00000000..0b64ccfc --- /dev/null +++ b/school/informatik/verkerhssimulation/doc/cmd-line cmds.txt @@ -0,0 +1,2 @@ +-ncle Keine Fehlermeldungen bei unbekannten CMD-Line-CMDs +-ne Keine Fehlermeldungen \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/doc/pixel auslesen.txt b/school/informatik/verkerhssimulation/doc/pixel auslesen.txt new file mode 100644 index 00000000..3440c1e8 --- /dev/null +++ b/school/informatik/verkerhssimulation/doc/pixel auslesen.txt @@ -0,0 +1,4 @@ +http://msdn2.microsoft.com/de-de/library/system.drawing.bitmap.getpixel(VS.80).aspx +http://www.c-plusplus.de/forum/viewtopic-var-p-is-944370.html +http://www.as-hu.de/heightmap/hm.php +http://www.gamedev.net/reference/articles/article2246.asp \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/installer/vcredist_x86.exe b/school/informatik/verkerhssimulation/installer/vcredist_x86.exe new file mode 100644 index 00000000..92b225aa Binary files /dev/null and b/school/informatik/verkerhssimulation/installer/vcredist_x86.exe differ diff --git a/school/informatik/verkerhssimulation/maps/motorway/heightmaps/field001.bmp b/school/informatik/verkerhssimulation/maps/motorway/heightmaps/field001.bmp new file mode 100644 index 00000000..e69de29b diff --git a/school/informatik/verkerhssimulation/maps/motorway/models/car001.model b/school/informatik/verkerhssimulation/maps/motorway/models/car001.model new file mode 100644 index 00000000..e69de29b diff --git a/school/informatik/verkerhssimulation/maps/motorway/models/tree001.model b/school/informatik/verkerhssimulation/maps/motorway/models/tree001.model new file mode 100644 index 00000000..e69de29b diff --git a/school/informatik/verkerhssimulation/maps/motorway/motorway.ini b/school/informatik/verkerhssimulation/maps/motorway/motorway.ini new file mode 100644 index 00000000..80d919e6 --- /dev/null +++ b/school/informatik/verkerhssimulation/maps/motorway/motorway.ini @@ -0,0 +1,13 @@ +[Scripts] +Scrips\terrain.ini +scripts\cars.ini + +[Config] +//Verkehrsdichte: 1.0 ist Optimum = 1 Auto pro Feld mit Fahrbahn +trafficdensity=1.0 + +//Colors +//Alle Werte +/- 100 +righthandtrafficcolor=1000 +lefthandtrafficcolor=2000 +notrafficcolor=3000 \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/maps/motorway/roadmaps/field001.bmp b/school/informatik/verkerhssimulation/maps/motorway/roadmaps/field001.bmp new file mode 100644 index 00000000..e69de29b diff --git a/school/informatik/verkerhssimulation/maps/motorway/scripts/cars.ini b/school/informatik/verkerhssimulation/maps/motorway/scripts/cars.ini new file mode 100644 index 00000000..de0e6ed8 --- /dev/null +++ b/school/informatik/verkerhssimulation/maps/motorway/scripts/cars.ini @@ -0,0 +1,3 @@ +[Cars] +//Verschiedene Autos, die zur Verfügung stehen. Diese werden wiederholt auf die Straße gesetzt +Car=car001.model;maxacceleration;maxbrake;maxvelocity;numberplate;cartype; diff --git a/school/informatik/verkerhssimulation/maps/motorway/scripts/terrain.ini b/school/informatik/verkerhssimulation/maps/motorway/scripts/terrain.ini new file mode 100644 index 00000000..78bd19db --- /dev/null +++ b/school/informatik/verkerhssimulation/maps/motorway/scripts/terrain.ini @@ -0,0 +1,5 @@ +[Terrain] +Terrain=scripts\Terrain\field001;posx;posy;posz; + +[Models] +model=models\tree001.model;posx;posy;posz;strechfactorx;strechfactory;strechfactorz;rotate; \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/maps/motorway/scripts/terrain/field001.ini b/school/informatik/verkerhssimulation/maps/motorway/scripts/terrain/field001.ini new file mode 100644 index 00000000..cb940b61 --- /dev/null +++ b/school/informatik/verkerhssimulation/maps/motorway/scripts/terrain/field001.ini @@ -0,0 +1,4 @@ +[Terrain] +heightmap=heightmaps\field001.bmp +texture=textures\field001.bmp +roadmap=roadmaps\field001.bmp \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/maps/motorway/textures/field001.bmp b/school/informatik/verkerhssimulation/maps/motorway/textures/field001.bmp new file mode 100644 index 00000000..e69de29b diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/COPYING b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/COPYING new file mode 100644 index 00000000..f73ddcf2 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/COPYING @@ -0,0 +1,18 @@ +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/glsl/nm_notex_ps.glsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/glsl/nm_notex_ps.glsl new file mode 100644 index 00000000..29c18115 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/glsl/nm_notex_ps.glsl @@ -0,0 +1,54 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Material shader: Single colour normal mapped +*/ + +#extension GL_ARB_draw_buffers : enable + +varying vec3 normal; +varying vec3 tangent_; +varying vec3 binormal; + +varying vec2 texCoord0; +varying float depth; + +uniform sampler2D normTex; + +uniform float specularity; +uniform vec3 colour; + +void main() +{ + // Frame for normal mapping + mat3 rotation = mat3(tangent_, binormal, normal); + vec3 texnormal = (vec3(texture2D(normTex, texCoord0))-0.5)*2.0; + + gl_FragData[0].rgb = colour; + gl_FragData[0].a = specularity; + // rotation*texnormal is reversed for GL because matrices are stored transposed internally + // compared to HLSL + gl_FragData[1].xyz = normalize(rotation*texnormal); // Do normalisation here, saves an operation per light + gl_FragData[1].w = depth; + +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/glsl/nm_ps.glsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/glsl/nm_ps.glsl new file mode 100644 index 00000000..8363b5e6 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/glsl/nm_ps.glsl @@ -0,0 +1,52 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Material shader: Textured normal mapped +*/ + +#extension GL_ARB_draw_buffers : enable + +varying vec3 normal; +varying vec3 tangent_; +varying vec3 binormal; + +varying vec2 texCoord0; +varying float depth; +uniform sampler2D tex0; +uniform sampler2D normTex; + +uniform float specularity; + +void main() +{ + // Frame for normal mapping + mat3 rotation = mat3(tangent_, binormal, normal); + vec3 texnormal = (vec3(texture2D(normTex, texCoord0))-0.5)*2.0; + + gl_FragData[0].rgb = vec3(texture2D(tex0, texCoord0)); + gl_FragData[0].a = specularity; + // rotation*texnormal is reversed for GL because matrices are stored transposed internally + // compared to HLSL + gl_FragData[1].xyz = normalize(rotation*texnormal); // Do normalisation here, saves an operation per light + gl_FragData[1].w = depth; +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/glsl/nm_vs.glsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/glsl/nm_vs.glsl new file mode 100644 index 00000000..a03e5220 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/glsl/nm_vs.glsl @@ -0,0 +1,47 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Material shader: Normal mapped +*/ +varying vec3 normal; +varying vec3 tangent_; +varying vec3 binormal; + +varying vec2 texCoord0; +varying float depth; + +attribute vec3 tangent; + +void main() +{ + vec4 projPos = gl_ModelViewProjectionMatrix * gl_Vertex; + + gl_Position = projPos; + depth = projPos.w; + texCoord0 = vec2(gl_MultiTexCoord0); + + normal = vec3(gl_ModelViewMatrix*vec4(gl_Normal,0)); + tangent_ = vec3(gl_ModelViewMatrix*vec4(tangent,0)); + binormal = cross(normal, tangent_); + +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/glsl/notex_ps.glsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/glsl/notex_ps.glsl new file mode 100644 index 00000000..6ab6c2af --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/glsl/notex_ps.glsl @@ -0,0 +1,42 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Material shader: Single colour phong +*/ + +#extension GL_ARB_draw_buffers : enable + +varying vec3 normal; +varying vec2 texCoord0; +varying float depth; + +uniform float specularity; +uniform vec3 colour; + +void main() +{ + gl_FragData[0].rgb = colour; + gl_FragData[0].a = specularity; + gl_FragData[1].xyz = normalize(normal); // Do normalisation here, saves an operation per light + gl_FragData[1].w = depth; +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/glsl/ps.glsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/glsl/ps.glsl new file mode 100644 index 00000000..3dbe9eb5 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/glsl/ps.glsl @@ -0,0 +1,42 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Material shader: Textured phongs +*/ + +#extension GL_ARB_draw_buffers : enable + +varying vec3 normal; +varying vec2 texCoord0; +varying float depth; + +uniform sampler2D Tex0; +uniform float specularity; + +void main() +{ + gl_FragData[0].rgb = vec3(texture2D(Tex0, texCoord0)); + gl_FragData[0].a = specularity; + gl_FragData[1].xyz = normalize(normal); // Do normalisation here, saves an operation per light + gl_FragData[1].w = depth; +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/glsl/vs.glsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/glsl/vs.glsl new file mode 100644 index 00000000..51634eba --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/glsl/vs.glsl @@ -0,0 +1,40 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Material shader: Phong material vertex shader +*/ +varying vec3 normal; +varying vec2 texCoord0; +varying float depth; + +void main() +{ + + vec4 projPos = gl_ModelViewProjectionMatrix * gl_Vertex; + + gl_Position = projPos; + depth = projPos.w; + texCoord0 = vec2(gl_MultiTexCoord0); + + normal = vec3(gl_ModelViewMatrix*vec4(gl_Normal,0)); +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/hlsl/nm_notex_ps.hlsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/hlsl/nm_notex_ps.hlsl new file mode 100644 index 00000000..5b681afe --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/hlsl/nm_notex_ps.hlsl @@ -0,0 +1,56 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Material shader: Single colour normal mapped +*/ +sampler Tex0: register(s0); + +struct OUTPUT +{ + float4 color0 : COLOR0; // Diffuse color + ? + float4 color1 : COLOR1; // Normal + depth +}; + +float3 colour; +float specularity; + +OUTPUT main( + float3 normal: TEXCOORD0, + float4 texCoord0: TEXCOORD1, + float depth: TEXCOORD2, + float3 tangent: TEXCOORD3, + float3 binormal: TEXCOORD4 +) +{ + OUTPUT output; + // Frame for normal mapping + float3x3 rotation = float3x3(tangent, binormal, normal); + float3 texnormal = (tex2D(Tex0, texCoord0)-0.5)*2; + + output.color0.rgb = colour; + output.color0.a = specularity; + output.color1.xyz = normalize(mul(texnormal,rotation)); // Do normalisation here, saves an operation per light + output.color1.w = depth; + + return output; +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/hlsl/nm_ps.hlsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/hlsl/nm_ps.hlsl new file mode 100644 index 00000000..9b858713 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/hlsl/nm_ps.hlsl @@ -0,0 +1,56 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Material shader: Textured normal mapped +*/ +sampler Tex0: register(s0); +sampler Tex1: register(s1); + +struct OUTPUT +{ + float4 color0 : COLOR0; // Diffuse color + ? + float4 color1 : COLOR1; // Normal + depth +}; + +float specularity; + +OUTPUT main( + float3 normal: TEXCOORD0, + float4 texCoord0: TEXCOORD1, + float depth: TEXCOORD2, + float3 tangent: TEXCOORD3, + float3 binormal: TEXCOORD4 +) +{ + OUTPUT output; + // Frame for normal mapping + float3x3 rotation = float3x3(tangent, binormal, normal); + float3 texnormal = (tex2D(Tex1, texCoord0)-0.5)*2; + + output.color0.rgb = tex2D(Tex0, texCoord0); + output.color0.a = specularity; + output.color1.xyz = normalize(mul(texnormal,rotation)); // Do normalisation here, saves an operation per light + output.color1.w = depth; + + return output; +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/hlsl/nm_vs.hlsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/hlsl/nm_vs.hlsl new file mode 100644 index 00000000..16c9274c --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/hlsl/nm_vs.hlsl @@ -0,0 +1,61 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Material shader: Normal mapped +*/ +struct VS_OUTPUT { + float4 pos: POSITION; + float4 normal: TEXCOORD0; + float2 texCoord0: TEXCOORD1; + float depth: TEXCOORD2; + float3 tangent: TEXCOORD3; + float3 binormal: TEXCOORD4; +}; + +float4x4 worldViewProj; +float4x4 world; +float4x4 worldView; + +VS_OUTPUT main( + float4 Pos: POSITION, + float3 normal: NORMAL, + float2 texCoord0: TEXCOORD0, + float3 tangent: TANGENT0 +){ + VS_OUTPUT Out; + + Out.normal = mul(worldView, normal); + float4 projPos = mul(worldViewProj, Pos); + + Out.tangent = mul(worldView, tangent); + Out.binormal = cross(Out.normal, Out.tangent); + + Out.pos = projPos; + Out.texCoord0 = texCoord0; + Out.depth = projPos.w; + //Out.depth = projPos.z/projPos.w; + + return Out; +} + + diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/hlsl/notex_ps.hlsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/hlsl/notex_ps.hlsl new file mode 100644 index 00000000..c7daeebe --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/hlsl/notex_ps.hlsl @@ -0,0 +1,47 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Material shader: Single colour phong +*/ +struct OUTPUT +{ + float4 color0 : COLOR0; // Diffuse color + float4 color1 : COLOR1; // Position +}; + +float3 colour; +float specularity; + +OUTPUT main( + float4 normal: TEXCOORD0, + float4 texCoord0: TEXCOORD1, + float depth: TEXCOORD2 +) +{ + OUTPUT output; + output.color0.rgb = colour; + output.color0.a = specularity; + output.color1.xyz = normal; + output.color1.w = depth; + return output; +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/hlsl/ps.hlsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/hlsl/ps.hlsl new file mode 100644 index 00000000..1e5f6965 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/hlsl/ps.hlsl @@ -0,0 +1,48 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Material shader: Textured phongs +*/ +sampler Tex0: register(s0); + +struct OUTPUT +{ + float4 color0 : COLOR0; // Diffuse color + float4 color1 : COLOR1; // Position +}; + +float specularity; + +OUTPUT main( + float4 normal: TEXCOORD0, + float4 texCoord0: TEXCOORD1, + float depth: TEXCOORD2 +) +{ + OUTPUT output; + output.color0.rgb = tex2D(Tex0, texCoord0); + output.color0.a = specularity; + output.color1.xyz = normalize(normal); // Do normalisation here, saves an operation per light + output.color1.w = depth; + return output; +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/hlsl/vs.hlsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/hlsl/vs.hlsl new file mode 100644 index 00000000..5292c3d0 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/material/hlsl/vs.hlsl @@ -0,0 +1,54 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Material shader: Phong material vertex shader +*/ +struct VS_OUTPUT { + float4 pos: POSITION; + float4 normal: TEXCOORD0; + float2 texCoord0: TEXCOORD1; + float1 depth: TEXCOORD2; +}; + +float4x4 worldViewProj; +float4x4 world; +float4x4 worldView; + +VS_OUTPUT main( + float4 Pos: POSITION, + float3 Normal: NORMAL, + float2 texCoord0: TEXCOORD0 +){ + VS_OUTPUT Out; + + Out.normal = mul(worldView, Normal); + float4 projPos = mul(worldViewProj, Pos); + Out.pos = projPos; + Out.texCoord0 = texCoord0; + Out.depth = projPos.w; + //Out.depth = projPos.z/projPos.w; + + return Out; +} + + diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/Ambient_ps.glsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/Ambient_ps.glsl new file mode 100644 index 00000000..2984aefe --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/Ambient_ps.glsl @@ -0,0 +1,56 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Multipass, ambient (base) pass +*/ +uniform sampler2D tex0; +uniform sampler2D tex1; + +varying vec2 texCoord; +varying vec3 projCoord; + +uniform mat4 proj; + +uniform vec3 ambientColor; + +void main() +{ + vec4 a0 = texture2D(tex0, texCoord); // Attribute 0: Diffuse color+shininess + vec4 a1 = texture2D(tex1, texCoord); // Attribute 1: Normal+depth + + // Clip fragment if depth is too far, so the skybox can be rendered on the background + if(a1.w==0.0) + discard; + + // Attributes + vec3 colour = a0.rgb; + float alpha = a0.a; // Specularity + float distance = a1.w; // Distance from viewer -- is zero if no lighting wanted + + // Calculate ambient colour of fragment + gl_FragColor = vec4( ambientColor*colour ,0); + + // Calculate depth of fragment; GL requires a 2.0* here as the range is [-1, 1] + // Also, see again how matrix is transposed ([3][2] instead of [2][3]) + gl_FragDepth = projCoord.z*proj[2][2] + proj[3][2]/(2.0*distance); +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/GlobalLight_ps.glsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/GlobalLight_ps.glsl new file mode 100644 index 00000000..b77c4fc9 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/GlobalLight_ps.glsl @@ -0,0 +1,96 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Multipass, one light +*/ +uniform sampler2D tex0; +uniform sampler2D tex1; + +varying vec2 texCoord; +varying vec3 projCoord; + +// Attributes of light +uniform vec4 lightPos0; +uniform vec3 lightDiffuseColor0; +uniform vec3 lightSpecularColor0; + +// Global parameters for lights +struct LightGlobal +{ + vec3 position; + vec3 normal; + vec3 viewDir; +}; + +// Current state of light +struct LightAccum +{ + vec3 light_diffuse; + vec3 light_specular; +}; + +// Do lighting calculations for one light +void processLight( + inout LightAccum accum, + LightGlobal global, + vec4 lightPos, + vec3 lightDiffuseColor, + vec3 lightSpecularColor) +{ + vec3 lightVec = vec3(lightPos) - global.position; + vec3 lightDir = normalize(lightVec); + accum.light_diffuse += max(0.0,dot(lightDir, global.normal)) * lightDiffuseColor; + + vec3 h = normalize(global.viewDir + lightDir); + accum.light_specular += pow(dot(global.normal, h),32.0) * lightSpecularColor; +} + +void main() +{ + vec4 a0 = texture2D(tex0, texCoord); // Attribute 0: Diffuse color+shininess + vec4 a1 = texture2D(tex1, texCoord); // Attribute 1: Normal+depth + + // Attributes + vec3 colour = a0.rgb; + float alpha = a0.a; // Specularity + float distance = a1.w; // Distance from viewer -- is zero if no lighting wanted + + LightGlobal global; + global.normal = a1.xyz; + global.position = projCoord*distance; + + // Apply light + LightAccum accum; + accum.light_diffuse = vec3(0,0,0); + accum.light_specular = vec3(0,0,0); + global.viewDir = -normalize(global.position); + + processLight(accum, global, lightPos0, lightDiffuseColor0, lightSpecularColor0); + + // Calcalate total lighting for this fragment + vec3 total_light_contrib; + total_light_contrib = accum.light_diffuse+alpha*accum.light_specular; + + // Calculate colour of fragment + gl_FragColor = vec4( total_light_contrib*colour ,0); +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/LightMaterial_ps.glsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/LightMaterial_ps.glsl new file mode 100644 index 00000000..e11b938a --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/LightMaterial_ps.glsl @@ -0,0 +1,85 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Light geometry material +*/ +uniform sampler2D tex0; +uniform sampler2D tex1; + +varying vec2 texCoord; +varying vec3 projCoord; + +// World view matrix to get object position in view space +uniform mat4 worldView; + +// Attributes of light +uniform vec3 lightDiffuseColor; +uniform vec3 lightSpecularColor; +uniform vec3 lightFalloff; + +void main() +{ + vec4 a0 = texture2D(tex0, texCoord); // Attribute 0: Diffuse color+shininess + vec4 a1 = texture2D(tex1, texCoord); // Attribute 1: Normal+depth + + // Attributes + vec3 colour = a0.rgb; + float alpha = a0.a; // Specularity + float distance = a1.w; // Distance from viewer (w) + vec3 normal = a1.xyz; + + // Calculate position of texel in view space + vec3 position = projCoord*distance; + + // Extract position in view space from worldView matrix + //vec3 lightPos = vec3(worldView[0][3],worldView[1][3],worldView[2][3]); + vec3 lightPos = vec3(worldView[3][0],worldView[3][1],worldView[3][2]); + + // Calculate light direction and distance + vec3 lightVec = lightPos - position; + float len_sq = dot(lightVec, lightVec); + float len = sqrt(len_sq); + vec3 lightDir = lightVec/len; + + /// Calculate attenuation + float attenuation = dot(lightFalloff, vec3(1, len, len_sq)); + + /// Calculate diffuse colour + vec3 light_diffuse = max(0.0,dot(lightDir, normal)) * lightDiffuseColor; + + /// Calculate specular component + vec3 viewDir = -normalize(position); + vec3 h = normalize(viewDir + lightDir); + vec3 light_specular = pow(dot(normal, h),32.0) * lightSpecularColor; + + // Calcalate total lighting for this fragment + vec3 total_light_contrib; + total_light_contrib = light_diffuse; + // Uncomment next line if specular desired + //total_light_contrib += alpha * light_specular; + + gl_FragColor = vec4(total_light_contrib*colour/attenuation, 0); + //gl_FragColor = vec4(1.0/attenuation, 0.0,0.0,0.0); + //gl_FragColor = vec4(a1.xyz, 0.0); +} + diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/LightMaterial_vs.glsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/LightMaterial_vs.glsl new file mode 100644 index 00000000..67fb852d --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/LightMaterial_vs.glsl @@ -0,0 +1,61 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Light geometry material +*/ +varying vec2 texCoord; +varying vec3 projCoord; + +uniform float vpWidth; +uniform float vpHeight; +uniform mat4 invProj; + +void main() +{ + vec4 projPos = gl_ModelViewProjectionMatrix * gl_Vertex; + projPos = projPos/projPos.w; + + // projPos is now in nonhomogeneous 2d space -- this makes sure no perspective interpolation is + // done that could mess with our concept. + //gl_Position = projPos; + vec2 texSize = vec2(vpWidth, vpHeight); + vec2 tcTemp = vec2(projPos[0], projPos[1])/2.0+0.5; + tcTemp = (floor(tcTemp * texSize)+0.5)/texSize; + + //float3 position = mul(invProj, float4(projCoord, 0, 1))*distance; + // Acquire view space position via inverse projection transformation + // Optimisation for perspective, symmetric view frustrums + // These interpolate over the frustrum plane for w=1 + + projCoord = vec3(projPos[0], projPos[1], 1)*vec3( + invProj[0][0], // X vector component from X + invProj[1][1], // Y vector component from Y + invProj[3][2] // Z vector component from W + ); + + //projCoord = vec3(invProj*vec4(projPos[0], projPos[1], 0, 1)); + + // Texture coordinate magic, this compensates for jitter + texCoord = vec2(tcTemp[0], 1.0-tcTemp[1]); + gl_Position = vec4((tcTemp-0.5)*2.0, 0.0, 1.0); +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/ShowColour_ps.glsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/ShowColour_ps.glsl new file mode 100644 index 00000000..463237d7 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/ShowColour_ps.glsl @@ -0,0 +1,39 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Debug, show colour channel +*/ +uniform sampler2D tex0; +uniform sampler2D tex1; + +varying vec2 texCoord; +varying vec3 projCoord; + +void main() +{ + vec4 a0 = texture2D(tex0, texCoord); // Attribute 0: Diffuse color+shininess + vec4 a1 = texture2D(tex1, texCoord); // Attribute 1: Normal+depth + + gl_FragColor=vec4(a0.xyz, 0); +} + diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/ShowDS_ps.glsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/ShowDS_ps.glsl new file mode 100644 index 00000000..21929a7d --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/ShowDS_ps.glsl @@ -0,0 +1,39 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Debug, show depth and specularity channel +*/ +uniform sampler2D tex0; +uniform sampler2D tex1; + +varying vec2 texCoord; +varying vec3 projCoord; + +void main() +{ + vec4 a0 = texture2D(tex0, texCoord); // Attribute 0: Diffuse color+shininess + vec4 a1 = texture2D(tex1, texCoord); // Attribute 1: Normal+depth + + gl_FragColor=vec4(a0.w, 0, a1.w/1000.0, 0); +} + diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/ShowNormal_ps.glsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/ShowNormal_ps.glsl new file mode 100644 index 00000000..3e0c5238 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/ShowNormal_ps.glsl @@ -0,0 +1,39 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Debug, show normal channel +*/ +uniform sampler2D tex0; +uniform sampler2D tex1; + +varying vec2 texCoord; +varying vec3 projCoord; + +void main() +{ + vec4 a0 = texture2D(tex0, texCoord); // Attribute 0: Diffuse color+shininess + vec4 a1 = texture2D(tex1, texCoord); // Attribute 1: Normal+depth + + gl_FragColor=vec4((a1.xyz+vec3(1))*0.5,0); +} + diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/SinglePass_ps.glsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/SinglePass_ps.glsl new file mode 100644 index 00000000..f55b3c18 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/SinglePass_ps.glsl @@ -0,0 +1,111 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Single pass +*/ +uniform sampler2D tex0; +uniform sampler2D tex1; + +varying vec2 texCoord; +varying vec3 projCoord; + +uniform mat4 proj; + +uniform vec3 ambientColor; +// Attributes of light 0 +uniform vec4 lightPos0; +uniform vec3 lightDiffuseColor0; +uniform vec3 lightSpecularColor0; +// Attributes of light 1 +uniform vec4 lightPos1; +uniform vec3 lightDiffuseColor1; +uniform vec3 lightSpecularColor1; + +// Global parameters for lights +struct LightGlobal +{ + vec3 position; + vec3 normal; + vec3 viewDir; +}; + +// Current state of light +struct LightAccum +{ + vec3 light_diffuse; + vec3 light_specular; +}; + +// Do lighting calculations for one light +void processLight( + inout LightAccum accum, + LightGlobal global, + vec4 lightPos, + vec3 lightDiffuseColor, + vec3 lightSpecularColor) +{ + vec3 lightVec = vec3(lightPos) - global.position; + vec3 lightDir = normalize(lightVec); + accum.light_diffuse += max(0.0,dot(lightDir, global.normal)) * lightDiffuseColor; + + vec3 h = normalize(global.viewDir + lightDir); + accum.light_specular += pow(dot(global.normal, h),32.0) * lightSpecularColor; +} + +void main() +{ + vec4 a0 = texture2D(tex0, texCoord); // Attribute 0: Diffuse color+shininess + vec4 a1 = texture2D(tex1, texCoord); // Attribute 1: Normal+depth + + // Clip fragment if depth is too far, so the skybox can be rendered on the background + if(a1.w==0.0) + discard; + + // Attributes + vec3 colour = a0.rgb; + float alpha = a0.a; // Specularity + float distance = a1.w; // Distance from viewer -- is zero if no lighting wanted + + LightGlobal global; + global.normal = a1.xyz; + global.position = projCoord*distance; + + // Apply light + LightAccum accum; + accum.light_diffuse = vec3(0,0,0); + accum.light_specular = vec3(0,0,0); + global.viewDir = -normalize(global.position); + + processLight(accum, global, lightPos0, lightDiffuseColor0, lightSpecularColor0); + processLight(accum, global, lightPos1, lightDiffuseColor1, lightSpecularColor1); + + // Calcalate total lighting for this fragment + vec3 total_light_contrib; + total_light_contrib = ambientColor+accum.light_diffuse+alpha*accum.light_specular; + + // Calculate colour of fragment + gl_FragColor = vec4( total_light_contrib*colour ,0); + + // Calculate depth of fragment; GL requires a 2.0* here as the range is [-1, 1] + gl_FragDepth = projCoord.z*proj[2][2] + proj[3][2]/(2.0*distance); +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/vs.glsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/vs.glsl new file mode 100644 index 00000000..51b46227 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/glsl/vs.glsl @@ -0,0 +1,42 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Generic fullscreen quad +*/ +varying vec2 texCoord; +varying vec3 projCoord; + +uniform mat4 invProj; + +void main() +{ + vec2 inPos = sign(gl_Vertex.xy); + gl_Position = vec4(inPos.xy, 0.0, 1.0); + + texCoord = (vec2(inPos.x, -inPos.y) + 1.0)/2.0; + + // Projection coordinates + // Inverted projection matrix + // These interpolate over the frustrum plane for w=1 + projCoord = vec3(invProj*vec4(inPos.x, inPos.y, 0, 1)); +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/Ambient_ps.hlsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/Ambient_ps.hlsl new file mode 100644 index 00000000..feb4f01d --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/Ambient_ps.hlsl @@ -0,0 +1,55 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Multipass, ambient (base) pass +*/ +sampler Tex0: register(s0); +sampler Tex1: register(s1); + +// Ambient and depth pass +float4 ambientColor; + +float4x4 proj; + +struct POUTPUT +{ + float4 colour: COLOR; + float depth: DEPTH; +}; + +POUTPUT main(float2 texCoord: TEXCOORD0, float3 projCoord: TEXCOORD1) +{ + float4 a0 = tex2D(Tex0, texCoord); // Attribute 0: Diffuse color+shininess + float4 a1 = tex2D(Tex1, texCoord); // Attribute 1: Normal+depth + + // Clip fragment if depth is too close, so the skybox can be rendered on the background + clip(a1.w-0.001); + + // Attributes + POUTPUT o; + float3 colour = a0.rgb; + o.colour = float4( ambientColor*colour ,0); + o.depth = projCoord.z*proj[2][2] + proj[2][3]/a1.w; + return o; +} + diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/GlobalLight_ps.hlsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/GlobalLight_ps.hlsl new file mode 100644 index 00000000..6e7fc28d --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/GlobalLight_ps.hlsl @@ -0,0 +1,101 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Multipass, one light +*/ +sampler Tex0: register(s0); +sampler Tex1: register(s1); + +// Attributes of light 0 +float4 lightPos0; +float4 lightDiffuseColor0; +float4 lightSpecularColor0; + +// Global parameters for lights +struct LightGlobal +{ + float3 position; + float3 normal; + float3 viewDir; +}; + +// Current state of light +struct LightAccum +{ + float3 light_diffuse; + float3 light_specular; +}; + +// Do lighting calculations for one light +void processLight( + inout LightAccum accum, + LightGlobal global, + float4 lightPos, + float4 lightDiffuseColor, + float4 lightSpecularColor) +{ + float3 lightVec = lightPos - global.position; + float3 lightDir = normalize(lightVec); + accum.light_diffuse += max(0,dot(lightDir, global.normal)) * lightDiffuseColor; + + float3 h = normalize(global.viewDir + lightDir); + accum.light_specular += pow(dot(global.normal, h),32) * lightSpecularColor; +} + +float4 main(float2 texCoord: TEXCOORD0, float3 projCoord: TEXCOORD1) : COLOR +{ + float4 a0 = tex2D(Tex0, texCoord); // Attribute 0: Diffuse color+shininess + float4 a1 = tex2D(Tex1, texCoord); // Attribute 1: Normal+depth + + LightGlobal global; + + // Clip fragment if depth is too close, so the skybox can be rendered on the background + //clip(a1.w-0.001); + + // Attributes + float3 colour = a0.rgb; + float alpha = a0.a; // Specularity + float distance = a1.w; // Distance from viewer + //global.normal = normalize(a1.xyz); + global.normal = a1.xyz; + + // Acquire view space position via inverse projection transformation + //global.position = mul(invProj, float4(projCoord, 0, 1))*distance; + global.position = projCoord*distance; + + // Apply light + LightAccum accum; + accum.light_diffuse = float3(0,0,0); + accum.light_specular = float3(0,0,0); + global.viewDir = -normalize(global.position); + + processLight(accum, global, lightPos0, lightDiffuseColor0, lightSpecularColor0); + + // Calcalate total lighting for this fragment + float3 total_light_contrib; + total_light_contrib = accum.light_diffuse+alpha*accum.light_specular; + return float4( total_light_contrib*colour ,0); + //return float4(accum.light_diffuse,0); + //return float4(global.position/1000.0,0); +} + diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/LightMaterial_ps.hlsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/LightMaterial_ps.hlsl new file mode 100644 index 00000000..ede10ddd --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/LightMaterial_ps.hlsl @@ -0,0 +1,89 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Light geometry material +*/ +sampler Tex0: register(s0); +sampler Tex1: register(s1); + +float4x4 worldView; + +// Attributes of light +float4 lightDiffuseColor; +float4 lightSpecularColor; +float4 lightFalloff; + +float4 main(float2 texCoord: TEXCOORD0, float3 projCoord: TEXCOORD1) : COLOR +{ + float4 a0 = tex2D(Tex0, texCoord); // Attribute 0: Diffuse color+shininess + float4 a1 = tex2D(Tex1, texCoord); // Attribute 1: Normal+depth + + // Attributes + float3 colour = a0.rgb; + float alpha = a0.a; // Specularity + float distance = a1.w; // Distance from viewer (w) + float3 normal = a1.xyz; + + // Calculate position of texel in view space + float3 position = projCoord*distance; + + // Extract position in view space from worldView matrix + float3 lightPos = float3(worldView[0][3],worldView[1][3],worldView[2][3]); + + // Calculate light direction and distance + float3 lightVec = lightPos - position; + float len_sq = dot(lightVec, lightVec); + float len = sqrt(len_sq); + float3 lightDir = lightVec/len; + + /// Calculate attenuation + float attenuation = dot(lightFalloff, float3(1, len, len_sq)); + + /// Calculate diffuse colour + float3 light_diffuse = max(0,dot(lightDir, normal)) * lightDiffuseColor; + + /// Calculate specular component + float3 viewDir = -normalize(position); + float3 h = normalize(viewDir + lightDir); + float3 light_specular = pow(dot(normal, h),32) * lightSpecularColor; + + // Calcalate total lighting for this fragment + float3 total_light_contrib; + total_light_contrib = light_diffuse; + // Uncomment next line if specular desired + //total_light_contrib += alpha * light_specular; + + return float4(total_light_contrib*colour/attenuation, 0); +} +// Debugging only + //return lightDiffuseColor; + //return lightDiffuseColor/attenuation; + //return float4(abs(position-position2),0); + //return length(lightPos-position)/1000.0; + //return float4(abs(lightPos-lightPos2),0); + //return float4(lightPos-position,0); + //return float4(-global.position/1000.0f,0); + //return float4(global.position/1000.0,0); + ///return float4(lightPos[0], lightPos[1], -lightPos[2], 0)/1000.0f; + //return lightDiffuseColor*a0.xyzw/2; + diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/LightMaterial_vs.hlsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/LightMaterial_vs.hlsl new file mode 100644 index 00000000..2c3229be --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/LightMaterial_vs.hlsl @@ -0,0 +1,69 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Light geometry material +*/ +struct VS_OUTPUT { + float4 pos: POSITION; + float2 texCoord: TEXCOORD0; + float3 projCoord: TEXCOORD1; +}; + +uniform float vpWidth, vpHeight; +uniform float4x4 worldViewProj; +uniform float4x4 invProj; + +VS_OUTPUT main( + float4 Pos: POSITION +){ + VS_OUTPUT Out; + + float4 projPos = mul(worldViewProj, Pos); + projPos = projPos/projPos.w; + //projPos[2] = 0; + + // projPos is now in nonhomogeneous 2d space -- this makes sure no perspective interpolation is + // done that could mess with our concept. + Out.pos = projPos; + + //float3 position = mul(invProj, float4(projCoord, 0, 1))*distance; + // Acquire view space position via inverse projection transformation + // Optimisation for perspective, symmetric view frustrums + // These interpolate over the frustrum plane for w=1 + Out.projCoord = float3(projPos[0], projPos[1], 1)*float3( + invProj[0][0], // X vector component from X + invProj[1][1], // Y vector component from Y + invProj[2][3] // Z vector component from W + ); + + // Texture coordinate magic, this compensates for jitter + float2 texCoord = float2(projPos[0]/2+0.5, -projPos[1]/2+0.5); + float2 texSize = float2(vpWidth, vpHeight); + texCoord = floor(texCoord * texSize)/texSize; + Out.texCoord = texCoord; + + + return Out; +} + + diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/ShowColour_ps.hlsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/ShowColour_ps.hlsl new file mode 100644 index 00000000..bed4b630 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/ShowColour_ps.hlsl @@ -0,0 +1,36 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Debug, show colour channel +*/ +sampler Tex0: register(s0); +sampler Tex1: register(s1); + +float4 main(float2 texCoord: TEXCOORD0, float2 projCoord: TEXCOORD1) : COLOR +{ + float4 a0 = tex2D(Tex0, texCoord); // Attribute 0: Diffuse color+shininess + float4 a1 = tex2D(Tex1, texCoord); // Attribute 1: Normal+depth + + return float4(a0.xyz, 0); +} + diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/ShowDS_ps.hlsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/ShowDS_ps.hlsl new file mode 100644 index 00000000..9512f92d --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/ShowDS_ps.hlsl @@ -0,0 +1,36 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Debug, show depth and specularity channel +*/ +sampler Tex0: register(s0); +sampler Tex1: register(s1); + +float4 main(float2 texCoord: TEXCOORD0, float2 projCoord: TEXCOORD1) : COLOR +{ + float4 a0 = tex2D(Tex0, texCoord); // Attribute 0: Diffuse color+shininess + float4 a1 = tex2D(Tex1, texCoord); // Attribute 1: Normal+depth + + return float4(a0.w, 0, a1.w/1000.0, 0); +} + diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/ShowNormal_ps.hlsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/ShowNormal_ps.hlsl new file mode 100644 index 00000000..dd767899 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/ShowNormal_ps.hlsl @@ -0,0 +1,38 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Debug, show normal channel +*/ +sampler Tex0: register(s0); +sampler Tex1: register(s1); + +float4 main(float2 texCoord: TEXCOORD0, float2 projCoord: TEXCOORD1) : COLOR +{ + float4 a0 = tex2D(Tex0, texCoord); // Attribute 0: Diffuse color+shininess + float4 a1 = tex2D(Tex1, texCoord); // Attribute 1: Normal+depth + + return float4((a1.xyz+1)*0.5,0); + //float d=dot(a1.xyz,float3(0,0,1))*2.0+0.5; + //return float4(1,0,0,0)*d+float4(0,0,1,0)*(1-d); +} + diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/SinglePass_ps.hlsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/SinglePass_ps.hlsl new file mode 100644 index 00000000..c3175349 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/SinglePass_ps.hlsl @@ -0,0 +1,132 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Single pass +*/ +sampler Tex0: register(s0); +sampler Tex1: register(s1); + +float4x4 proj; + +float4 ambientColor; +// Attributes of light 0 +float4 lightPos0; +float4 lightDiffuseColor0; +float4 lightSpecularColor0; +// Attributes of light 1 +float4 lightPos1; +float4 lightDiffuseColor1; +float4 lightSpecularColor1; + +// Global parameters for lights +struct LightGlobal +{ + float3 position; + float3 normal; + float3 viewDir; +}; + +// Current state of light +struct LightAccum +{ + float3 light_diffuse; + float3 light_specular; +}; + +// Do lighting calculations for one light +void processLight( + inout LightAccum accum, + LightGlobal global, + float4 lightPos, + float4 lightDiffuseColor, + float4 lightSpecularColor) +{ + float3 lightVec = lightPos - global.position; + float3 lightDir = normalize(lightVec); + accum.light_diffuse += max(0,dot(lightDir, global.normal)) * lightDiffuseColor; + + float3 h = normalize(global.viewDir + lightDir); + accum.light_specular += pow(dot(global.normal, h),32) * lightSpecularColor; +} + +struct POUTPUT +{ + float4 colour: COLOR; + float depth: DEPTH; +}; + +POUTPUT main(float2 texCoord: TEXCOORD0, float3 projCoord: TEXCOORD1) +{ + POUTPUT o; + + float4 a0 = tex2D(Tex0, texCoord); // Attribute 0: Diffuse color+shininess + float4 a1 = tex2D(Tex1, texCoord); // Attribute 1: Normal+depth + + LightGlobal global; + + // Clip fragment if depth is too far, so the skybox can be rendered on the background + clip(a1.w-0.001); + + // Attributes + float3 colour = a0.rgb; + float alpha = a0.a; // Specularity + float distance = a1.w; // Distance from viewer -- is zero if no lighting wanted + //global.normal = normalize(a1.xyz); // normalizing done already + global.normal = a1.xyz; + + // Acquire view space position via inverse projection transformation + //global.position = mul(invProj, float4(projCoord, 0, 1))*distance; + // Acquire view space position via inverse projection transformation + //float4 tpos; + //tpos = float4(projCoord, distance, 1.0); + //tpos = mul(invProj, tpos); + //tpos = tpos / tpos.w; + //global.position = tpos; + //global.position = float3( + // invProj[0][0], // X vector component from X + // invProj[1][1], // Y vector component from Y + // invProj[2][3] // Z vector component from W + //)*projCoord*distance; + global.position = projCoord*distance; + + // Apply light + LightAccum accum; + accum.light_diffuse = float3(0,0,0); + accum.light_specular = float3(0,0,0); + global.viewDir = -normalize(global.position); + + processLight(accum, global, lightPos0, lightDiffuseColor0, lightSpecularColor0); + processLight(accum, global, lightPos1, lightDiffuseColor1, lightSpecularColor1); + + // Calcalate total lighting for this fragment + float3 total_light_contrib; + total_light_contrib = ambientColor+accum.light_diffuse+alpha*accum.light_specular; + + o.colour = float4( total_light_contrib*colour ,0); + // Depth buffer value + // Transfering depth makes it possible to render particle effects and other transparent + // things unaffected by light in the postprocessing phase. + o.depth = projCoord.z*proj[2][2] + proj[2][3]/distance; + return o; +} + diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/vs.hlsl b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/vs.hlsl new file mode 100644 index 00000000..9a16edd2 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/DeferredShading/post/hlsl/vs.hlsl @@ -0,0 +1,59 @@ +/****************************************************************************** +Copyright (c) W.J. van der Laan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ +/** Deferred shading framework + // W.J. :wumpus: van der Laan 2005 // + + Post shader: Generic fullscreen quad +*/ +struct VS_OUTPUT { + float4 Pos: POSITION; + float2 texCoord: TEXCOORD0; + float3 projCoord: TEXCOORD1; +}; +float4x4 invProj; + +VS_OUTPUT main(float4 Pos: POSITION){ + VS_OUTPUT Out; + + // Clean up inaccuracies + Pos.xy = sign(Pos.xy); + + Out.Pos = float4(Pos.xy, 0, 1); + + // Image-space + Out.texCoord.x = 0.5 * (1 + Pos.x); + Out.texCoord.y = 0.5 * (1 - Pos.y); + + // Projection coordinates + // Inverted projection matrix + // These interpolate over the frustrum plane for w=1 + Out.projCoord = float3(Pos.x, Pos.y, 1) * + float3( + invProj[0][0], // X vector component from X + invProj[1][1], // Y vector component from Y + invProj[2][3] // Z vector component from W + ); + + return Out; +} + + + diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred.glsl.program b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred.glsl.program new file mode 100644 index 00000000..17c9ca54 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred.glsl.program @@ -0,0 +1,50 @@ +// Materials for rendering to the fat buffer + +// Plain phong +vertex_program DeferredShading/material/glsl/vs glsl +{ + source DeferredShading/material/glsl/vs.glsl +} +fragment_program DeferredShading/material/glsl/ps glsl +{ + source DeferredShading/material/glsl/ps.glsl + default_params + { + param_named specularity float 0.0 + } +} +fragment_program DeferredShading/material/glsl/notex_ps glsl +{ + source DeferredShading/material/glsl/notex_ps.glsl + default_params + { + param_named specularity float 0.0 + param_named colour float3 0.7 0.7 0.7 + } +} + +// Normal mapping +vertex_program DeferredShading/material/glsl/nm_vs glsl +{ + source DeferredShading/material/glsl/nm_vs.glsl +} +fragment_program DeferredShading/material/glsl/nm_ps glsl +{ + source DeferredShading/material/glsl/nm_ps.glsl + default_params + { + param_named specularity float 0.0 + param_named tex0 int 0 + param_named normTex int 1 + } +} +fragment_program DeferredShading/material/glsl/nm_notex_ps glsl +{ + source DeferredShading/material/glsl/nm_notex_ps.glsl + default_params + { + param_named colour float3 0.7 0.7 0.7 + param_named specularity float 0.0 + param_named normTex int 0 + } +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred.hlsl.program b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred.hlsl.program new file mode 100644 index 00000000..7772fa1f --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred.hlsl.program @@ -0,0 +1,70 @@ +// Materials for rendering to the fat buffer + +// Plain phong +vertex_program DeferredShading/material/hlsl/vs hlsl +{ + source DeferredShading/material/hlsl/vs.hlsl + target vs_1_1 + entry_point main + + default_params + { + param_named_auto worldView worldview_matrix + param_named_auto worldViewProj worldviewproj_matrix + } +} +fragment_program DeferredShading/material/hlsl/ps hlsl +{ + source DeferredShading/material/hlsl/ps.hlsl + target ps_2_0 + entry_point main + default_params + { + param_named specularity float 0.0 + } +} +fragment_program DeferredShading/material/hlsl/notex_ps hlsl +{ + source DeferredShading/material/hlsl/notex_ps.hlsl + target ps_2_0 + entry_point main + default_params + { + param_named specularity float 0.0 + } +} + +// Normal mapping +vertex_program DeferredShading/material/hlsl/nm_vs hlsl +{ + source DeferredShading/material/hlsl/nm_vs.hlsl + target vs_1_1 + entry_point main + + default_params + { + param_named_auto worldView worldview_matrix + param_named_auto worldViewProj worldviewproj_matrix + } +} +fragment_program DeferredShading/material/hlsl/nm_ps hlsl +{ + source DeferredShading/material/hlsl/nm_ps.hlsl + target ps_2_0 + entry_point main + default_params + { + param_named specularity float 0.0 + } +} +fragment_program DeferredShading/material/hlsl/nm_notex_ps hlsl +{ + source DeferredShading/material/hlsl/nm_notex_ps.hlsl + target ps_2_0 + entry_point main + default_params + { + param_named colour float3 0.7 0.7 0.7 + param_named specularity float 0.0 + } +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred.material b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred.material new file mode 100644 index 00000000..88c6ae5b --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred.material @@ -0,0 +1,152 @@ +// Materials for rendering to the fat buffer + +// Textured Phong shading material +material DeferredShading/Material/TexturedPhong +{ + technique hlsl + { + pass main + { + vertex_program_ref DeferredShading/material/hlsl/vs + { + } + fragment_program_ref DeferredShading/material/hlsl/ps + { + } + + texture_unit + { + } + } + } + technique glsl + { + pass main + { + vertex_program_ref DeferredShading/material/glsl/vs + { + } + fragment_program_ref DeferredShading/material/glsl/ps + { + } + + texture_unit + { + } + } + } +} + +// Untextured Phong shading material +material DeferredShading/Material/UntexturedPhong +{ + technique hlsl + { + pass main + { + vertex_program_ref DeferredShading/material/hlsl/vs + { + } + fragment_program_ref DeferredShading/material/hlsl/notex_ps + { + } + } + } + technique glsl + { + pass main + { + vertex_program_ref DeferredShading/material/glsl/vs + { + } + fragment_program_ref DeferredShading/material/glsl/notex_ps + { + } + } + } +} + +// Textured normal mapped material +material DeferredShading/Material/TexturedNormalMapped +{ + technique hlsl + { + pass main + { + vertex_program_ref DeferredShading/material/hlsl/nm_vs + { + } + fragment_program_ref DeferredShading/material/hlsl/nm_ps + { + } + + texture_unit + { + } + texture_unit + { + tex_coord_set 1 + } + } + } + technique glsl + { + pass main + { + vertex_program_ref DeferredShading/material/glsl/nm_vs + { + } + fragment_program_ref DeferredShading/material/glsl/nm_ps + { + } + + texture_unit + { + } + texture_unit + { + tex_coord_set 1 + } + } + } +} + +// Untextured normal mapped material +material DeferredShading/Material/UntexturedNormalMapped +{ + technique hlsl + { + pass main + { + vertex_program_ref DeferredShading/material/hlsl/nm_vs + { + } + fragment_program_ref DeferredShading/material/hlsl/nm_notex_ps + { + } + texture_unit + { + } + } + } + technique glsl + { + pass main + { + vertex_program_ref DeferredShading/material/glsl/nm_vs + { + } + fragment_program_ref DeferredShading/material/glsl/nm_notex_ps + { + } + texture_unit + { + tex_coord_set 0 + } + texture_unit + { + tex_coord_set 1 + } + } + } +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_debug.glsl.program b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_debug.glsl.program new file mode 100644 index 00000000..98151f31 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_debug.glsl.program @@ -0,0 +1,27 @@ +fragment_program DeferredShading/post/glsl/ShowNormal_ps glsl +{ + source DeferredShading/post/glsl/ShowNormal_ps.glsl + default_params + { + param_named tex0 int 0 + param_named tex1 int 1 + } +} +fragment_program DeferredShading/post/glsl/ShowDS_ps glsl +{ + source DeferredShading/post/glsl/ShowDS_ps.glsl + default_params + { + param_named tex0 int 0 + param_named tex1 int 1 + } +} +fragment_program DeferredShading/post/glsl/ShowColour_ps glsl +{ + source DeferredShading/post/glsl/ShowColour_ps.glsl + default_params + { + param_named tex0 int 0 + param_named tex1 int 1 + } +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_debug.hlsl.program b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_debug.hlsl.program new file mode 100644 index 00000000..494c640e --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_debug.hlsl.program @@ -0,0 +1,18 @@ +fragment_program DeferredShading/post/hlsl/ShowNormal_ps hlsl +{ + source DeferredShading/post/hlsl/ShowNormal_ps.hlsl + target ps_2_0 + entry_point main +} +fragment_program DeferredShading/post/hlsl/ShowDS_ps hlsl +{ + source DeferredShading/post/hlsl/ShowDS_ps.hlsl + target ps_2_0 + entry_point main +} +fragment_program DeferredShading/post/hlsl/ShowColour_ps hlsl +{ + source DeferredShading/post/hlsl/ShowColour_ps.hlsl + target ps_2_0 + entry_point main +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_debug.material b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_debug.material new file mode 100644 index 00000000..b74a6e6f --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_debug.material @@ -0,0 +1,172 @@ +material DeferredShading/Post/ShowNormal +{ + technique + { + pass + { + cull_hardware none + cull_software none + depth_func always_pass + + fragment_program_ref DeferredShading/post/hlsl/ShowNormal_ps + { + } + vertex_program_ref DeferredShading/post/hlsl/vs + { + } + texture_unit + { + tex_address_mode clamp + filtering none + } + texture_unit + { + tex_coord_set 1 + tex_address_mode clamp + filtering none + } + } + } + technique + { + pass + { + cull_hardware none + cull_software none + depth_func always_pass + + fragment_program_ref DeferredShading/post/glsl/ShowNormal_ps + { + } + vertex_program_ref DeferredShading/post/glsl/vs + { + } + texture_unit + { + tex_address_mode clamp + filtering none + } + texture_unit + { + tex_coord_set 1 + tex_address_mode clamp + filtering none + } + } + } +} + +material DeferredShading/Post/ShowDS +{ + technique + { + pass + { + cull_hardware none + cull_software none + depth_func always_pass + + fragment_program_ref DeferredShading/post/hlsl/ShowDS_ps + { + } + vertex_program_ref DeferredShading/post/hlsl/vs + { + } + texture_unit + { + tex_address_mode clamp + filtering none + } + texture_unit + { + tex_coord_set 1 + tex_address_mode clamp + filtering none + } + } + } + technique + { + pass + { + cull_hardware none + cull_software none + depth_func always_pass + + fragment_program_ref DeferredShading/post/glsl/ShowDS_ps + { + } + vertex_program_ref DeferredShading/post/glsl/vs + { + } + texture_unit + { + tex_address_mode clamp + filtering none + } + texture_unit + { + tex_coord_set 1 + tex_address_mode clamp + filtering none + } + } + } +} +material DeferredShading/Post/ShowColour +{ + technique + { + pass + { + cull_hardware none + cull_software none + depth_func always_pass + + fragment_program_ref DeferredShading/post/hlsl/ShowColour_ps + { + } + vertex_program_ref DeferredShading/post/hlsl/vs + { + } + texture_unit + { + tex_address_mode clamp + filtering none + } + texture_unit + { + tex_coord_set 1 + tex_address_mode clamp + filtering none + } + } + } + technique + { + pass + { + cull_hardware none + cull_software none + depth_func always_pass + + fragment_program_ref DeferredShading/post/glsl/ShowColour_ps + { + } + vertex_program_ref DeferredShading/post/glsl/vs + { + } + texture_unit + { + tex_address_mode clamp + filtering none + } + texture_unit + { + tex_coord_set 1 + tex_address_mode clamp + filtering none + } + } + } +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_minilight.glsl.program b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_minilight.glsl.program new file mode 100644 index 00000000..6e831add --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_minilight.glsl.program @@ -0,0 +1,26 @@ +// Auxilary lights +vertex_program DeferredShading/post/glsl/LightMaterial_vs glsl +{ + source DeferredShading/post/glsl/LightMaterial_vs.glsl + default_params + { + param_named_auto invProj inverse_projection_matrix + param_named_auto vpWidth viewport_width + param_named_auto vpHeight viewport_height + } +} +fragment_program DeferredShading/post/glsl/LightMaterial_ps glsl +{ + source DeferredShading/post/glsl/LightMaterial_ps.glsl + default_params + { + param_named_auto worldView worldview_matrix + + param_named_auto lightDiffuseColor custom 1 + param_named_auto lightSpecularColor custom 2 + param_named_auto lightFalloff custom 3 + + param_named tex0 int 0 + param_named tex1 int 1 + } +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_minilight.hlsl.program b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_minilight.hlsl.program new file mode 100644 index 00000000..e1639a39 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_minilight.hlsl.program @@ -0,0 +1,29 @@ +// Auxilary lights +vertex_program DeferredShading/post/hlsl/LightMaterial_vs hlsl +{ + source DeferredShading/post/hlsl/LightMaterial_vs.hlsl + target vs_1_1 + entry_point main + default_params + { + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto invProj inverse_projection_matrix + param_named_auto vpWidth viewport_width + param_named_auto vpHeight viewport_height + } +} +fragment_program DeferredShading/post/hlsl/LightMaterial_ps hlsl +{ + source DeferredShading/post/hlsl/LightMaterial_ps.hlsl + target ps_2_0 + entry_point main + + default_params + { + param_named_auto worldView worldview_matrix + + param_named_auto lightDiffuseColor custom 1 + param_named_auto lightSpecularColor custom 2 + param_named_auto lightFalloff custom 3 + } +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_minilight.material b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_minilight.material new file mode 100644 index 00000000..1c0c42f0 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_minilight.material @@ -0,0 +1,56 @@ +// Auxilary lights + +/// Reference material [geometry] +material DeferredShading/LightMaterial +{ + technique + { + pass + { + // Don't disable depth test, because the light doesn't have to be rendered + // if the bounding geometry is obscured. + scene_blend add + depth_write off + depth_check on + lighting off + + + texture_unit + { + tex_address_mode clamp + filtering none + } + texture_unit + { + tex_address_mode clamp + filtering none + } + } + } +} +/// Reference material [quad] +material DeferredShading/LightMaterialQuad +{ + technique + { + pass + { + scene_blend add + depth_write off + depth_check off + lighting off + + texture_unit + { + tex_address_mode clamp + filtering none + } + texture_unit + { + tex_address_mode clamp + filtering none + } + } + } +} + diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_multipass.glsl.program b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_multipass.glsl.program new file mode 100644 index 00000000..855a99c0 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_multipass.glsl.program @@ -0,0 +1,26 @@ +// Post processors +fragment_program DeferredShading/post/glsl/Ambient_ps glsl +{ + source DeferredShading/post/glsl/Ambient_ps.glsl + + default_params + { + param_named_auto ambientColor ambient_light_colour 0 + param_named_auto proj projection_matrix + param_named tex0 int 0 + param_named tex1 int 1 + } +} +fragment_program DeferredShading/post/glsl/GlobalLight_ps glsl +{ + source DeferredShading/post/glsl/GlobalLight_ps.glsl + + default_params + { + param_named_auto lightPos0 light_position_view_space 0 + param_named_auto lightDiffuseColor0 light_diffuse_colour 0 + param_named_auto lightSpecularColor0 light_specular_colour 0 + param_named tex0 int 0 + param_named tex1 int 1 + } +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_multipass.hlsl.program b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_multipass.hlsl.program new file mode 100644 index 00000000..8a67dc46 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_multipass.hlsl.program @@ -0,0 +1,28 @@ +// Post processors +fragment_program DeferredShading/post/hlsl/Ambient_ps hlsl +{ + source DeferredShading/post/hlsl/Ambient_ps.hlsl + target ps_2_0 + entry_point main + + default_params + { + param_named_auto ambientColor ambient_light_colour 0 + param_named_auto proj projection_matrix + } +} +fragment_program DeferredShading/post/hlsl/GlobalLight_ps hlsl +{ + source DeferredShading/post/hlsl/GlobalLight_ps.hlsl + target ps_2_0 + entry_point main + + default_params + { + //param_named_auto invProj inverse_projection_matrix + + param_named_auto lightPos0 light_position_view_space 0 + param_named_auto lightDiffuseColor0 light_diffuse_colour 0 + param_named_auto lightSpecularColor0 light_specular_colour 0 + } +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_multipass.material b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_multipass.material new file mode 100644 index 00000000..bebff742 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_multipass.material @@ -0,0 +1,118 @@ +// Post processors + +material DeferredShading/Post/Multi +{ + technique + { + pass + { + // Ambient and depth write pass + cull_hardware none + cull_software none + //depth_check off + depth_write on + + fragment_program_ref DeferredShading/post/hlsl/Ambient_ps + { + } + vertex_program_ref DeferredShading/post/hlsl/vs + { + } + texture_unit + { + tex_address_mode clamp + filtering none + } + texture_unit + { + tex_coord_set 1 + tex_address_mode clamp + filtering none + } + } + pass + { + scene_blend add + cull_hardware none + cull_software none + iteration once_per_light + depth_write off + //depth_check off + + fragment_program_ref DeferredShading/post/hlsl/GlobalLight_ps + { + } + vertex_program_ref DeferredShading/post/hlsl/vs + { + } + texture_unit + { + tex_address_mode clamp + filtering none + } + texture_unit + { + tex_coord_set 1 + tex_address_mode clamp + filtering none + } + } + } + technique + { + pass + { + // Ambient and depth write pass + cull_hardware none + cull_software none + //depth_check off + depth_write on + + fragment_program_ref DeferredShading/post/glsl/Ambient_ps + { + } + vertex_program_ref DeferredShading/post/glsl/vs + { + } + texture_unit + { + tex_address_mode clamp + filtering none + } + texture_unit + { + tex_coord_set 1 + tex_address_mode clamp + filtering none + } + } + pass + { + scene_blend add + cull_hardware none + cull_software none + iteration once_per_light + depth_write off + depth_check off + + fragment_program_ref DeferredShading/post/glsl/GlobalLight_ps + { + } + vertex_program_ref DeferredShading/post/glsl/vs + { + } + texture_unit + { + tex_address_mode clamp + filtering none + } + texture_unit + { + tex_coord_set 1 + tex_address_mode clamp + filtering none + } + } + } +} + diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_onepass.glsl.program b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_onepass.glsl.program new file mode 100644 index 00000000..8b58c160 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_onepass.glsl.program @@ -0,0 +1,27 @@ +// Post processors + +vertex_program DeferredShading/post/glsl/vs glsl +{ + source DeferredShading/post/glsl/vs.glsl + default_params + { + param_named_auto invProj inverse_projection_matrix + } +} +fragment_program DeferredShading/post/glsl/SinglePass_ps glsl +{ + source DeferredShading/post/glsl/SinglePass_ps.glsl + default_params + { + param_named_auto proj projection_matrix + param_named_auto ambientColor ambient_light_colour 0 + param_named_auto lightPos0 light_position_view_space 0 + param_named_auto lightDiffuseColor0 light_diffuse_colour 0 + param_named_auto lightSpecularColor0 light_specular_colour 0 + param_named_auto lightPos1 light_position_view_space 1 + param_named_auto lightDiffuseColor1 light_diffuse_colour 1 + param_named_auto lightSpecularColor1 light_specular_colour 1 + param_named tex0 int 0 + param_named tex1 int 1 + } +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_onepass.hlsl.program b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_onepass.hlsl.program new file mode 100644 index 00000000..31157639 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_onepass.hlsl.program @@ -0,0 +1,29 @@ +// Post processors +vertex_program DeferredShading/post/hlsl/vs hlsl +{ + source DeferredShading/post/hlsl/vs.hlsl + target vs_1_1 + entry_point main + default_params + { + param_named_auto invProj inverse_projection_matrix + } +} +fragment_program DeferredShading/post/hlsl/SinglePass_ps hlsl +{ + source DeferredShading/post/hlsl/SinglePass_ps.hlsl + target ps_2_0 + entry_point main + + default_params + { + param_named_auto proj projection_matrix + param_named_auto ambientColor ambient_light_colour 0 + param_named_auto lightPos0 light_position_view_space 0 + param_named_auto lightDiffuseColor0 light_diffuse_colour 0 + param_named_auto lightSpecularColor0 light_specular_colour 0 + param_named_auto lightPos1 light_position_view_space 1 + param_named_auto lightDiffuseColor1 light_diffuse_colour 1 + param_named_auto lightSpecularColor1 light_specular_colour 1 + } +} diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_onepass.material b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_onepass.material new file mode 100644 index 00000000..c97c107b --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferred_post_onepass.material @@ -0,0 +1,65 @@ +// Post processors +material DeferredShading/Post/Single +{ + technique + { + pass + { + cull_hardware none + cull_software none + depth_func always_pass + depth_write on + // Doesn't work for some reason + //depth_check off + + fragment_program_ref DeferredShading/post/hlsl/SinglePass_ps + { + } + vertex_program_ref DeferredShading/post/hlsl/vs + { + } + texture_unit + { + tex_address_mode clamp + filtering none + } + texture_unit + { + tex_coord_set 1 + tex_address_mode clamp + filtering none + } + } + } + technique + { + pass + { + cull_hardware none + cull_software none + depth_func always_pass + depth_write on + // Doesn't work for some reason + //depth_check off + + fragment_program_ref DeferredShading/post/glsl/SinglePass_ps + { + } + vertex_program_ref DeferredShading/post/glsl/vs + { + } + texture_unit + { + tex_address_mode clamp + filtering none + } + texture_unit + { + tex_coord_set 1 + tex_address_mode clamp + filtering none + } + } + } +} + diff --git a/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferreddemo.material b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferreddemo.material new file mode 100644 index 00000000..7124ec5f --- /dev/null +++ b/school/informatik/verkerhssimulation/media/DeferredShadingMedia/deferreddemo.material @@ -0,0 +1,228 @@ +// Materials for deferred shading test + +// Sky box +material Test13/SkyBox +{ + technique + { + pass + { + depth_write off + lighting off + texture_unit + { + cubic_texture evening.jpg separateUV + tex_address_mode clamp + } + } + } +} + +// Ground plane +material Test13/Ground: DeferredShading/Material/TexturedPhong +{ + technique hlsl + { + pass main + { + texture_unit + { + texture grass_1024.jpg + } + } + } + technique glsl + { + pass main + { + texture_unit + { + texture grass_1024.jpg + } + } + } +} + +// Rock wall texture [bumpmapped] +material Test13/RockWall: DeferredShading/Material/TexturedNormalMapped +{ + technique hlsl + { + pass main + { + texture_unit + { + texture rockwall.tga + } + texture_unit + { + texture rockwall_NH.tga + } + } + } + technique glsl + { + pass main + { + texture_unit + { + texture rockwall.tga + } + texture_unit + { + texture rockwall_NH.tga + } + } + } +} + + +// Athena texture [bumpmapped, untextured] +material Test13/DeferredAthena: DeferredShading/Material/UntexturedNormalMapped +{ + technique hlsl + { + pass main + { + texture_unit + { + texture atheneNormalMap.png + } + fragment_program_ref + { + param_named specularity float 0.5 + } + } + } + technique glsl + { + pass main + { + texture_unit + { + texture atheneNormalMap.png + } + fragment_program_ref + { + param_named specularity float 0.5 + } + } + } +} + +/// Ogre parts +material Test13/DeferredOgre/Skin: DeferredShading/Material/TexturedPhong +{ + technique hlsl + { + pass main + { + cull_hardware none + texture_unit + { + texture GreenSkin.jpg + tex_address_mode mirror + } + } + } + technique glsl + { + pass main + { + cull_hardware none + texture_unit + { + texture GreenSkin.jpg + tex_address_mode mirror + } + } + } +} +material Test13/DeferredOgre/EarRing: DeferredShading/Material/UntexturedPhong +{ + technique hlsl + { + pass main + { + fragment_program_ref + { + param_named specularity float 1.5 + param_named colour float3 0.5 0.5 0 + } + } + } + technique glsl + { + pass main + { + fragment_program_ref + { + param_named specularity float 1.5 + param_named colour float3 0.5 0.5 0 + } + } + } +} +material Test13/DeferredOgre/Tusks: DeferredShading/Material/TexturedPhong +{ + technique hlsl + { + pass main + { + fragment_program_ref + { + param_named specularity float 0.5 + } + texture_unit + { + texture dirt01.jpg + } + } + } + technique glsl + { + pass main + { + fragment_program_ref + { + param_named specularity float 0.5 + } + texture_unit + { + texture dirt01.jpg + } + } + } +} +material Test13/DeferredOgre/Eyes: DeferredShading/Material/TexturedPhong +{ + technique hlsl + { + pass main + { + fragment_program_ref + { + param_named specularity float 1.0 + } + texture_unit + { + texture WeirdEye.png + } + } + } + technique glsl + { + pass main + { + fragment_program_ref + { + param_named specularity float 1.0 + } + texture_unit + { + texture WeirdEye.png + } + } + } +} + diff --git a/school/informatik/verkerhssimulation/media/fonts/bluebold.ttf b/school/informatik/verkerhssimulation/media/fonts/bluebold.ttf new file mode 100644 index 00000000..ce5d9048 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/fonts/bluebold.ttf differ diff --git a/school/informatik/verkerhssimulation/media/fonts/bluecond.ttf b/school/informatik/verkerhssimulation/media/fonts/bluecond.ttf new file mode 100644 index 00000000..4c5b01f9 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/fonts/bluecond.ttf differ diff --git a/school/informatik/verkerhssimulation/media/fonts/bluehigh.ttf b/school/informatik/verkerhssimulation/media/fonts/bluehigh.ttf new file mode 100644 index 00000000..14d45c5a Binary files /dev/null and b/school/informatik/verkerhssimulation/media/fonts/bluehigh.ttf differ diff --git a/school/informatik/verkerhssimulation/media/fonts/read_me.html b/school/informatik/verkerhssimulation/media/fonts/read_me.html new file mode 100644 index 00000000..9f53dc86 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/fonts/read_me.html @@ -0,0 +1,2 @@ +Larabie Fonts "read me" file, license and FAQ

LARABIE FONTS “README.TXT”

All Larabie Fonts in this file are free to use for personal and/or commercial purposes. No payment is necessary to use these fonts for personal or commercial use. For Software Products who want to include Larabie Fonts see the License Agreement below. You can add this font to a website but do not combine fonts into a single archive or alter them in any way.

All Larabie Fonts are free for commercial use but a sample of your product would be gratefully appreciated so I can see how the font looks in use. Contact www.larabiefonts.com/donation.html for mailing information.

Some Larabie Fonts have enhanced and expanded families available for sale at www.typodermic.com.

If you'd like to make a voluntary donation to Larabie Fonts for the use of the free fonts in any amount please go to www.larabiefonts.com/donation.html

I accept CDs, magazines, t-shirts, a sample of your merchandise or anything featuring Larabie Fonts. Please remember to list your item as a ‘gift’ on the customs form or I will have to pay import duties and taxes on the item. Mailing information is provided at the link above.

Font installation help is available at www.larabiefonts.com/help.html

LARABIE FONTS FREQUENTLY ASKED QUESTIONS

  • Q: How do use these fonts in my favourite software?
  • A: In Windows, you take the fonts out of the ZIP archive and place them in your fonts folder which can be found in your Control Panel. The next time you run your software, the font will be available. For example: If you install a new font, the next time you run Microsoft Word, that font will be available in the menu under Format / Font. For anything more complicated, or Mac installation, visit www.larabiefonts.com/help.html
  • Q: How can I use this font in AOL Instant Messenger, MSN Messenger, Outlook, Outlook Express, Euodora or any other email software?
  • A: At the time of this writing (Feb 2004) you can’t. After installing one of my fonts, you may be able to select it in the above applications but the person at the other end won’t see that same thing unless they have the font installed. If you really want to use my fonts in these applications, make sure the people at the other end have the same fonts installed.
  • Q: How can I use these fonts on a web page?
  • A: If you’re creating a web page using Flash, it’s easy. Consult your Flash manual. If you’re using Acrobat, make sure the font embedding settings are turned on. Consult your Acrobat manual. For anything else there are limitations: If you want to use one of my fonts as your main, text font you’re pretty much out of luck unless you explore a font embedding tool such as WEFT but I don’t recommend it. To use my fonts as headings or titles, use image creation software such as The Gimp, Photoshop, Paint Shop Pro, Pixia etc. Save the images as GIF files and place them on your web page. There’s a lot more to it than can be explained here but there are countless books available on web page design.
  • Q: How can I make these fonts bigger?
  • A: All my fonts are infinitely scalable; the limitations are in your software. A common problem is scaling fonts in Microsoft Word. If you choose Format / Font you can type in any number you like under “size”.
  • Q: Are these fonts really free?
  • A: Yes they are. Some fonts such as Neuropol have expanded font families available for sale at www.typodermic.com but the version you downloaded at Larabie Fonts is free.
  • Q: Your licence agreement states that the fonts can’t be altered. Does that mean I can’t mess around with your fonts in Photoshop/Illustrator/Publisher etc?
  • A: Those license restrictions refer to altering the actual fonts themselves, not what you make with them. As long as you don’t alter the font files in font creation software such as FontLab or Fontographer you’re free to create anything you like with them.
  • Q: Can I use your fonts in a logo?
  • A: Yes. But check with a lawyer if you’re not sure. It’s okay with me if you use it but do so at your own risk.
  • Q: Can you make a custom font for me?
  • A: Possibly. Check typodermic.com/custom.html for details. Keep in mind that making fonts is my full-time job so no freebies.
  • Q: I want to sell rubber stamp alphabets, alphabet punches or stencil alphabets using your font designs.
  • A: Contact me first at www.larabiefonts.com/email.html.
  • Q: My software won’t let me embed one of your fonts.
  • A: You may have an old version of one of my fonts. Uninstall it and install a current version on Larabie Fonts.
  • Q: Can you help me find a font?
  • A: I really don’t have the time but if you send a donation, I can give it a try. If not. post your question on my font forum: www.larabiefonts.com/info.html.

LARABIE FONTS END-USER LICENSE AGREEMENT FOR SOFTWARE PRODUCTS

SOFTWARE PRODUCT LICENSE

The SOFTWARE PRODUCT is protected by copyright laws and International copyright treaties, as well as other intellectual property laws and treaties. The SOFTWARE PRODUCT is licensed, not sold.

1. GRANT OF LICENSE. This document grants you the following rights:

- Installation and Use. You may install and use an unlimited number of copies of the SOFTWARE PRODUCT. You may copy and distribute unlimited copies of the SOFTWARE PRODUCT as you receive them, in any medium, provided that you publish on each copy an appropriate copyright notice. Keep intact all the notices that refer to this License and give any other recipients of the fonts a copy of this License along with the fonts.

2. DESCRIPTION OF OTHER RIGHTS AND LIMITATIONS.

- You may modify your copy or copies of the SOFTWARE PRODUCT or any portion of it, provided that you also meet all of these rules:

a) Do not alter in any way alphanumeric characters (A-Z, a-z, 1-9) contained in the font. An exception is converting between formats, here is allowed the nominal distortion that occurs during conversion from second order to third order quadratic curves (TrueType to Postscript) and vice versa.

b) Extra characters may be added; here it is allowed to use curves (shapes) from alphanumeric characters in fonts under same license.

c) It is allowed to modify and remove analpahbetics (punctuation, special characters, ligatures and symbols).

d) The original font name must be retained but can be augmented. (ie. a Font named Blue Highway can be renamed Blue Highway Cyrillic or Blue Highway ANSI, etc.)

e) Character mapping may be altered.

f) If the kerning information is altered or discarded it must be stated in the user notes or documentation.

g) All modifications must be released under this license.

LIMITED WARRANTY NO WARRANTIES. Larabie Fonts expressly disclaims any warranty for the SOFTWARE PRODUCT. The SOFTWARE PRODUCT and any related documentation is provided "as is" without warranty of any kind, either express or implied, including, without limitation, the implied warranties or merchantability, fitness for a particular purpose, or non-infringement. The entire risk arising out of use or performance of the SOFTWARE PRODUCT remains with you.

NO LIABILITY FOR CONSEQUENTIAL DAMAGES. In no event shall Larabie Fonts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or any other pecuniary loss) arising out of the use of or inability to use this product, even if Larabie Fonts has been advised of the possibility of such damages.

3. MISCELLANEOUS

Should you have any questions concerning this document, or if you desire to contact Larabie Fonts for any reason, please email www.larabiefonts.com/email.html.

+ diff --git a/school/informatik/verkerhssimulation/media/fonts/sample.fontdef b/school/informatik/verkerhssimulation/media/fonts/sample.fontdef new file mode 100644 index 00000000..462defc5 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/fonts/sample.fontdef @@ -0,0 +1,11 @@ +StarWars +{ + // Now this one I agree with ;) + // A Star Wars font :) + type truetype + source solo5.ttf + size 16 + resolution 96 +} + + diff --git a/school/informatik/verkerhssimulation/media/fonts/solo5.ttf b/school/informatik/verkerhssimulation/media/fonts/solo5.ttf new file mode 100644 index 00000000..c723496e Binary files /dev/null and b/school/informatik/verkerhssimulation/media/fonts/solo5.ttf differ diff --git a/school/informatik/verkerhssimulation/media/gui/CompositorDemo.layout b/school/informatik/verkerhssimulation/media/gui/CompositorDemo.layout new file mode 100644 index 00000000..4e8fda95 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/CompositorDemo.layout @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/school/informatik/verkerhssimulation/media/gui/CompositorDemoCegui.config b/school/informatik/verkerhssimulation/media/gui/CompositorDemoCegui.config new file mode 100644 index 00000000..3623f0b8 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/CompositorDemoCegui.config @@ -0,0 +1,6 @@ + + diff --git a/school/informatik/verkerhssimulation/media/gui/CrowdDemo.layout b/school/informatik/verkerhssimulation/media/gui/CrowdDemo.layout new file mode 100644 index 00000000..471968b4 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/CrowdDemo.layout @@ -0,0 +1,201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/school/informatik/verkerhssimulation/media/gui/Falagard.xsd b/school/informatik/verkerhssimulation/media/gui/Falagard.xsd new file mode 100644 index 00000000..09c1b20c --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/Falagard.xsd @@ -0,0 +1,391 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/school/informatik/verkerhssimulation/media/gui/Font.xsd b/school/informatik/verkerhssimulation/media/gui/Font.xsd new file mode 100644 index 00000000..5ab529cd --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/Font.xsd @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/school/informatik/verkerhssimulation/media/gui/GUILayout.xsd b/school/informatik/verkerhssimulation/media/gui/GUILayout.xsd new file mode 100644 index 00000000..0a3a5b9c --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/GUILayout.xsd @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/school/informatik/verkerhssimulation/media/gui/GUIScheme.xsd b/school/informatik/verkerhssimulation/media/gui/GUIScheme.xsd new file mode 100644 index 00000000..24dba207 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/GUIScheme.xsd @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/media/gui/Imageset.xsd b/school/informatik/verkerhssimulation/media/gui/Imageset.xsd new file mode 100644 index 00000000..49ced132 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/Imageset.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/school/informatik/verkerhssimulation/media/gui/InstancingDemo.layout b/school/informatik/verkerhssimulation/media/gui/InstancingDemo.layout new file mode 100644 index 00000000..33469a88 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/InstancingDemo.layout @@ -0,0 +1,214 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/school/informatik/verkerhssimulation/media/gui/OceanDemoCegui.config b/school/informatik/verkerhssimulation/media/gui/OceanDemoCegui.config new file mode 100644 index 00000000..bf6ac773 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/OceanDemoCegui.config @@ -0,0 +1,6 @@ + + diff --git a/school/informatik/verkerhssimulation/media/gui/OceanDemoLayout.xml b/school/informatik/verkerhssimulation/media/gui/OceanDemoLayout.xml new file mode 100644 index 00000000..62e323ac --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/OceanDemoLayout.xml @@ -0,0 +1,264 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/school/informatik/verkerhssimulation/media/gui/TaharezLook.imageset b/school/informatik/verkerhssimulation/media/gui/TaharezLook.imageset new file mode 100644 index 00000000..e5aef981 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/TaharezLook.imageset @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/school/informatik/verkerhssimulation/media/gui/TaharezLook.looknfeel b/school/informatik/verkerhssimulation/media/gui/TaharezLook.looknfeel new file mode 100644 index 00000000..e9c8b1c9 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/TaharezLook.looknfeel @@ -0,0 +1,4315 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ + + + +
+
+ +
+ + + + +
+
+ +
+ + + + +
+
+ +
+ + + + +
+ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ + + + +
+
+ +
+ + + + +
+ +
+
+ +
+
+
+ + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+ +
+
+ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ + + + +
+
+ +
+ + + + +
+ +
+
+ +
+
+
+ + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+ +
+
+ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ +
+
+
+ + +
+ +
+
+
+ + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
+ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ +
+
+
+ + +
+ + + + +
+ + + + +
+ +
+
+
+ + +
+ + + + +
+ + + + +
+ +
+
+
+ + +
+ + + + +
+ + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+
+
+ + +
+ + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+
+
+ + +
+ + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ +
+
+
+ + +
+ +
+
+
+ + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + +
+
+
+ + + + +
+
+
+ + + + +
+ +
+
+ +
+
+ +
+
+
+ + +
+ + + + +
+ + + + +
+ +
+
+
+ + +
+ +
+
+
+ + +
+ +
+
+ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ + + + +
+
+ +
+ + + + +
+
+ +
+ + + + +
+
+ +
+ + + + +
+
+ +
+ + + + +
+
+ +
+ + + + +
+
+ +
+ + + + +
+
+ +
+ + + + +
+ +
+
+ +
+
+
+ + +
+ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+ + +
+ +
+
+ +
+
+
+ + +
+ +
+
+ +
+
+
+ + +
+ +
+
+ +
+
+
+ + +
+ +
+
+
+ + +
+ +
+
+ +
+
+
+ + +
+ +
+
+ +
+
+
+ + +
+ +
+
+ +
+
+
+ + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+ + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+ + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + + + diff --git a/school/informatik/verkerhssimulation/media/gui/TaharezLook.tga b/school/informatik/verkerhssimulation/media/gui/TaharezLook.tga new file mode 100644 index 00000000..81c00dec Binary files /dev/null and b/school/informatik/verkerhssimulation/media/gui/TaharezLook.tga differ diff --git a/school/informatik/verkerhssimulation/media/gui/TaharezLookSkin.scheme b/school/informatik/verkerhssimulation/media/gui/TaharezLookSkin.scheme new file mode 100644 index 00000000..9babf932 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/TaharezLookSkin.scheme @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/school/informatik/verkerhssimulation/media/gui/TaharezLookWidgetAliases.scheme b/school/informatik/verkerhssimulation/media/gui/TaharezLookWidgetAliases.scheme new file mode 100644 index 00000000..dfe66ac6 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/TaharezLookWidgetAliases.scheme @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/school/informatik/verkerhssimulation/media/gui/bluehighway-10.font b/school/informatik/verkerhssimulation/media/gui/bluehighway-10.font new file mode 100644 index 00000000..23a7bc7e --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/bluehighway-10.font @@ -0,0 +1,2 @@ + + diff --git a/school/informatik/verkerhssimulation/media/gui/bluehighway-12.font b/school/informatik/verkerhssimulation/media/gui/bluehighway-12.font new file mode 100644 index 00000000..e6aac73e --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/bluehighway-12.font @@ -0,0 +1,2 @@ + + diff --git a/school/informatik/verkerhssimulation/media/gui/bluehighway-8.font b/school/informatik/verkerhssimulation/media/gui/bluehighway-8.font new file mode 100644 index 00000000..ba3ac2e6 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/bluehighway-8.font @@ -0,0 +1,2 @@ + + diff --git a/school/informatik/verkerhssimulation/media/gui/cegui8.layout b/school/informatik/verkerhssimulation/media/gui/cegui8.layout new file mode 100644 index 00000000..b8623ec5 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/cegui8.layout @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/school/informatik/verkerhssimulation/media/gui/facial.layout b/school/informatik/verkerhssimulation/media/gui/facial.layout new file mode 100644 index 00000000..ffc882ba --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/facial.layout @@ -0,0 +1,379 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/school/informatik/verkerhssimulation/media/gui/ogregui.layout b/school/informatik/verkerhssimulation/media/gui/ogregui.layout new file mode 100644 index 00000000..fc0eb0fc --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/ogregui.layout @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/school/informatik/verkerhssimulation/media/gui/shadows.layout b/school/informatik/verkerhssimulation/media/gui/shadows.layout new file mode 100644 index 00000000..9ed8fdd1 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/gui/shadows.layout @@ -0,0 +1,247 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/AmbientOneTexture.glsl b/school/informatik/verkerhssimulation/media/materials/programs/AmbientOneTexture.glsl new file mode 100644 index 00000000..66b4bcd3 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/AmbientOneTexture.glsl @@ -0,0 +1,13 @@ +uniform vec4 ambient; + +/* + Basic ambient lighting vertex program +*/ +void main() +{ + gl_Position = ftransform(); + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_FrontColor = ambient; +} + + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Bloom_ps20.hlsl b/school/informatik/verkerhssimulation/media/materials/programs/Bloom_ps20.hlsl new file mode 100644 index 00000000..15aa068c --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Bloom_ps20.hlsl @@ -0,0 +1,52 @@ +sampler Blur1: register(s1); +sampler RT: register(s0); + + +float luminance(float3 c) +{ + return dot( c, float3(0.3, 0.59, 0.11) ); +} + +float4 main(float2 texCoord: TEXCOORD0) : COLOR { + float4 sharp = tex2D(RT, texCoord); + float4 blur = tex2D(Blur1, texCoord); + + + + return ( sharp + blur * 1.8 ) / 2; + +// float4 color = lerp( sharp, blur, 0.4f ); + +// return color; + + +/* + return ( sharp + blur * 1.8 ) / 2 + + luminance(blur) * + float4( 0.5, 0.5, 0.5, 0) + + luminance(sharp) * + float4( 0.3, 0.3, 0.3, 0); +*/ +/* + return ( sharp + blur * 0.9) / 2 + + luminance(blur) * float4(0.1, 0.15, 0.7, 0); +*/ + +/* + return ( sharp + blur * 0.9) / 2 + + luminance(blur) * float4(0.1, 0.15, 0.7, 0); +*/ + +// float4 retColor = luminance( sharp ) + +// luminance( blur ) + blur / 2; +// return retColor; +} + + + + + + + + + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Bloom_vs11.hlsl b/school/informatik/verkerhssimulation/media/materials/programs/Bloom_vs11.hlsl new file mode 100644 index 00000000..b6e49a3e --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Bloom_vs11.hlsl @@ -0,0 +1,21 @@ + +struct VS_OUTPUT { + float4 Pos: POSITION; + float2 texCoord: TEXCOORD0; +}; + +VS_OUTPUT main(float4 Pos: POSITION){ + VS_OUTPUT Out; + + // Clean up inaccuracies + Pos.xy = sign(Pos.xy); + + Out.Pos = float4(Pos.xy, 0, 1); + // Image-space + Out.texCoord.x = 0.5 * (1 + Pos.x); + Out.texCoord.y = 0.5 * (1 - Pos.y); + + return Out; +} + + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Blur0_ps20.hlsl b/school/informatik/verkerhssimulation/media/materials/programs/Blur0_ps20.hlsl new file mode 100644 index 00000000..5790dce5 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Blur0_ps20.hlsl @@ -0,0 +1,31 @@ +sampler RT: register(s0); +// Simple blur filter + +float4 main(float2 texCoord: TEXCOORD0) : COLOR { + + float2 samples[12] = { + -0.326212, -0.405805, + -0.840144, -0.073580, + -0.695914, 0.457137, + -0.203345, 0.620716, + 0.962340, -0.194983, + 0.473434, -0.480026, + 0.519456, 0.767022, + 0.185461, -0.893124, + 0.507431, 0.064425, + 0.896420, 0.412458, + -0.321940, -0.932615, + -0.791559, -0.597705, + }; + + float4 sum = tex2D(RT, texCoord); + for (int i = 0; i < 12; i++){ + sum += tex2D(RT, texCoord + 0.025 * samples[i]); + } + return sum / 13; + +} + + + + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Blur0_vs.glsl b/school/informatik/verkerhssimulation/media/materials/programs/Blur0_vs.glsl new file mode 100644 index 00000000..24212edd --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Blur0_vs.glsl @@ -0,0 +1,15 @@ +varying vec2 texCoord[5]; + +void main() +{ + vec2 inPos = sign(gl_Vertex.xy); + gl_Position = vec4(inPos.xy, 0.0, 1.0); + + texCoord[0] = (vec2(inPos.x, -inPos.y) + 1.0)/2.0; + + const float size = 0.01; + texCoord[1] = texCoord[0] + vec2(1.0, 0.0)*size; + texCoord[2] = texCoord[0] + vec2(2.0, 0.0)*size; + texCoord[3] = texCoord[0] + vec2(-1.0, 0.0)*size; + texCoord[4] = texCoord[0] + vec2(-2.0, 0.0)*size; +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Blur0_vs11.hlsl b/school/informatik/verkerhssimulation/media/materials/programs/Blur0_vs11.hlsl new file mode 100644 index 00000000..3979eae9 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Blur0_vs11.hlsl @@ -0,0 +1,22 @@ +struct VS_OUTPUT { + float4 Pos: POSITION; + float2 texCoord: TEXCOORD0; +}; + +VS_OUTPUT main(float4 Pos: POSITION){ + VS_OUTPUT Out; + + // Clean up inaccuracies + Pos.xy = sign(Pos.xy); + + Out.Pos = float4(Pos.xy, 0, 1); + // Image-space + Out.texCoord.x = 0.5 * (1 + Pos.x); + Out.texCoord.y = 0.5 * (1 - Pos.y); + + return Out; +} + + + + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Blur1_ps20.hlsl b/school/informatik/verkerhssimulation/media/materials/programs/Blur1_ps20.hlsl new file mode 100644 index 00000000..95e754b2 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Blur1_ps20.hlsl @@ -0,0 +1,28 @@ +sampler Blur0: register(s0); +// Simple blur filter + +float4 main(float2 texCoord: TEXCOORD0) : COLOR { + + float2 samples[12] = { + -0.326212, -0.405805, + -0.840144, -0.073580, + -0.695914, 0.457137, + -0.203345, 0.620716, + 0.962340, -0.194983, + 0.473434, -0.480026, + 0.519456, 0.767022, + 0.185461, -0.893124, + 0.507431, 0.064425, + 0.896420, 0.412458, + -0.321940, -0.932615, + -0.791559, -0.597705, + }; + + float4 sum = tex2D(Blur0, texCoord); + for (int i = 0; i < 12; i++){ + sum += tex2D(Blur0, texCoord + 0.025 * samples[i]); + } + return sum / 13; + +} + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Blur1_vs.glsl b/school/informatik/verkerhssimulation/media/materials/programs/Blur1_vs.glsl new file mode 100644 index 00000000..dd201519 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Blur1_vs.glsl @@ -0,0 +1,15 @@ +varying vec2 texCoord[5]; + +void main() +{ + vec2 inPos = sign(gl_Vertex.xy); + gl_Position = vec4(inPos.xy, 0.0, 1.0); + + texCoord[0] = (vec2(inPos.x, -inPos.y) + 1.0)/2.0; + + const float size = 0.01; + texCoord[1] = texCoord[0] + vec2(0.0, 1.0)*size; + texCoord[2] = texCoord[0] + vec2(0.0, 2.0)*size; + texCoord[3] = texCoord[0] + vec2(0.0, -1.0)*size; + texCoord[4] = texCoord[0] + vec2(0.0, -2.0)*size; +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Blur1_vs11.hlsl b/school/informatik/verkerhssimulation/media/materials/programs/Blur1_vs11.hlsl new file mode 100644 index 00000000..49b316f1 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Blur1_vs11.hlsl @@ -0,0 +1,19 @@ +struct VS_OUTPUT { + float4 Pos: POSITION; + float2 texCoord: TEXCOORD0; +}; + +VS_OUTPUT main(float4 Pos: POSITION){ + VS_OUTPUT Out; + + // Clean up inaccuracies + Pos.xy = sign(Pos.xy); + + Out.Pos = float4(Pos.xy, 0, 1); + // Image-space + Out.texCoord.x = 0.5 * (1 + Pos.x); + Out.texCoord.y = 0.5 * (1 - Pos.y); + + return Out; +} + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Blur_ps.glsl b/school/informatik/verkerhssimulation/media/materials/programs/Blur_ps.glsl new file mode 100644 index 00000000..d6bb1939 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Blur_ps.glsl @@ -0,0 +1,14 @@ +uniform sampler2D tex0; + +varying vec2 texCoord[5]; + +void main() +{ + vec4 sum = texture2D(tex0, texCoord[0]) + + texture2D(tex0, texCoord[1]) + + texture2D(tex0, texCoord[2]) + + texture2D(tex0, texCoord[3]) + + texture2D(tex0, texCoord[4]); + gl_FragColor = sum / 5.0; +} + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Combine_fp.cg b/school/informatik/verkerhssimulation/media/materials/programs/Combine_fp.cg new file mode 100644 index 00000000..6ad9c7b7 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Combine_fp.cg @@ -0,0 +1,15 @@ +float4 Combine_fp +( + in float2 texCoord: TEXCOORD0, + + uniform sampler RT : register(s0), + uniform sampler Sum : register(s1), + + uniform float blur +) : COLOR +{ + float4 render = tex2D(RT, texCoord); + float4 sum = tex2D(Sum, texCoord); + + return lerp(render, sum, blur); +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/DOF_ps.cg b/school/informatik/verkerhssimulation/media/materials/programs/DOF_ps.cg new file mode 100644 index 00000000..ecf8ce06 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/DOF_ps.cg @@ -0,0 +1,47 @@ +// Simple blur filter + +const float2 samples[8] = { + {-1, 1}, + {-1, 0}, + {-1, -1}, + {0, -1}, + {1, -1}, + {1, 0}, + {1, 1}, + {0, 1} +}; + +float4 blur( + + in float2 texCoord: TEXCOORD0, + uniform float sampleDistance: register(c0), + uniform sampler Blur0: register(s0) + +) : COLOR +{ + float4 sum = tex2D(Blur0, texCoord); + for (int i = 0; i < 8; ++i){ + sum += tex2D(Blur0, texCoord + sampleDistance * samples[i]); + } + return sum / 9; +} + + + +float4 blend +( + in float2 texCoord: TEXCOORD0, + + uniform sampler Blur0 : register(s0), + uniform sampler Blur1 : register(s1), + + uniform float focus: register(c0), + uniform float range: register(c1) +) : COLOR +{ + float4 sharp = tex2D(Blur0, texCoord); + float4 blur = tex2D(Blur1, texCoord); + + // alpha channel of sharp RT has depth info + return lerp(sharp, blur, saturate(range * abs(focus - sharp.a))); +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmap.hlsl b/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmap.hlsl new file mode 100644 index 00000000..f7913434 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmap.hlsl @@ -0,0 +1,309 @@ +/* This file implements standard programs for depth shadow mapping. + These particular ones are suitable for additive lighting models, and + include 3 techniques to reduce depth fighting on self-shadowed surfaces, + constant bias, gradient (slope-scale) bias, and a fuzzy shadow map comparison*/ + + +// Shadow caster vertex program. +void casterVP( + float4 position : POSITION, + out float4 outPos : POSITION, + out float2 outDepth : TEXCOORD0, + + uniform float4x4 worldViewProj, + uniform float4 texelOffsets, + uniform float4 depthRange + ) +{ + outPos = mul(worldViewProj, position); + + // fix pixel / texel alignment + outPos.xy += texelOffsets.zw * outPos.w; + // linear depth storage + // offset / scale range output +#if LINEAR_RANGE + outDepth.x = (outPos.z - depthRange.x) * depthRange.w; +#else + outDepth.x = outPos.z; +#endif + outDepth.y = outPos.w; +} + + +// Shadow caster fragment program for high-precision single-channel textures +void casterFP( + float2 depth : TEXCOORD0, + out float4 result : COLOR) + +{ +#if LINEAR_RANGE + float finalDepth = depth.x; +#else + float finalDepth = depth.x / depth.y; +#endif + // just smear across all components + // therefore this one needs high individual channel precision + result = float4(finalDepth, finalDepth, finalDepth, 1); +} + + + +void receiverVP( + float4 position : POSITION, + float4 normal : NORMAL, + + out float4 outPos : POSITION, + out float4 outColour : COLOR, + out float4 outShadowUV : TEXCOORD0, + + uniform float4x4 world, + uniform float4x4 worldIT, + uniform float4x4 worldViewProj, + uniform float4x4 texViewProj, + uniform float4 lightPosition, + uniform float4 lightColour, + uniform float4 shadowDepthRange + ) +{ + float4 worldPos = mul(world, position); + outPos = mul(worldViewProj, position); + + float3 worldNorm = mul(worldIT, normal).xyz; + + // calculate lighting (simple vertex lighting) + float3 lightDir = normalize( + lightPosition.xyz - (worldPos.xyz * lightPosition.w)); + + outColour = lightColour * max(dot(lightDir, worldNorm), 0.0); + + // calculate shadow map coords + outShadowUV = mul(texViewProj, worldPos); +#if LINEAR_RANGE + // adjust by fixed depth bias, rescale into range + outShadowUV.z = (outShadowUV.z - shadowDepthRange.x) * shadowDepthRange.w; +#endif + + + + +} + +void receiverFP( + float4 position : POSITION, + float4 shadowUV : TEXCOORD0, + float4 vertexColour : COLOR, + + uniform sampler2D shadowMap : register(s0), + uniform float inverseShadowmapSize, + uniform float fixedDepthBias, + uniform float gradientClamp, + uniform float gradientScaleBias, + uniform float shadowFuzzyWidth, + + out float4 result : COLOR) +{ + // point on shadowmap +#if LINEAR_RANGE + shadowUV.xy = shadowUV.xy / shadowUV.w; +#else + shadowUV = shadowUV / shadowUV.w; +#endif + float centerdepth = tex2D(shadowMap, shadowUV.xy).x; + + // gradient calculation + float pixeloffset = inverseShadowmapSize; + float4 depths = float4( + tex2D(shadowMap, shadowUV.xy + float2(-pixeloffset, 0)).x, + tex2D(shadowMap, shadowUV.xy + float2(+pixeloffset, 0)).x, + tex2D(shadowMap, shadowUV.xy + float2(0, -pixeloffset)).x, + tex2D(shadowMap, shadowUV.xy + float2(0, +pixeloffset)).x); + + float2 differences = abs( depths.yw - depths.xz ); + float gradient = min(gradientClamp, max(differences.x, differences.y)); + float gradientFactor = gradient * gradientScaleBias; + + // visibility function + float depthAdjust = gradientFactor + (fixedDepthBias * centerdepth); + float finalCenterDepth = centerdepth + depthAdjust; + + // shadowUV.z contains lightspace position of current object + +#if FUZZY_TEST + // fuzzy test - introduces some ghosting in result and doesn't appear to be needed? + //float visibility = saturate(1 + delta_z / (gradient * shadowFuzzyWidth)); + float visibility = saturate(1 + (finalCenterDepth - shadowUV.z) * shadowFuzzyWidth * shadowUV.w); + + result = vertexColour * visibility; +#else + // hard test +#if PCF + // use depths from prev, calculate diff + depths += depthAdjust.xxxx; + float final = (finalCenterDepth > shadowUV.z) ? 1.0f : 0.0f; + final += (depths.x > shadowUV.z) ? 1.0f : 0.0f; + final += (depths.y > shadowUV.z) ? 1.0f : 0.0f; + final += (depths.z > shadowUV.z) ? 1.0f : 0.0f; + final += (depths.w > shadowUV.z) ? 1.0f : 0.0f; + + final *= 0.2f; + + result = float4(vertexColour.xyz * final, 1); + +#else + result = (finalCenterDepth > shadowUV.z) ? vertexColour : float4(0,0,0,1); +#endif + +#endif + + + +} + + + + +// Expand a range-compressed vector +float3 expand(float3 v) +{ + return (v - 0.5) * 2; +} + + +/* Normal mapping plus depth shadowmapping receiver programs +*/ +void normalMapShadowReceiverVp(float4 position : POSITION, + float3 normal : NORMAL, + float2 uv : TEXCOORD0, + float3 tangent : TANGENT0, + + // outputs + out float4 outPos : POSITION, + out float4 outShadowUV : TEXCOORD0, + out float2 oUv : TEXCOORD1, + out float3 oTSLightDir : TEXCOORD2, + // parameters + uniform float4 lightPosition, // object space + uniform float4x4 world, + uniform float4x4 worldViewProj, + uniform float4x4 texViewProj) +{ + float4 worldPos = mul(world, position); + outPos = mul(worldViewProj, position); + + // calculate shadow map coords + outShadowUV = mul(texViewProj, worldPos); +#if LINEAR_RANGE + // adjust by fixed depth bias, rescale into range + outShadowUV.z = (outShadowUV.z - shadowDepthRange.x) * shadowDepthRange.w; +#endif + + // pass the main uvs straight through unchanged + oUv = uv; + + // calculate tangent space light vector + // Get object space light direction + // Non-normalised since we'll do that in the fragment program anyway + float3 lightDir = lightPosition.xyz - (position * lightPosition.w); + + // Calculate the binormal (NB we assume both normal and tangent are + // already normalised) + // NB looks like nvidia cross params are BACKWARDS to what you'd expect + // this equates to NxT, not TxN + float3 binormal = cross(tangent, normal); + + // Form a rotation matrix out of the vectors + float3x3 rotation = float3x3(tangent, binormal, normal); + + // Transform the light vector according to this matrix + oTSLightDir = mul(rotation, lightDir); + + +} + + +void normalMapShadowReceiverFp( + float4 shadowUV : TEXCOORD0, + float2 uv : TEXCOORD1, + float3 TSlightDir : TEXCOORD2, + + out float4 result : COLOR, + + uniform float4 lightColour, + uniform float inverseShadowmapSize, + uniform float fixedDepthBias, + uniform float gradientClamp, + uniform float gradientScaleBias, + uniform float shadowFuzzyWidth, + + uniform sampler2D shadowMap : register(s0), + uniform sampler2D normalMap : register(s1), + uniform samplerCUBE normalCubeMap : register(s2)) +{ + + // retrieve normalised light vector, expand from range-compressed + float3 lightVec = expand(texCUBE(normalCubeMap, TSlightDir).xyz); + + // get bump map vector, again expand from range-compressed + float3 bumpVec = expand(tex2D(normalMap, uv).xyz); + + // Calculate dot product + float4 vertexColour = lightColour * dot(bumpVec, lightVec); + + + // point on shadowmap +#if LINEAR_RANGE + shadowUV.xy = shadowUV.xy / shadowUV.w; +#else + shadowUV = shadowUV / shadowUV.w; +#endif + float centerdepth = tex2D(shadowMap, shadowUV.xy).x; + + // gradient calculation + float pixeloffset = inverseShadowmapSize; + float4 depths = float4( + tex2D(shadowMap, shadowUV.xy + float2(-pixeloffset, 0)).x, + tex2D(shadowMap, shadowUV.xy + float2(+pixeloffset, 0)).x, + tex2D(shadowMap, shadowUV.xy + float2(0, -pixeloffset)).x, + tex2D(shadowMap, shadowUV.xy + float2(0, +pixeloffset)).x); + + float2 differences = abs( depths.yw - depths.xz ); + float gradient = min(gradientClamp, max(differences.x, differences.y)); + float gradientFactor = gradient * gradientScaleBias; + + // visibility function + float depthAdjust = gradientFactor + (fixedDepthBias * centerdepth); + float finalCenterDepth = centerdepth + depthAdjust; + + // shadowUV.z contains lightspace position of current object + +#if FUZZY_TEST + // fuzzy test - introduces some ghosting in result and doesn't appear to be needed? + //float visibility = saturate(1 + delta_z / (gradient * shadowFuzzyWidth)); + float visibility = saturate(1 + (finalCenterDepth - shadowUV.z) * shadowFuzzyWidth * shadowUV.w); + + result = vertexColour * visibility; +#else + // hard test +#if PCF + // use depths from prev, calculate diff + depths += depthAdjust.xxxx; + float final = (finalCenterDepth > shadowUV.z) ? 1.0f : 0.0f; + final += (depths.x > shadowUV.z) ? 1.0f : 0.0f; + final += (depths.y > shadowUV.z) ? 1.0f : 0.0f; + final += (depths.z > shadowUV.z) ? 1.0f : 0.0f; + final += (depths.w > shadowUV.z) ? 1.0f : 0.0f; + + final *= 0.2f; + + result = float4(vertexColour.xyz * final, 1); + +#else + result = (finalCenterDepth > shadowUV.z) ? vertexColour : float4(0,0,0,1); +#endif + +#endif + + + +} + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmapCasterFp.glsl b/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmapCasterFp.glsl new file mode 100644 index 00000000..1e32d262 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmapCasterFp.glsl @@ -0,0 +1,16 @@ + +varying vec2 depth; + +void main() +{ +#if LINEAR_RANGE + float finalDepth = depth.x; +#else + float finalDepth = depth.x / depth.y; +#endif + // just smear across all components + // therefore this one needs high individual channel precision + gl_FragColor = vec4(finalDepth, finalDepth, finalDepth, 1); + +} + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmapCasterVp.glsl b/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmapCasterVp.glsl new file mode 100644 index 00000000..2f19c759 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmapCasterVp.glsl @@ -0,0 +1,24 @@ +uniform mat4 worldViewProj; +uniform vec4 texelOffsets; +uniform vec4 depthRange; + +varying vec2 depth; + +void main() +{ + gl_Position = ftransform(); + + // fix pixel / texel alignment + gl_Position.xy += texelOffsets.zw * gl_Position.w; + // linear depth storage + // offset / scale range output +#if LINEAR_RANGE + depth.x = (gl_Position.z - depthRange.x) * depthRange.w; +#else + depth.x = gl_Position.z; +#endif + depth.y = gl_Position.w; + + +} + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmapNormalMapReceiverFp.glsl b/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmapNormalMapReceiverFp.glsl new file mode 100644 index 00000000..2c45a545 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmapNormalMapReceiverFp.glsl @@ -0,0 +1,84 @@ +uniform float inverseShadowmapSize; +uniform float fixedDepthBias; +uniform float gradientClamp; +uniform float gradientScaleBias; +uniform float shadowFuzzyWidth; +uniform vec4 lightColour; + +uniform sampler2D shadowMap; +uniform sampler2D normalMap; + +varying vec3 tangentLightDir; + + +// Expand a range-compressed vector +vec3 expand(vec3 v) +{ + return (v - 0.5) * 2.0; +} + +void main() +{ + + // get the new normal and diffuse values + vec3 normal = normalize(expand(texture2D(normalMap, gl_TexCoord[1].xy).xyz)); + + vec4 vertexColour = clamp(dot(normal, tangentLightDir),0.0,1.0) * lightColour; + + + vec4 shadowUV = gl_TexCoord[0]; + // point on shadowmap +#if LINEAR_RANGE + shadowUV.xy = shadowUV.xy / shadowUV.w; +#else + shadowUV = shadowUV / shadowUV.w; +#endif + float centerdepth = texture2D(shadowMap, shadowUV.xy).x; + + // gradient calculation + float pixeloffset = inverseShadowmapSize; + vec4 depths = vec4( + texture2D(shadowMap, shadowUV.xy + vec2(-pixeloffset, 0)).x, + texture2D(shadowMap, shadowUV.xy + vec2(+pixeloffset, 0)).x, + texture2D(shadowMap, shadowUV.xy + vec2(0, -pixeloffset)).x, + texture2D(shadowMap, shadowUV.xy + vec2(0, +pixeloffset)).x); + + vec2 differences = abs( depths.yw - depths.xz ); + float gradient = min(gradientClamp, max(differences.x, differences.y)); + float gradientFactor = gradient * gradientScaleBias; + + // visibility function + float depthAdjust = gradientFactor + (fixedDepthBias * centerdepth); + float finalCenterDepth = centerdepth + depthAdjust; + + // shadowUV.z contains lightspace position of current object + +#if FUZZY_TEST + // fuzzy test - introduces some ghosting in result and doesn't appear to be needed? + //float visibility = saturate(1 + delta_z / (gradient * shadowFuzzyWidth)); + float visibility = saturate(1 + (finalCenterDepth - shadowUV.z) * shadowFuzzyWidth * shadowUV.w); + + gl_FragColor = vertexColour * visibility; +#else + // hard test +#if PCF + // use depths from prev, calculate diff + depths += depthAdjust; + float final = (finalCenterDepth > shadowUV.z) ? 1.0 : 0.0; + final += (depths.x > shadowUV.z) ? 1.0 : 0.0; + final += (depths.y > shadowUV.z) ? 1.0 : 0.0; + final += (depths.z > shadowUV.z) ? 1.0 : 0.0; + final += (depths.w > shadowUV.z) ? 1.0 : 0.0; + + final *= 0.2; + + gl_FragColor = vec4(vertexColour.xyz * final, 1); + +#else + gl_FragColor = (finalCenterDepth > shadowUV.z) ? vertexColour : vec4(0,0,0,1); +#endif + +#endif + +} + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmapNormalMapReceiverVp.glsl b/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmapNormalMapReceiverVp.glsl new file mode 100644 index 00000000..66762f3e --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmapNormalMapReceiverVp.glsl @@ -0,0 +1,42 @@ +attribute vec3 tangent; + +uniform mat4 world; +uniform mat4 worldViewProj; +uniform mat4 texViewProj; +uniform vec4 lightPosition; // object space +uniform vec4 shadowDepthRange; + +varying vec3 tangentLightDir; + + +void main() +{ + gl_Position = ftransform(); + + vec4 worldPos = world * gl_Vertex; + + // Get object space light direction + vec3 lightDir = normalize(lightPosition.xyz - (gl_Vertex.xyz * lightPosition.w)); + + // calculate shadow map coords + gl_TexCoord[0] = texViewProj * worldPos; +#if LINEAR_RANGE + // adjust by fixed depth bias, rescale into range + gl_TexCoord[0].z = (gl_TexCoord[0].z - shadowDepthRange.x) * shadowDepthRange.w; +#endif + + // pass the main uvs straight through unchanged + gl_TexCoord[1] = gl_MultiTexCoord0; + + // Calculate the binormal (NB we assume both normal and tangent are + // already normalised) + vec3 binormal = cross(gl_Normal, tangent); + + // Form a rotation matrix out of the vectors + mat3 rotation = mat3(tangent, binormal, gl_Normal); + + // Transform the light vector according to this matrix + tangentLightDir = normalize(rotation * lightDir); + +} + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmapReceiverFp.glsl b/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmapReceiverFp.glsl new file mode 100644 index 00000000..04ebeaad --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmapReceiverFp.glsl @@ -0,0 +1,66 @@ +uniform float inverseShadowmapSize; +uniform float fixedDepthBias; +uniform float gradientClamp; +uniform float gradientScaleBias; +uniform float shadowFuzzyWidth; + +uniform sampler2D shadowMap; + +void main() +{ + vec4 shadowUV = gl_TexCoord[0]; + // point on shadowmap +#if LINEAR_RANGE + shadowUV.xy = shadowUV.xy / shadowUV.w; +#else + shadowUV = shadowUV / shadowUV.w; +#endif + float centerdepth = texture2D(shadowMap, shadowUV.xy).x; + + // gradient calculation + float pixeloffset = inverseShadowmapSize; + vec4 depths = vec4( + texture2D(shadowMap, shadowUV.xy + vec2(-pixeloffset, 0)).x, + texture2D(shadowMap, shadowUV.xy + vec2(+pixeloffset, 0)).x, + texture2D(shadowMap, shadowUV.xy + vec2(0, -pixeloffset)).x, + texture2D(shadowMap, shadowUV.xy + vec2(0, +pixeloffset)).x); + + vec2 differences = abs( depths.yw - depths.xz ); + float gradient = min(gradientClamp, max(differences.x, differences.y)); + float gradientFactor = gradient * gradientScaleBias; + + // visibility function + float depthAdjust = gradientFactor + (fixedDepthBias * centerdepth); + float finalCenterDepth = centerdepth + depthAdjust; + + // shadowUV.z contains lightspace position of current object + +#if FUZZY_TEST + // fuzzy test - introduces some ghosting in result and doesn't appear to be needed? + //float visibility = saturate(1 + delta_z / (gradient * shadowFuzzyWidth)); + float visibility = saturate(1 + (finalCenterDepth - shadowUV.z) * shadowFuzzyWidth * shadowUV.w); + + gl_FragColor = vertexColour * visibility; +#else + // hard test +#if PCF + // use depths from prev, calculate diff + depths += depthAdjust; + float final = (finalCenterDepth > shadowUV.z) ? 1.0 : 0.0; + final += (depths.x > shadowUV.z) ? 1.0 : 0.0; + final += (depths.y > shadowUV.z) ? 1.0 : 0.0; + final += (depths.z > shadowUV.z) ? 1.0 : 0.0; + final += (depths.w > shadowUV.z) ? 1.0 : 0.0; + + final *= 0.2; + + gl_FragColor = vec4(gl_Color.xyz * final, 1); + +#else + gl_FragColor = (finalCenterDepth > shadowUV.z) ? gl_Color : vec4(0,0,0,1); +#endif + +#endif + +} + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmapReceiverVp.glsl b/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmapReceiverVp.glsl new file mode 100644 index 00000000..85c32e6a --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/DepthShadowmapReceiverVp.glsl @@ -0,0 +1,32 @@ +uniform mat4 world; +uniform mat4 worldIT; +uniform mat4 worldViewProj; +uniform mat4 texViewProj; +uniform vec4 lightPosition; +uniform vec4 lightColour; +uniform vec4 shadowDepthRange; + + +void main() +{ + gl_Position = ftransform(); + + vec4 worldPos = world * gl_Vertex; + + vec3 worldNorm = (worldIT * vec4(gl_Normal, 1)).xyz; + + // calculate lighting (simple vertex lighting) + vec3 lightDir = normalize( + lightPosition.xyz - (worldPos.xyz * lightPosition.w)); + + gl_FrontColor = lightColour * max(dot(lightDir, worldNorm), 0.0); + + // calculate shadow map coords + gl_TexCoord[0] = texViewProj * worldPos; +#if LINEAR_RANGE + // adjust by fixed depth bias, rescale into range + gl_TexCoord[0].z = (gl_TexCoord[0].z - shadowDepthRange.x) * shadowDepthRange.w; +#endif + +} + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Example_Basic.cg b/school/informatik/verkerhssimulation/media/materials/programs/Example_Basic.cg new file mode 100644 index 00000000..dbeb1e7b --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Example_Basic.cg @@ -0,0 +1,272 @@ +/* + Basic ambient lighting vertex program +*/ +void ambientOneTexture_vp(float4 position : POSITION, + float2 uv : TEXCOORD0, + + out float4 oPosition : POSITION, + out float2 oUv : TEXCOORD0, + out float4 colour : COLOR, + + uniform float4x4 worldViewProj, + uniform float4 ambient) +{ + oPosition = mul(worldViewProj, position); + oUv = uv; + colour = ambient; +} + +/* + Single-weight-per-vertex hardware skinning, 2 lights + The trouble with vertex programs is they're not general purpose, but + fixed function hardware skinning is very poorly supported +*/ +void hardwareSkinningOneWeight_vp( + float4 position : POSITION, + float3 normal : NORMAL, + float2 uv : TEXCOORD0, + float blendIdx : BLENDINDICES, + + + out float4 oPosition : POSITION, + out float2 oUv : TEXCOORD0, + out float4 colour : COLOR, + // Support up to 24 bones of float3x4 + // vs_1_1 only supports 96 params so more than this is not feasible + uniform float3x4 worldMatrix3x4Array[24], + uniform float4x4 viewProjectionMatrix, + uniform float4 lightPos[2], + uniform float4 lightDiffuseColour[2], + uniform float4 ambient) +{ + // transform by indexed matrix + float4 blendPos = float4(mul(worldMatrix3x4Array[blendIdx], position).xyz, 1.0); + // view / projection + oPosition = mul(viewProjectionMatrix, blendPos); + // transform normal + float3 norm = mul((float3x3)worldMatrix3x4Array[blendIdx], normal); + // Lighting - support point and directional + float3 lightDir0 = normalize( + lightPos[0].xyz - (blendPos.xyz * lightPos[0].w)); + float3 lightDir1 = normalize( + lightPos[1].xyz - (blendPos.xyz * lightPos[1].w)); + + oUv = uv; + colour = ambient + + (saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) + + (saturate(dot(lightDir1, norm)) * lightDiffuseColour[1]); + +} + +/* + Single-weight-per-vertex hardware skinning, shadow-caster pass +*/ +void hardwareSkinningOneWeightCaster_vp( + float4 position : POSITION, + float3 normal : NORMAL, + float blendIdx : BLENDINDICES, + + + out float4 oPosition : POSITION, + out float4 colour : COLOR, + // Support up to 24 bones of float3x4 + // vs_1_1 only supports 96 params so more than this is not feasible + uniform float3x4 worldMatrix3x4Array[24], + uniform float4x4 viewProjectionMatrix, + uniform float4 ambient) +{ + // transform by indexed matrix + float4 blendPos = float4(mul(worldMatrix3x4Array[blendIdx], position).xyz, 1.0); + // view / projection + oPosition = mul(viewProjectionMatrix, blendPos); + + colour = ambient; + +} + +/* + Two-weight-per-vertex hardware skinning, 2 lights + The trouble with vertex programs is they're not general purpose, but + fixed function hardware skinning is very poorly supported +*/ +void hardwareSkinningTwoWeights_vp( + float4 position : POSITION, + float3 normal : NORMAL, + float2 uv : TEXCOORD0, + float4 blendIdx : BLENDINDICES, + float4 blendWgt : BLENDWEIGHT, + + + out float4 oPosition : POSITION, + out float2 oUv : TEXCOORD0, + out float4 colour : COLOR, + // Support up to 24 bones of float3x4 + // vs_1_1 only supports 96 params so more than this is not feasible + uniform float3x4 worldMatrix3x4Array[24], + uniform float4x4 viewProjectionMatrix, + uniform float4 lightPos[2], + uniform float4 lightDiffuseColour[2], + uniform float4 ambient) +{ + // transform by indexed matrix + float4 blendPos = float4(0,0,0,0); + int i; + for (i = 0; i < 2; ++i) + { + blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i]; + } + // view / projection + oPosition = mul(viewProjectionMatrix, blendPos); + // transform normal + float3 norm = float3(0,0,0); + for (i = 0; i < 2; ++i) + { + norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) * + blendWgt[i]; + } + norm = normalize(norm); + // Lighting - support point and directional + float3 lightDir0 = normalize( + lightPos[0].xyz - (blendPos.xyz * lightPos[0].w)); + float3 lightDir1 = normalize( + lightPos[1].xyz - (blendPos.xyz * lightPos[1].w)); + + + oUv = uv; + colour = float4(0.5, 0.5, 0.5, 1) + + (saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) + + (saturate(dot(lightDir1, norm)) * lightDiffuseColour[1]); + +} + +/* + Two-weight-per-vertex hardware skinning, shadow caster pass +*/ +void hardwareSkinningTwoWeightsCaster_vp( + float4 position : POSITION, + float3 normal : NORMAL, + float2 uv : TEXCOORD0, + float4 blendIdx : BLENDINDICES, + float4 blendWgt : BLENDWEIGHT, + + + out float4 oPosition : POSITION, + out float4 colour : COLOR, + // Support up to 24 bones of float3x4 + // vs_1_1 only supports 96 params so more than this is not feasible + uniform float3x4 worldMatrix3x4Array[24], + uniform float4x4 viewProjectionMatrix, + uniform float4 ambient) +{ + // transform by indexed matrix + float4 blendPos = float4(0,0,0,0); + int i; + for (i = 0; i < 2; ++i) + { + blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i]; + } + // view / projection + oPosition = mul(viewProjectionMatrix, blendPos); + + + colour = ambient; + + +} + + +/* + Four-weight-per-vertex hardware skinning, 2 lights + The trouble with vertex programs is they're not general purpose, but + fixed function hardware skinning is very poorly supported +*/ +void hardwareSkinningFourWeights_vp( + float4 position : POSITION, + float3 normal : NORMAL, + float2 uv : TEXCOORD0, + float4 blendIdx : BLENDINDICES, + float4 blendWgt : BLENDWEIGHT, + + + out float4 oPosition : POSITION, + out float2 oUv : TEXCOORD0, + out float4 colour : COLOR, + // Support up to 24 bones of float3x4 + // vs_1_1 only supports 96 params so more than this is not feasible + uniform float3x4 worldMatrix3x4Array[24], + uniform float4x4 viewProjectionMatrix, + uniform float4 lightPos[2], + uniform float4 lightDiffuseColour[2], + uniform float4 ambient) +{ + // transform by indexed matrix + float4 blendPos = float4(0,0,0,0); + int i; + for (i = 0; i < 4; ++i) + { + blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i]; + } + // view / projection + oPosition = mul(viewProjectionMatrix, blendPos); + // transform normal + float3 norm = float3(0,0,0); + for (i = 0; i < 4; ++i) + { + norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) * + blendWgt[i]; + } + norm = normalize(norm); + // Lighting - support point and directional + float3 lightDir0 = normalize( + lightPos[0].xyz - (blendPos.xyz * lightPos[0].w)); + float3 lightDir1 = normalize( + lightPos[1].xyz - (blendPos.xyz * lightPos[1].w)); + + + oUv = uv; + colour = ambient + + (saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) + + (saturate(dot(lightDir1, norm)) * lightDiffuseColour[1]); + +} + +void hardwareMorphAnimation(float3 pos1 : POSITION, + float4 normal : NORMAL, + float2 uv : TEXCOORD0, + float3 pos2 : TEXCOORD1, + + out float4 oPosition : POSITION, + out float2 oUv : TEXCOORD0, + out float4 colour : COLOR, + + uniform float4x4 worldViewProj, + uniform float4 anim_t) +{ + // interpolate + float4 interp = float4(pos1 + anim_t.x*(pos2 - pos1), 1.0f); + + oPosition = mul(worldViewProj, interp); + oUv = uv; + colour = float4(1,0,0,1); +} + +void hardwarePoseAnimation(float3 pos : POSITION, + float4 normal : NORMAL, + float2 uv : TEXCOORD0, + float3 pose1 : TEXCOORD1, + float3 pose2 : TEXCOORD2, + + out float4 oPosition : POSITION, + out float2 oUv : TEXCOORD0, + out float4 colour : COLOR, + + uniform float4x4 worldViewProj, + uniform float4 anim_t) +{ + // interpolate + float4 interp = float4(pos + anim_t.x*pose1 + anim_t.y*pose2, 1.0f); + + oPosition = mul(worldViewProj, interp); + oUv = uv; + colour = float4(1,0,0,1); +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Example_Basic.hlsl b/school/informatik/verkerhssimulation/media/materials/programs/Example_Basic.hlsl new file mode 100644 index 00000000..b7a2f51a --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Example_Basic.hlsl @@ -0,0 +1,273 @@ +/* + Basic ambient lighting vertex program +*/ +void ambientOneTexture_vp(float4 position : POSITION, + float2 uv : TEXCOORD0, + + out float4 oPosition : POSITION, + out float2 oUv : TEXCOORD0, + out float4 colour : COLOR, + + uniform float4x4 worldViewProj, + uniform float4 ambient) +{ + oPosition = mul(worldViewProj, position); + oUv = uv; + colour = ambient; +} + +/* + Single-weight-per-vertex hardware skinning, 2 lights + The trouble with vertex programs is they're not general purpose, but + fixed function hardware skinning is very poorly supported +*/ +void hardwareSkinningOneWeight_vp( + float4 position : POSITION, + float3 normal : NORMAL, + float2 uv : TEXCOORD0, + float blendIdx : BLENDINDICES, + + + out float4 oPosition : POSITION, + out float2 oUv : TEXCOORD0, + out float4 colour : COLOR, + // Support up to 24 bones of float3x4 + // vs_1_1 only supports 96 params so more than this is not feasible + uniform float3x4 worldMatrix3x4Array[24], + uniform float4x4 viewProjectionMatrix, + uniform float4 lightPos[2], + uniform float4 lightDiffuseColour[2], + uniform float4 ambient) +{ + // transform by indexed matrix + float4 blendPos = float4(mul(worldMatrix3x4Array[blendIdx], position).xyz, 1.0); + // view / projection + oPosition = mul(viewProjectionMatrix, blendPos); + // transform normal + float3 norm = mul((float3x3)worldMatrix3x4Array[blendIdx], normal); + // Lighting - support point and directional + float3 lightDir0 = normalize( + lightPos[0].xyz - (blendPos.xyz * lightPos[0].w)); + float3 lightDir1 = normalize( + lightPos[1].xyz - (blendPos.xyz * lightPos[1].w)); + + oUv = uv; + colour = ambient + + (saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) + + (saturate(dot(lightDir1, norm)) * lightDiffuseColour[1]); + +} + +/* + Single-weight-per-vertex hardware skinning, shadow-caster pass +*/ +void hardwareSkinningOneWeightCaster_vp( + float4 position : POSITION, + float3 normal : NORMAL, + float blendIdx : BLENDINDICES, + + + out float4 oPosition : POSITION, + out float4 colour : COLOR, + // Support up to 24 bones of float3x4 + // vs_1_1 only supports 96 params so more than this is not feasible + uniform float3x4 worldMatrix3x4Array[24], + uniform float4x4 viewProjectionMatrix, + uniform float4 ambient) +{ + // transform by indexed matrix + float4 blendPos = float4(mul(worldMatrix3x4Array[blendIdx], position).xyz, 1.0); + // view / projection + oPosition = mul(viewProjectionMatrix, blendPos); + + colour = ambient; + +} + +/* + Two-weight-per-vertex hardware skinning, 2 lights + The trouble with vertex programs is they're not general purpose, but + fixed function hardware skinning is very poorly supported +*/ +void hardwareSkinningTwoWeights_vp( + float4 position : POSITION, + float3 normal : NORMAL, + float2 uv : TEXCOORD0, + float4 blendIdx : BLENDINDICES, + float4 blendWgt : BLENDWEIGHT, + + + out float4 oPosition : POSITION, + out float2 oUv : TEXCOORD0, + out float4 colour : COLOR, + // Support up to 24 bones of float3x4 + // vs_1_1 only supports 96 params so more than this is not feasible + uniform float3x4 worldMatrix3x4Array[24], + uniform float4x4 viewProjectionMatrix, + uniform float4 lightPos[2], + uniform float4 lightDiffuseColour[2], + uniform float4 ambient) +{ + // transform by indexed matrix + float4 blendPos = float4(0,0,0,0); + int i; + for (i = 0; i < 2; ++i) + { + blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i]; + } + // view / projection + oPosition = mul(viewProjectionMatrix, blendPos); + // transform normal + float3 norm = float3(0,0,0); + for (i = 0; i < 2; ++i) + { + norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) * + blendWgt[i]; + } + norm = normalize(norm); + // Lighting - support point and directional + float3 lightDir0 = normalize( + lightPos[0].xyz - (blendPos.xyz * lightPos[0].w)); + float3 lightDir1 = normalize( + lightPos[1].xyz - (blendPos.xyz * lightPos[1].w)); + + + oUv = uv; + colour = ambient + + (saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) + + (saturate(dot(lightDir1, norm)) * lightDiffuseColour[1]); + +} + +/* + Two-weight-per-vertex hardware skinning, shadow caster pass +*/ +void hardwareSkinningTwoWeightsCaster_vp( + float4 position : POSITION, + float3 normal : NORMAL, + float2 uv : TEXCOORD0, + float4 blendIdx : BLENDINDICES, + float4 blendWgt : BLENDWEIGHT, + + + out float4 oPosition : POSITION, + out float4 colour : COLOR, + // Support up to 24 bones of float3x4 + // vs_1_1 only supports 96 params so more than this is not feasible + uniform float3x4 worldMatrix3x4Array[24], + uniform float4x4 viewProjectionMatrix, + uniform float4 ambient) +{ + // transform by indexed matrix + float4 blendPos = float4(0,0,0,0); + int i; + for (i = 0; i < 2; ++i) + { + blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i]; + } + // view / projection + oPosition = mul(viewProjectionMatrix, blendPos); + + + colour = ambient; + + +} + + +/* + Four-weight-per-vertex hardware skinning, 2 lights + The trouble with vertex programs is they're not general purpose, but + fixed function hardware skinning is very poorly supported +*/ +void hardwareSkinningFourWeights_vp( + float4 position : POSITION, + float3 normal : NORMAL, + float2 uv : TEXCOORD0, + float4 blendIdx : BLENDINDICES, + float4 blendWgt : BLENDWEIGHT, + + + out float4 oPosition : POSITION, + out float2 oUv : TEXCOORD0, + out float4 colour : COLOR, + // Support up to 24 bones of float3x4 + // vs_1_1 only supports 96 params so more than this is not feasible + uniform float3x4 worldMatrix3x4Array[24], + uniform float4x4 viewProjectionMatrix, + uniform float4 lightPos[2], + uniform float4 lightDiffuseColour[2], + uniform float4 ambient) +{ + // transform by indexed matrix + float4 blendPos = float4(0,0,0,0); + int i; + for (i = 0; i < 4; ++i) + { + blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i]; + } + // view / projection + oPosition = mul(viewProjectionMatrix, blendPos); + // transform normal + float3 norm = float3(0,0,0); + for (i = 0; i < 4; ++i) + { + norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) * + blendWgt[i]; + } + norm = normalize(norm); + // Lighting - support point and directional + float3 lightDir0 = normalize( + lightPos[0].xyz - (blendPos.xyz * lightPos[0].w)); + float3 lightDir1 = normalize( + lightPos[1].xyz - (blendPos.xyz * lightPos[1].w)); + + + oUv = uv; + colour = ambient + + (saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) + + (saturate(dot(lightDir1, norm)) * lightDiffuseColour[1]); + +} + +void hardwareMorphAnimation(float3 pos1 : POSITION, + float4 normal : NORMAL, + float2 uv : TEXCOORD0, + float3 pos2 : TEXCOORD1, + + out float4 oPosition : POSITION, + out float2 oUv : TEXCOORD0, + out float4 colour : COLOR, + + uniform float4x4 worldViewProj, + uniform float4 anim_t) +{ + // interpolate + float4 interp = float4(pos1 + anim_t.x*(pos2 - pos1), 1.0f); + + oPosition = mul(worldViewProj, interp); + oUv = uv; + colour = float4(1,0,0,1); +} + +void hardwarePoseAnimation(float3 pos : POSITION, + float4 normal : NORMAL, + float2 uv : TEXCOORD0, + float3 pose1 : TEXCOORD1, + float3 pose2 : TEXCOORD2, + + out float4 oPosition : POSITION, + out float2 oUv : TEXCOORD0, + out float4 colour : COLOR, + + uniform float4x4 worldViewProj, + uniform float4 anim_t) +{ + // interpolate + float4 interp = float4(pos + anim_t.x*pose1 + anim_t.y*pose2, 1.0f); + + oPosition = mul(worldViewProj, interp); + oUv = uv; + colour = float4(1,0,0,1); +} + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Example_BumpMapping.cg b/school/informatik/verkerhssimulation/media/materials/programs/Example_BumpMapping.cg new file mode 100644 index 00000000..17225317 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Example_BumpMapping.cg @@ -0,0 +1,236 @@ +// General functions + +// Expand a range-compressed vector +float3 expand(float3 v) +{ + return (v - 0.5) * 2; +} + + +/* Bump mapping vertex program + In this program, we want to calculate the tangent space light vector + on a per-vertex level which will get passed to the fragment program, + or to the fixed function dot3 operation, to produce the per-pixel + lighting effect. +*/ +void main_vp(float4 position : POSITION, + float3 normal : NORMAL, + float2 uv : TEXCOORD0, + float3 tangent : TANGENT0, + // outputs + out float4 oPosition : POSITION, + out float2 oUv : TEXCOORD0, + out float3 oTSLightDir : TEXCOORD1, + // parameters + uniform float4 lightPosition, // object space + uniform float4x4 worldViewProj) +{ + // calculate output position + oPosition = mul(worldViewProj, position); + + // pass the main uvs straight through unchanged + oUv = uv; + + // calculate tangent space light vector + // Get object space light direction + // Non-normalised since we'll do that in the fragment program anyway + float3 lightDir = lightPosition.xyz - (position * lightPosition.w); + + // Calculate the binormal (NB we assume both normal and tangent are + // already normalised) + // NB looks like nvidia cross params are BACKWARDS to what you'd expect + // this equates to NxT, not TxN + float3 binormal = cross(tangent, normal); + + // Form a rotation matrix out of the vectors + float3x3 rotation = float3x3(tangent, binormal, normal); + + // Transform the light vector according to this matrix + oTSLightDir = mul(rotation, lightDir); + + +} + +/* Bump mapping vertex program for shadow receiving + In this program, we want to calculate the tangent space light vector + on a per-vertex level which will get passed to the fragment program, + or to the fixed function dot3 operation, to produce the per-pixel + lighting effect. +*/ +void main_shadowreceiver_vp(float4 position : POSITION, + float3 normal : NORMAL, + float2 uv : TEXCOORD0, + float3 tangent : TANGENT0, + + // outputs + out float4 oPosition : POSITION, + out float4 uvproj : TEXCOORD0, + out float2 oUv : TEXCOORD1, + out float3 oTSLightDir : TEXCOORD2, + + // parameters + uniform float4 lightPosition, // object space + uniform float4x4 worldViewProj, + uniform float4x4 worldMatrix, + uniform float4x4 texViewProj) +{ + // calculate output position + oPosition = mul(worldViewProj, position); + + // pass the main uvs straight through unchanged + oUv = uv; + + // calculate tangent space light vector + // Get object space light direction + // Non-normalised since we'll do that in the fragment program anyway + float3 lightDir = lightPosition.xyz - (position * lightPosition.w); + + // Calculate the binormal (NB we assume both normal and tangent are + // already normalised) + // NB looks like nvidia cross params are BACKWARDS to what you'd expect + // this equates to NxT, not TxN + float3 binormal = cross(tangent, normal); + + // Form a rotation matrix out of the vectors + float3x3 rotation = float3x3(tangent, binormal, normal); + + // Transform the light vector according to this matrix + oTSLightDir = mul(rotation, lightDir); + + // Projection + uvproj = mul(worldMatrix, position); + uvproj = mul(texViewProj, uvproj); + +} + + +void main_fp( float2 uv : TEXCOORD0, + float3 TSlightDir : TEXCOORD1, + + out float4 colour : COLOR, + + uniform float4 lightDiffuse, + uniform sampler2D normalMap : register(s0), + uniform samplerCUBE normalCubeMap : register(s1) ) +{ + // retrieve normalised light vector, expand from range-compressed + float3 lightVec = expand(texCUBE(normalCubeMap, TSlightDir).xyz); + + // get bump map vector, again expand from range-compressed + float3 bumpVec = expand(tex2D(normalMap, uv).xyz); + + // Calculate dot product + colour = lightDiffuse * dot(bumpVec, lightVec); + +} + +void main_shadowreceiver_fp( + float4 uvproj : TEXCOORD0, + float2 uv : TEXCOORD1, + float3 TSlightDir : TEXCOORD2, + + out float4 colour : COLOR, + + uniform float4 lightDiffuse, + uniform sampler2D shadowMap : register(s0), + uniform sampler2D normalMap : register(s1), + uniform samplerCUBE normalCubeMap : register(s2)) +{ + + + // retrieve normalised light vector, expand from range-compressed + float3 lightVec = expand(texCUBE(normalCubeMap, TSlightDir).xyz); + + // get bump map vector, again expand from range-compressed + float3 bumpVec = expand(tex2D(normalMap, uv).xyz); + + // get shadow value + float3 shadow = tex2Dproj(shadowMap, uvproj).xyz; + + // Calculate dot product + colour = float4(shadow * lightDiffuse * dot(bumpVec, lightVec), 1.0f); + +} + +/* Vertex program which includes specular component */ +void specular_vp(float4 position : POSITION, + float3 normal : NORMAL, + float2 uv : TEXCOORD0, + float3 tangent : TANGENT0, + // outputs + out float4 oPosition : POSITION, + out float2 oUv : TEXCOORD0, + out float3 oTSLightDir : TEXCOORD1, + out float3 oTSHalfAngle : TEXCOORD2, + // parameters + uniform float4 lightPosition, // object space + uniform float3 eyePosition, // object space + uniform float4x4 worldViewProj) +{ + // calculate output position + oPosition = mul(worldViewProj, position); + + // pass the main uvs straight through unchanged + oUv = uv; + + // calculate tangent space light vector + // Get object space light direction + float3 lightDir = normalize(lightPosition.xyz - (position * lightPosition.w)); + + // Calculate the binormal (NB we assume both normal and tangent are + // already normalised) + // NB looks like nvidia cross params are BACKWARDS to what you'd expect + // this equates to NxT, not TxN + float3 binormal = cross(tangent, normal); + + // Form a rotation matrix out of the vectors + float3x3 rotation = float3x3(tangent, binormal, normal); + + // Transform the light vector according to this matrix + oTSLightDir = mul(rotation, lightDir); + + // Calculate half-angle in tangent space + float3 eyeDir = normalize(eyePosition - position.xyz); + float3 halfAngle = normalize(eyeDir + lightDir); + oTSHalfAngle = mul(rotation, halfAngle); + + +} + +/* Fragment program which supports specular component */ +void specular_fp( float2 uv : TEXCOORD0, + float3 TSlightDir : TEXCOORD1, + float3 TShalfAngle: TEXCOORD2, + + out float4 colour : COLOR, + + uniform float4 lightDiffuse, + uniform float4 lightSpecular, + uniform sampler2D normalMap : register(s0), + uniform samplerCUBE normalCubeMap : register(s1), + uniform samplerCUBE normalCubeMap2 : register(s2)) // we need this second binding to be compatible with ps_1_1, ps_2_0 could reuse the other +{ + // retrieve normalised light vector, expand from range-compressed + float3 lightVec = expand(texCUBE(normalCubeMap, TSlightDir).xyz); + + // retrieve half angle and normalise through cube map + float3 halfAngle = expand(texCUBE(normalCubeMap2, TShalfAngle).xyz); + + // get bump map vector, again expand from range-compressed + float3 bumpVec = expand(tex2D(normalMap, uv).xyz); + + // Pre-raise the specular exponent to the eight power + // Note we have no 'pow' function in basic fragment programs, if we were willing to accept compatibility + // with ps_2_0 / arbfp1 and above, we could have a variable shininess parameter + // This is equivalent to + float specFactor = dot(bumpVec, halfAngle); + for (int i = 0; i < 3; ++i) + specFactor *= specFactor; + + + // Calculate dot product for diffuse + colour = (lightDiffuse * saturate(dot(bumpVec, lightVec))) + + (lightSpecular * specFactor); + +} + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Example_CelShading.cg b/school/informatik/verkerhssimulation/media/materials/programs/Example_CelShading.cg new file mode 100644 index 00000000..895944fa --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Example_CelShading.cg @@ -0,0 +1,63 @@ + +/* Cel shading vertex program for single-pass rendering + In this program, we want to calculate the diffuse and specular + ramp components, and the edge factor (for doing simple outlining) + For the outlining to look good, we need a pretty well curved model. +*/ +void main_vp(float4 position : POSITION, + float3 normal : NORMAL, + // outputs + out float4 oPosition : POSITION, + out float diffuse : TEXCOORD0, + out float specular : TEXCOORD1, + out float edge : TEXCOORD2, + // parameters + uniform float3 lightPosition, // object space + uniform float3 eyePosition, // object space + uniform float4 shininess, + uniform float4x4 worldViewProj) +{ + // calculate output position + oPosition = mul(worldViewProj, position); + + // calculate light vector + float3 N = normalize(normal); + float3 L = normalize(lightPosition - position.xyz); + + // Calculate diffuse component + diffuse = max(dot(N, L) , 0); + + // Calculate specular component + float3 E = normalize(eyePosition - position.xyz); + float3 H = normalize(L + E); + specular = pow(max(dot(N, H), 0), shininess); + // Mask off specular if diffuse is 0 + if (diffuse == 0) specular = 0; + + // Edge detection, dot eye and normal vectors + edge = max(dot(N, E), 0); +} + +void main_fp(float diffuseIn : TEXCOORD0, + float specularIn : TEXCOORD1, + float edge : TEXCOORD2, + + out float4 colour : COLOR, + + uniform float4 diffuse, + uniform float4 specular, + + uniform sampler1D diffuseRamp, + uniform sampler1D specularRamp, + uniform sampler1D edgeRamp) +{ + // Step functions from textures + diffuseIn = tex1D(diffuseRamp, diffuseIn).x; + specularIn = tex1D(specularRamp, specularIn).x; + edge = tex1D(edgeRamp, edge).x; + + colour = edge * ((diffuse * diffuseIn) + + (specular * specularIn)); +} + + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Example_Fresnel.cg b/school/informatik/verkerhssimulation/media/materials/programs/Example_Fresnel.cg new file mode 100644 index 00000000..2d8d0dc8 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Example_Fresnel.cg @@ -0,0 +1,115 @@ +// Vertex program for fresnel reflections / refractions +void main_vp( + float4 pos : POSITION, + float4 normal : NORMAL, + float2 tex : TEXCOORD0, + + out float4 oPos : POSITION, + out float3 noiseCoord : TEXCOORD0, + out float4 projectionCoord : TEXCOORD1, + out float3 oEyeDir : TEXCOORD2, + out float3 oNormal : TEXCOORD3, + + uniform float4x4 worldViewProjMatrix, + uniform float3 eyePosition, // object space + uniform float timeVal, + uniform float scale, // the amount to scale the noise texture by + uniform float scroll, // the amount by which to scroll the noise + uniform float noise // the noise perturb as a factor of the time + ) +{ + oPos = mul(worldViewProjMatrix, pos); + // Projective texture coordinates, adjust for mapping + float4x4 scalemat = float4x4(0.5, 0, 0, 0.5, + 0,-0.5, 0, 0.5, + 0, 0, 0.5, 0.5, + 0, 0, 0, 1); + projectionCoord = mul(scalemat, oPos); + // Noise map coords + noiseCoord.xy = (tex + (timeVal * scroll)) * scale; + noiseCoord.z = noise * timeVal; + + oEyeDir = normalize(pos.xyz - eyePosition); + oNormal = normal.rgb; + +} + +// Fragment program for distorting a texture using a 3D noise texture +void main_fp( + float3 noiseCoord : TEXCOORD0, + float4 projectionCoord : TEXCOORD1, + float3 eyeDir : TEXCOORD2, + float3 normal : TEXCOORD3, + + out float4 col : COLOR, + + uniform float4 tintColour, + uniform float noiseScale, + uniform float fresnelBias, + uniform float fresnelScale, + uniform float fresnelPower, + uniform sampler2D noiseMap : register(s0), + uniform sampler2D reflectMap : register(s1), + uniform sampler2D refractMap : register(s2) + ) +{ + // Do the tex projection manually so we can distort _after_ + float2 final = projectionCoord.xy / projectionCoord.w; + + // Noise + float3 noiseNormal = (tex2D(noiseMap, (noiseCoord.xy / 5)).rgb - 0.5).rbg * noiseScale; + final += noiseNormal.xz; + + // Fresnel + //normal = normalize(normal + noiseNormal.xz); + float fresnel = fresnelBias + fresnelScale * pow(1 + dot(eyeDir, normal), fresnelPower); + + // Reflection / refraction + float4 reflectionColour = tex2D(reflectMap, final); + float4 refractionColour = tex2D(refractMap, final) + tintColour; + + // Final colour + col = lerp(refractionColour, reflectionColour, fresnel); + + +} + + +// Old version to match ATI PS 1.3 implementation +void main_vp_old( + float4 pos : POSITION, + float4 normal : NORMAL, + float2 tex : TEXCOORD0, + + out float4 oPos : POSITION, + out float fresnel : COLOR, + out float3 noiseCoord : TEXCOORD0, + out float4 projectionCoord : TEXCOORD1, + + uniform float4x4 worldViewProjMatrix, + uniform float3 eyePosition, // object space + uniform float fresnelBias, + uniform float fresnelScale, + uniform float fresnelPower, + uniform float timeVal, + uniform float scale, // the amount to scale the noise texture by + uniform float scroll, // the amount by which to scroll the noise + uniform float noise // the noise perturb as a factor of the time + ) +{ + oPos = mul(worldViewProjMatrix, pos); + // Projective texture coordinates, adjust for mapping + float4x4 scalemat = float4x4(0.5, 0, 0, 0.5, + 0,-0.5, 0, 0.5, + 0, 0, 0.5, 0.5, + 0, 0, 0, 1); + projectionCoord = mul(scalemat, oPos); + // Noise map coords + noiseCoord.xy = (tex + (timeVal * scroll)) * scale; + noiseCoord.z = noise * timeVal; + + // calc fresnel factor (reflection coefficient) + float3 eyeDir = normalize(pos.xyz - eyePosition); + fresnel = fresnelBias + fresnelScale * pow(1 + dot(eyeDir, normal), fresnelPower); + +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Example_FresnelPS.asm b/school/informatik/verkerhssimulation/media/materials/programs/Example_FresnelPS.asm new file mode 100644 index 00000000..2de078ef --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Example_FresnelPS.asm @@ -0,0 +1,72 @@ +ps.1.4 + // conversion from Cg generated ARB_fragment_program to ps.1.4 by NFZ + // command line args: -profile arbfp1 -entry main_fp + // program main_fp + // c0 : distortionRange + // c1 : tintColour + // testure 0 : noiseMap + // texture 1 : reflectMap + // texture 2 : refractMap + // v0.x : fresnel + // t0.xyz : noiseCoord + // t1.xyw : projectionCoord + +def c2, 2, 1, 0, 0 + + // Cg: distort.x = tex3D(noiseMap, noiseCoord).x; + // arbfp1: TEX R0.x, fragment.texcoord[0], texture[0], 3D; + // sample noise map using noiseCoord in TEX unit 0 + +texld r0, t0.xyz + + // get projected texture coordinates from TEX coord 1 + // will be used in phase 2 + +texcrd r1.xy, t1_dw.xyw +mov r1.z, c2.y + + // Cg: distort.y = tex3D(noiseMap, noiseCoord + yoffset).x; + // arbfp1: ADD R1.xyz, fragment.texcoord[0], c1; + // arbfp1: TEX R1.x, R1, texture[0], 3D; + // arbfp1: MOV R0.y, R1.x; + + // Cg: distort = (distort * 2 - 1) * distortionRange; + // arbfp1: MAD R0.xy, R0, c0.x, -c0.y; + // arbfp1: MUL R0.xy, R0, u0.x; + // (distort * 2 - 1) same as 2*(distort -.5) so use _bx2 + + + // Cg: final = projectionCoord.xy / projectionCoord.w; + // Cg: final += distort; + // arbfp1: RCP R0.w, fragment.texcoord[1].w; + // arbfp1: MAD R0.xy, fragment.texcoord[1], R0.w, R0; + // final = (distort * projectionCoord.w) + projectionCoord.xy + // for ps.1.4 have to re-arrange things a bit to perturb projected texture coordinates + +mad r0.xyz, r0_bx2, c0.x, r1 + +phase + + // do dependant texture reads + // Cg: reflectionColour = tex2D(reflectMap, final); + // arbfp1: TEX R0, R0, texture[1], 2D; + // sampe reflectMap using dependant read : texunit 1 + +texld r1, r0.xyz + + // Cg: refractionColour = tex2D(refractMap, final) + tintColour; + // arbfp1: TEX R1, R0, texture[2], 2D; + // sample refractMap : texunit 2 + +texld r2, r0.xyz + + // adding tintColour that is in global c1 + // arbfp1: ADD R1, R1, u1; + +add r2, r2, c1 + + // Cg: col = lerp(refractionColour, reflectionColour, fresnel); + // arbfp1: ADD R0, R0, -R1; + // arbfp1: MAD result.color, fragment.color.primary.x, R0, R1; + +lrp r0, v0.x, r1, r2 diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Example_Projection.cg b/school/informatik/verkerhssimulation/media/materials/programs/Example_Projection.cg new file mode 100644 index 00000000..c43f5904 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Example_Projection.cg @@ -0,0 +1,28 @@ + +void generalPurposeProjection_vp( + float4 pos : POSITION, + + out float4 oPos : POSITION, + out float4 texCoord : TEXCOORD0, + + uniform float4x4 worldViewProjMatrix, + uniform float4x4 worldMatrix, + uniform float4x4 texViewProjMatrix) +{ + oPos = mul(worldViewProjMatrix, pos); + // multiply position by world matrix, then by projective view/proj + float4 newpos = mul(worldMatrix, pos); + texCoord = mul(texViewProjMatrix, newpos); + +} + +void generalPurposeProjection_fp( + float4 texCoord : TEXCOORD0, + out float4 col : COLOR, + uniform sampler2D texMap) +{ + col = tex2Dproj(texMap, texCoord); + +} + + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/GlassFP.cg b/school/informatik/verkerhssimulation/media/materials/programs/GlassFP.cg new file mode 100644 index 00000000..734c8039 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/GlassFP.cg @@ -0,0 +1,9 @@ +sampler RT : register(s0); +sampler NormalMap : register(s1); + +float4 main_ps(float2 iTexCoord : TEXCOORD0) : COLOR +{ + float4 normal = 2 * (tex2D(NormalMap, iTexCoord * 2.5) - 0.5); + + return tex2D(RT, iTexCoord + normal.xy * 0.05); +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Grass.cg b/school/informatik/verkerhssimulation/media/materials/programs/Grass.cg new file mode 100644 index 00000000..4d2517b8 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Grass.cg @@ -0,0 +1,30 @@ +// Vertex program to wave some grass about +// Simplistic, assumes base of the grass at 0 +void grass_vp(float4 position : POSITION, + float3 normal : NORMAL, + float2 uv : TEXCOORD0, + out float4 oPosition : POSITION, + out float2 oUv : TEXCOORD0, + out float4 colour : COLOR, + + uniform float4x4 worldViewProj, + uniform float4 ambient, + uniform float4 objSpaceLight, + uniform float4 lightColour, + uniform float4 offset) +{ + float4 mypos = position; + //offset = float4(0.5, 0, 0, 0); + mypos = mypos + offset * mypos.yyyy; + oPosition = mul(worldViewProj, mypos); + + oUv = uv; + // get vertex light direction (support directional and point) + float3 light = normalize( + objSpaceLight.xyz - (position.xyz * objSpaceLight.w)); + float diffuseFactor = max(dot(normal, light), 0); + + + colour = ambient + diffuseFactor * lightColour; +} + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/GrayScale.cg b/school/informatik/verkerhssimulation/media/materials/programs/GrayScale.cg new file mode 100644 index 00000000..cb0c0dfb --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/GrayScale.cg @@ -0,0 +1,18 @@ +sampler RT : register(s0); + +float4 GrayScale_ps(float2 iTexCoord : TEXCOORD0) : COLOR +{ + float3 greyscale = dot(tex2D(RT, iTexCoord).rgb, float3(0.3, 0.59, 0.11)); + return float4(greyscale, 1.0); +} + +float4 Embossed_ps(float2 iTexCoord : TEXCOORD0) : COLOR +{ + float4 Color; + Color.a = 1.0f; + Color.rgb = 0.5f; + Color -= tex2D( RT, iTexCoord - 0.001)*2.0f; + Color += tex2D( RT, iTexCoord + 0.001)*2.0f; + Color.rgb = (Color.r+Color.g+Color.b)/3.0f; + return Color; +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/HeatVision.cg b/school/informatik/verkerhssimulation/media/materials/programs/HeatVision.cg new file mode 100644 index 00000000..86d5b812 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/HeatVision.cg @@ -0,0 +1,230 @@ +////////////////////////////////////////////// +// CASTER PASS // +// HEAT // +////////////////////////////////////////////// + +// vs_1_1 +void HeatCaster_vp( + // in + float4 vPos: POSITION, + float4 vNormal: NORMAL, + + // out + out float4 oPos: POSITION, + out float2 oNDotV: TEXCOORD0, + + // parameters + uniform float4x4 worldViewProj, + uniform float3 eyePosition // object space + ) +{ + float4 eyeDir = float4(eyePosition - vPos.xyz, 0); + eyeDir = normalize(eyeDir); + oPos = mul( worldViewProj, vPos ); + oNDotV = clamp( dot( vNormal, eyeDir ), 0, 1 ); +} + +// ps_2_0 +float4 HeatCaster_fp( + // input from vp + float2 iNDotV: TEXCOORD0 + ) : COLOR0 +{ + return iNDotV.x; +} + + +////////////////////////////////////////////// +// CASTER PASS // +// COLD // +////////////////////////////////////////////// + +// vs_1_1 +void ColdCaster_vp( + // in + float4 vPos: POSITION, + float4 vNormal: NORMAL, + + // out + out float4 oPos: POSITION, + out float2 oNDotV: TEXCOORD0, + + // parameters + uniform float4x4 worldViewProj, + uniform float3 eyePosition // object space + ) +{ + float4 eyeDir = float4(eyePosition - vPos.xyz, 0); + eyeDir = normalize(eyeDir); + oPos = mul( worldViewProj, vPos ); + oNDotV = clamp( dot( vNormal, eyeDir ), 0, 1 ); +} + +// ps_2_0 +float4 ColdCaster_fp( + // input from vp + float2 iNDotV: TEXCOORD0 + ) : COLOR0 +{ + return iNDotV.x / 2; +} + + +////////////////////////////////////////////// +// PASS 1 - Light to heat conversion // +////////////////////////////////////////////// + +// vs_1_1 +void LightToHeat_vp( + // in + float4 inPos: POSITION, + + uniform float flipping, + + // out + out float4 Pos: POSITION, + out float2 uv0: TEXCOORD0 + ) +{ + Pos = float4(inPos.x, flipping * inPos.y, 0.0f, 1.0f); + inPos.xy = sign(inPos.xy); + uv0 = (float2(inPos.x, -inPos.y) + 1.0f)/2.0f; +} + + +// ps_2_0 +void LightToHeat_fp( + // input from vp + float4 inDiffuse: COLOR0, + float2 inUV0: TEXCOORD0, + + // out + out float4 outColor: COLOR0, + + // params + uniform float4 random_fractions, + uniform float4 heatBiasScale, + uniform float4 depth_modulator, + + uniform sampler2D Input, // output of HeatVisionCaster_fp (NdotV) + uniform sampler2D NoiseMap, + uniform sampler2D HeatLookup + ) +{ + float depth, heat, interference; + + // Output constant color: + depth = tex2D( Input, inUV0 ); + depth *= (depth * depth_modulator); + + heat = (depth * heatBiasScale.y); + +// if (depth > 0) + { + interference = -0.5 + tex2D( NoiseMap, inUV0 + float2( random_fractions.x, random_fractions.y ) ); + interference *= interference; + interference *= 1 - heat; + heat += interference;//+ heatBiasScale.x; + } + +/* + heatBias isn't used for now + if (heat > 0) + heat += heatBiasScale.x; +*/ + + // Clamp UVs + heat = max( 0.005, min( 0.995, heat ) ); + outColor = tex2D( HeatLookup, float2( heat, 0.f ) ); +} + + +////////////////////////////////////////////// +// PASS 2 - add simple blur (final pass) // +////////////////////////////////////////////// + +// vs_1_1 +void Blur_vp( + // in + float4 inPos: POSITION, + + uniform float flipping, + + // out + out float4 Pos: POSITION, + out float2 uv0: TEXCOORD0 + ) +{ + Pos = float4(inPos.x, flipping * inPos.y, 0.0f, 1.0f); + inPos.xy = sign(inPos.xy); + uv0 = (float2(inPos.x, -inPos.y) + 1.0f)/2.0f; +} + +// ps_2_0 +void Blur_fp( + // input from vp + float4 inDiffuse: COLOR0, + float2 inUV0: TEXCOORD0, + + // out + out float4 outColor: COLOR0, + + // parameters + uniform sampler2D Input, // output of HeatVision_fp1 (HeatRenderTexture) + uniform float4 blurAmount + ) +{ + int i; + float4 tmpOutColor; + float diffuseGlowFactor; + const float2 offsets[4] = + { +/* + // hazy blur + -1.8, -1.8, + -1.8, 1.8, + 1.8, -1.8, + 1.8, 1.8 +*/ +/* + // less-hazy blur + -1.0, 2.0, + -1.0, -1.0, + 1.0, -1.0, + 1.0, 1.0 +*/ +/* + -0.326212, -0.405805, + -0.840144, -0.073580, + -0.695914, 0.457137, + -0.203345, 0.620716 +*/ + + -0.3, 0.4, + -0.3, -0.4, + 0.3, -0.4, + 0.3, 0.4 + + }; + + tmpOutColor = tex2D( Input, inUV0 ); // UV coords are in image space + + // calculate glow amount + diffuseGlowFactor = 0.0113f * (2.0 - max( tmpOutColor.r, tmpOutColor.g )); + + // basic blur filter + for (i = 0; i < 4; i++) { + tmpOutColor += tex2D( Input, inUV0 + blurAmount.x * diffuseGlowFactor * offsets[i] ); + } + + tmpOutColor *= 0.25; + + // TIPS (old-skool strikes again!) + // Pay attention here! If you use the "out float4 outColor" directly + // in your steps while creating the output color (like you remove + // the "tmpOutColor" var and just use the "outColor" directly) + // your pixel-color output IS CHANGING EACH TIME YOU DO AN ASSIGNMENT TOO! + // A temporary variable, instead, acts like a per-pixel double buffer, and + // best of all, lead to better performance. + outColor = tmpOutColor; +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/media/materials/programs/InvertFP.cg b/school/informatik/verkerhssimulation/media/materials/programs/InvertFP.cg new file mode 100644 index 00000000..2ef442bc --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/InvertFP.cg @@ -0,0 +1,6 @@ +sampler RT : register(s0); + +float4 Invert_ps (float2 iTexCoord : TEXCOORD0) : COLOR +{ + return 1 - tex2D(RT, iTexCoord); +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/LaplaceFP.cg b/school/informatik/verkerhssimulation/media/materials/programs/LaplaceFP.cg new file mode 100644 index 00000000..999e1bf9 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/LaplaceFP.cg @@ -0,0 +1,36 @@ +sampler Image : register(s0); + +// The Laplace filter approximates the second order derivate, +// that is, the rate of change of slope in the image. It can be +// used for edge detection. The Laplace filter gives negative +// response on the higher side of the edge and positive response +// on the lower side. + +// This is the filter kernel: +// 0 1 0 +// 1 -4 1 +// 0 1 0 + + + +float4 Laplace_ps (float2 texCoord: TEXCOORD0, + uniform float scale, + uniform float pixelSize) : COLOR +{ + + float2 samples[4] = { + 0, -1, + -1, 0, + 1, 0, + 0, 1 + }; + float4 laplace = -4 * tex2D(Image, texCoord); + + // Sample the neighbor pixels + for (int i = 0; i < 4; i++){ + laplace += tex2D(Image, texCoord + pixelSize * samples[i]); + } + + return (0.5 + scale * laplace); +} + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Ocean2GLSL.frag b/school/informatik/verkerhssimulation/media/materials/programs/Ocean2GLSL.frag new file mode 100644 index 00000000..024b68eb --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Ocean2GLSL.frag @@ -0,0 +1,71 @@ +/*********************************************************************NVMH3**** +Copyright NVIDIA Corporation 2003 +TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED +*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS +BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES +WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, +BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) +ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + +Comments: + Simple ocean shader with animated bump map and geometric waves + Based partly on "Effective Water Simulation From Physical Models", GPU Gems + +11 Aug 05: converted from HLSL to GLSL by Jeff Doyle (nfz) to work in Ogre + +******************************************************************************/ + + +uniform sampler2D NormalMap; +uniform samplerCube EnvironmentMap; +uniform vec4 deepColor; +uniform vec4 shallowColor; +uniform vec4 reflectionColor; +uniform float reflectionAmount; +uniform float reflectionBlur; +uniform float waterAmount; +uniform float fresnelPower; +uniform float fresnelBias; +uniform float hdrMultiplier; + +varying mat3 rotMatrix; // first row of the 3x3 transform from tangent to cube space +varying vec2 bumpCoord0; +varying vec2 bumpCoord1; +varying vec2 bumpCoord2; +varying vec3 eyeVector; + + +void main(void) +{ + // sum normal maps + // sample from 3 different points so no texture repetition is noticeable + vec4 t0 = texture2D(NormalMap, bumpCoord0) * 2.0 - 1.0; + vec4 t1 = texture2D(NormalMap, bumpCoord1) * 2.0 - 1.0; + vec4 t2 = texture2D(NormalMap, bumpCoord2) * 2.0 - 1.0; + vec3 N = t0.xyz + t1.xyz + t2.xyz; + + N = normalize(rotMatrix * N); + + // reflection + vec3 E = normalize(eyeVector); + vec3 R = reflect(E, N); + // Ogre conversion for cube map lookup + R.z = -R.z; + + vec4 reflection = textureCube(EnvironmentMap, R, reflectionBlur); + // cheap hdr effect + reflection.rgb *= (reflection.r + reflection.g + reflection.b) * hdrMultiplier; + + // fresnel + float facing = 1.0 - dot(-E, N); + float fresnel = clamp(fresnelBias + pow(facing, fresnelPower), 0.0, 1.0); + + vec4 waterColor = mix(shallowColor, deepColor, facing) * waterAmount; + + reflection = mix(waterColor, reflection * reflectionColor, fresnel) * reflectionAmount; + gl_FragColor = waterColor + reflection; +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/Ocean2GLSL.vert b/school/informatik/verkerhssimulation/media/materials/programs/Ocean2GLSL.vert new file mode 100644 index 00000000..d42db4bd --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/Ocean2GLSL.vert @@ -0,0 +1,91 @@ +/*********************************************************************NVMH3**** +Copyright NVIDIA Corporation 2003 +TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED +*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS +BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES +WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, +BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) +ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + +Comments: + Simple ocean shader with animated bump map and geometric waves + Based partly on "Effective Water Simulation From Physical Models", GPU Gems + +11 Aug 05: converted from HLSL to GLSL by Jeff Doyle (nfz) to work in Ogre + +******************************************************************************/ + +uniform vec3 eyePosition; +uniform float BumpScale; +uniform vec2 textureScale; +uniform vec2 bumpSpeed; +uniform float time; +uniform float waveFreq; +uniform float waveAmp; + +varying mat3 rotMatrix; // transform from tangent to obj space +varying vec2 bumpCoord0; +varying vec2 bumpCoord1; +varying vec2 bumpCoord2; +varying vec3 eyeVector; + +// wave functions +struct Wave { + float freq; // 2*PI / wavelength + float amp; // amplitude + float phase; // speed * 2*PI / wavelength + vec2 dir; +}; + + +void main(void) +{ + + #define NWAVES 2 + + Wave wave[NWAVES]; + + wave[0] = Wave( waveFreq, waveAmp, 0.5, vec2(-1, 0) ); + wave[1] = Wave( 3.0 * waveFreq, 0.33 * waveAmp, 1.7, vec2(-0.7, 0.7) ); + + + vec4 P = gl_Vertex; + + // sum waves + float ddx = 0.0, ddy = 0.0; + float deriv; + float angle; + + // wave synthesis using two sine waves at different frequencies and phase shift + for(int i = 0; i st.y) { c1 = invOff; } + half threshholdB = 1.0 - Threshhold; + if (st.x > threshholdB) { c2 = c1; } + if (st.y > threshholdB) { c2 = c1; } + half4 cBottom = c2; + c1 = (half4)0; + c2 = (half4)0; + if (st.x > st.y) { c1 = invOff; } + if (st.x < Threshhold) { c2 = c1; } + if (st.y < Threshhold) { c2 = c1; } + half4 cTop = c2; + half4 tileColor = tex2D(RT, PCenter); + half4 result = tileColor + cTop - cBottom; + return result; +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/crowdVp.glsl b/school/informatik/verkerhssimulation/media/materials/programs/crowdVp.glsl new file mode 100644 index 00000000..cb7a6e04 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/crowdVp.glsl @@ -0,0 +1,62 @@ +uniform mat4 viewProjectionMatrix; +uniform float numBones; +uniform vec4 worldMatrix3x4Array[240]; +uniform vec4 lightDiffuseColour; +uniform vec4 ambient; +uniform vec4 lightPos; + +attribute vec4 blendIndices; +attribute vec4 blendWeights; + + +void main() +{ + vec3 blendPos = vec3(0,0,0); + vec3 blendNorm = vec3(0,0,0); + + vec3 tmpPos = vec3(0,0,0); + vec3 tmpNorm = vec3(0,0,0); + + + int instanceOffset = int(gl_MultiTexCoord1.x) * 3 * int(numBones); + for (int bone = 0; bone < 2; ++bone) + { + // perform matrix multiplication manually since no 3x4 matrices + for (int row = 0; row < 3; ++row) + { + int idx = instanceOffset + int(blendIndices[bone]) * 3 + row; + vec4 blendMatrixRow = worldMatrix3x4Array[idx]; + tmpPos[row] = dot(blendMatrixRow, gl_Vertex); +#if SHADOW_CASTER +#else + tmpNorm[row] = dot(blendMatrixRow.xyz, gl_Normal); +#endif + + } + // now weight this into final + blendPos += tmpPos * blendWeights[bone]; +#if SHADOW_CASTER +#else + blendNorm += tmpNorm * blendWeights[bone]; +#endif + } + + // apply view / projection to position + gl_Position = viewProjectionMatrix * vec4(blendPos, 1); + + +#if SHADOW_CASTER + gl_FrontColor = ambient; +#else + // simple lighting model + vec3 lightDir = normalize( + lightPos.xyz - (blendPos.xyz * lightPos.w)); + gl_FrontColor = ambient + + clamp(dot(lightDir, blendNorm), 0.0, 1.0) * lightDiffuseColour; +#endif + gl_FrontSecondaryColor = vec4(0); + gl_TexCoord[0] = gl_MultiTexCoord0; + + +} + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/hdr.cg b/school/informatik/verkerhssimulation/media/materials/programs/hdr.cg new file mode 100644 index 00000000..a12237c9 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/hdr.cg @@ -0,0 +1,25 @@ +void morningskybox_fp ( + float2 uv : TEXCOORD0, + out float4 colour : COLOR, + + uniform sampler2D tex : register(s0) ) +{ + colour = tex2D(tex, uv); + + // blow out the light a bit + colour *= 1.7; +} +void morningcubemap_fp ( + float3 uv : TEXCOORD0, + out float4 colour : COLOR, + + uniform samplerCUBE tex : register(s0) ) +{ + colour = texCUBE(tex, uv); + + // blow out the light a bit + colour *= 1.7; +} + + + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/hdr.hlsl b/school/informatik/verkerhssimulation/media/materials/programs/hdr.hlsl new file mode 100644 index 00000000..6dfef6b8 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/hdr.hlsl @@ -0,0 +1,228 @@ +// RGBE mode utilities +// RGB each carry a mantissa, A carries a shared exponent +// The exponent is calculated based on the largest colour channel + + +float3 decodeRGBE8(in float4 rgbe) +{ + // get exponent (-128 since it can be +ve or -ve) + float exp = rgbe.a * 255 - 128; + + // expand out the rgb value + return rgbe.rgb * exp2(exp); +} + +float4 encodeRGBE8(in float3 rgb) +{ + float4 ret; + + // What is the largest colour channel? + float highVal = max(rgb.r, max(rgb.g, rgb.b)); + + // Take the logarithm, clamp it to a whole value + float exp = ceil(log2(highVal)); + + // Divide the components by the shared exponent + ret.rgb = rgb / exp2(exp); + + // Store the shared exponent in the alpha channel + ret.a = (exp + 128) / 255; + + return ret; +} + + +static const float4 LUMINENCE_FACTOR = float4(0.27f, 0.67f, 0.06f, 0.0f); +static const float MIDDLE_GREY = 0.72f; +static const float FUDGE = 0.001f; +static const float L_WHITE = 1.5f; +static const float4 BRIGHT_LIMITER = float4(0.6f, 0.6f, 0.6f, 0.0f); + + +/** Tone mapping function +@note Only affects rgb, not a +@param inColour The HDR colour +@param lum The scene lumninence +@returns Tone mapped colour +*/ +float4 toneMap(float4 inColour, float lum) +{ + // From Reinhard et al + // "Photographic Tone Reproduction for Digital Images" + + // Initial luminence scaling (equation 2) + inColour.rgb *= MIDDLE_GREY / (FUDGE + lum); + + // Control white out (equation 4 nom) + inColour.rgb *= (1.0f + inColour / L_WHITE); + + // Final mapping (equation 4 denom) + inColour.rgb /= (1.0f + inColour); + + return inColour; + +} + +/* Downsample a 2x2 area and convert to greyscale +*/ +float4 downscale2x2Luminence( + float2 uv : TEXCOORD0, + uniform float2 texelSize, // depends on size of source texture + uniform sampler2D inRTT : register(s0) + ) : COLOR +{ + + float4 accum = float4(0.0f, 0.0f, 0.0f, 0.0f); + + float2 texOffset[4] = { + -0.5, -0.5, + -0.5, 0.5, + 0.5, -0.5, + 0.5, 0.5 }; + + for( int i = 0; i < 4; i++ ) + { + // Get colour from source + accum += tex2D(inRTT, uv + texelSize * texOffset[i]); + } + + // Adjust the accumulated amount by lum factor + // Cannot use float3's here because it generates dependent texture errors because of swizzle + float lum = dot(accum, LUMINENCE_FACTOR); + // take average of 4 samples + lum *= 0.25; + return lum; + +} + +/* Downsample a 3x3 area + * This shader is used multiple times on different source sizes, so texel size has to be configurable +*/ +float4 downscale3x3( + float2 uv : TEXCOORD0, + uniform float2 texelSize, // depends on size of source texture + uniform sampler2D inRTT : register(s0) + ) : COLOR +{ + + float4 accum = float4(0.0f, 0.0f, 0.0f, 0.0f); + + float2 texOffset[9] = { + -1.0, -1.0, + 0.0, -1.0, + 1.0, -1.0, + -1.0, 0.0, + 0.0, 0.0, + 1.0, 0.0, + -1.0, 1.0, + 0.0, 1.0, + 1.0, 1.0 + }; + + for( int i = 0; i < 9; i++ ) + { + // Get colour from source + accum += tex2D(inRTT, uv + texelSize * texOffset[i]); + } + + // take average of 9 samples + accum *= 0.1111111111111111; + return accum; + +} + +/* Downsample a 3x3 area from main RTT and perform a brightness pass +*/ +float4 downscale3x3brightpass( + float2 uv : TEXCOORD0, + uniform float2 texelSize, // depends on size of source texture + uniform sampler2D inRTT : register(s0), + uniform sampler2D inLum : register(s1) + ) : COLOR +{ + + float4 accum = float4(0.0f, 0.0f, 0.0f, 0.0f); + + float2 texOffset[9] = { + -1.0, -1.0, + 0.0, -1.0, + 1.0, -1.0, + -1.0, 0.0, + 0.0, 0.0, + 1.0, 0.0, + -1.0, 1.0, + 0.0, 1.0, + 1.0, 1.0 + }; + + for( int i = 0; i < 9; i++ ) + { + // Get colour from source + accum += tex2D(inRTT, uv + texelSize * texOffset[i]); + } + + // take average of 9 samples + accum *= 0.1111111111111111; + + // Reduce bright and clamp + accum = max(float4(0.0f, 0.0f, 0.0f, 1.0f), accum - BRIGHT_LIMITER); + + // Sample the luminence texture + float4 lum = tex2D(inLum, float2(0.5f, 0.5f)); + + // Tone map result + return toneMap(accum, lum.r); + +} + +/* Gaussian bloom, requires offsets and weights to be provided externally +*/ +float4 bloom( + float2 uv : TEXCOORD0, + uniform float2 sampleOffsets[15], + uniform float4 sampleWeights[15], + uniform sampler2D inRTT : register(s0) + ) : COLOR +{ + float4 accum = float4(0.0f, 0.0f, 0.0f, 1.0f); + float2 sampleUV; + + for( int i = 0; i < 15; i++ ) + { + // Sample from adjacent points, 7 each side and central + sampleUV = uv + sampleOffsets[i]; + accum += sampleWeights[i] * tex2D(inRTT, sampleUV); + } + + return accum; + +} + + +/* Final scene composition, with tone mapping +*/ +float4 finalToneMapping( + float2 uv : TEXCOORD0, + uniform sampler2D inRTT : register(s0), + uniform sampler2D inBloom : register(s1), + uniform sampler2D inLum : register(s2) + ) : COLOR +{ + // Get main scene colour + float4 sceneCol = tex2D(inRTT, uv); + + // Get luminence value + float4 lum = tex2D(inLum, float2(0.5f, 0.5f)); + + // tone map this + float4 toneMappedSceneCol = toneMap(sceneCol, lum.r); + + // Get bloom colour + float4 bloom = tex2D(inBloom, uv); + + // Add scene & bloom + return float4(toneMappedSceneCol.rgb + bloom.rgb, 1.0f); + +} + + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/hdr_bloom.glsl b/school/informatik/verkerhssimulation/media/materials/programs/hdr_bloom.glsl new file mode 100644 index 00000000..d6992666 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/hdr_bloom.glsl @@ -0,0 +1,22 @@ +uniform sampler2D inRTT; + +uniform vec4 sampleOffsets[15]; +uniform vec4 sampleWeights[15]; + +varying vec2 uv; + +void main(void) +{ + vec4 accum = vec4(0.0, 0.0, 0.0, 1.0); + vec2 sampleUV; + + for( int i = 0; i < 15; i++ ) + { + // Sample from adjacent points, 7 each side and central + sampleUV = uv + sampleOffsets[i].xy; + accum += sampleWeights[i] * texture2D(inRTT, sampleUV); + } + + gl_FragColor = accum; + +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/hdr_downscale2x2luminence.glsl b/school/informatik/verkerhssimulation/media/materials/programs/hdr_downscale2x2luminence.glsl new file mode 100644 index 00000000..976a726b --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/hdr_downscale2x2luminence.glsl @@ -0,0 +1,24 @@ +uniform sampler2D inRTT; +uniform vec2 texelSize; + +varying vec2 uv; + +void main(void) +{ + + vec4 accum = vec4(0.0, 0.0, 0.0, 0.0); + vec4 LUMINENCE_FACTOR = vec4(0.27, 0.67, 0.06, 0.0); + + // Get colour from source + accum += texture2D(inRTT, uv + texelSize * vec2(-0.5, -0.5)); + accum += texture2D(inRTT, uv + texelSize * vec2(-0.5, 0.5)); + accum += texture2D(inRTT, uv + texelSize * vec2(0.5, 0.5)); + accum += texture2D(inRTT, uv + texelSize * vec2(0.5, -0.5)); + + // Adjust the accumulated amount by lum factor + float lum = dot(accum, LUMINENCE_FACTOR); + // take average of 4 samples + lum *= 0.25; + gl_FragColor = vec4(lum, lum, lum, 1.0); + +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/hdr_downscale3x3.glsl b/school/informatik/verkerhssimulation/media/materials/programs/hdr_downscale3x3.glsl new file mode 100644 index 00000000..2f6a999c --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/hdr_downscale3x3.glsl @@ -0,0 +1,26 @@ +uniform sampler2D inRTT; +uniform vec2 texelSize; + +varying vec2 uv; + +void main(void) +{ + vec4 accum = vec4(0.0, 0.0, 0.0, 0.0); + + // Get colour from source + accum += texture2D(inRTT, uv + texelSize * vec2(-1.0, -1.0)); + accum += texture2D(inRTT, uv + texelSize * vec2( 0.0, -1.0)); + accum += texture2D(inRTT, uv + texelSize * vec2( 1.0, -1.0)); + accum += texture2D(inRTT, uv + texelSize * vec2(-1.0, 0.0)); + accum += texture2D(inRTT, uv + texelSize * vec2( 0.0, 0.0)); + accum += texture2D(inRTT, uv + texelSize * vec2( 1.0, 0.0)); + accum += texture2D(inRTT, uv + texelSize * vec2(-1.0, 1.0)); + accum += texture2D(inRTT, uv + texelSize * vec2( 0.0, 1.0)); + accum += texture2D(inRTT, uv + texelSize * vec2( 1.0, 1.0)); + + // take average of 9 samples + accum *= 0.1111111111111111; + + gl_FragColor = accum; + +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/hdr_downscale3x3brightpass.glsl b/school/informatik/verkerhssimulation/media/materials/programs/hdr_downscale3x3brightpass.glsl new file mode 100644 index 00000000..83d4afba --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/hdr_downscale3x3brightpass.glsl @@ -0,0 +1,37 @@ +uniform sampler2D inRTT; +uniform sampler2D inLum; +uniform vec2 texelSize; + +varying vec2 uv; +const vec4 BRIGHT_LIMITER = vec4(0.6, 0.6, 0.6, 0.0); + +// declare external function +vec4 toneMap(in vec4 inColour, in float lum); + +void main(void) +{ + vec4 accum = vec4(0.0, 0.0, 0.0, 0.0); + + accum += texture2D(inRTT, uv + texelSize * vec2(-1.0, -1.0)); + accum += texture2D(inRTT, uv + texelSize * vec2( 0.0, -1.0)); + accum += texture2D(inRTT, uv + texelSize * vec2( 1.0, -1.0)); + accum += texture2D(inRTT, uv + texelSize * vec2(-1.0, 0.0)); + accum += texture2D(inRTT, uv + texelSize * vec2( 0.0, 0.0)); + accum += texture2D(inRTT, uv + texelSize * vec2( 1.0, 0.0)); + accum += texture2D(inRTT, uv + texelSize * vec2(-1.0, 1.0)); + accum += texture2D(inRTT, uv + texelSize * vec2( 0.0, 1.0)); + accum += texture2D(inRTT, uv + texelSize * vec2( 1.0, 1.0)); + + // take average of 9 samples + accum *= 0.1111111111111111; + + // Reduce bright and clamp + accum = max(vec4(0.0, 0.0, 0.0, 1.0), accum - BRIGHT_LIMITER); + + // Sample the luminence texture + vec4 lum = texture2D(inLum, vec2(0.5, 0.5)); + + // Tone map result + gl_FragColor = toneMap(accum, lum.r); + +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/hdr_finalToneMapping.glsl b/school/informatik/verkerhssimulation/media/materials/programs/hdr_finalToneMapping.glsl new file mode 100644 index 00000000..94c1b3e6 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/hdr_finalToneMapping.glsl @@ -0,0 +1,28 @@ +uniform sampler2D inRTT; +uniform sampler2D inBloom; +uniform sampler2D inLum; + +varying vec2 uv; + +// declare external function +vec4 toneMap(in vec4 inColour, in float lum); + +void main(void) +{ + // Get main scene colour + vec4 sceneCol = texture2D(inRTT, uv); + + // Get luminence value + vec4 lum = texture2D(inLum, vec2(0.5, 0.5)); + + // tone map this + vec4 toneMappedSceneCol = toneMap(sceneCol, lum.r); + + // Get bloom colour + vec4 bloom = texture2D(inBloom, uv); + + // Add scene & bloom + gl_FragColor = vec4(toneMappedSceneCol.rgb + bloom.rgb, 1.0); + +} + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/hdr_tonemap_util.glsl b/school/informatik/verkerhssimulation/media/materials/programs/hdr_tonemap_util.glsl new file mode 100644 index 00000000..14c58fb1 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/hdr_tonemap_util.glsl @@ -0,0 +1,29 @@ +const float MIDDLE_GREY = 0.72; +const float FUDGE = 0.001; +const float L_WHITE = 1.5; + +/** Tone mapping function +@note Only affects rgb, not a +@param inColour The HDR colour +@param lum The scene lumninence +@returns Tone mapped colour +*/ +vec4 toneMap(in vec4 inColour, in float lum) +{ + // From Reinhard et al + // "Photographic Tone Reproduction for Digital Images" + + // Initial luminence scaling (equation 2) + inColour.rgb *= MIDDLE_GREY / (FUDGE + lum); + + // Control white out (equation 4 nom) + inColour.rgb *= (1.0 + inColour.rgb / L_WHITE); + + // Final mapping (equation 4 denom) + inColour.rgb /= (1.0 + inColour.rgb); + + return inColour; + +} + + diff --git a/school/informatik/verkerhssimulation/media/materials/programs/instancing.cg b/school/informatik/verkerhssimulation/media/materials/programs/instancing.cg new file mode 100644 index 00000000..241f41be --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/instancing.cg @@ -0,0 +1,125 @@ + + +void instancing_vp(uniform float3x4 worldMatrix3x4Array[80], float4 position : POSITION, + float3 normal : NORMAL, + float2 uv : TEXCOORD0, + float index : TEXCOORD1, + uniform float4x4 viewProjectionMatrix, + uniform float4 lightPos, + uniform float4 ambient, + uniform float4 lightDiffuseColour, + out float4 oPosition : POSITION, + out float2 oUv : TEXCOORD0, + out float4 Color : COLOR ) +{ + // transform by indexed matrix + float4 transformedPos = float4(mul(worldMatrix3x4Array[index], position).xyz, 1.0); + + // view / projection + oPosition = mul(viewProjectionMatrix, transformedPos); + oUv = uv; + + float3 norm = mul((float3x3)worldMatrix3x4Array[index], normal); + + float3 lightDir = normalize( + lightPos.xyz - (transformedPos.xyz * lightPos.w)); + + Color = ambient + saturate(dot(lightDir, norm)) * lightDiffuseColour; + + +} + +/* + Instancing shadow-caster pass +*/ +void instancingCaster_vp( + float4 position : POSITION, + float3 normal : NORMAL, + float index : TEXCOORD1, + + out float4 oPosition : POSITION, + out float4 colour : COLOR, + // Support up to 80 bones of float3x4 + uniform float3x4 worldMatrix3x4Array[80], + uniform float4x4 viewProjectionMatrix, + uniform float4 ambient) +{ + // transform by indexed matrix + float4 transformedPos = float4(mul(worldMatrix3x4Array[index], position).xyz, 1.0); + + // view / projection + oPosition = mul(viewProjectionMatrix, transformedPos); + + colour = ambient; + +} +void crowd_vp( + float4 position : POSITION, + float3 normal : NORMAL, + float2 uv : TEXCOORD0, + float4 blendIdx : BLENDINDICES, + float4 blendWgt : BLENDWEIGHT, + float index : TEXCOORD1, + + out float4 oPosition : POSITION, + out float2 oUv : TEXCOORD0, + out float4 colour : COLOR, + // Support up to 20 bones of float3x4 + // vs_2_0 only supports 256 params so more than this is not feasible + uniform float4x4 viewProjectionMatrix, + uniform float numBones, + uniform float3x4 worldMatrix3x4Array[80], + uniform float4 lightDiffuseColour, + uniform float4 ambient, + uniform float4 lightPos) +{ + // transform by indexed matrix + float4 blendPos = float4(0,0,0,0); + int i; + for (i = 0; i < 4; ++i) + { + blendPos += float4(mul(worldMatrix3x4Array[index*numBones+blendIdx[i]], position).xyz, 1.0) * blendWgt[i]; + } + // view / projection + oPosition = mul(viewProjectionMatrix, blendPos); + oUv = uv; + float3 norm = float3(0,0,0); + for (i = 0; i < 4; ++i) + { + norm += mul((float3x3)worldMatrix3x4Array[index*numBones+blendIdx[i]], normal)* blendWgt[i]; + } + float3 lightDir = normalize( + lightPos.xyz - (blendPos.xyz * lightPos.w)); + + colour = ambient + saturate(dot(lightDir, norm)) * lightDiffuseColour; + + +} + +/* + Single-weight-per-vertex hardware skinning, shadow-caster pass +*/ +void crowdCaster_vp( + float4 position : POSITION, + float3 normal : NORMAL, + float blendIdx : BLENDINDICES, + float index : TEXCOORD1, + + out float4 oPosition : POSITION, + out float4 colour : COLOR, + // Support up to 24 bones of float3x4 + // vs_1_1 only supports 96 params so more than this is not feasible + uniform float3x4 worldMatrix3x4Array[80], + uniform float4x4 viewProjectionMatrix, + uniform float numBones, + uniform float4 ambient) +{ + // transform by indexed matrix + float4 blendPos = float4(mul(worldMatrix3x4Array[index*numBones+blendIdx], position).xyz, 1.0); + + // view / projection + oPosition = mul(viewProjectionMatrix, blendPos); + + colour = ambient; + +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/instancingVp.glsl b/school/informatik/verkerhssimulation/media/materials/programs/instancingVp.glsl new file mode 100644 index 00000000..06a65665 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/instancingVp.glsl @@ -0,0 +1,39 @@ +uniform vec4 worldMatrix3x4Array[240]; +uniform mat4 viewProjectionMatrix; +uniform vec4 lightPos; +uniform vec4 ambient; +uniform vec4 lightDiffuseColour; + +void main() +{ + + // transform by indexed matrix + // perform matrix multiplication manually since no 3x4 matrices + vec3 transformedPos; + vec3 transformedNorm; + int instanceOffset = int(gl_MultiTexCoord1.x) * 3; + for (int row = 0; row < 3; ++row) + { + vec4 matrixRow = worldMatrix3x4Array[instanceOffset + row]; + transformedPos[row] = dot(matrixRow, gl_Vertex); +#if SHADOW_CASTER +#else + transformedNorm[row] = dot(matrixRow.xyz, gl_Normal); +#endif + + } + + // view / projection + gl_Position = viewProjectionMatrix * vec4(transformedPos,1); + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_FrontSecondaryColor = vec4(0); + +#if SHADOW_CASTER + gl_FrontColor = ambient; +#else + vec3 lightDir = normalize( + lightPos.xyz - (transformedPos.xyz * lightPos.w)); + gl_FrontColor = ambient + clamp(dot(lightDir, transformedNorm),0.0,1.0) * lightDiffuseColour; +#endif + +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/oceanGLSL.frag b/school/informatik/verkerhssimulation/media/materials/programs/oceanGLSL.frag new file mode 100644 index 00000000..dd737482 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/oceanGLSL.frag @@ -0,0 +1,45 @@ +// oceanGLSL.frag +// fragment program for Ocean water simulation +// 05 Aug 2005 +// adapted for Ogre by nfz +// converted from HLSL to GLSL +// original shader source from Render Monkey 1.6 Reflections Refractions.rfx + +// 06 Aug 2005: moved uvw calculation from fragment program into vertex program + +uniform float fadeBias; +uniform float fadeExp; +uniform vec4 waterColor; +uniform sampler3D Noise; +uniform samplerCube skyBox; + +varying vec3 uvw; +varying vec3 normal; +varying vec3 vVec; + +void main(void) +{ + vec3 noisy = texture3D(Noise, uvw).xyz; + + // convert to signed noise + vec3 bump = 2.0 * noisy - 1.0; + bump.xz *= 0.15; + // Make sure the normal always points upwards + // note that Ogres y axis is vertical (RM Z axis is vertical) + bump.y = 0.8 * abs(bump.y) + 0.2; + // Offset the surface normal with the bump + bump = normalize(normal + bump); + + // Find the reflection vector + vec3 normView = normalize(vVec); + vec3 reflVec = reflect(normView, bump); + // Ogre has z flipped for cubemaps + reflVec.z = -reflVec.z; + vec4 refl = textureCube(skyBox, reflVec); + + // set up for fresnel calc + float lrp = 1.0 - dot(-normView, bump); + + // Interpolate between the water color and reflection for fresnel effect + gl_FragColor = mix(waterColor, refl, clamp(fadeBias + pow(lrp, fadeExp), 0.0, 1.0) ); +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/oceanGLSL.vert b/school/informatik/verkerhssimulation/media/materials/programs/oceanGLSL.vert new file mode 100644 index 00000000..f0f59497 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/oceanGLSL.vert @@ -0,0 +1,32 @@ +// oceanGLSL.vert +// vertex program for Ocean water simulation +// 05 Aug 2005 +// adapted for Ogre by nfz +// converted from HLSL to GLSL +// original shader source from Render Monkey 1.6 Reflections Refractions.rfx + +// 06 Aug 2005: moved uvw calculation from fragment program into vertex program + +uniform vec3 scale; +uniform vec3 eyePosition; +uniform vec2 waveSpeed; +uniform float noiseSpeed; +uniform float time_0_X; + +varying vec3 uvw; +varying vec3 normal; +varying vec3 vVec; + +void main(void) +{ + gl_Position = ftransform(); + + // the view vector needs to be in vertex space + vVec = gl_Vertex.xyz - eyePosition; + normal = gl_Normal; + // uvw is the calculated uvw coordinates based on vertex position + uvw = gl_Vertex.xyz * scale.xyz; + uvw.xz += waveSpeed * time_0_X; + uvw.y += uvw.z + noiseSpeed * time_0_X; + +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/oceanHLSL_Cg.frag b/school/informatik/verkerhssimulation/media/materials/programs/oceanHLSL_Cg.frag new file mode 100644 index 00000000..4994aec9 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/oceanHLSL_Cg.frag @@ -0,0 +1,44 @@ +// oceanHLSL_Cg.frag +// fragment program for Ocean water simulation +// 04 Aug 2005 +// adapted for Ogre by nfz +// original shader source from Render Monkey 1.6 Reflections Refractions.rfx +// can be used in both Cg and HLSL compilers + +// 06 Aug 2005: moved uvw calculation from fragment program into vertex program + +float4 main(float3 uvw: TEXCOORD0, float3 normal: TEXCOORD1, float3 vVec: TEXCOORD2, + uniform float fadeBias, + uniform float fadeExp, + uniform float4 waterColor, + uniform sampler Noise, + uniform sampler skyBox + +) : COLOR +{ + + float3 noisy = tex3D(Noise, uvw).xyz; + + // convert to Signed noise + float3 bump = 2 * noisy - 1; + bump.xz *= 0.15; + // Make sure the normal always points upwards + // note that Ogres y axis is vertical (RM Z axis is vertical) + bump.y = 0.8 * abs(bump.y) + 0.2; + // Offset the surface normal with the bump + bump = normalize(normal + bump); + + // Find the reflection vector + float3 normView = normalize(vVec); + float3 reflVec = reflect(normView, bump); + // Ogre has z flipped for cubemaps + reflVec.z = -reflVec.z; + float4 refl = texCUBE(skyBox, reflVec); + + // set up for fresnel calc + float lrp = 1 - dot(-normView, bump); + + // Interpolate between the water color and reflection for fresnel effect + return lerp(waterColor, refl, saturate(fadeBias + pow(lrp, fadeExp))); + +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/oceanHLSL_Cg.vert b/school/informatik/verkerhssimulation/media/materials/programs/oceanHLSL_Cg.vert new file mode 100644 index 00000000..a3f517ea --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/oceanHLSL_Cg.vert @@ -0,0 +1,41 @@ +// oceanHLSL_Cg.vert +// vertex program for Ocean water simulation +// 04 Aug 2005 +// adapted for Ogre by nfz +// original shader source from Render Monkey 1.6 Reflections Refractions.rfx +// can be used in both Cg and HLSL compilers + +// 06 Aug 2005: moved uvw calculation from fragment program into vertex program + +struct VS_OUTPUT { + float4 Pos: POSITION; + float3 uvw: TEXCOORD0; + float3 normal: TEXCOORD1; + float3 vVec: TEXCOORD2; +}; + +VS_OUTPUT main(float4 Pos: POSITION, float3 normal: NORMAL, + uniform float4x4 worldViewProj_matrix, + uniform float3 scale, + uniform float2 waveSpeed, + uniform float noiseSpeed, + uniform float time_0_X, + uniform float3 eyePosition + +) +{ + VS_OUTPUT Out; + + Out.Pos = mul(worldViewProj_matrix, Pos); + + // uvw is the calculated uvw coordinates based on vertex position + Out.uvw = Pos.xyz * scale; + Out.uvw.xz += waveSpeed * time_0_X; + Out.uvw.y += Out.uvw.z + noiseSpeed * time_0_X; + + // the view vector needs to be in vertex space + Out.vVec = Pos.xyz - eyePosition; + Out.normal = normal; + + return Out; +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/skinningTwoWeightsShadowCasterVp.glsl b/school/informatik/verkerhssimulation/media/materials/programs/skinningTwoWeightsShadowCasterVp.glsl new file mode 100644 index 00000000..0ae96e97 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/skinningTwoWeightsShadowCasterVp.glsl @@ -0,0 +1,40 @@ +// Example GLSL program for skinning with two bone weights per vertex + +attribute vec4 blendIndices; +attribute vec4 blendWeights; + +// 3x4 matrix, passed as vec4's for compatibility with GL 2.0 +// GL 2.0 supports 3x4 matrices +// Support 24 bones ie 24*3, but use 72 since our parser can pick that out for sizing +uniform vec4 worldMatrix3x4Array[72]; +uniform mat4 viewProjectionMatrix; +uniform vec4 ambient; + +void main() +{ + vec3 blendPos = vec3(0,0,0); + + for (int bone = 0; bone < 2; ++bone) + { + // perform matrix multiplication manually since no 3x4 matrices + // ATI GLSL compiler can't handle indexing an array within an array so calculate the inner index first + int idx = int(blendIndices[bone]) * 3; + // ATI GLSL compiler can't handle unrolling the loop so do it manually + // ATI GLSL has better performance when mat4 is used rather than using individual dot product + // There is a bug in ATI mat4 constructor (Cat 7.2) when indexed uniform array elements are used as vec4 parameter so manually assign + mat4 worldMatrix; + worldMatrix[0] = worldMatrix3x4Array[idx]; + worldMatrix[1] = worldMatrix3x4Array[idx + 1]; + worldMatrix[2] = worldMatrix3x4Array[idx + 2]; + worldMatrix[3] = vec4(0); + // now weight this into final + blendPos += (gl_Vertex * worldMatrix).xyz * blendWeights[bone]; + } + + // apply view / projection to position + gl_Position = viewProjectionMatrix * vec4(blendPos, 1); + + gl_FrontSecondaryColor = vec4(0,0,0,0); + gl_FrontColor = ambient; + gl_TexCoord[0] = gl_MultiTexCoord0; +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/skinningTwoWeightsVp.glsl b/school/informatik/verkerhssimulation/media/materials/programs/skinningTwoWeightsVp.glsl new file mode 100644 index 00000000..2c9ce818 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/skinningTwoWeightsVp.glsl @@ -0,0 +1,57 @@ +// Example GLSL program for skinning with two bone weights per vertex + +attribute vec4 blendIndices; +attribute vec4 blendWeights; + +// 3x4 matrix, passed as vec4's for compatibility with GL 2.0 +// GL 2.0 supports 3x4 matrices +// Support 24 bones ie 24*3, but use 72 since our parser can pick that out for sizing +uniform vec4 worldMatrix3x4Array[72]; +uniform mat4 viewProjectionMatrix; +uniform vec4 lightPos[2]; +uniform vec4 lightDiffuseColour[2]; + +void main() +{ + vec3 blendPos = vec3(0,0,0); + vec3 blendNorm = vec3(0,0,0); + + for (int bone = 0; bone < 2; ++bone) + { + // perform matrix multiplication manually since no 3x4 matrices + // ATI GLSL compiler can't handle indexing an array within an array so calculate the inner index first + int idx = int(blendIndices[bone]) * 3; + // ATI GLSL compiler can't handle unrolling the loop so do it manually + // ATI GLSL has better performance when mat4 is used rather than using individual dot product + // There is a bug in ATI mat4 constructor (Cat 7.2) when indexed uniform array elements are used as vec4 parameter so manually assign + mat4 worldMatrix; + worldMatrix[0] = worldMatrix3x4Array[idx]; + worldMatrix[1] = worldMatrix3x4Array[idx + 1]; + worldMatrix[2] = worldMatrix3x4Array[idx + 2]; + worldMatrix[3] = vec4(0); + // now weight this into final + float weight = blendWeights[bone]; + blendPos += (gl_Vertex * worldMatrix).xyz * weight; + + mat3 worldRotMatrix = mat3(worldMatrix[0].xyz, worldMatrix[1].xyz, worldMatrix[2].xyz); + blendNorm += (gl_Normal * worldRotMatrix) * weight; + + } + + // apply view / projection to position + gl_Position = viewProjectionMatrix * vec4(blendPos, 1); + + // simple vertex lighting model + vec3 lightDir0 = normalize( + lightPos[0].xyz - (blendPos.xyz * lightPos[0].w)); + vec3 lightDir1 = normalize( + lightPos[1].xyz - (blendPos.xyz * lightPos[1].w)); + + gl_FrontSecondaryColor = vec4(0); + gl_FrontColor = vec4(0.5, 0.5, 0.5, 1.0) + + clamp(dot(lightDir0, blendNorm), 0.0, 1.0) * lightDiffuseColour[0] + + clamp(dot(lightDir1, blendNorm), 0.0, 1.0) * lightDiffuseColour[1]; + + gl_TexCoord[0] = gl_MultiTexCoord0; + +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/varianceshadowcasterfp.cg b/school/informatik/verkerhssimulation/media/materials/programs/varianceshadowcasterfp.cg new file mode 100644 index 00000000..f39e8a05 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/varianceshadowcasterfp.cg @@ -0,0 +1,65 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// shadowcasterfp.cg +// +// Hamilton Chong +// (c) 2006 +// +// This is an example fragment shader for shadow caster objects. +// +///////////////////////////////////////////////////////////////////////////////// + + +// Define outputs from vertex shader. +struct VertexOut +{ + float4 position : POSITION; // can't rely on access to this + float4 pos : TEXCOORD0; // position of fragment (in homogeneous coordinates) + float4 normal : TEXCOORD1; // un-normalized normal in object space + float4 modelPos : TEXCOORD2; // coordinates of model in object space at this point +}; + +struct FragmentOut +{ + float4 color : COLOR0; +}; + +FragmentOut main( VertexOut In, // fragment to process + uniform float uDepthOffset, // offset amount (constant in eye space) + uniform float4x4 uProjection // projection matrix + ) +{ + FragmentOut Out; + + // compute the "normalized device coordinates" (no viewport applied yet) + float4 postproj = In.pos / In.pos.w; + + // get the normalized normal of the geometry seen at this point + float4 normal = normalize(In.normal); + + + // -- Computing Depth Bias Quantities ----------------------------- + + // We now compute the change in z that would signify a push in the z direction + // by 1 unit in eye space. Note that eye space z is related in a nonlinear way to + // screen space z, so this is not just a constant. + // ddepth below is how much screen space z at this point would change for that push. + // NOTE: computation of ddepth likely differs from OpenGL's glPolygonOffset "unit" + // computation, which is allowed to be vendor specific. + float4 dpwdz = mul(uProjection, float4(0.0, 0.0, 1.0, 0.0)); + float4 dpdz = (dpwdz - (postproj * dpwdz.w)) / In.pos.w; + float ddepth = abs(dpdz.z); + + // -- End depth bias helper section -------------------------------- + + // We now compute the depth of the fragment. This is the actual depth value plus + // our depth bias. The depth bias depends on how uncertain we are about the z value + // plus some constant push in the z direction. The exact coefficients to use are + // up to you, but at least it should be somewhat intuitive now what the tradeoffs are. + float depthval = postproj.z /* + (0.5 * dzlen)*/ + (uDepthOffset * ddepth); + depthval = (0.5 * depthval) + 0.5; // put into [0,1] range instead of [-1,1] + + + Out.color = float4(depthval, depthval * depthval, depthval, 0.0); + return Out; +} diff --git a/school/informatik/verkerhssimulation/media/materials/programs/varianceshadowcastervp.cg b/school/informatik/verkerhssimulation/media/materials/programs/varianceshadowcastervp.cg new file mode 100644 index 00000000..60d6de3a --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/varianceshadowcastervp.cg @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// shadowcastervp.cg +// +// Hamilton Chong +// (c) 2006 +// +// This is an example vertex shader for shadow caster objects. +// +///////////////////////////////////////////////////////////////////////////////// + + +// Define inputs from application. +struct VertexIn +{ + float4 position : POSITION; // vertex position in object space + float4 normal : NORMAL; // vertex normal in object space +}; + +// Define outputs from vertex shader. +struct VertexOut +{ + float4 position : POSITION; // post projection position coordinates + float4 pos : TEXCOORD0; // ditto. Not all hardware allows access values bound to POSITION in fp. + float4 normal : TEXCOORD1; // normal in object space (to be interpolated) + float4 modelPos : TEXCOORD2; // position in object space (to be interpolated) +}; + +VertexOut main( VertexIn In, // vertex to process + uniform float4x4 uModelViewProjection // model-view-projection matrix + ) +{ + VertexOut Out; // output data + + // Transform vertex position into post projective (homogenous screen) space. + Out.position = mul(uModelViewProjection, In.position); + Out.pos = mul(uModelViewProjection, In.position); + + // copy over data to interpolate using perspective correct interpolation + Out.normal = float4(In.normal.x, In.normal.y, In.normal.z, 0.0); + Out.modelPos = In.position; + + return Out; +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/media/materials/programs/varianceshadowreceiverfp.cg b/school/informatik/verkerhssimulation/media/materials/programs/varianceshadowreceiverfp.cg new file mode 100644 index 00000000..28a9aacf --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/varianceshadowreceiverfp.cg @@ -0,0 +1,107 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// shadowreceiverfp.cg +// +// Hamilton Chong +// (c) 2006 +// +// This is an example fragment shader for shadow receiver objects. +// +///////////////////////////////////////////////////////////////////////////////// + + +sampler2D ShadowMap : TEXUNIT0; + +// Define outputs from vertex shader. +struct Vertex +{ + float4 position : POSITION; // fragment position in post projective space + float4 shadowCoord : TEXCOORD0; // fragment position in shadow map coordinates + float diffuse : TEXCOORD1; // diffuse shading value +}; + +struct Fragment +{ + float4 color : COLOR0; +}; + +Fragment main(Vertex In, + uniform float uSTexWidth, + uniform float uSTexHeight) +{ + Fragment Out; + + // compute the shadow coordinates for texture lookup + // NOTE: texture_viewproj_matrix maps z into [0,1] range, not [-1,1], so + // have to make sure shadow caster stores depth values with same convention. + float4 scoord = In.shadowCoord / In.shadowCoord.w; + + + // -- Bilinear Filtering of Sample -------------------------------------------- + + // One could use scoord.xy to look up the shadow map for depth testing, but + // we'll be implementing a simple "percentage closest filtering" algorithm instead. + // This mimics the behavior of turning on bilinear filtering on NVIDIA hardware + // when also performing shadow comparisons. This causes bilinear filtering of + // depth tests. Note that this is NOT the same as bilinear filtering the depth + // values and then doing the depth comparison. The two operations are not + // commutative. PCF is explicitly about filtering the test values since + // testing filtered z values is often meaningless. + + // Real percentage closest filtering should sample from the entire footprint + // on the shadow map, not just seek the closest four sample points. Such + // an improvement is for future work. + + + // NOTE: Assuming OpenGL convention for texture lookups with integers in centers. + // DX convention is to have integers mark sample corners + float2 tcoord; + tcoord.x = (scoord.x * uSTexWidth) - 0.5; + tcoord.y = (scoord.y * uSTexHeight) - 0.5; + float x0 = floor(tcoord.x); + float x1 = ceil(tcoord.x); + float fracx = frac(tcoord.x); + float y0 = floor(tcoord.y); + float y1 = ceil(tcoord.y); + float fracy = frac(tcoord.y); + + // sample coordinates in [0,1]^2 domain + float2 t00, t01, t10, t11; + float invWidth = 1.0 / uSTexWidth; + float invHeight = 1.0 / uSTexHeight; + t00 = float2((x0+0.5) * invWidth, (y0+0.5) * invHeight); + t10 = float2((x1+0.5) * invWidth, (y0+0.5) * invHeight); + t01 = float2((x0+0.5) * invWidth, (y1+0.5) * invHeight); + t11 = float2((x1+0.5) * invWidth, (y1+0.5) * invHeight); + + // grab the samples + float2 z00 = tex2D(ShadowMap, t00).xy; + float2 z01 = tex2D(ShadowMap, t01).xy; + float2 z10 = tex2D(ShadowMap, t10).xy; + float2 z11 = tex2D(ShadowMap, t11).xy; + + // bilinear filter the sample data + float2 d0 = ((1.0 - fracx) * z00) + (fracx * z10); + float2 d1 = ((1.0 - fracx) * z01) + (fracx * z11); + float2 datum = ((1.0 - fracy) * d0) + (fracy * d1); + + // -- Variance Shadow Mapping --------------------------------------------------- + + float zVariance = datum.y - (datum.x * datum.x); + float zDeviation = scoord.z - datum.x; + zDeviation = (zDeviation < 0.0) ? 0.0 : zDeviation; + float visibility = zVariance / (zVariance + (zDeviation * zDeviation)); + float ztest = (scoord.z < datum.x) ? 1.0:0.0; // filtering depth ok, because used only for small variance + visibility = (zVariance > 0.0) ? visibility : ztest; // if variance too small, we get garbage + //0.0000001 + + // determine that all geometry within pixel border of shadow map (and outside) is lit + float filterBorder = max(invWidth, invHeight); + visibility = (all(abs(scoord.xy-0.5)<=0.5-filterBorder)) ? visibility : 1.0; + + // ------------------------------------------------------------------------------ + + visibility *= In.diffuse; + Out.color = float4(visibility, visibility, visibility, 0.0); + return Out; +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/media/materials/programs/varianceshadowreceivervp.cg b/school/informatik/verkerhssimulation/media/materials/programs/varianceshadowreceivervp.cg new file mode 100644 index 00000000..ff950405 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/programs/varianceshadowreceivervp.cg @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// shadowreceivervp.cg +// +// Hamilton Chong +// (c) 2006 +// +// This is an example vertex shader for shadow receiver objects. +// +///////////////////////////////////////////////////////////////////////////////// + +// Define inputs from application. +struct VertexIn +{ + float4 position : POSITION; // vertex position in object space + float4 normal : NORMAL; // vertex normal in object space +}; + +// Define outputs from vertex shader. +struct Vertex +{ + float4 position : POSITION; // vertex position in post projective space + float4 shadowCoord : TEXCOORD0; // vertex position in shadow map coordinates + float diffuse : TEXCOORD1; // diffuse shading value +}; + +Vertex main(VertexIn In, + uniform float4x4 uModelViewProjection, // model-view-projection matrix + uniform float4 uLightPosition, // light position in object space + uniform float4x4 uModel, // model matrix + uniform float4x4 uTextureViewProjection // shadow map's view projection matrix + ) +{ + Vertex Out; + + // compute diffuse shading + float3 lightDirection = normalize(uLightPosition.xyz - In.position.xyz); + Out.diffuse = dot(In.normal.xyz, lightDirection); + + // compute shadow map lookup coordinates + Out.shadowCoord = mul(uTextureViewProjection, mul(uModel, In.position)); + + // compute vertex's homogenous screen-space coordinates + Out.position = mul(uModelViewProjection, In.position); + + return Out; +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/BlackAndWhite.material b/school/informatik/verkerhssimulation/media/materials/scripts/BlackAndWhite.material new file mode 100644 index 00000000..a99670cf --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/BlackAndWhite.material @@ -0,0 +1,34 @@ +fragment_program Ogre/Compositor/B&W_FP cg +{ + source GrayScale.cg + entry_point GrayScale_ps + profiles ps_2_0 arbfp1 +} + +material Ogre/Compositor/BlackAndWhite +{ + technique + { + + pass + { + depth_check off + + vertex_program_ref Ogre/Compositor/StdQuad_Cg_vp + { + } + + fragment_program_ref Ogre/Compositor/B&W_FP + { + } + + texture_unit + { + texture RT + tex_coord_set 0 + tex_address_mode clamp + filtering linear linear linear + } + } + } +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/Bloom.material b/school/informatik/verkerhssimulation/media/materials/scripts/Bloom.material new file mode 100644 index 00000000..02da77c0 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/Bloom.material @@ -0,0 +1,178 @@ +//DirectX 9.0 HLSL Vertex Shader vs_1_1 +vertex_program Blur0_vs11 hlsl +{ + source Blur0_vs11.hlsl + target vs_1_1 + entry_point main +} + +//DirectX 9.0 HLSL Pixel Shader ps_2_0 +fragment_program Blur0_ps20 hlsl +{ + source Blur0_ps20.hlsl + target ps_2_0 + entry_point main +} + +//DirectX 9.0 HLSL Vertex Shader vs_1_1 +vertex_program Blur1_vs11 hlsl +{ + source Blur1_vs11.hlsl + target vs_1_1 + entry_point main +} + +//DirectX 9.0 HLSL Pixel Shader ps_2_0 +fragment_program Blur1_ps20 hlsl +{ + source Blur1_ps20.hlsl + target ps_2_0 + entry_point main +} + +vertex_program Blur0_vs_glsl glsl +{ + source Blur0_vs.glsl +} +vertex_program Blur1_vs_glsl glsl +{ + source Blur1_vs.glsl +} +fragment_program Blur_ps_glsl glsl +{ + source Blur_ps.glsl + default_params + { + param_named tex0 int 0 + } +} + +//Effect: Bloom +material Ogre/Compositor/Blur0 +{ + technique + { + //Rendering Pass: Blur0 (pass index: #1 ) + pass + { + //State: D3DRS_CULLMODE, Value : D3DCULL_NONE + cull_hardware none + cull_software none + depth_check off + + fragment_program_ref Blur0_ps20 + { + } + vertex_program_ref Blur0_vs11 + { + } + texture_unit RT + { + tex_coord_set 0 + tex_address_mode clamp + filtering linear linear linear + } + } + } + technique + { + //Rendering Pass: Blur0 (pass index: #1 ) + pass + { + cull_hardware none + cull_software none + depth_check off + + fragment_program_ref Blur_ps_glsl + { + } + vertex_program_ref Blur0_vs_glsl + { + } + texture_unit RT + { + tex_coord_set 0 + tex_address_mode clamp + filtering linear linear linear + } + } + } +} + +material Ogre/Compositor/Blur1 +{ + technique + { + + //Rendering Pass: Blur1 (pass index: #2 ) + pass + { + cull_hardware none + cull_software none + depth_check off + + fragment_program_ref Blur1_ps20 + { + } + vertex_program_ref Blur1_vs11 + { + } + texture_unit + { + tex_coord_set 0 + tex_address_mode clamp + filtering linear linear linear + } + } + } + technique + { + + //Rendering Pass: Blur1 (pass index: #2 ) + pass + { + cull_hardware none + cull_software none + depth_func always_pass + + fragment_program_ref Blur_ps_glsl + { + } + vertex_program_ref Blur1_vs_glsl + { + } + texture_unit + { + tex_coord_set 0 + tex_address_mode clamp + filtering linear linear linear + } + } + } +} + +/// Overlay quad +material Ogre/Compositor/BloomBlend +{ + technique + { + pass + { + lighting on + diffuse 0.0 0.0 0.0 0.6 + specular 0.0 0.0 0.0 0.0 + ambient 0.0 0.0 0.0 + emissive 1.0 1.0 1.0 + cull_hardware none + depth_check off + scene_blend alpha_blend + + texture_unit + { + tex_coord_set 0 + tex_address_mode clamp + filtering linear linear linear + } + } + } +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/DOF.material b/school/informatik/verkerhssimulation/media/materials/scripts/DOF.material new file mode 100644 index 00000000..8d62737d --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/DOF.material @@ -0,0 +1,94 @@ +fragment_program DOF_Blur_ps cg +{ + source DOF_ps.cg + entry_point blur + profiles ps_2_0 arbfp1 +} + +fragment_program DOF_Blend_ps cg +{ + source DOF_ps.cg + entry_point blend + profiles ps_2_0 arbfp1 +} + +//Effect: Depth of Field +material Ogre/Compositor/DOF_Blur0 +{ + technique + { + //Rendering Pass: Blur0 (pass index: #1 ) + pass + { + //State: D3DRS_CULLMODE, Value : D3DCULL_NONE + cull_hardware none + cull_software none + depth_check off + + fragment_program_ref DOF_Blur_ps + { + param_named sampleDistance float 0.1 + } + vertex_program_ref Ogre/Compositor/StdQuad_Tex2a_vp + { + } + texture_unit + { + // texture will get added at runtime + tex_coord_set 0 + tex_address_mode wrap + filtering trilinear + } + } + } +} + +// cheat here by copying from DOF_Blur0 +material Ogre/Compositor/DOF_Blur1 : Ogre/Compositor/DOF_Blur0 +{ + technique + { + //Rendering Pass: Blur0 (pass index: #1 ) + pass + { + // use the same pixel shader as DOF_Blur0 + fragment_program_ref + { + // override value from copied DOF_Blur0 material + param_named sampleDistance float 0.1 + } + } + } +} + +material Ogre/Compositor/DOF_Blend +{ + technique + { + pass + { + fragment_program_ref DOF_Blend_ps + { + param_named focus float 0.66 + param_named range float 1.0 + } + vertex_program_ref Ogre/Compositor/StdQuad_Tex2a_vp + { + } + texture_unit Blur0 + { + // texture will get added at runtime + tex_coord_set 0 + tex_address_mode clamp + filtering trilinear + } + texture_unit Blur1 + { + // texture will get added at runtime + tex_coord_set 0 + tex_address_mode clamp + filtering trilinear + } + } + } +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/DepthShadowmap.material b/school/informatik/verkerhssimulation/media/materials/scripts/DepthShadowmap.material new file mode 100644 index 00000000..024419f6 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/DepthShadowmap.material @@ -0,0 +1,595 @@ + +// ***-- Begin HLSL section --** + +vertex_program Ogre/DepthShadowmap/CasterVP_HLSL hlsl +{ + source DepthShadowmap.hlsl + entry_point casterVP + target vs_2_0 + + preprocessor_defines LINEAR_RANGE=0 + + default_params + { + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto texelOffsets texel_offsets + //param_named_auto depthRange scene_depth_range + } +} + + +fragment_program Ogre/DepthShadowmap/CasterFP_HLSL hlsl +{ + source DepthShadowmap.hlsl + entry_point casterFP + target ps_2_0 + + preprocessor_defines LINEAR_RANGE=0 + + default_params + { + } +} + + +vertex_program Ogre/DepthShadowmap/ReceiverVP_HLSL hlsl +{ + source DepthShadowmap.hlsl + entry_point receiverVP + target vs_2_0 + + preprocessor_defines LINEAR_RANGE=0 + + default_params + { + param_named_auto world world_matrix + param_named_auto worldIT inverse_transpose_world_matrix + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto texViewProj texture_viewproj_matrix + param_named_auto lightPosition light_position 0 + param_named_auto lightColour light_diffuse_colour 0 + //param_named_auto shadowDepthRange shadow_scene_depth_range 0 + } +} + + +fragment_program Ogre/DepthShadowmap/ReceiverFP_HLSL hlsl +{ + source DepthShadowmap.hlsl + entry_point receiverFP + target ps_2_0 + + preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=0 + + default_params + { + param_named inverseShadowmapSize float 0.0009765625 + param_named fixedDepthBias float 0.0005 + param_named gradientClamp float 0.0098 + param_named gradientScaleBias float 0 + //param_named shadowFuzzyWidth float 1 + } +} + +fragment_program Ogre/DepthShadowmap/ReceiverFPPCF_HLSL hlsl +{ + source DepthShadowmap.hlsl + entry_point receiverFP + target ps_2_0 + + preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=1 + + default_params + { + param_named inverseShadowmapSize float 0.0009765625 + param_named gradientClamp float 0.0098 + param_named gradientScaleBias float 0 + //param_named shadowFuzzyWidth float 1 + } +} +vertex_program Ogre/DepthShadowmap/NormalMapReceiverVP_HLSL hlsl +{ + source DepthShadowmap.hlsl + entry_point normalMapShadowReceiverVp + target vs_2_0 + + preprocessor_defines LINEAR_RANGE=0 + + default_params + { + param_named_auto world world_matrix + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto texViewProj texture_viewproj_matrix + param_named_auto lightPosition light_position_object_space 0 + //param_named_auto shadowDepthRange shadow_scene_depth_range 0 + } +} + +fragment_program Ogre/DepthShadowmap/NormalMapReceiverFP_HLSL hlsl +{ + source DepthShadowmap.hlsl + entry_point normalMapShadowReceiverFp + target ps_2_0 + + preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=0 + + default_params + { + param_named_auto lightColour light_diffuse_colour 0 + param_named inverseShadowmapSize float 0.0009765625 + param_named fixedDepthBias float 0.0005 + param_named gradientClamp float 0.0098 + param_named gradientScaleBias float 0 + //param_named shadowFuzzyWidth float 1 + } +} +fragment_program Ogre/DepthShadowmap/NormalMapReceiverFPPCF_HLSL hlsl +{ + source DepthShadowmap.hlsl + entry_point normalMapShadowReceiverFp + target ps_2_0 + + preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=1 + + default_params + { + param_named_auto lightColour light_diffuse_colour 0 + param_named inverseShadowmapSize float 0.0009765625 + param_named fixedDepthBias float 0.0005 + param_named gradientClamp float 0.0098 + param_named gradientScaleBias float 0 + //param_named shadowFuzzyWidth float 1 + } +} + + + +// **-- End HLSL Section --** + +// **-- Begin GLSL Section --** +vertex_program Ogre/DepthShadowmap/CasterVP_GLSL glsl +{ + source DepthShadowmapCasterVp.glsl + + preprocessor_defines LINEAR_RANGE=0 + + default_params + { + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto texelOffsets texel_offsets + //param_named_auto depthRange scene_depth_range + } +} + + +fragment_program Ogre/DepthShadowmap/CasterFP_GLSL glsl +{ + source DepthShadowmapCasterFp.glsl + + preprocessor_defines LINEAR_RANGE=0 + + default_params + { + } +} + + +vertex_program Ogre/DepthShadowmap/ReceiverVP_GLSL glsl +{ + source DepthShadowmapReceiverVp.glsl + + preprocessor_defines LINEAR_RANGE=0 + + default_params + { + param_named_auto world world_matrix + param_named_auto worldIT inverse_transpose_world_matrix + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto texViewProj texture_viewproj_matrix + param_named_auto lightPosition light_position 0 + param_named_auto lightColour light_diffuse_colour 0 + //param_named_auto shadowDepthRange shadow_scene_depth_range 0 + } +} + + +fragment_program Ogre/DepthShadowmap/ReceiverFP_GLSL glsl +{ + source DepthShadowmapReceiverFp.glsl + + preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=0 + + default_params + { + param_named shadowMap int 0 + param_named inverseShadowmapSize float 0.0009765625 + param_named fixedDepthBias float 0.0005 + param_named gradientClamp float 0.0098 + param_named gradientScaleBias float 0 + //param_named shadowFuzzyWidth float 1 + } +} + +fragment_program Ogre/DepthShadowmap/ReceiverFPPCF_GLSL glsl +{ + source DepthShadowmapReceiverFp.glsl + + preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=1 + + default_params + { + param_named inverseShadowmapSize float 0.0009765625 + param_named gradientClamp float 0.0098 + param_named gradientScaleBias float 0 + //param_named shadowFuzzyWidth float 1 + } +} +vertex_program Ogre/DepthShadowmap/NormalMapReceiverVP_GLSL glsl +{ + source DepthShadowmapNormalMapReceiverVp.glsl + + preprocessor_defines LINEAR_RANGE=0 + + default_params + { + param_named_auto world world_matrix + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto texViewProj texture_viewproj_matrix + param_named_auto lightPosition light_position_object_space 0 + //param_named_auto shadowDepthRange shadow_scene_depth_range 0 + } +} + +fragment_program Ogre/DepthShadowmap/NormalMapReceiverFP_GLSL glsl +{ + source DepthShadowmapNormalMapReceiverFp.glsl + + preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=0 + + default_params + { + param_named_auto lightColour light_diffuse_colour 0 + param_named inverseShadowmapSize float 0.0009765625 + param_named fixedDepthBias float 0.0005 + param_named gradientClamp float 0.0098 + param_named gradientScaleBias float 0 + //param_named shadowFuzzyWidth float 1 + + param_named shadowMap int 0 + param_named normalMap int 1 + } +} +fragment_program Ogre/DepthShadowmap/NormalMapReceiverFPPCF_GLSL glsl +{ + source DepthShadowmapNormalMapReceiverFp.glsl + + preprocessor_defines LINEAR_RANGE=0,FUZZY_TEST=0,PCF=1 + + default_params + { + param_named_auto lightColour light_diffuse_colour 0 + param_named inverseShadowmapSize float 0.0009765625 + param_named fixedDepthBias float 0.0005 + param_named gradientClamp float 0.0098 + param_named gradientScaleBias float 0 + //param_named shadowFuzzyWidth float 1 + + param_named shadowMap int 0 + param_named normalMap int 1 + } +} + +// **-- End GLSL Section --** + +// **-- Begin Unified Section --** +vertex_program Ogre/DepthShadowmap/CasterVP unified +{ + delegate Ogre/DepthShadowmap/CasterVP_GLSL + delegate Ogre/DepthShadowmap/CasterVP_HLSL +} +fragment_program Ogre/DepthShadowmap/CasterFP unified +{ + delegate Ogre/DepthShadowmap/CasterFP_GLSL + delegate Ogre/DepthShadowmap/CasterFP_HLSL +} +vertex_program Ogre/DepthShadowmap/ReceiverVP unified +{ + delegate Ogre/DepthShadowmap/ReceiverVP_GLSL + delegate Ogre/DepthShadowmap/ReceiverVP_HLSL +} +fragment_program Ogre/DepthShadowmap/ReceiverFP unified +{ + delegate Ogre/DepthShadowmap/ReceiverFP_GLSL + delegate Ogre/DepthShadowmap/ReceiverFP_HLSL +} +fragment_program Ogre/DepthShadowmap/ReceiverFPPCF unified +{ + delegate Ogre/DepthShadowmap/ReceiverFPPCF_GLSL + delegate Ogre/DepthShadowmap/ReceiverFPPCF_HLSL +} +vertex_program Ogre/DepthShadowmap/NormalMapReceiverVP unified +{ + delegate Ogre/DepthShadowmap/NormalMapReceiverVP_HLSL + delegate Ogre/DepthShadowmap/NormalMapReceiverVP_GLSL +} +vertex_program Ogre/DepthShadowmap/NormalMapReceiverFP unified +{ + delegate Ogre/DepthShadowmap/NormalMapReceiverFP_HLSL + delegate Ogre/DepthShadowmap/NormalMapReceiverFP_GLSL +} +vertex_program Ogre/DepthShadowmap/NormalMapReceiverFPPCF unified +{ + delegate Ogre/DepthShadowmap/NormalMapReceiverFPPCF_HLSL + delegate Ogre/DepthShadowmap/NormalMapReceiverFPPCF_GLSL +} + +// **-- End Unified Section --** + + + +// Generic Shadow caster material (floating point shadowmap) +material Ogre/DepthShadowmap/Caster/Float +{ + technique + { + pass + { + vertex_program_ref Ogre/DepthShadowmap/CasterVP + { + } + fragment_program_ref Ogre/DepthShadowmap/CasterFP + { + } + } + } +} + +// Generic Shadow receiver material (floating point shadowmap) +material Ogre/DepthShadowmap/Receiver/Float +{ + technique + { + pass + { + vertex_program_ref Ogre/DepthShadowmap/ReceiverVP + { + } + fragment_program_ref Ogre/DepthShadowmap/ReceiverFP + { + } + texture_unit ShadowMap + { + tex_address_mode clamp + filtering none + } + } + } +} + + +// Specific receiver material for rockwall +material Ogre/DepthShadowmap/Receiver/RockWall +{ + + // This is the preferred technique which uses both vertex and + // fragment programs, supports coloured lights + technique + { + // Base ambient pass + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 1 1 1 + diffuse 0 0 0 + specular 0 0 0 0 + // Really basic vertex program + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTextureUnified + { + } + + } + // Now do the lighting pass + // NB we don't do decal texture here because this is repeated per light + pass lighting + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 0 0 0 + + // do this for each light + iteration once_per_light + + + scene_blend add + + // Vertex program reference + vertex_program_ref Ogre/DepthShadowmap/ReceiverVP + { + } + shadow_receiver_vertex_program_ref Ogre/DepthShadowmap/ReceiverVP + { + } + + // Fragment program + fragment_program_ref Ogre/DepthShadowmap/ReceiverFP + { + } + shadow_receiver_fragment_program_ref Ogre/DepthShadowmap/ReceiverFP + { + } + + // shadowmap texture will be bound by code + + } + + // Decal pass + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + lighting off + // Really basic vertex program + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTextureUnified + { + param_named ambient float4 1 1 1 1 + } + scene_blend dest_colour zero + + + texture_unit + { + texture rockwall.tga + } + + } + } + + +} + +// Specific receiver material for Athene +material Ogre/DepthShadowmap/Receiver/Athene +{ + + // This is the preferred technique which uses both vertex and + // fragment programs, supports coloured lights + technique + { + // Base ambient pass + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 1 1 1 + diffuse 0 0 0 + specular 0 0 0 0 + // Really basic vertex program + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTextureUnified + { + } + + } + // Now do the lighting pass + // NB we don't do decal texture here because this is repeated per light + pass lighting + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 0 0 0 + + // do this for each light + iteration once_per_light + + + scene_blend add + + // Vertex program reference + vertex_program_ref Ogre/DepthShadowmap/NormalMapReceiverVP + { + } + shadow_receiver_vertex_program_ref Ogre/DepthShadowmap/NormalMapReceiverVP + { + } + + // Fragment program + fragment_program_ref Ogre/DepthShadowmap/NormalMapReceiverFP + { + } + shadow_receiver_fragment_program_ref Ogre/DepthShadowmap/NormalMapReceiverFP + { + } + + // shadowmap texture will be bound by code + + // Base bump map + texture_unit + { + texture atheneNormalMap.png + colour_op replace + } + // Normalisation cube map + texture_unit + { + cubic_texture nm.png combinedUVW + tex_coord_set 1 + tex_address_mode clamp + } + + } + + // Decal pass + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + lighting off + // Really basic vertex program + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTextureUnified + { + param_named ambient float4 1 1 1 1 + } + scene_blend dest_colour zero + + + texture_unit + { + texture egyptrockyfull.jpg + } + + } + } + + +} + + + +// Specialisation to use PCF +material Ogre/DepthShadowmap/Receiver/Float/PCF : Ogre/DepthShadowmap/Receiver/Float +{ + technique + { + pass + { + // override just receiver program + fragment_program_ref Ogre/DepthShadowmap/ReceiverFPPCF + { + } + + } + } +} + +// Specialisation to use PCF +material Ogre/DepthShadowmap/Receiver/RockWall/PCF : Ogre/DepthShadowmap/Receiver/RockWall +{ + technique + { + pass lighting + { + // override just receiver program + shadow_receiver_fragment_program_ref Ogre/DepthShadowmap/ReceiverFPPCF + { + } + + } + } +} +// Specialisation to use PCF +material Ogre/DepthShadowmap/Receiver/Athene/PCF : Ogre/DepthShadowmap/Receiver/Athene +{ + technique + { + pass lighting + { + // override just receiver program + shadow_receiver_fragment_program_ref Ogre/DepthShadowmap/NormalMapReceiverFPPCF + { + } + + } + } +} + + diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/Embossed.material b/school/informatik/verkerhssimulation/media/materials/scripts/Embossed.material new file mode 100644 index 00000000..0e62fa4f --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/Embossed.material @@ -0,0 +1,33 @@ +fragment_program Ogre/Compositor/Embossed_FP cg +{ + source GrayScale.cg + entry_point Embossed_ps + profiles ps_2_0 arbfp1 +} + +material Ogre/Compositor/Embossed +{ + technique + { + + pass + { + depth_check off + + vertex_program_ref Ogre/Compositor/StdQuad_Cg_vp + { + } + + fragment_program_ref Ogre/Compositor/Embossed_FP + { + } + + texture_unit RT + { + tex_coord_set 0 + tex_address_mode clamp + filtering linear linear linear + } + } + } +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/Example-DynTex.material b/school/informatik/verkerhssimulation/media/materials/scripts/Example-DynTex.material new file mode 100644 index 00000000..e1d51c7a --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/Example-DynTex.material @@ -0,0 +1,86 @@ + +material Examples/DynaTest +{ + technique + { + pass + { + texture_unit + { + texture DynaTex 2d + } + depth_write off + scene_blend alpha_blend + lighting off + } + } +} + + +material Examples/DynaTest2 +{ + technique + { + pass + { + texture_unit + { + texture DynaTex 2d + } + diffuse 0.8 0.8 0.8 + specular 0.7 0.7 0.7 40.0 + ambient 0.5 0.5 0.5 + } + } +} + +material Examples/DynaTest3 +{ + technique + { + pass + { + texture_unit + { + texture DynaTex 2d + } + diffuse 0.2 0.8 0.8 + specular 0.4 0.7 0.7 30.0 + ambient 0.2 0.5 1.0 + depth_write off + scene_blend alpha_blend + } + } +} + +material Examples/DynaTest4 +{ + technique + { + pass + { + texture_unit + { + texture DynaTex 2d + } + diffuse 0.8 0.8 0.8 + specular 0.7 0.7 0.4 20.0 + ambient 1.0 0.5 0.2 + } + } +} + +material Examples/VTDarkStuff +{ + technique + { + pass + { + diffuse 0.0 0.0 0.0 + ambient 0.1 0.1 0.15 + cull_hardware none + lighting on + } + + } +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/Example-Water.material b/school/informatik/verkerhssimulation/media/materials/scripts/Example-Water.material new file mode 100644 index 00000000..431eec5d --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/Example-Water.material @@ -0,0 +1,183 @@ + +material Examples/Water0 +{ + technique + { + pass + { + scene_blend colour_blend + depth_write off + + texture_unit + { + texture Water01.jpg + env_map spherical + scroll_anim 0.01 0.01 + } + } + } +} +material Examples/Water1 +{ + technique + { + pass + { + scene_blend colour_blend + depth_write off + + texture_unit + { + texture BeachStones.jpg + scale 0.25 0.25 + } + + texture_unit + { + texture Water01.jpg + env_map spherical + scroll_anim 0.01 0.01 + } + } + } +} +material Examples/Water2 +{ + technique + { + pass + { + scene_blend colour_blend + depth_write off + + texture_unit + { + texture Water01.jpg + scroll_anim 0.01 0.01 + } + } + } +} +material Examples/Water3 +{ + technique + { + pass + { + scene_blend colour_blend + depth_write off + + texture_unit + { + texture Water02.jpg + env_map spherical + scroll_anim 0.01 0.01 + rotate_anim 0.03 + } + } + } +} +material Examples/Water4 +{ + technique + { + pass + { + cull_hardware none + cull_software none + + texture_unit + { + texture Water02.jpg + env_map spherical + scroll_anim 0.01 0.01 + } + } + } +} +material Examples/Water5 +{ + technique + { + pass + { + cull_hardware none + cull_software none + + texture_unit + { + texture BeachStones.jpg + scale 0.25 0.25 + } + + texture_unit + { + texture Water01.jpg + env_map spherical + scroll_anim 0.01 0.01 + } + } + } +} +material Examples/Water6 +{ + technique + { + pass + { + lighting off + + texture_unit + { + cubic_texture cubescene.jpg combinedUVW + tex_address_mode clamp + env_map cubic_reflection + } + } + } +} +material Examples/Water7 +{ + technique + { + pass + { + cull_hardware none + cull_software none + + texture_unit + { + texture BeachStones.jpg + scale 0.25 0.25 + } + + texture_unit + { + cubic_texture cubescene.jpg combinedUVW + tex_address_mode clamp + env_map cubic_reflection + } + } + } +} +material Examples/Water8 +{ + technique + { + pass + { + lighting off + scene_blend add + depth_write off + cull_hardware none + cull_software none + + texture_unit + { + cubic_texture cubescene.jpg combinedUVW + tex_address_mode clamp + env_map cubic_reflection + } + } + } +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/Example.material b/school/informatik/verkerhssimulation/media/materials/scripts/Example.material new file mode 100644 index 00000000..6faa2d3b --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/Example.material @@ -0,0 +1,1044 @@ + +material Examples/EnvMappedRustySteel +{ + technique + { + pass + { + + texture_unit + { + texture RustySteel.jpg + } + + texture_unit + { + texture spheremap.png + colour_op_ex add src_texture src_current + colour_op_multipass_fallback one one + env_map spherical + } + } + } +} +material Examples/OgreLogo +{ + technique + { + pass + { + ambient 0.8 0.8 0.8 + + texture_unit + { + texture ogrelogo.png + } + } + } +} +material Examples/DarkMaterial +{ + technique + { + pass + { + ambient 0.1 0.1 0.1 + + texture_unit + { + texture BeachStones.jpg + } + } + } +} +material Examples/SpaceSkyBox +{ + technique + { + pass + { + lighting off + depth_write off + + texture_unit + { + cubic_texture stevecube.jpg separateUV + tex_address_mode clamp + } + } + } +} +material Examples/SceneSkyBox1 +{ + technique + { + pass + { + lighting off + depth_write off + + texture_unit + { + cubic_texture cubemap_fr.jpg cubemap_bk.jpg cubemap_lf.jpg cubemap_rt.jpg cubemap_up.jpg cubemap_dn.jpg separateUV + tex_address_mode clamp + } + } + } +} +material Examples/SceneCubeMap1 +{ + technique + { + pass + { + lighting off + + texture_unit + { + cubic_texture cubemap.jpg combinedUVW + tex_address_mode clamp + env_map cubic_reflection + } + } + } +} +material Examples/SceneSkyBox2 +{ + technique + { + pass + { + lighting off + depth_write off + + texture_unit + { + cubic_texture cubescene_fr.jpg cubescene_bk.jpg cubescene_lf.jpg cubescene_rt.jpg cubescene_up.jpg cubescene_dn.jpg separateUV + tex_address_mode clamp + } + } + } +} +material Examples/SceneCubeMap2 +{ + technique + { + pass + { + lighting off + + texture_unit + { + cubic_texture cubescene.jpg combinedUVW + tex_address_mode clamp + env_map cubic_reflection + } + } + } +} + +material Examples/CloudyNoonSkyBox +{ + technique + { + pass + { + lighting off + depth_write off + + texture_unit + { + cubic_texture cloudy_noon.jpg separateUV + tex_address_mode clamp + } + } + } +} + +material Examples/StormySkyBox +{ + technique + { + pass + { + lighting off + depth_write off + + texture_unit + { + cubic_texture stormy.jpg separateUV + tex_address_mode clamp + } + } + } +} + + +fragment_program Examples/MorningSkyBoxHDRfp cg +{ + source hdr.cg + entry_point morningskybox_fp + profiles ps_2_0 arbfp1 + +} +material Examples/MorningSkyBox +{ + technique + { + pass + { + lighting off + depth_write off + + texture_unit + { + cubic_texture morning.jpg separateUV + tex_address_mode clamp + } + } + } + + // HDR technique (fake) + technique + { + scheme HDR + + pass + { + lighting off + depth_write off + + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture + { + param_named_auto worldViewProj worldviewproj_matrix + param_named ambient float4 1 1 1 1 + } + fragment_program_ref Examples/MorningSkyBoxHDRfp + { + } + + texture_unit + { + cubic_texture morning.jpg separateUV + tex_address_mode clamp + } + } + } +} +fragment_program Examples/MorningCubeMapHDRfp cg +{ + source hdr.cg + entry_point morningcubemap_fp + profiles ps_2_0 arbfp1 + +} +material Examples/MorningCubeMap +{ + technique + { + pass + { + lighting off + + texture_unit + { + cubic_texture morning.jpg combinedUVW + tex_address_mode clamp + env_map cubic_reflection + } + } + } + // HDR technique (fake) + technique + { + scheme HDR + + pass + { + lighting off + + fragment_program_ref Examples/MorningCubeMapHDRfp + { + } + texture_unit + { + cubic_texture morning.jpg combinedUVW + tex_address_mode clamp + env_map cubic_reflection + } + } + } +} + + +material Examples/EveningSkyBox +{ + technique + { + pass + { + lighting off + depth_write off + + texture_unit + { + cubic_texture evening.jpg separateUV + tex_address_mode clamp + } + } + } +} + +material Examples/CloudySky +{ + technique + { + pass + { + lighting off + depth_write off + + texture_unit + { + texture clouds.jpg + scroll_anim 0.05 0 + } + } + } +} +material Examples/RustySteel +{ + technique + { + pass + { + + texture_unit + { + texture RustySteel.jpg + } + } + } +} +material Examples/Chrome +{ + technique + { + pass + { + + texture_unit + { + texture Chrome.jpg + env_map spherical + } + } + } +} +material Examples/SpaceSkyPlane +{ + technique + { + pass + { + lighting off + depth_write off + fog_override true none + + texture_unit + { + texture spacesky.jpg + } + } + } +} +material Examples/TextureEffect1 +{ + technique + { + pass + { + ambient 0.75 0.75 0.75 + cull_hardware none + cull_software none + + texture_unit + { + texture BumpyMetal.jpg + rotate_anim 0.2 + wave_xform scale_x sine 1 0.1 0 5 + wave_xform scale_y sine 0.5 0.2 0.5 3 + } + } + } +} +material Examples/TextureEffect2 +{ + technique + { + pass + { + + texture_unit + { + texture Water02.jpg + scroll_anim 0.5 0 + } + } + } +} +material Examples/TextureEffect3 +{ + technique + { + pass + { + ambient 0.7 0.7 0.7 + cull_hardware none + cull_software none + + texture_unit + { + texture Water01.jpg + scroll_anim -0.25 0.1 + } + + texture_unit + { + texture Water01.jpg + colour_op_ex add src_texture src_current + colour_op_multipass_fallback one one + scroll_anim -0.1 0.25 + } + } + } +} +material Examples/TextureEffect4 +{ + technique + { + pass + { + ambient 0.3 0.3 0.3 + scene_blend colour_blend + cull_hardware none + cull_software none + + texture_unit + { + texture Water02.jpg + scroll_anim 0.01 0.01 + } + } + } +} +material Examples/BumpyMetal +{ + technique + { + pass + { + ambient 0.75 0.75 0.75 + cull_hardware none + cull_software none + + texture_unit + { + texture BumpyMetal.jpg + } + } + } +} +material Examples/TransparentTest +{ + technique + { + pass + { + ambient 0.2 0.2 0.2 + scene_blend add + depth_write off + + texture_unit + { + texture Water01.jpg + scroll_anim 0.25 0 + } + + texture_unit + { + texture Water01.jpg + wave_xform scroll_y sine 0 0.1 0 0.5 + } + } + } +} +material Examples/Flare +{ + technique + { + pass + { + lighting off + scene_blend add + depth_write off + + texture_unit + { + texture flare.png + } + } + } +} +material Examples/Flare2 +{ + technique + { + pass + { + lighting off + scene_blend add + depth_write off + + texture_unit + { + texture flaretrail.png + } + } + } +} +material Examples/FlarePointSprite +{ + technique + { + pass + { + lighting off + scene_blend add + depth_write off + + point_sprites on + point_size 2 + point_size_attenuation on + + texture_unit + { + texture flare.png + } + } + } +} + +material Examples/Droplet +{ + technique + { + pass + { + scene_blend colour_blend + depth_write off + + texture_unit + { + texture basic_droplet.png + } + } + } +} +material Examples/Hilite/Yellow +{ + technique + { + pass + { + + texture_unit + { + texture dkyellow.png + } + } + } +} +material Examples/Rocky +{ + technique + { + pass + { + ambient 0.2 0.2 0.2 + + texture_unit + { + texture egyptrockyfull.jpg + } + } + } +} +material Examples/10PointBlock +{ + technique + { + pass + { + + texture_unit + { + texture 10points.png + } + } + } +} +material Material__25 +{ + technique + { + pass + { + + texture_unit + { + texture texmap2.jpg + } + } + } +} +material 2 - Default +{ + technique + { + pass + { + + texture_unit + { + texture MtlPlat2.jpg + } + } + } +} +material Material #8 +{ + technique + { + pass + { + + texture_unit + { + texture BODY.jpg + } + } + } +} +material Material #3 +{ + technique + { + pass + { + + texture_unit + { + texture HEAD4.jpg + } + } + } +} +material Material #9 +{ + technique + { + pass + { + + texture_unit + { + texture LEGS.jpg + } + } + } +} + +material Examples/Fish +{ + technique + { + pass + { + texture_unit + { + texture steelhead.png + } + } + } +} +material Examples/Ninja +{ + technique + { + pass + { + + texture_unit + { + texture nskingr.jpg + } + } + } +} + +material Examples/Robot +{ + // Hardware skinning techniique + technique + { + pass + { + vertex_program_ref Ogre/HardwareSkinningOneWeight + { + param_named_auto worldMatrix3x4Array world_matrix_array_3x4 + param_named_auto viewProjectionMatrix viewproj_matrix + param_named_auto lightPos[0] light_position 0 + param_named_auto lightPos[1] light_position 1 + param_named_auto lightDiffuseColour[0] light_diffuse_colour 0 + param_named_auto lightDiffuseColour[1] light_diffuse_colour 1 + param_named_auto ambient ambient_light_colour + + } + // alternate shadow caster program + shadow_caster_vertex_program_ref Ogre/HardwareSkinningOneWeightShadowCaster + { + param_named_auto worldMatrix3x4Array world_matrix_array_3x4 + param_named_auto viewProjectionMatrix viewproj_matrix + param_named_auto ambient ambient_light_colour + + } + + texture_unit + { + texture r2skin.jpg + } + } + } + + // Software blending technique + technique + { + pass + { + + texture_unit + { + texture r2skin.jpg + } + } + } +} + +material Examples/GrassFloor +{ + technique + { + pass + { + texture_unit + { + texture grass_1024.jpg + } + } + } +} + +vertex_program Examples/GrassWaverVp cg +{ + source Grass.cg + entry_point grass_vp + profiles vs_1_1 arbvp1 +} + +material Examples/GrassBlades +{ + // Vertex program waving grass + technique + { + pass + { + vertex_program_ref Examples/GrassWaverVp + { + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto ambient ambient_light_colour + param_named_auto objSpaceLight light_position_object_space 0 + param_named_auto lightColour light_diffuse_colour 0 + param_named_auto offset custom 999 + } + alpha_rejection greater 150 + scene_blend alpha_blend + cull_hardware none + cull_software none + texture_unit + { + texture gras_02.png + } + } + } + + // Non-vertex program technique (no waving) + technique + { + pass + { + alpha_rejection greater 150 + scene_blend alpha_blend + cull_hardware none + cull_software none + texture_unit + { + texture gras_02.png + } + } + } +} + +material Examples/Rockwall +{ + technique + { + pass + { + texture_unit + { + texture rockwall.tga + } + } + } +} + +material Examples/Aureola +{ + technique + { + pass + { + lighting off + scene_blend alpha_blend + depth_write off + cull_hardware none + + texture_unit + { + texture aureola.png PF_BYTE_LA + tex_address_mode clamp + } + } + } +} + +// Test hardware morph animation +material Examples/HardwareMorphAnimation +{ + technique + { + pass + { + + vertex_program_ref Ogre/HardwareMorphAnimation + { + // all default + } + + texture_unit + { + tex_coord_set 0 + colour_op_ex source1 src_current src_current + } + // need to define these texture units otherwise GL won't use the uv sets + texture_unit + { + tex_coord_set 1 + // also need to set blending to ignore texture which is GL warning texture + colour_op_ex source1 src_current src_current + } + texture_unit + { + tex_coord_set 2 + colour_op_ex source1 src_current src_current + } + + } + } +} + +// Test hardware pose animation +material Examples/HardwarePoseAnimation +{ + technique + { + pass + { + + vertex_program_ref Ogre/HardwarePoseAnimation + { + // all default + } + texture_unit + { + tex_coord_set 0 + colour_op_ex source1 src_current src_current + } + // need to define these texture units otherwise GL won't use the uv sets + texture_unit + { + tex_coord_set 1 + // also need to set blending to ignore texture which is GL warning texture + colour_op_ex source1 src_current src_current + } + texture_unit + { + tex_coord_set 2 + colour_op_ex source1 src_current src_current + } + + + } + } +} + +material RustyBarrel +{ + technique + { + pass + { + ambient 0.5 0.5 0.5 1.0 + diffuse 1.0 1.0 1.0 1.0 + specular 0.0 0.0 0.0 1.0 12.5 + emissive 0.0 0.0 0.0 1.0 + texture_unit + { + texture RustyBarrel.png + filtering trilinear + } + } + } +} + +material WoodPallet +{ + receive_shadows on + technique + { + pass + { + ambient 0.5 0.5 0.5 1.0 + diffuse 1.0 1.0 1.0 1.0 + specular 0.0 0.0 0.0 1.0 12.5 + + texture_unit + { + texture WoodPallet.png + filtering trilinear + } + } + } +} + +material Examples/LightRibbonTrail +{ + technique + { + pass + { + lighting off + scene_blend add + depth_write off + + texture_unit + { + texture ribbonband.png 1d + tex_address_mode clamp + filtering none + } + } + } +} + +material Examples/TudorHouse +{ + technique + { + pass + { + texture_unit + { + texture fw12b.jpg + tex_address_mode clamp + } + } + } +} + +material jaiqua +{ + // Hardware skinning techniique + technique + { + pass + { + vertex_program_ref Ogre/HardwareSkinningTwoWeights + { + + } + // alternate shadow caster program + shadow_caster_vertex_program_ref Ogre/HardwareSkinningTwoWeightsShadowCaster + { + param_named_auto worldMatrix3x4Array world_matrix_array_3x4 + param_named_auto viewProjectionMatrix viewproj_matrix + param_named_auto ambient ambient_light_colour + + } + + texture_unit + { + texture blue_jaiqua.jpg + tex_address_mode clamp + } + } + } + + // Software blending technique + technique + { + pass + { + texture_unit + { + texture blue_jaiqua.jpg + tex_address_mode clamp + } + } + } + +} + + +material Examples/Plane/IntegratedShadows +{ + technique + { + pass + { + // Single-pass shadowing + texture_unit + { + texture MtlPlat2.jpg + } + texture_unit + { + // standard modulation blend + content_type shadow + tex_address_mode clamp + } + } + } + +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/Examples-Advanced.material b/school/informatik/verkerhssimulation/media/materials/scripts/Examples-Advanced.material new file mode 100644 index 00000000..afde7e63 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/Examples-Advanced.material @@ -0,0 +1,1167 @@ +// ------------------------------- +// Cel Shading Section +// ------------------------------- +vertex_program Ogre/CelShadingVP cg +{ + source Example_CelShading.cg + entry_point main_vp + profiles vs_1_1 arbvp1 + + default_params + { + param_named_auto lightPosition light_position_object_space 0 + param_named_auto eyePosition camera_position_object_space + param_named_auto worldViewProj worldviewproj_matrix + param_named shininess float 10 + } +} + +fragment_program Ogre/CelShadingFP cg +{ + source Example_CelShading.cg + entry_point main_fp + profiles ps_1_1 arbfp1 fp20 +} + + +material Examples/CelShading +{ + technique + { + pass + { + vertex_program_ref Ogre/CelShadingVP + { + // map shininess from custom renderable param 1 + param_named_auto shininess custom 1 + } + fragment_program_ref Ogre/CelShadingFP + { + // map diffuse from custom renderable param 2 + param_named_auto diffuse custom 2 + // map specular from custom renderable param 2 + param_named_auto specular custom 3 + } + texture_unit + { + texture cel_shading_diffuse.png 1d + tex_address_mode clamp + filtering none + } + texture_unit + { + texture cel_shading_specular.png 1d + tex_address_mode clamp + filtering none + tex_coord_set 1 + } + texture_unit + { + texture cel_shading_edge.png 1d + tex_address_mode clamp + filtering none + tex_coord_set 2 + } + } + } + +} + + + +//------------------------ +// Bump mapping section +//------------------------ + +// Bump map vertex program, support for this is required +vertex_program Examples/BumpMapVP cg +{ + source Example_BumpMapping.cg + entry_point main_vp + profiles vs_1_1 arbvp1 +} + +// Bump map fragment program, support for this is optional +fragment_program Examples/BumpMapFP cg +{ + source Example_BumpMapping.cg + entry_point main_fp + profiles ps_1_1 arbfp1 fp20 +} + +// Bump map vertex program shadow receiver +vertex_program Examples/BumpMapVPShadowRcv cg +{ + source Example_BumpMapping.cg + entry_point main_shadowreceiver_vp + profiles vs_1_1 arbvp1 +} +// Bump map fragment program shadow receiver, support for this is optional +fragment_program Examples/BumpMapFPShadowRcv cg +{ + source Example_BumpMapping.cg + entry_point main_shadowreceiver_fp + profiles ps_1_1 arbfp1 fp20 +} + + +// Bump map with specular vertex program, support for this is required +vertex_program Examples/BumpMapVPSpecular cg +{ + source Example_BumpMapping.cg + entry_point specular_vp + profiles vs_1_1 arbvp1 +} + +// Bump map fragment program, support for this is optional +fragment_program Examples/BumpMapFPSpecular cg +{ + source Example_BumpMapping.cg + entry_point specular_fp + profiles ps_1_1 arbfp1 fp20 +} + +// Single light material, less passes (one pass on a 4-unit card) +material Examples/BumpMapping/SingleLight +{ + // Preferred technique, uses vertex and fragment programs + // to support a single coloured light + technique + { + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 0 0 0 + // Vertex program reference + vertex_program_ref Examples/BumpMapVP + { + param_named_auto lightPosition light_position_object_space 0 + param_named_auto worldViewProj worldviewproj_matrix + } + + // Fragment program + fragment_program_ref Examples/BumpMapFP + { + param_named_auto lightDiffuse light_diffuse_colour 0 + } + + // Base bump map + texture_unit + { + texture NMBumpsOut.png + colour_op replace + } + // Normalisation cube map + texture_unit + { + cubic_texture nm.png combinedUVW + tex_coord_set 1 + tex_address_mode clamp + } + // Decal + texture_unit + { + texture RustySteel.jpg + } + } + } + // Fallback technique, uses vertex program but only fixed-function + // fragment shading, which does not support coloured light + technique + { + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 0 0 0 + // Vertex program reference + vertex_program_ref Examples/BumpMapVP + { + param_named_auto lightPosition light_position_object_space 0 + param_named_auto worldViewProj worldviewproj_matrix + } + + // Base bump map + texture_unit + { + texture NMBumpsOut.png + colour_op replace + } + // Normalisation cube map + texture_unit + { + cubic_texture nm.png combinedUVW + tex_coord_set 1 + tex_address_mode clamp + colour_op_ex dotproduct src_texture src_current + colour_op_multipass_fallback dest_colour zero + } + // Decal + texture_unit + { + texture RustySteel.jpg + } + } + } +} + +// Any number of lights, diffuse +material Examples/BumpMapping/MultiLight +{ + + // This is the preferred technique which uses both vertex and + // fragment programs, supports coloured lights + technique + { + // Base ambient pass + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 1 1 1 + diffuse 0 0 0 + specular 0 0 0 0 + // Really basic vertex program + // NB we don't use fixed function here because GL does not like + // mixing fixed function and vertex programs, depth fighting can + // be an issue + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture + { + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto ambient ambient_light_colour + } + + } + // Now do the lighting pass + // NB we don't do decal texture here because this is repeated per light + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 0 0 0 + + // do this for each light + iteration once_per_light + + + scene_blend add + + // Vertex program reference + vertex_program_ref Examples/BumpMapVP + { + param_named_auto lightPosition light_position_object_space 0 + param_named_auto worldViewProj worldviewproj_matrix + } + + // Fragment program + fragment_program_ref Examples/BumpMapFP + { + param_named_auto lightDiffuse light_diffuse_colour 0 + } + + // Base bump map + texture_unit + { + texture NMBumpsOut.png + colour_op replace + } + // Normalisation cube map + texture_unit + { + cubic_texture nm.png combinedUVW + tex_coord_set 1 + tex_address_mode clamp + } + } + + // Decal pass + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + lighting off + // Really basic vertex program + // NB we don't use fixed function here because GL does not like + // mixing fixed function and vertex programs, depth fighting can + // be an issue + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture + { + param_named_auto worldViewProj worldviewproj_matrix + param_named ambient float4 1 1 1 1 + } + scene_blend dest_colour zero + texture_unit + { + texture RustedMetal.jpg + } + + } + } + + // This is the fallback which cards which don't have fragment program + // support will use + // Note that it still requires vertex program support + technique + { + // Base ambient pass + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 1 1 1 + diffuse 0 0 0 + specular 0 0 0 0 + // Really basic vertex program + // NB we don't use fixed function here because GL does not like + // mixing fixed function and vertex programs, depth fighting can + // be an issue + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture + { + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto ambient ambient_light_colour + } + + } + // Now do the lighting pass + // NB we don't do decal texture here because this is repeated per light + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 0 0 0 + // do this for each light + iteration once_per_light + + + scene_blend add + + // Vertex program reference + vertex_program_ref Examples/BumpMapVP + { + param_named_auto lightPosition light_position_object_space 0 + param_named_auto worldViewProj worldviewproj_matrix + } + + // Base bump map + texture_unit + { + texture NMBumpsOut.png + colour_op replace + } + // Normalisation cube map, with dot product on bump map + texture_unit + { + cubic_texture nm.png combinedUVW + tex_coord_set 1 + tex_address_mode clamp + colour_op_ex dotproduct src_texture src_current + colour_op_multipass_fallback dest_colour zero + } + } + + // Decal pass + pass + { + lighting off + // Really basic vertex program + // NB we don't use fixed function here because GL does not like + // mixing fixed function and vertex programs, depth fighting can + // be an issue + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture + { + param_named_auto worldViewProj worldviewproj_matrix + param_named ambient float4 1 1 1 1 + } + scene_blend dest_colour zero + texture_unit + { + texture RustedMetal.jpg + } + + } + + } +} + +// Any number of lights, diffuse and specular +material Examples/BumpMapping/MultiLightSpecular +{ + + // This is the preferred technique which uses both vertex and + // fragment programs, supports coloured lights + technique + { + // Base ambient pass + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 1 1 1 + diffuse 0 0 0 + specular 0 0 0 0 + // Really basic vertex program + // NB we don't use fixed function here because GL does not like + // mixing fixed function and vertex programs, depth fighting can + // be an issue + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture + { + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto ambient ambient_light_colour + } + + } + // Now do the lighting pass + // NB we don't do decal texture here because this is repeated per light + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 0 0 0 + // do this for each light + iteration once_per_light + + + scene_blend add + + // Vertex program reference + vertex_program_ref Examples/BumpMapVPSpecular + { + param_named_auto lightPosition light_position_object_space 0 + param_named_auto eyePosition camera_position_object_space + param_named_auto worldViewProj worldviewproj_matrix + } + + // Fragment program + fragment_program_ref Examples/BumpMapFPSpecular + { + param_named_auto lightDiffuse light_diffuse_colour 0 + param_named_auto lightSpecular light_specular_colour 0 + } + + // Base bump map + texture_unit + { + texture NMBumpsOut.png + colour_op replace + } + // Normalisation cube map + texture_unit + { + cubic_texture nm.png combinedUVW + tex_coord_set 1 + tex_address_mode clamp + } + // Normalisation cube map #2 + texture_unit + { + cubic_texture nm.png combinedUVW + tex_coord_set 2 + tex_address_mode clamp + } + } + + // Decal pass + pass + { + lighting off + // Really basic vertex program + // NB we don't use fixed function here because GL does not like + // mixing fixed function and vertex programs, depth fighting can + // be an issue + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture + { + param_named_auto worldViewProj worldviewproj_matrix + param_named ambient float4 1 1 1 1 + } + scene_blend dest_colour zero + texture_unit + { + texture RustedMetal.jpg + } + + } + } + + // This is the fallback which cards which don't have fragment program + // support will use, NB does not support specular colour + // Note that it still requires vertex program support + technique + { + // Base ambient pass + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 1 1 1 + diffuse 0 0 0 + specular 0 0 0 0 + // Really basic vertex program + // NB we don't use fixed function here because GL does not like + // mixing fixed function and vertex programs, depth fighting can + // be an issue + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture + { + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto ambient ambient_light_colour + } + + } + // Now do the lighting pass + // NB we don't do decal texture here because this is repeated per light + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 0 0 0 + // do this for each light + iteration once_per_light + + + scene_blend add + + // Vertex program reference + vertex_program_ref Examples/BumpMapVP + { + param_named_auto lightPosition light_position_object_space 0 + param_named_auto worldViewProj worldviewproj_matrix + } + + // Base bump map + texture_unit + { + texture NMBumpsOut.png + colour_op replace + } + // Normalisation cube map, with dot product on bump map + texture_unit + { + cubic_texture nm.png combinedUVW + tex_coord_set 1 + tex_address_mode clamp + colour_op_ex dotproduct src_texture src_current + colour_op_multipass_fallback dest_colour zero + } + } + + // Decal pass + pass + { + lighting off + // Really basic vertex program + // NB we don't use fixed function here because GL does not like + // mixing fixed function and vertex programs, depth fighting can + // be an issue + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture + { + param_named_auto worldViewProj worldviewproj_matrix + param_named ambient float4 1 1 1 1 + } + scene_blend dest_colour zero + texture_unit + { + texture RustedMetal.jpg + } + + } + + } +} + +//--------------------------- +// Projective texture section +//--------------------------- + + +vertex_program Examples/TexProjectionVP cg +{ + source Example_Projection.cg + entry_point generalPurposeProjection_vp + profiles vs_1_1 arbvp1 +} + +fragment_program Examples/TexProjectionFP cg +{ + source Example_Projection.cg + entry_point generalPurposeProjection_fp + // sorry, ps_1_1 can't do this, fp20 can though + profiles ps_2_0 arbfp1 fp20 +} + +material Examples/GeneralTexProjection +{ + technique + { + pass + { + + vertex_program_ref Examples/TexProjectionVP + { + param_named_auto worldViewProjMatrix worldviewproj_matrix + param_named_auto worldMatrix world_matrix + // You'll need to update the tex projection, I suggest using + // the Frustum class + //param_named_auto texWorldViewProj worldviewproj_matrix + } + fragment_program_ref Examples/TexProjectionFP + { + // no params + } + texture_unit + { + // Project the OGRE logo + texture ogrelogo.png + tex_address_mode clamp + } + } + + + } + +} + +//---------------------------- +// Distortion effects +//---------------------------- + +vertex_program Examples/FresnelRefractReflectVP cg +{ + source Example_Fresnel.cg + entry_point main_vp + profiles vs_1_1 arbvp1 +} +vertex_program Examples/FresnelRefractReflectVPold cg +{ + source Example_Fresnel.cg + entry_point main_vp_old + profiles vs_1_1 arbvp1 +} + +fragment_program Examples/FresnelRefractReflectFP cg +{ + source Example_Fresnel.cg + entry_point main_fp + // sorry, ps_1_1 and fp20 can't do this + profiles ps_2_0 arbfp1 +} + +fragment_program Examples/FresnelRefractReflectPS asm +{ + source Example_FresnelPS.asm + // sorry, only for ps_1_4 :) + syntax ps_1_4 + +} + +material Examples/FresnelReflectionRefraction +{ + // ps_2_0 / arbfp1 + technique + { + pass + { + + vertex_program_ref Examples/FresnelRefractReflectVP + { + param_named_auto worldViewProjMatrix worldviewproj_matrix + param_named_auto eyePosition camera_position_object_space + param_named_auto timeVal time 0.05 + param_named scroll float 1 + param_named scale float 1 + param_named noise float 1 + // scroll and noisePos will need updating per frame + } + fragment_program_ref Examples/FresnelRefractReflectFP + { + param_named fresnelBias float -0.1 + param_named fresnelScale float 1.8 + param_named fresnelPower float 8 + param_named tintColour float4 0 0.0.05 0.05 1 + param_named noiseScale float 0.05 + } + // Noise + texture_unit + { + // Perlin noise volume + texture waves2.dds + // min / mag filtering, no mip + filtering linear linear none + } + // Reflection + texture_unit + { + // Will be filled in at runtime + texture Reflection + tex_address_mode clamp + // needed by ps.1.4 + tex_coord_set 1 + } + // Refraction + texture_unit + { + // Will be filled in at runtime + texture Refraction + tex_address_mode clamp + // needed by ps.1.4 + tex_coord_set 2 + } + } + + + } + + // ATI 8500 + + technique + { + pass + { + vertex_program_ref Examples/FresnelRefractReflectVPold + { + param_named_auto worldViewProjMatrix worldviewproj_matrix + param_named_auto eyePosition camera_position_object_space + param_named fresnelBias float -0.3 + param_named fresnelScale float 1.4 + param_named fresnelPower float 8 + param_named_auto timeVal time_0_1 20 + param_named scroll float 1 + param_named scale float 4 + param_named noise float 1 + // scroll and noisePos will need updating per frame + } + + // for ATI RADEON 8500 - 9200 + fragment_program_ref Examples/FresnelRefractReflectPS + { + // distortionRange + param_indexed 0 float 0.025 + // tintColour + param_indexed 1 float4 0.05 0.12 0.15 1 + } + + // Noise + texture_unit + { + // Perlin noise volume + texture perlinvolume.dds 3d + // min / mag filtering, no mip + filtering linear linear none + } + // Reflection + texture_unit + { + // Will be filled in at runtime + texture Reflection + tex_address_mode clamp + // needed by ps.1.4 + tex_coord_set 1 + } + // Refraction + texture_unit + { + // Will be filled in at runtime + texture Refraction + tex_address_mode clamp + // needed by ps.1.4 + tex_coord_set 2 + } + } + } +} + +// Normal-mapped Athene statue +material Examples/Athene/NormalMapped +{ + + // This is the preferred technique which uses both vertex and + // fragment programs, supports coloured lights + technique + { + // Base ambient pass + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 1 1 1 + diffuse 0 0 0 + specular 0 0 0 0 + // Really basic vertex program + // NB we don't use fixed function here because GL does not like + // mixing fixed function and vertex programs, depth fighting can + // be an issue + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture + { + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto ambient ambient_light_colour + } + + } + // Now do the lighting pass + // NB we don't do decal texture here because this is repeated per light + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 0 0 0 + + // do this for each light + iteration once_per_light + + + scene_blend add + + // Vertex program reference + vertex_program_ref Examples/BumpMapVP + { + param_named_auto lightPosition light_position_object_space 0 + param_named_auto worldViewProj worldviewproj_matrix + } + + // Fragment program + fragment_program_ref Examples/BumpMapFP + { + param_named_auto lightDiffuse light_diffuse_colour 0 + } + + // texture shadow receiver program + shadow_receiver_vertex_program_ref Examples/BumpMapVPShadowRcv + { + param_named_auto lightPosition light_position_object_space 0 + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto worldMatrix world_matrix + param_named_auto texViewProj texture_viewproj_matrix + } + // Additive texture shadow receiver program + shadow_receiver_fragment_program_ref Examples/BumpMapFPShadowRcv + { + param_named_auto lightDiffuse light_diffuse_colour 0 + } + + // Base bump map + texture_unit + { + texture atheneNormalMap.png + colour_op replace + } + // Normalisation cube map + texture_unit + { + cubic_texture nm.png combinedUVW + tex_coord_set 1 + tex_address_mode clamp + } + } + + // Decal pass + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + lighting off + // Really basic vertex program + // NB we don't use fixed function here because GL does not like + // mixing fixed function and vertex programs, depth fighting can + // be an issue + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture + { + param_named_auto worldViewProj worldviewproj_matrix + param_named ambient float4 1 1 1 1 + } + scene_blend dest_colour zero + texture_unit + { + texture egyptrockyfull.jpg + } + + } + } + + // This is the fallback which cards which don't have fragment program + // support will use + // Note that it still requires vertex program support + technique + { + // Base ambient pass + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 1 1 1 + diffuse 0 0 0 + specular 0 0 0 0 + // Really basic vertex program + // NB we don't use fixed function here because GL does not like + // mixing fixed function and vertex programs, depth fighting can + // be an issue + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture + { + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto ambient ambient_light_colour + } + + } + // Now do the lighting pass + // NB we don't do decal texture here because this is repeated per light + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 0 0 0 + // do this for each light + iteration once_per_light + + + scene_blend add + + // Vertex program reference + vertex_program_ref Examples/BumpMapVP + { + param_named_auto lightPosition light_position_object_space 0 + param_named_auto worldViewProj worldviewproj_matrix + } + + // Base bump map + texture_unit + { + texture atheneNormalMap.png + colour_op replace + } + // Normalisation cube map, with dot product on bump map + texture_unit + { + cubic_texture nm.png combinedUVW + tex_coord_set 1 + tex_address_mode clamp + colour_op_ex dotproduct src_texture src_current + colour_op_multipass_fallback dest_colour zero + } + } + + // Decal pass + pass + { + lighting off + // Really basic vertex program + // NB we don't use fixed function here because GL does not like + // mixing fixed function and vertex programs, depth fighting can + // be an issue + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture + { + param_named_auto worldViewProj worldviewproj_matrix + param_named ambient float4 1 1 1 1 + } + scene_blend dest_colour zero + texture_unit + { + texture egyptrockyfull.jpg + } + + } + + } +} + +// Basic Athene statue +material Examples/Athene/Basic +{ + + technique + { + pass + { + ambient 0.3 0.3 0.3 + diffuse 1.0 1.0 0.9 + + texture_unit + { + texture egyptrockyfull.jpg + } + + } + } +} + + +// Any number of lights, diffuse and specular +material Examples/Athene/NormalMappedSpecular +{ + + // This is the preferred technique which uses both vertex and + // fragment programs, supports coloured lights + technique + { + // Base ambient pass + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 1 1 1 + diffuse 0 0 0 + specular 0 0 0 0 + // Really basic vertex program + // NB we don't use fixed function here because GL does not like + // mixing fixed function and vertex programs, depth fighting can + // be an issue + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture + { + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto ambient ambient_light_colour + } + + } + // Now do the lighting pass + // NB we don't do decal texture here because this is repeated per light + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 0 0 0 + // do this for each light + iteration once_per_light + + + scene_blend add + + // Vertex program reference + vertex_program_ref Examples/BumpMapVPSpecular + { + param_named_auto lightPosition light_position_object_space 0 + param_named_auto eyePosition camera_position_object_space + param_named_auto worldViewProj worldviewproj_matrix + } + + // Fragment program + fragment_program_ref Examples/BumpMapFPSpecular + { + param_named_auto lightDiffuse light_diffuse_colour 0 + param_named_auto lightSpecular light_specular_colour 0 + } + + // Base bump map + texture_unit + { + texture atheneNormalMap.png + colour_op replace + } + // Normalisation cube map + texture_unit + { + cubic_texture nm.png combinedUVW + tex_coord_set 1 + tex_address_mode clamp + } + // Normalisation cube map #2 + texture_unit + { + cubic_texture nm.png combinedUVW + tex_coord_set 2 + tex_address_mode clamp + } + } + + // Decal pass + pass + { + lighting off + // Really basic vertex program + // NB we don't use fixed function here because GL does not like + // mixing fixed function and vertex programs, depth fighting can + // be an issue + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture + { + param_named_auto worldViewProj worldviewproj_matrix + param_named ambient float4 1 1 1 1 + } + scene_blend dest_colour zero + texture_unit + { + texture egyptrockyfull.jpg + } + + } + } + + // This is the fallback which cards which don't have fragment program + // support will use, NB does not support specular colour + // Note that it still requires vertex program support + technique + { + // Base ambient pass + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 1 1 1 + diffuse 0 0 0 + specular 0 0 0 0 + // Really basic vertex program + // NB we don't use fixed function here because GL does not like + // mixing fixed function and vertex programs, depth fighting can + // be an issue + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture + { + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto ambient ambient_light_colour + } + + } + // Now do the lighting pass + // NB we don't do decal texture here because this is repeated per light + pass + { + // base colours, not needed for rendering, but as information + // to lighting pass categorisation routine + ambient 0 0 0 + // do this for each light + iteration once_per_light + + + scene_blend add + + // Vertex program reference + vertex_program_ref Examples/BumpMapVP + { + param_named_auto lightPosition light_position_object_space 0 + param_named_auto worldViewProj worldviewproj_matrix + } + + // Base bump map + texture_unit + { + texture atheneNormalMap.png + colour_op replace + } + // Normalisation cube map, with dot product on bump map + texture_unit + { + cubic_texture nm.png combinedUVW + tex_coord_set 1 + tex_address_mode clamp + colour_op_ex dotproduct src_texture src_current + colour_op_multipass_fallback dest_colour zero + } + } + + // Decal pass + pass + { + lighting off + // Really basic vertex program + // NB we don't use fixed function here because GL does not like + // mixing fixed function and vertex programs, depth fighting can + // be an issue + vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture + { + param_named_auto worldViewProj worldviewproj_matrix + param_named ambient float4 1 1 1 1 + } + scene_blend dest_colour zero + texture_unit + { + texture egyptrockyfull.jpg + } + + } + + } +} + diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/Examples.compositor b/school/informatik/verkerhssimulation/media/materials/scripts/Examples.compositor new file mode 100644 index 00000000..5e560162 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/Examples.compositor @@ -0,0 +1,592 @@ +// Manuel's bloom +// Needs a scene-sized rtt, but does only one render of the scene +compositor Bloom +{ + technique + { + // Temporary textures + texture rt0 128 128 PF_A8R8G8B8 + texture rt1 128 128 PF_A8R8G8B8 + + target rt1 + { + // Render output from previous compositor (or original scene) + input previous + } + + target rt0 + { + // Start with clear texture + input none + // Vertical blur pass + pass render_quad + { + // Renders a fullscreen quad with a material + material Ogre/Compositor/Blur0 + input 0 rt1 + } + } + + target rt1 + { + // Start with clear texture + input none + // Horizontal blur pass + pass render_quad + { + // Renders a fullscreen quad with a material + material Ogre/Compositor/Blur1 + input 0 rt0 + } + } + + target_output + { + // Start with clear output + input previous + // Draw a fullscreen quad + pass render_quad + { + // Renders a fullscreen quad with a material + material Ogre/Compositor/BloomBlend + input 0 rt1 + } + } + } +} + +compositor Glass +{ + technique + { + texture rt0 target_width target_height PF_R8G8B8 + + target rt0 { input previous } + + target_output + { + // Start with clear output + input none + + pass render_quad + { + material Ogre/Compositor/GlassPass + input 0 rt0 + } + } + } +} + +compositor "Old TV" +{ + technique + { + texture rt0 target_width target_height PF_R8G8B8 + + // render scene to a texture + target rt0 { input previous } + + target_output + { + // Start with clear output + input none + + pass render_quad + { + // convert the previous render target to a black and white image, add some noise, distort it, + // then render to scene aligned quad + material Ogre/Compositor/OldTV + input 0 rt0 + } + } + } +} + + +// Black and white effect +compositor B&W +{ + technique + { + // Temporary textures + texture rt0 target_width target_height PF_A8R8G8B8 + + target rt0 + { + // Render output from previous compositor (or original scene) + input previous + } + + target_output + { + // Start with clear output + input none + // Draw a fullscreen quad with the black and white image + pass render_quad + { + // Renders a fullscreen quad with a material + material Ogre/Compositor/BlackAndWhite + input 0 rt0 + } + } + } +} + +//compositor DOF // based on Blur but final pass does depth of field +//{ +// technique +// { +// // Temporary textures +// texture rt0 target_width target_height PF_A8R8G8B8 +// texture rt1 target_width target_height PF_A8R8G8B8 +// +// target rt1 +// { +// // Render output from previous compositor (or original scene) +// input previous +// } +// +// target rt0 +// { +// // Start with clear texture +// input none +// // Vertical blur pass +// pass render_quad +// { +// // Renders a fullscreen quad with a material +// material Ogre/Compositor/DOF_Blur0 +// input 0 rt1 +// } +// } +// +// target rt1 +// { +// // Start with clear texture +// input none +// // Horizontal blur pass +// pass render_quad +// { +// // Renders a fullscreen quad with a material +// material Ogre/Compositor/DOF_Blur1 +// input 0 rt0 +// } +// } +// +// target_output +// { +// // Start with clear output +// input none +// // Draw a fullscreen quad +// pass render_quad +// { +// // Renders a fullscreen quad with a material +// material Ogre/Compositor/DOF_Blend +// input 0 rt0 +// input 1 rt1 +// } +// } +// } +//} + +// Embossed (fake bump) effect +compositor Embossed +{ + technique + { + // Temporary textures + texture rt0 target_width target_height PF_A8R8G8B8 + + target rt0 + { + // Render output from previous compositor (or original scene) + input previous + } + + target_output + { + // Start with clear output + input none + // Draw a fullscreen quad with the black and white image + pass render_quad + { + // Renders a fullscreen quad with a material + material Ogre/Compositor/Embossed + input 0 rt0 + } + } + } +} + +// SharpenEdges +compositor Sharpen Edges +{ + technique + { + // Temporary textures + texture rt0 target_width target_height PF_A8R8G8B8 + + target rt0 + { + // Render output from previous compositor (or original scene) + input previous + } + + target_output + { + // Start with clear output + input none + // Draw a fullscreen quad with the black and white image + pass render_quad + { + // Renders a fullscreen quad with a material + material Ogre/Compositor/SharpenEdges + input 0 rt0 + } + } + } +} + +// Invert +compositor Invert +{ + technique + { + // Temporary textures + texture rt0 target_width target_height PF_A8R8G8B8 + + target rt0 + { + // Render output from previous compositor (or original scene) + input previous + } + + target_output + { + // Start with clear output + input none + // Draw a fullscreen quad with the black and white image + pass render_quad + { + // Renders a fullscreen quad with a material + material Ogre/Compositor/Invert + input 0 rt0 + } + } + } +} + +// Posterize +compositor Posterize +{ + technique + { + // Temporary textures + texture rt0 target_width target_height PF_A8R8G8B8 + + target rt0 + { + // Render output from previous compositor (or original scene) + input previous + } + + target_output + { + // Start with clear output + input none + // Draw a fullscreen quad with the black and white image + pass render_quad + { + // Renders a fullscreen quad with a material + material Ogre/Compositor/Posterize + input 0 rt0 + } + } + } +} + +// Laplace +compositor Laplace +{ + technique + { + // Temporary textures + texture rt0 target_width target_height PF_A8R8G8B8 + + target rt0 + { + // Render output from previous compositor (or original scene) + input previous + } + + target_output + { + // Start with clear output + input none + // Draw a fullscreen quad with the black and white image + pass render_quad + { + // Renders a fullscreen quad with a material + material Ogre/Compositor/Laplace + input 0 rt0 + } + } + } +} + +// Tiling +compositor Tiling +{ + technique + { + // Temporary textures + texture rt0 target_width target_height PF_A8R8G8B8 + + target rt0 + { + // Render output from previous compositor (or original scene) + input previous + } + + target_output + { + // Start with clear output + input none + // Draw a fullscreen quad with the black and white image + pass render_quad + { + // Renders a fullscreen quad with a material + material Ogre/Compositor/Tiling + input 0 rt0 + } + } + } +} + +// Old Movie +compositor Old Movie +{ + technique + { + // Temporary textures + texture rt0 target_width target_height PF_A8R8G8B8 + + target rt0 + { + // Render output from previous compositor (or original scene) + input previous + } + + target_output + { + // Start with clear output + input none + // Draw a fullscreen quad with the black and white image + pass render_quad + { + // Renders a fullscreen quad with a material + material Ogre/Compositor/OldMovie + input 0 rt0 + } + } + } +} + +// HDR +compositor HDR +{ + // floating point only for now + technique + { + // Temporary textures + // Fullsize HDR render target, used as tone mapping source + texture rt_full target_width target_height PF_FLOAT16_RGB + // Targets used for luminance evaluation (3x3 downsample, point filtering) + texture rt_lum0 1 1 PF_FLOAT16_RGB + texture rt_lum1 4 4 PF_FLOAT16_RGB + texture rt_lum2 16 16 PF_FLOAT16_RGB + texture rt_lum3 64 64 PF_FLOAT16_RGB + texture rt_lum4 128 128 PF_FLOAT16_RGB + // Bright-pass filtered target (tone mapped) + texture rt_brightpass 128 128 PF_R8G8B8 + // Bloom filter targets + texture rt_bloom0 128 128 PF_R8G8B8 + texture rt_bloom1 128 128 PF_R8G8B8 + + + target rt_full + { + // No input, render differently + input none + + // Use float target HDR material scheme (unclamped shaders) + material_scheme HDR + + pass clear + { + } + + pass render_scene + { + } + + } + + // Downsample the original HDR scene to extract luminence value + target rt_lum4 + { + input none + pass render_quad + { + // Downsample using a 2x2 filter and convert to greyscale + material Ogre/Compositor/HDR/Downsample2x2Luminence + input 0 rt_full + identifier 994 + } + } + target rt_lum3 + { + input none + pass render_quad + { + // Downsample using a 3x3 filter + material Ogre/Compositor/HDR/Downsample3x3 + input 0 rt_lum4 + identifier 993 + } + } + target rt_lum2 + { + input none + pass render_quad + { + // Downsample using a 3x3 filter + material Ogre/Compositor/HDR/Downsample3x3 + input 0 rt_lum3 + identifier 992 + } + } + target rt_lum1 + { + input none + pass render_quad + { + // Downsample using a 3x3 filter + material Ogre/Compositor/HDR/Downsample3x3 + input 0 rt_lum2 + identifier 991 + } + } + target rt_lum0 + { + input none + pass render_quad + { + // Downsample using a 3x3 filter + material Ogre/Compositor/HDR/Downsample3x3 + input 0 rt_lum1 + identifier 990 + } + } + + + target rt_brightpass + { + input none + pass render_quad + { + // Downsample using a 3x3 filter, hi-pass and tone map + material Ogre/Compositor/HDR/Downsample3x3Brightpass + input 0 rt_full + input 1 rt_lum0 + identifier 800 + } + } + + target rt_bloom1 + { + input none + pass render_quad + { + // Blur horizontally + material Ogre/Compositor/HDR/GaussianBloom + input 0 rt_brightpass + identifier 701 + } + } + target rt_bloom0 + { + input none + pass render_quad + { + // Blur horizontally + material Ogre/Compositor/HDR/GaussianBloom + input 0 rt_bloom1 + identifier 700 + } + } + + + // Final output combines tone mapping of the original scene, with an + // exposure setting passed in as a GPU parameter, and an additive bloom + // effect + target_output + { + input none + pass render_quad + { + material Ogre/Compositor/HDR/ToneMapping + input 0 rt_full + input 1 rt_bloom0 + input 2 rt_lum0 + } + } + + + } + +} + + +// Gaussian blur effect +compositor Gaussian Blur +{ + technique + { + // Temporary textures + texture rt0 target_width target_height PF_A8R8G8B8 + texture rt1 target_width target_height PF_A8R8G8B8 + + target rt0 + { + // Render output from previous compositor (or original scene) + input previous + } + + target rt1 + { + // Blur horizontally + input none + pass render_quad + { + material Ogre/Compositor/HDR/GaussianBloom + input 0 rt0 + identifier 700 + } + } + + target_output + { + // Start with clear output + input none + // Blur vertically + pass render_quad + { + // Renders a fullscreen quad with a material + material Ogre/Compositor/HDR/GaussianBloom + input 0 rt1 + identifier 701 + } + } + } +} + diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/Examples.program b/school/informatik/verkerhssimulation/media/materials/scripts/Examples.program new file mode 100644 index 00000000..a817d833 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/Examples.program @@ -0,0 +1,158 @@ +//--------------------------------------------------- +// This file includes a number of basic GPU programs +// for use in many materials. +//--------------------------------------------------- + + +// A really basic ambient pass program, support for one texture coodinate set +vertex_program Ogre/BasicVertexPrograms/AmbientOneTexture cg +{ + source Example_Basic.cg + entry_point ambientOneTexture_vp + profiles vs_1_1 arbvp1 + + default_params + { + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto ambient ambient_light_colour + } + +} +// A really basic ambient pass program, support for one texture coodinate set +vertex_program Ogre/BasicVertexPrograms/AmbientOneTextureHLSL hlsl +{ + source Example_Basic.hlsl + entry_point ambientOneTexture_vp + target vs_1_1 + + default_params + { + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto ambient ambient_light_colour + } +} +// A really basic ambient pass program, support for one texture coodinate set +vertex_program Ogre/BasicVertexPrograms/AmbientOneTextureGLSL glsl +{ + source AmbientOneTexture.glsl + + default_params + { + param_named_auto ambient ambient_light_colour + } +} + +vertex_program Ogre/BasicVertexPrograms/AmbientOneTextureUnified unified +{ + delegate Ogre/BasicVertexPrograms/AmbientOneTextureGLSL + delegate Ogre/BasicVertexPrograms/AmbientOneTextureHLSL +} + + +// Same as below, but for use when rendering texture shadows +vertex_program Ogre/HardwareSkinningOneWeightShadowCaster cg +{ + source Example_Basic.cg + entry_point hardwareSkinningOneWeightCaster_vp + profiles vs_1_1 arbvp1 + includes_skeletal_animation true +} +// Basic hardware skinning using one indexed weight per vertex +vertex_program Ogre/HardwareSkinningOneWeight cg +{ + source Example_Basic.cg + entry_point hardwareSkinningOneWeight_vp + profiles vs_1_1 arbvp1 + includes_skeletal_animation true +} +// Same as below, but for use when rendering texture shadows +vertex_program Ogre/HardwareSkinningTwoWeightsShadowCasterCg cg +{ + source Example_Basic.cg + entry_point hardwareSkinningTwoWeightsCaster_vp + profiles vs_1_1 arbvp1 + includes_skeletal_animation true +} + +vertex_program Ogre/HardwareSkinningTwoWeightsShadowCasterGLSL glsl +{ + source skinningTwoWeightsShadowCasterVp.glsl + includes_skeletal_animation true +} + +vertex_program Ogre/HardwareSkinningTwoWeightsShadowCaster unified +{ + delegate Ogre/HardwareSkinningTwoWeightsShadowCasterGLSL + delegate Ogre/HardwareSkinningTwoWeightsShadowCasterCg +} + +// Basic hardware skinning using two indexed weights per vertex +vertex_program Ogre/HardwareSkinningTwoWeightsCg cg +{ + source Example_Basic.cg + entry_point hardwareSkinningTwoWeights_vp + profiles vs_1_1 arbvp1 + includes_skeletal_animation true +} + +vertex_program Ogre/HardwareSkinningTwoWeightsGLSL glsl +{ + source skinningTwoWeightsVp.glsl + includes_skeletal_animation true +} + +vertex_program Ogre/HardwareSkinningTwoWeights unified +{ + delegate Ogre/HardwareSkinningTwoWeightsGLSL + delegate Ogre/HardwareSkinningTwoWeightsCg + + default_params + { + param_named_auto worldMatrix3x4Array world_matrix_array_3x4 + param_named_auto viewProjectionMatrix viewproj_matrix + param_named_auto lightPos[0] light_position 0 + param_named_auto lightPos[1] light_position 1 + param_named_auto lightDiffuseColour[0] light_diffuse_colour 0 + param_named_auto lightDiffuseColour[1] light_diffuse_colour 1 + } +} + +// Basic hardware skinning using four indexed weights per vertex +vertex_program Ogre/HardwareSkinningFourWeights cg +{ + source Example_Basic.cg + entry_point hardwareSkinningFourWeights_vp + profiles vs_1_1 arbvp1 + includes_skeletal_animation true + +} +// Basic hardware morph animation +vertex_program Ogre/HardwareMorphAnimation cg +{ + source Example_Basic.cg + entry_point hardwareMorphAnimation + profiles vs_1_1 arbvp1 + + includes_morph_animation true + default_params + { + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto anim_t animation_parametric + } +} +// Basic hardware pose animation supporting 2 active poses +vertex_program Ogre/HardwarePoseAnimation cg +{ + source Example_Basic.cg + entry_point hardwarePoseAnimation + profiles vs_1_1 arbvp1 + + includes_pose_animation 2 + default_params + { + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto anim_t animation_parametric + } +} + + diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/Glass.material b/school/informatik/verkerhssimulation/media/materials/scripts/Glass.material new file mode 100644 index 00000000..457d5b42 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/Glass.material @@ -0,0 +1,40 @@ +fragment_program Ogre/Compositor/GlassFP cg +{ + source GlassFP.cg + entry_point main_ps + profiles ps_2_0 arbfp1 +} + +material Ogre/Compositor/GlassPass +{ + technique + { + pass + { + depth_check off + + vertex_program_ref Ogre/Compositor/StdQuad_Cg_vp + { + } + + fragment_program_ref Ogre/Compositor/GlassFP + { + } + + texture_unit RT + { + tex_coord_set 0 + tex_address_mode clamp + filtering linear linear linear + } + + texture_unit + { + texture WaterNormal1.tga 2d + tex_coord_set 1 + //tex_address_mode clamp + filtering linear linear linear + } + } + } +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/HeatVision.material b/school/informatik/verkerhssimulation/media/materials/scripts/HeatVision.material new file mode 100644 index 00000000..eb6cdb4f --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/HeatVision.material @@ -0,0 +1,209 @@ +/////////////////////////////////// +// PASS 0 +// HEAT CASTERS PASS +/////////////////////////////////// + +vertex_program Fury/HeatVision/HeatCaster_vp cg +{ + source HeatVision.cg + entry_point HeatCaster_vp + profiles vs_1_1 arbvp1 +} + +fragment_program Fury/HeatVision/HeatCaster_fp cg +{ + source HeatVision.cg + entry_point HeatCaster_fp + profiles ps_2_0 arbfp1 +} + +material Fury/HeatVision/HeatCaster +{ + technique + { + pass + { + vertex_program_ref Fury/HeatVision/HeatCaster_vp + { + param_named_auto eyePosition camera_position_object_space + param_named_auto worldViewProj worldviewproj_matrix + } + + fragment_program_ref Fury/HeatVision/HeatCaster_fp + { + } + } + } +} + +/////////////////////////////////// +// PASS 0 +// HEAT CASTERS PASS +/////////////////////////////////// + +vertex_program Fury/HeatVision/ColdCaster_vp cg +{ + source HeatVision.cg + entry_point ColdCaster_vp + profiles vs_1_1 arbvp1 +} + +fragment_program Fury/HeatVision/ColdCaster_fp cg +{ + source HeatVision.cg + entry_point ColdCaster_fp + profiles ps_2_0 arbfp1 +} + +material Fury/HeatVision/ColdCaster +{ + technique + { + pass + { + vertex_program_ref Fury/HeatVision/ColdCaster_vp + { + param_named_auto eyePosition camera_position_object_space + param_named_auto worldViewProj worldviewproj_matrix + } + + fragment_program_ref Fury/HeatVision/ColdCaster_fp + { + } + } + } +} + +/////////////////////////////////// +// PASS 1 +// LIGHT TO HEAT CONVERSION PASS +/////////////////////////////////// + +vertex_program Fury/HeatVision/LightToHeat_vp cg +{ + source HeatVision.cg + entry_point LightToHeat_vp + profiles vs_1_1 arbvp1 + + default_params + { + param_named_auto flipping render_target_flipping + } +} + +fragment_program Fury/HeatVision/LightToHeat_fp cg +{ + source HeatVision.cg + entry_point LightToHeat_fp + profiles ps_2_0 arbfp1 +} + +material Fury/HeatVision/LightToHeat +{ + technique + { + // pass 1 + pass + { + cull_hardware none + cull_software none + depth_func always_pass + + vertex_program_ref Fury/HeatVision/LightToHeat_vp + { + } + + fragment_program_ref Fury/HeatVision/LightToHeat_fp + { + // these should be *really* random! + param_named random_fractions float4 0.3 0.7 0 0 + + param_named depth_modulator float4 0.6 0 0 0 + + // this one can be fixed + param_named heatBiasScale float4 0.0 1.0 0 0 + } + + // INPUT (from scene, where entities has "Fury/HeatVision/Caster" material for heat emanation) + texture_unit + { + tex_coord_set 0 + filtering linear linear none + tex_address_mode clamp + } + + // Noise map + texture_unit + { + texture HeatNoise.tga + tex_coord_set 0 + } + + // heat conversion texture + texture_unit + { + texture HeatLookup.tga + tex_coord_set 0 + filtering point point none + } + } + } + +} + + +/////////////////////////////////// +// PASS 2 +// BLUR PASS +/////////////////////////////////// + +vertex_program Fury/HeatVision/Blur_vp cg +{ + source HeatVision.cg + entry_point Blur_vp + profiles vs_1_1 arbvp1 + + default_params + { + param_named_auto flipping render_target_flipping + } +} + +fragment_program Fury/HeatVision/Blur_fp cg +{ + source HeatVision.cg + entry_point Blur_fp + profiles ps_2_0 arbfp1 +} + +material Fury/HeatVision/Blur +{ + technique + { + // pass 1 + pass + { + cull_hardware none + cull_software none + depth_func always_pass + + vertex_program_ref Fury/HeatVision/Blur_vp + { + } + + fragment_program_ref Fury/HeatVision/Blur_fp + { + param_named blurAmount float4 0.5 0 0 0 + } + + // INPUT (from previous) + texture_unit + { + texture Input + tex_coord_set 0 + filtering linear linear none + tex_address_mode clamp + } + } + } +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/Hurt.material b/school/informatik/verkerhssimulation/media/materials/scripts/Hurt.material new file mode 100644 index 00000000..e70ab4de --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/Hurt.material @@ -0,0 +1,18 @@ +/// Just a simple red quad blended over the scene +material RedQuad +{ + technique + { + pass + { + lighting on + diffuse 0.0 0.0 0.0 0.5 + specular 0.0 0.0 0.0 1.0 + ambient 0.0 0.0 0.0 + emissive 1.0 0.0 0.0 + cull_hardware none + depth_check off + scene_blend alpha_blend + } + } +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/Invert.material b/school/informatik/verkerhssimulation/media/materials/scripts/Invert.material new file mode 100644 index 00000000..c04abdd3 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/Invert.material @@ -0,0 +1,36 @@ +fragment_program Ogre/Compositor/InvertFP cg +{ + source InvertFP.cg + entry_point Invert_ps + profiles ps_2_0 arbfp1 +} + +material Ogre/Compositor/Invert +{ + technique + { + + pass + { + cull_hardware none + cull_software none + depth_func always_pass + + vertex_program_ref Ogre/Compositor/StdQuad_Tex2a_vp + { + } + + fragment_program_ref Ogre/Compositor/InvertFP + { + } + + texture_unit RT + { + tex_coord_set 0 + tex_address_mode clamp + filtering trilinear + } + + } + } +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/Laplace.material b/school/informatik/verkerhssimulation/media/materials/scripts/Laplace.material new file mode 100644 index 00000000..7b4615d7 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/Laplace.material @@ -0,0 +1,39 @@ +fragment_program Ogre/Compositor/LaplaceFP cg +{ + source LaplaceFP.cg + entry_point Laplace_ps + profiles ps_2_0 arbfp1 +} + +material Ogre/Compositor/Laplace +{ + technique + { + + pass + { + cull_hardware none + cull_software none + depth_func always_pass + + vertex_program_ref Ogre/Compositor/StdQuad_Tex2a_vp + { + } + + fragment_program_ref Ogre/Compositor/LaplaceFP + { + param_named pixelSize float 0.0031 + param_named scale float 1.0 + } + + + texture_unit RT + { + tex_coord_set 0 + tex_address_mode clamp + filtering trilinear + } + + } + } +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/MotionBlur.material b/school/informatik/verkerhssimulation/media/materials/scripts/MotionBlur.material new file mode 100644 index 00000000..05c6f3e5 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/MotionBlur.material @@ -0,0 +1,84 @@ +fragment_program Ogre/Compositor/Combine_fp cg +{ + source Combine_fp.cg + profiles ps_2_0 arbfp1 + entry_point Combine_fp + + default_params + { + param_named blur float 0.8 + } +} + +material Ogre/Compositor/Combine +{ + technique + { + pass + { + depth_check off + + fragment_program_ref Ogre/Compositor/Combine_fp + { + } + + vertex_program_ref Ogre/Compositor/StdQuad_Cg_vp + { + } + + texture_unit RT + { + tex_address_mode clamp + filtering linear linear none + tex_coord_set 0 + } + + texture_unit SUM + { + tex_address_mode clamp + filtering linear linear none + tex_coord_set 0 + } + } + } +} + +material Ogre/Compositor/Copyback +{ + technique + { + pass + { + lighting off + depth_check off + + texture_unit Temp + { + tex_address_mode clamp + filtering linear linear none + colour_op replace + tex_coord_set 0 + } + } + } +} + +material Ogre/Compositor/MotionBlur +{ + technique + { + pass + { + lighting off + depth_check off + + texture_unit Sum + { + tex_address_mode clamp + filtering linear linear none + colour_op replace + tex_coord_set 0 + } + } + } +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/Ocean.controls b/school/informatik/verkerhssimulation/media/materials/scripts/Ocean.controls new file mode 100644 index 00000000..07f2481a --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/Ocean.controls @@ -0,0 +1,90 @@ +[1. Ocean2 Cg] +material = Ocean2_Cg +control = Wavelet Scale, BumpScale, GPU_VERTEX, 0, 2, 0 +control = Texture Scale X, textureScale, GPU_VERTEX, 0, 40, 0 +control = Texture Scale Y, textureScale, GPU_VERTEX, 0, 40, 1 +control = Wavelet Speed X, bumpSpeed, GPU_VERTEX, -0.1, 0.1, 0 +control = Wavelet Speed Y, bumpSpeed, GPU_VERTEX, -0.1, 0.1, 1 +control = Wave Frequency, waveFreq, GPU_VERTEX, 0, 0.05, 0 +control = Wave Amplitude, waveAmp, GPU_VERTEX, 0, 25, 0 + +control = Deep Color [Red], deepColor, GPU_FRAGMENT, 0, 1, 0 +control = Deep Color [Green], deepColor, GPU_FRAGMENT, 0, 1, 1 +control = Deep Color [Blue], deepColor, GPU_FRAGMENT, 0, 1, 2 + +control = Shallow Color [Red], shallowColor, GPU_FRAGMENT, 0, 1, 0 +control = Shallow Color [Green], shallowColor, GPU_FRAGMENT, 0, 1, 1 +control = Shallow Color [Blue], shallowColor, GPU_FRAGMENT, 0, 1, 2 + +control = Reflection Color [Red], reflectionColor, GPU_FRAGMENT, 0, 1, 0 +control = Reflection Color [Green], reflectionColor, GPU_FRAGMENT, 0, 1, 1 +control = Reflection Color [Blue], reflectionColor, GPU_FRAGMENT, 0, 1, 2 + +control = Reflection Amount, reflectionAmount, GPU_FRAGMENT, 0, 1, 0 +control = Reflection Blur, reflectionBlur, GPU_FRAGMENT, 0, 8, 0 +control = Water Amount, waterAmount, GPU_FRAGMENT, 0, 1, 0 +control = Fresnel Power, fresnelPower, GPU_FRAGMENT, 0, 10, 0 +control = Fresnel Bias, fresnelBias, GPU_FRAGMENT, 0, 1, 0 +control = HDR Mulitplier, hdrMultiplier, GPU_FRAGMENT, 0, 2, 0 + +[1a. Ocean2 HLSL/GLSL] +material = Ocean2_HLSL_GLSL +control = Wavelet Scale, BumpScale, GPU_VERTEX, 0, 2, 0 +control = Texture Scale X, textureScale, GPU_VERTEX, 0, 40, 0 +control = Texture Scale Y, textureScale, GPU_VERTEX, 0, 40, 1 +control = Wavelet Speed X, bumpSpeed, GPU_VERTEX, -0.1, 0.1, 0 +control = Wavelet Speed Y, bumpSpeed, GPU_VERTEX, -0.1, 0.1, 1 +control = Wave Frequency, waveFreq, GPU_VERTEX, 0, 0.05, 0 +control = Wave Amplitude, waveAmp, GPU_VERTEX, 0, 25, 0 + +control = Deep Color [Red], deepColor, GPU_FRAGMENT, 0, 1, 0 +control = Deep Color [Green], deepColor, GPU_FRAGMENT, 0, 1, 1 +control = Deep Color [Blue], deepColor, GPU_FRAGMENT, 0, 1, 2 + +control = Shallow Color [Red], shallowColor, GPU_FRAGMENT, 0, 1, 0 +control = Shallow Color [Green], shallowColor, GPU_FRAGMENT, 0, 1, 1 +control = Shallow Color [Blue], shallowColor, GPU_FRAGMENT, 0, 1, 2 + +control = Reflection Color [Red], reflectionColor, GPU_FRAGMENT, 0, 1, 0 +control = Reflection Color [Green], reflectionColor, GPU_FRAGMENT, 0, 1, 1 +control = Reflection Color [Blue], reflectionColor, GPU_FRAGMENT, 0, 1, 2 + +control = Reflection Amount, reflectionAmount, GPU_FRAGMENT, 0, 1, 0 +control = Reflection Blur, reflectionBlur, GPU_FRAGMENT, 0, 8, 0 +control = Water Amount, waterAmount, GPU_FRAGMENT, 0, 1, 0 +control = Fresnel Power, fresnelPower, GPU_FRAGMENT, 0, 10, 0 +control = Fresnel Bias, fresnelBias, GPU_FRAGMENT, 0, 1, 0 +control = HDR Mulitplier, hdrMultiplier, GPU_FRAGMENT, 0, 2, 0 + +[2. Ocean1 HLSL/GLSL] +material = OceanHLSL_GLSL +control = scale x, scale, GPU_VERTEX, 0, 0.1, 0 +control = scale y, scale, GPU_VERTEX, 0, 0.1, 1 +control = scale z, scale, GPU_VERTEX, 0, 0.1, 2 +control = Wave Speed X, waveSpeed, GPU_VERTEX, 0, 1, 0 +control = Wave Speed Y, waveSpeed, GPU_VERTEX, 0, 1, 1 +control = Noise Speed, noiseSpeed, GPU_VERTEX, 0, 1, 0 + +control = Fade Bias, fadeBias, GPU_FRAGMENT, 0, 1, 0 +control = Fade Exponent, fadeExp, GPU_FRAGMENT, 0, 20, 0 +control = Water Color (r), waterColor, GPU_FRAGMENT, 0, 1, 0 +control = Water Color (g), waterColor, GPU_FRAGMENT, 0, 1, 1 +control = Water Color (b), waterColor, GPU_FRAGMENT, 0, 1, 2 + +[3. Ocean1 Cg] +material = OceanCg +control = scale x, scale, GPU_VERTEX, 0, 0.1, 0 +control = scale y, scale, GPU_VERTEX, 0, 0.1, 1 +control = scale z, scale, GPU_VERTEX, 0, 0.1, 2 +control = Wave Speed X, waveSpeed, GPU_VERTEX, 0, 1, 0 +control = Wave Speed Y, waveSpeed, GPU_VERTEX, 0, 1, 1 +control = Noise Speed, noiseSpeed, GPU_VERTEX, 0, 1, 0 + +control = Fade Bias, fadeBias, GPU_FRAGMENT, 0, 1, 0 +control = Fade Exponent, fadeExp, GPU_FRAGMENT, 0, 20, 0 +control = Water Color (r), waterColor, GPU_FRAGMENT, 0, 1, 0 +control = Water Color (g), waterColor, GPU_FRAGMENT, 0, 1, 1 +control = Water Color (b), waterColor, GPU_FRAGMENT, 0, 1, 2 + + + diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/Ocean.material b/school/informatik/verkerhssimulation/media/materials/scripts/Ocean.material new file mode 100644 index 00000000..568aff91 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/Ocean.material @@ -0,0 +1,427 @@ +vertex_program HLSL/OceanVS hlsl +{ + source oceanHLSL_Cg.vert + entry_point main + target vs_1_1 + + + default_params + { + param_named_auto worldViewProj_matrix worldviewproj_matrix + param_named_auto eyePosition camera_position_object_space + param_named scale float3 0.012 0.005 0.03 + param_named_auto time_0_X time_0_x 100.0 + } +} + +fragment_program HLSL/OceanFS hlsl +{ + source oceanHLSL_Cg.frag + entry_point main + target ps_2_0 + +} + +vertex_program GLSL/OceanVS glsl +{ + source oceanGLSL.vert + + default_params + { + param_named_auto eyePosition camera_position_object_space + param_named scale float3 0.012 0.005 0.03 + param_named_auto time_0_X time_0_x 100.0 + } +} + +fragment_program GLSL/OceanFS glsl +{ + source oceanGLSL.frag + + default_params + { + param_named Noise int 0 + param_named skyBox int 1 + } +} + +material OceanHLSL_GLSL +{ + technique + { + pass + { + vertex_program_ref HLSL/OceanVS + { + param_named waveSpeed float2 0.0 0.168 + param_named noiseSpeed float 0.155 + } + + fragment_program_ref HLSL/OceanFS + { + param_named fadeBias float 0.336 + param_named fadeExp float 5.546 + param_named waterColor float4 0.0 0.244 0.395 1.0 + } + + texture_unit + { + texture NoiseVolume.dds 3d + tex_coord_set 0 + filtering linear linear none + } + + texture_unit + { + cubic_texture morning.jpg combinedUVW + tex_address_mode clamp + tex_coord_set 1 + } + + } + + } + + technique + { + pass + { + vertex_program_ref GLSL/OceanVS + { + param_named waveSpeed float2 0.0 0.168 + param_named noiseSpeed float 0.155 + } + + fragment_program_ref GLSL/OceanFS + { + param_named fadeBias float 0.336 + param_named fadeExp float 5.546 + param_named waterColor float4 0.0 0.244 0.395 1.0 + } + + texture_unit + { + texture NoiseVolume.dds 3d + tex_coord_set 0 + filtering linear linear none + tex_address_mode wrap + } + + texture_unit + { + cubic_texture morning.jpg combinedUVW + tex_address_mode clamp + tex_coord_set 1 + } + + } + + } + +} + + +vertex_program Cg/OceanVS cg +{ + source oceanHLSL_Cg.vert + entry_point main + profiles vs_1_1 arbvp1 + + + default_params + { + param_named_auto worldViewProj_matrix worldviewproj_matrix + param_named_auto eyePosition camera_position_object_space + param_named scale float3 0.012 0.005 0.03 + param_named_auto time_0_X time_0_x 100.0 + } +} + +fragment_program Cg/OceanFS cg +{ + source oceanHLSL_Cg.frag + entry_point main + profiles ps_2_0 arbfp1 + +} + +material OceanCg +{ + technique + { + pass + { + vertex_program_ref Cg/OceanVS + { + param_named waveSpeed float2 0.0 0.168 + param_named noiseSpeed float 0.155 + } + + fragment_program_ref Cg/OceanFS + { + param_named fadeBias float 0.336 + param_named fadeExp float 5.546 + param_named waterColor float4 0.0 0.244 0.395 1.0 + } + + texture_unit + { + texture NoiseVolume.dds 3d + tex_coord_set 0 + filtering linear linear none + } + + texture_unit + { + cubic_texture morning.jpg combinedUVW + tex_address_mode clamp + tex_coord_set 1 + } + + } + + } +} + + +vertex_program Cg/Ocean2VS cg +{ + source Ocean2HLSL_Cg.vert + entry_point main + profiles vs_1_1 arbvp1 + + + default_params + { + param_named_auto WorldViewProj worldviewproj_matrix + param_named_auto eyePosition camera_position_object_space + } +} + +fragment_program Cg/Ocean2FS cg +{ + source Ocean2HLSL_Cg.frag + entry_point main + profiles ps_2_0 arbfp1 + +} + +material Ocean2_Cg +{ + technique + { + pass + { + vertex_program_ref Cg/Ocean2VS + { + param_named BumpScale float 0.2 + param_named textureScale float2 25 26 + param_named bumpSpeed float2 0.015 0.005 + param_named_auto time time_0_x 100.0 + param_named waveFreq float 0.028 + param_named waveAmp float 1.8 + } + + fragment_program_ref Cg/Ocean2FS + { + param_named deepColor float4 0 0.3 0.5 1.0 + param_named shallowColor float4 0 1 1 1.0 + param_named reflectionColor float4 0.95 1 1 1.0 + param_named reflectionAmount float 1.0 + param_named reflectionBlur float 0.0 + param_named waterAmount float 0.3 + param_named fresnelPower float 5.0 + param_named fresnelBias float 0.328 + param_named hdrMultiplier float 0.471 + } + + texture_unit + { + texture waves2.dds + tex_coord_set 0 + filtering linear linear linear + } + + texture_unit + { + cubic_texture morning.jpg combinedUVW + tex_address_mode clamp + tex_coord_set 1 + filtering linear linear linear + } + + } + + } +} + + +vertex_program HLSL/Ocean2VS hlsl +{ + source Ocean2HLSL_Cg.vert + entry_point main + target vs_1_1 + + + default_params + { + param_named_auto WorldViewProj worldviewproj_matrix + param_named_auto eyePosition camera_position_object_space + } +} + +fragment_program HLSL/Ocean2FS hlsl +{ + source Ocean2HLSL_Cg.frag + entry_point main + target ps_2_0 + +} + +vertex_program GLSL/Ocean2VS glsl +{ + source Ocean2GLSL.vert + +} + +fragment_program GLSL/Ocean2FS glsl +{ + source Ocean2GLSL.frag +} + +material Ocean2_HLSL_GLSL +{ + technique HLSL + { + pass + { + vertex_program_ref HLSL/Ocean2VS + { + param_named BumpScale float 0.2 + param_named textureScale float2 25 26 + param_named bumpSpeed float2 0.015 0.005 + param_named_auto time time_0_x 100.0 + param_named waveFreq float 0.028 + param_named waveAmp float 1.8 + } + + fragment_program_ref HLSL/Ocean2FS + { + param_named deepColor float4 0 0.3 0.5 1.0 + param_named shallowColor float4 0 1 1 1.0 + param_named reflectionColor float4 0.95 1 1 1.0 + param_named reflectionAmount float 1.0 + param_named reflectionBlur float 0.0 + param_named waterAmount float 0.3 + param_named fresnelPower float 5.0 + param_named fresnelBias float 0.328 + param_named hdrMultiplier float 0.471 + } + + texture_unit + { + texture waves2.dds + tex_coord_set 0 + filtering linear linear linear + } + + texture_unit + { + cubic_texture morning.jpg combinedUVW + tex_address_mode clamp + filtering linear linear linear + tex_coord_set 1 + } + + } + + } + + technique GLSL + { + pass + { + vertex_program_ref GLSL/Ocean2VS + { + param_named_auto eyePosition camera_position_object_space + param_named_auto time time_0_x 100.0 + param_named BumpScale float 0.2 + param_named textureScale float2 25 26 + param_named bumpSpeed float2 0.015 0.005 + param_named waveFreq float 0.028 + param_named waveAmp float 1.8 + } + + fragment_program_ref GLSL/Ocean2FS + { + param_named deepColor float4 0 0.3 0.5 1.0 + param_named shallowColor float4 0 1 1 1.0 + param_named reflectionColor float4 0.95 1 1 1.0 + param_named reflectionAmount float 1.0 + param_named reflectionBlur float 0.0 + param_named waterAmount float 0.3 + param_named fresnelPower float 5.0 + param_named fresnelBias float 0.328 + param_named hdrMultiplier float 0.471 + param_named NormalMap int 0 + param_named EnvironmentMap int 1 + } + + texture_unit + { + texture waves2.dds + tex_coord_set 0 + filtering linear linear linear + } + + texture_unit + { + cubic_texture morning.jpg combinedUVW + tex_address_mode clamp + tex_coord_set 1 + filtering linear linear linear + } + + } + + } +} + +material SkyBox +{ + technique + { + pass + { + lighting off + depth_write off + depth_check off + + texture_unit + { + cubic_texture morning.jpg separateUV + tex_address_mode clamp + } + } + } +} + +material LightFlare +{ + technique + { + pass + { + lighting off + scene_blend add + depth_write off + + texture_unit + { + texture flare.png + } + } + } +} + + diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/OffsetMapping.material b/school/informatik/verkerhssimulation/media/materials/scripts/OffsetMapping.material new file mode 100644 index 00000000..95f1c689 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/OffsetMapping.material @@ -0,0 +1,242 @@ +// Bump map with Parallax offset vertex program, support for this is required +vertex_program Examples/OffsetMappingVP cg +{ + source OffsetMapping.cg + entry_point main_vp + profiles vs_1_1 arbvp1 +} + +// Bump map with parallax fragment program +fragment_program Examples/OffsetMappingFP cg +{ + source OffsetMapping.cg + entry_point main_fp + profiles ps_2_0 arbfp1 +} + +// Bump map with parallax fragment program +fragment_program Examples/OffsetMappingPS asm +{ + source OffsetMapping_specular.asm + // sorry, only for ps_1_4 and above:) + syntax ps_1_4 +} + + +material Examples/OffsetMapping/Specular +{ + + // This is the preferred technique which uses both vertex and + // fragment programs, supports coloured lights + technique + { + // do the lighting and bump mapping with parallax pass + pass + { + + // Vertex program reference + vertex_program_ref Examples/OffsetMappingVP + { + param_named_auto lightPosition light_position_object_space 0 + param_named_auto eyePosition camera_position_object_space + param_named_auto worldViewProj worldviewproj_matrix + } + + // Fragment program + fragment_program_ref Examples/OffsetMappingFP + { + param_named_auto lightDiffuse light_diffuse_colour 0 + param_named_auto lightSpecular light_specular_colour 0 + // Parallax Height scale and bias + param_named scaleBias float4 0.04 -0.02 1 0 + } + + // Normal + height(alpha) map + texture_unit + { + texture rockwall_NH.tga + tex_coord_set 0 + } + + // Base diffuse texture map + texture_unit + { + texture rockwall.tga + tex_coord_set 1 + } + } + } + + + // This is the preferred technique which uses both vertex and + // fragment programs, supports coloured lights + technique + { + // do the lighting and bump mapping with parallax pass + pass + { + + // Vertex program reference + vertex_program_ref Examples/OffsetMappingVP + { + param_named_auto lightPosition light_position_object_space 0 + param_named_auto eyePosition camera_position_object_space + param_named_auto worldViewProj worldviewproj_matrix + } + + // Fragment program + fragment_program_ref Examples/OffsetMappingPS + { + param_indexed_auto 0 light_diffuse_colour 0 + param_indexed_auto 1 light_specular_colour 0 + // Parallax Height scale and bias + param_indexed 2 float4 0.04 -0.02 1 0 + } + + // Normal + height(alpha) map + texture_unit + { + texture rockwall_NH.tga + tex_coord_set 0 + } + + // Base diffuse texture map + texture_unit + { + texture rockwall.tga + tex_coord_set 1 + } + } + } + + // Simple no-shader fallback + technique + { + pass + { + // Base diffuse texture map + texture_unit + { + texture rockwall.tga + } + } + } + +} + + + +// Single-pass offset mapping with shadows +vertex_program Examples/OffsetMappingIntegratedShadowsVPhlsl hlsl +{ + source OffsetMapping.hlsl + entry_point integratedshadows_vp + target vs_2_0 +} +vertex_program Examples/OffsetMappingIntegratedShadowsVPglsl glsl +{ + source OffsetMappingVp.glsl +} + +// Single-pass offset mapping with shadows +fragment_program Examples/OffsetMappingIntegratedShadowsFPhlsl hlsl +{ + source OffsetMapping.hlsl + entry_point integratedshadows_fp + target ps_2_0 +} +fragment_program Examples/OffsetMappingIntegratedShadowsFPglsl glsl +{ + source OffsetMappingFp.glsl + default_params + { + // assign samplers as required by GLSL + param_named normalHeightMap int 0 + param_named diffuseMap int 1 + param_named shadowMap1 int 2 + param_named shadowMap2 int 3 + } +} +// Single-pass offset mapping with shadows +vertex_program Examples/OffsetMappingIntegratedShadowsVP unified +{ + delegate Examples/OffsetMappingIntegratedShadowsVPhlsl + delegate Examples/OffsetMappingIntegratedShadowsVPglsl +} +// Single-pass offset mapping with shadows +fragment_program Examples/OffsetMappingIntegratedShadowsFP unified +{ + delegate Examples/OffsetMappingIntegratedShadowsFPhlsl + delegate Examples/OffsetMappingIntegratedShadowsFPglsl +} + + + +material Examples/OffsetMapping/IntegratedShadows +{ + + technique + { + // do the lighting and bump mapping with parallax pass + pass + { + + // Vertex program reference + vertex_program_ref Examples/OffsetMappingIntegratedShadowsVP + { + param_named_auto lightPosition light_position_object_space 0 + param_named_auto eyePosition camera_position_object_space + param_named_auto worldViewProj worldviewproj_matrix + param_named_auto spotDirection light_direction_object_space 0 + + param_named_auto lightPosition1 light_position_object_space 1 + param_named_auto spotDirection1 light_direction_object_space 1 + // shadow texture projections + param_named_auto worldMatrix world_matrix + param_named_auto texViewProj1 texture_viewproj_matrix 0 + param_named_auto texViewProj2 texture_viewproj_matrix 1 + } + + // Fragment program + fragment_program_ref Examples/OffsetMappingIntegratedShadowsFP + { + param_named_auto lightDiffuse light_diffuse_colour 0 + param_named_auto spotParams spotlight_params 0 + + param_named_auto lightDiffuse1 light_diffuse_colour 1 + param_named_auto spotParams1 spotlight_params 1 + // Parallax Height scale and bias + param_named scaleBias float4 0.04 -0.02 1 0 + } + + // Normal + height(alpha) map + texture_unit + { + texture rockwall_NH.tga + tex_coord_set 0 + } + + // Base diffuse texture map + texture_unit + { + texture rockwall.tga + tex_coord_set 1 + } + + // shadowmap 1 + texture_unit + { + content_type shadow + } + // shadowmap 2 + texture_unit + { + content_type shadow + } + } + } + + + +} + diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/Ogre.material b/school/informatik/verkerhssimulation/media/materials/scripts/Ogre.material new file mode 100644 index 00000000..ccca82ef --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/Ogre.material @@ -0,0 +1,119 @@ + +material Ogre/Earring +{ + technique + { + pass + { + ambient 0.5 0.5 0 + diffuse 1 1 0 + + texture_unit + { + texture spheremap.png + colour_op_ex add src_texture src_current + colour_op_multipass_fallback one one + env_map spherical + } + } + } +} +material Ogre/Skin +{ + technique + { + pass + { + ambient 0.7 0.7 0.7 + cull_hardware none + + texture_unit + { + texture GreenSkin.jpg + tex_address_mode mirror + } + } + } +} +material Ogre/Tusks +{ + technique + { + pass + { + ambient 0.5 0.5 0.4 + diffuse 1 1 0.8 + + texture_unit + { + texture dirt01.jpg + colour_op_ex add src_texture src_current + colour_op_multipass_fallback one one + } + } + } +} +material Ogre/Eyes +{ + technique + { + pass + { + + texture_unit + { + texture WeirdEye.png + } + } + } +} +material Cursor/default +{ + technique + { + pass + { + scene_blend alpha_blend + + texture_unit + { + texture cursor.png + tex_address_mode clamp + } + } + } +} +material Core/StatsBlockBorder/Down +{ + technique + { + pass + { + lighting off + scene_blend alpha_blend + depth_check off + + texture_unit + { + texture ogreborder.png + } + } + } +} +material Core/StatsBlockBorder/Up +{ + technique + { + pass + { + lighting off + scene_blend alpha_blend + depth_check off + + texture_unit + { + texture ogreborderUp.png + } + } + } +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/OldMovie.material b/school/informatik/verkerhssimulation/media/materials/scripts/OldMovie.material new file mode 100644 index 00000000..a8d122e2 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/OldMovie.material @@ -0,0 +1,67 @@ +fragment_program Ogre/Compositor/OldMovieFP cg +{ + source OldMovieFP.cg + entry_point OldMovie_ps + profiles ps_2_0 arbfp1 +} + +material Ogre/Compositor/OldMovie +{ + technique + { + + pass + { + cull_hardware none + cull_software none + depth_func always_pass + + vertex_program_ref Ogre/Compositor/StdQuad_Tex2a_vp + { + } + + fragment_program_ref Ogre/Compositor/OldMovieFP + { + param_named_auto time_cycle_period time 20 + param_named flicker float 0.4 + param_named DirtFrequency float 0.0005 + param_named luminance float3 0.30 0.59 0.11 + param_named frameJitter float 0.004 + param_named lumiShift float 0.03 + } + + texture_unit RT + { + tex_coord_set 0 + tex_address_mode clamp + filtering trilinear + } + + texture_unit SplotchesTx + { + texture 8x8PagesSplotches2.png 2d + tex_coord_set 1 + tex_address_mode wrap + filtering trilinear + } + + texture_unit + { + texture 1D_Noise.png 1d + tex_coord_set 2 + tex_address_mode wrap + filtering point point none + } + + + texture_unit SepiaTx + { + texture Sepia1D.tga 1d + tex_coord_set 3 + tex_address_mode mirror + filtering point point none + } + + } + } +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/OldTV.material b/school/informatik/verkerhssimulation/media/materials/scripts/OldTV.material new file mode 100644 index 00000000..c4ba1911 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/OldTV.material @@ -0,0 +1,59 @@ +fragment_program Ogre/Compositor/OldTV_FP cg +{ + source OldTV.cg + entry_point OldTV_ps + profiles ps_2_0 arbfp1 +} + +material Ogre/Compositor/OldTV +{ + technique + { + + pass + { + depth_check off + + vertex_program_ref Ogre/Compositor/StdQuad_Tex2a_vp + { + } + + fragment_program_ref Ogre/Compositor/OldTV_FP + { + param_named_auto time_0_X time_0_x 120 + param_named_auto sin_time_0_X sintime_0_x 120 + + param_named distortionFreq float 2.7 + param_named distortionScale float 2.5 + param_named distortionRoll float 0.93 + param_named interference float 0.5 + param_named frameLimit float 0.40 + param_named frameShape float 0.26 + param_named frameSharpness float 6.0 + } + + texture_unit 0 + { + tex_coord_set 0 + tex_address_mode clamp + filtering linear linear linear + } + + texture_unit 1 + { + texture Random3D.dds 3d + tex_coord_set 1 + tex_address_mode wrap + filtering linear linear linear + } + + texture_unit 2 + { + texture NoiseVolume.dds 3d + tex_coord_set 2 + tex_address_mode wrap + filtering linear linear linear + } + } + } +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/Posterize.material b/school/informatik/verkerhssimulation/media/materials/scripts/Posterize.material new file mode 100644 index 00000000..eab44fc0 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/Posterize.material @@ -0,0 +1,36 @@ +fragment_program Ogre/Compositor/PosterizeFP cg +{ + source PosterizeFP.cg + entry_point Posterize_ps + profiles ps_2_0 arbfp1 +} + +material Ogre/Compositor/Posterize +{ + technique + { + + pass + { + cull_hardware none + cull_software none + depth_func always_pass + + vertex_program_ref Ogre/Compositor/StdQuad_Tex2a_vp + { + } + + fragment_program_ref Ogre/Compositor/PosterizeFP + { + } + + texture_unit RT + { + tex_coord_set 0 + tex_address_mode clamp + filtering trilinear + } + + } + } +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/RZR-002.material b/school/informatik/verkerhssimulation/media/materials/scripts/RZR-002.material new file mode 100644 index 00000000..4b2dcc10 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/RZR-002.material @@ -0,0 +1,15 @@ + +material RZR-002 +{ + technique + { + pass + { + + texture_unit + { + texture RZR-002.png + } + } + } +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/SharpenEdges.material b/school/informatik/verkerhssimulation/media/materials/scripts/SharpenEdges.material new file mode 100644 index 00000000..c4ddb699 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/SharpenEdges.material @@ -0,0 +1,60 @@ +fragment_program Ogre/Compositor/SharpenEdgesFP_cg cg +{ + source SharpenEdgesFP.cg + entry_point sharpenEdges_fp + profiles ps_2_0 arbfp1 +} + +fragment_program Ogre/Compositor/SharpenEdgesFP_ps_2_a hlsl +{ + source SharpenEdgesFP.cg + entry_point sharpenEdges_fp + target ps_2_a +} + +fragment_program Ogre/Compositor/SharpenEdgesFP unified +{ + delegate Ogre/Compositor/SharpenEdgesFP_ps_2_a + delegate Ogre/Compositor/SharpenEdgesFP_cg + + default_params + { + param_named_auto vTexelSize inverse_texture_size 0 + } +} + +material Ogre/Compositor/SharpenEdges +{ + technique + { + + pass + { + cull_hardware none + cull_software none + depth_func always_pass + + //DirectX 9.0 HLSL Vertex Shader vs_1_1 + //vertex_program_ref PostFilters/SharpenEdgesVP + //{ + //} + + vertex_program_ref Ogre/Compositor/StdQuad_Tex2a_vp + { + } + + //DirectX 9.0 HLSL Pixel Shader ps_2_0 + fragment_program_ref Ogre/Compositor/SharpenEdgesFP + { + } + + texture_unit + { + tex_coord_set 0 + tex_address_mode clamp + filtering trilinear + } + + } + } +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/StdQuad_vp.program b/school/informatik/verkerhssimulation/media/materials/scripts/StdQuad_vp.program new file mode 100644 index 00000000..9fbab1cd --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/StdQuad_vp.program @@ -0,0 +1,71 @@ +vertex_program Ogre/Compositor/StdQuad_Cg_vp cg +{ + source StdQuad_vp.cg + entry_point StdQuad_vp + profiles vs_1_1 arbvp1 + + default_params + { + param_named_auto worldViewProj worldviewproj_matrix + } +} + +vertex_program Ogre/Compositor/StdQuad_Tex2_vp cg +{ + source StdQuad_vp.cg + entry_point StdQuad_Tex2_vp + profiles vs_1_1 arbvp1 + + default_params + { + param_named_auto worldViewProj worldviewproj_matrix + } +} + +vertex_program Ogre/Compositor/StdQuad_Tex2a_vp cg +{ + source StdQuad_vp.cg + entry_point StdQuad_Tex2a_vp + profiles vs_1_1 arbvp1 + + default_params + { + param_named_auto worldViewProj worldviewproj_matrix + } +} + +vertex_program Ogre/Compositor/StdQuad_Tex3_vp cg +{ + source StdQuad_vp.cg + entry_point StdQuad_Tex3_vp + profiles vs_1_1 arbvp1 + + default_params + { + param_named_auto worldViewProj worldviewproj_matrix + } +} + +vertex_program Ogre/Compositor/StdQuad_Tex4_vp cg +{ + source StdQuad_vp.cg + entry_point StdQuad_Tex4_vp + profiles vs_1_1 arbvp1 + + default_params + { + param_named_auto worldViewProj worldviewproj_matrix + } +} + +vertex_program Ogre/Compositor/StdQuad_GLSL_vp glsl +{ + source StdQuad_vp.glsl +} + + +vertex_program Ogre/Compositor/StdQuad_vp unified +{ + delegate Ogre/Compositor/StdQuad_GLSL_vp + delegate Ogre/Compositor/StdQuad_Cg_vp +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/Tiling.material b/school/informatik/verkerhssimulation/media/materials/scripts/Tiling.material new file mode 100644 index 00000000..05181381 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/Tiling.material @@ -0,0 +1,39 @@ +fragment_program Ogre/Compositor/TilingFP cg +{ + source TilingFP.cg + entry_point Tiling_ps + profiles ps_2_0 arbfp1 +} + +material Ogre/Compositor/Tiling +{ + technique + { + + pass + { + cull_hardware none + cull_software none + depth_func always_pass + + vertex_program_ref Ogre/Compositor/StdQuad_Tex2a_vp + { + } + + //DirectX 9.0 HLSL Pixel Shader ps_2_0 + fragment_program_ref Ogre/Compositor/TilingFP + { + param_named NumTiles float 75.0 + param_named Threshhold float 0.15 + } + + texture_unit RT + { + tex_coord_set 0 + tex_address_mode clamp + filtering trilinear + } + + } + } +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/VarianceShadowmap.material b/school/informatik/verkerhssimulation/media/materials/scripts/VarianceShadowmap.material new file mode 100644 index 00000000..16d9e594 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/VarianceShadowmap.material @@ -0,0 +1,103 @@ + +// Shadow Caster __________________________________________________ + + +vertex_program VarianceShadowMapping/ShadowCasterVP cg +{ + source varianceshadowcastervp.cg + entry_point main + profiles arbvp1 vs_2_x + + default_params + { + param_named_auto uModelViewProjection worldviewproj_matrix + } +} + +fragment_program VarianceShadowMapping/ShadowCasterFP cg +{ + source varianceshadowcasterfp.cg + entry_point main + profiles arbfp1 ps_2_x + + default_params + { + param_named uDepthOffset float 1.0 + param_named_auto uProjection projection_matrix + } +} + +material VarianceShadowMapping/ShadowCaster +{ + technique default + { + // Z-write only pass + pass Z-write + { + //Instead of using depth_bias, we'll be implementing it manually + + vertex_program_ref VarianceShadowMapping/ShadowCasterVP + { + } + fragment_program_ref VarianceShadowMapping/ShadowCasterFP + { + } + } + } +} + + + +// Shadow Receiver ________________________________________________ + +vertex_program VarianceShadowMapping/ShadowReceiverVP cg +{ + source varianceshadowreceivervp.cg + entry_point main + profiles arbvp1 vs_2_x + + default_params + { + param_named_auto uModelViewProjection worldviewproj_matrix + param_named_auto uLightPosition light_position_object_space 0 + param_named_auto uModel world_matrix + param_named_auto uTextureViewProjection texture_viewproj_matrix + } +} + +fragment_program VarianceShadowMapping/ShadowReceiverFP cg +{ + source varianceshadowreceiverfp.cg + entry_point main + profiles arbfp1 ps_2_x + + default_params + { + param_named uSTexWidth float 512.0 + param_named uSTexHeight float 512.0 + } +} + +material VarianceShadowMapping/ShadowReceiver +{ + technique default + { + pass lighting + { + vertex_program_ref VarianceShadowMapping/ShadowReceiverVP + { + } + + fragment_program_ref VarianceShadowMapping/ShadowReceiverFP + { + } + + // we won't rely on hardware specific filtering of z-tests + texture_unit ShadowMap + { + tex_address_mode clamp + filtering none + } + } + } +} diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/facial.material b/school/informatik/verkerhssimulation/media/materials/scripts/facial.material new file mode 100644 index 00000000..c0324742 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/facial.material @@ -0,0 +1,85 @@ + +material drbunsen_head +{ + technique + { + pass + { + ambient 0.25 0.25 0.25 + diffuse 1.0 1.0 1.0 + + texture_unit + { + texture Dr_Bunsen_Head.jpg + } + } + } +} + +material drbunsen_teeth +{ + technique + { + pass + { + ambient 0.25 0.25 0.25 + diffuse 1.0 1.0 1.0 + + } + } +} + +material drbunsen_tongue +{ + technique + { + pass + { + ambient 0.25 0.25 0.25 + diffuse 1.0 0.1 0.1 + + } + } +} + +material drbunsen_gums +{ + technique + { + pass + { + ambient 0.25 0.25 0.25 + diffuse 1.0 0.1 0.1 + + } + } +} + +material drbunsen_glasses +{ + technique + { + pass + { + depth_write off + scene_blend modulate + ambient 0.25 0.25 0.25 + diffuse 0.75 0.75 0.75 + + } + } +} + +material drbunsen_glasses_frame +{ + technique + { + pass + { + ambient 0.25 0.25 0.25 + diffuse 0.35 0.18 0 1 + + } + } +} + diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/hdr.material b/school/informatik/verkerhssimulation/media/materials/scripts/hdr.material new file mode 100644 index 00000000..97304765 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/hdr.material @@ -0,0 +1,286 @@ +// Downsample a 2x2 area & turn into luminence (unclamped) +fragment_program Ogre/Compositor/HDR/downscale2x2LuminenceHLSL_fp hlsl +{ + source hdr.hlsl + entry_point downscale2x2Luminence + target ps_2_0 +} +fragment_program Ogre/Compositor/HDR/downscale2x2LuminenceGLSL_fp glsl +{ + source hdr_downscale2x2luminence.glsl + default_params + { + param_named inRTT int 0 + } +} +fragment_program Ogre/Compositor/HDR/downscale2x2Luminence_fp unified +{ + delegate Ogre/Compositor/HDR/downscale2x2LuminenceGLSL_fp + delegate Ogre/Compositor/HDR/downscale2x2LuminenceHLSL_fp + default_params + { + param_named_auto texelSize inverse_texture_size 0 + } +} + +material Ogre/Compositor/HDR/Downsample2x2Luminence +{ + technique + { + pass + { + cull_hardware none + cull_software none + depth_check off + + vertex_program_ref Ogre/Compositor/StdQuad_vp + { + } + fragment_program_ref Ogre/Compositor/HDR/downscale2x2Luminence_fp + { + } + + texture_unit + { + tex_coord_set 0 + tex_address_mode clamp + filtering none + } + } + } +} + +// Downsample a 3x3 area +fragment_program Ogre/Compositor/HDR/downscale3x3HLSL_fp hlsl +{ + source hdr.hlsl + entry_point downscale3x3 + target ps_2_0 +} +fragment_program Ogre/Compositor/HDR/downscale3x3GLSL_fp glsl +{ + source hdr_downscale3x3.glsl + default_params + { + param_named inRTT int 0 + } +} +fragment_program Ogre/Compositor/HDR/downscale3x3_fp unified +{ + delegate Ogre/Compositor/HDR/downscale3x3GLSL_fp + delegate Ogre/Compositor/HDR/downscale3x3HLSL_fp + default_params + { + param_named_auto texelSize inverse_texture_size 0 + } +} + + +material Ogre/Compositor/HDR/Downsample3x3 +{ + technique + { + pass + { + cull_hardware none + cull_software none + depth_check off + + vertex_program_ref Ogre/Compositor/StdQuad_vp + { + } + fragment_program_ref Ogre/Compositor/HDR/downscale3x3_fp + { + } + + texture_unit + { + tex_coord_set 0 + tex_address_mode clamp + filtering none + } + } + } +} + +// Downsample a 3x3 area and perform a brightness filter pass +fragment_program Ogre/Compositor/HDR/downscale3x3brightpassHLSL_fp hlsl +{ + source hdr.hlsl + entry_point downscale3x3brightpass + target ps_2_0 +} +fragment_program Ogre/Compositor/HDR/utils_fp glsl +{ + source hdr_tonemap_util.glsl +} +fragment_program Ogre/Compositor/HDR/downscale3x3brightpassGLSL_fp glsl +{ + source hdr_downscale3x3brightpass.glsl + // re-use common functions + attach Ogre/Compositor/HDR/utils_fp + default_params + { + param_named inRTT int 0 + param_named inLum int 1 + } +} +fragment_program Ogre/Compositor/HDR/downscale3x3brightpass_fp unified +{ + delegate Ogre/Compositor/HDR/downscale3x3brightpassGLSL_fp + delegate Ogre/Compositor/HDR/downscale3x3brightpassHLSL_fp + default_params + { + param_named_auto texelSize inverse_texture_size 0 + } +} + + +material Ogre/Compositor/HDR/Downsample3x3Brightpass +{ + technique + { + pass + { + cull_hardware none + cull_software none + depth_check off + + vertex_program_ref Ogre/Compositor/StdQuad_vp + { + } + fragment_program_ref Ogre/Compositor/HDR/downscale3x3brightpass_fp + { + } + + // Scene + texture_unit + { + tex_coord_set 0 + tex_address_mode clamp + filtering none + } + // Luminence + texture_unit + { + tex_address_mode clamp + filtering none + } + } + } +} + +// Bloom an area using gaussian distribution +fragment_program Ogre/Compositor/HDR/bloomHLSL_fp hlsl +{ + source hdr.hlsl + entry_point bloom + target ps_2_0 +} +fragment_program Ogre/Compositor/HDR/bloomGLSL_fp glsl +{ + source hdr_bloom.glsl + default_params + { + param_named inRTT int 0 + } +} +fragment_program Ogre/Compositor/HDR/bloom_fp unified +{ + delegate Ogre/Compositor/HDR/bloomGLSL_fp + delegate Ogre/Compositor/HDR/bloomHLSL_fp +} + + +material Ogre/Compositor/HDR/GaussianBloom +{ + technique + { + pass + { + cull_hardware none + cull_software none + depth_check off + + vertex_program_ref Ogre/Compositor/StdQuad_vp + { + } + fragment_program_ref Ogre/Compositor/HDR/bloom_fp + { + } + + // Input + texture_unit + { + tex_coord_set 0 + tex_address_mode clamp + filtering none + } + } + } +} + + +// Perform final tone mapping +fragment_program Ogre/Compositor/HDR/finaltonemappingHLSL_fp hlsl +{ + source hdr.hlsl + entry_point finalToneMapping + target ps_2_0 +} +fragment_program Ogre/Compositor/HDR/finaltonemappingGLSL_fp glsl +{ + source hdr_finalToneMapping.glsl + // re-use common functions + attach Ogre/Compositor/HDR/utils_fp + default_params + { + param_named inRTT int 0 + param_named inBloom int 1 + param_named inLum int 2 + } +} +fragment_program Ogre/Compositor/HDR/finaltonemapping_fp unified +{ + delegate Ogre/Compositor/HDR/finaltonemappingHLSL_fp + delegate Ogre/Compositor/HDR/finaltonemappingGLSL_fp +} + +material Ogre/Compositor/HDR/ToneMapping +{ + technique + { + pass + { + cull_hardware none + cull_software none + depth_check off + + vertex_program_ref Ogre/Compositor/StdQuad_vp + { + } + fragment_program_ref Ogre/Compositor/HDR/finaltonemapping_fp + { + } + + // Scene + texture_unit + { + tex_coord_set 0 + tex_address_mode clamp + } + // Bloom + texture_unit + { + tex_address_mode clamp + } + // Luminence + texture_unit + { + tex_address_mode clamp + } + } + } +} + + diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/instancing.material b/school/informatik/verkerhssimulation/media/materials/scripts/instancing.material new file mode 100644 index 00000000..80c3a1f3 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/instancing.material @@ -0,0 +1,131 @@ + +vertex_program InstancingCg cg +{ + source instancing.cg + profiles vs_2_0 + entry_point instancing_vp + + default_params + { + param_named_auto ambient ambient_light_colour + param_named_auto lightDiffuseColour light_diffuse_colour 0 + param_named_auto lightPos light_position 0 + param_named_auto viewProjectionMatrix viewproj_matrix + param_named_auto worldMatrix3x4Array world_matrix_array_3x4 + } +} +vertex_program InstancingShadowCasterCg cg +{ + source instancing.cg + profiles vs_2_0 + entry_point instancingCaster_vp + default_params + { + param_named_auto ambient ambient_light_colour + param_named_auto viewProjectionMatrix viewproj_matrix + param_named_auto worldMatrix3x4Array world_matrix_array_3x4 + } +} +vertex_program CrowdCg cg +{ + source instancing.cg + profiles vs_2_0 + entry_point crowd_vp + default_params + { + param_named_auto viewProjectionMatrix viewproj_matrix + param_named_auto numBones custom 0 + param_named_auto worldMatrix3x4Array world_matrix_array_3x4 + param_named_auto lightPos light_position 0 + param_named_auto lightDiffuseColour light_diffuse_colour 0 + param_named_auto ambient ambient_light_colour + } +} +vertex_program CrowdShadowCasterCg cg +{ + source instancing.cg + profiles vs_2_0 + entry_point crowdCaster_vp + default_params + { + param_named_auto viewProjectionMatrix viewproj_matrix + param_named_auto numBones custom 0 + param_named_auto worldMatrix3x4Array world_matrix_array_3x4 + param_named_auto ambient ambient_light_colour + } +} + + +vertex_program InstancingGLSL glsl +{ + source instancingVp.glsl + preprocessor_defines SHADOW_CASTER=0 + default_params + { + param_named_auto ambient ambient_light_colour + param_named_auto lightDiffuseColour light_diffuse_colour 0 + param_named_auto lightPos light_position 0 + param_named_auto viewProjectionMatrix viewproj_matrix + param_named_auto worldMatrix3x4Array world_matrix_array_3x4 + } +} +vertex_program InstancingShadowCasterGLSL glsl +{ + source instancingVp.glsl + preprocessor_defines SHADOW_CASTER=1 + default_params + { + param_named_auto ambient ambient_light_colour + param_named_auto viewProjectionMatrix viewproj_matrix + param_named_auto worldMatrix3x4Array world_matrix_array_3x4 + } +} +vertex_program CrowdGLSL glsl +{ + source crowdVp.glsl + preprocessor_defines SHADOW_CASTER=0 + default_params + { + param_named_auto viewProjectionMatrix viewproj_matrix + param_named_auto numBones custom 0 + param_named_auto worldMatrix3x4Array world_matrix_array_3x4 + param_named_auto lightPos light_position 0 + param_named_auto lightDiffuseColour light_diffuse_colour 0 + param_named_auto ambient ambient_light_colour + } +} +vertex_program CrowdShadowCasterGLSL glsl +{ + source crowdVp.glsl + preprocessor_defines SHADOW_CASTER=1 + default_params + { + param_named_auto viewProjectionMatrix viewproj_matrix + param_named_auto numBones custom 0 + param_named_auto worldMatrix3x4Array world_matrix_array_3x4 + param_named_auto ambient ambient_light_colour + } +} + + +vertex_program Instancing unified +{ + delegate InstancingGLSL + delegate InstancingCg +} +vertex_program InstancingShadowCaster unified +{ + delegate InstancingShadowCasterGLSL + delegate InstancingShadowCasterCg +} +vertex_program Crowd unified +{ + delegate CrowdGLSL + delegate CrowdCg +} +vertex_program CrowdShadowCaster unified +{ + delegate CrowdShadowCasterGLSL + delegate CrowdShadowCasterCg +} + diff --git a/school/informatik/verkerhssimulation/media/materials/scripts/smoke.material b/school/informatik/verkerhssimulation/media/materials/scripts/smoke.material new file mode 100644 index 00000000..2eb8eb04 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/materials/scripts/smoke.material @@ -0,0 +1,19 @@ + +material Examples/Smoke +{ + technique + { + pass + { + lighting off + scene_blend alpha_blend + depth_write off + + texture_unit + { + texture smoke.png + tex_address_mode clamp + } + } + } +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/media/materials/textures/10points.png b/school/informatik/verkerhssimulation/media/materials/textures/10points.png new file mode 100644 index 00000000..a932146c Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/10points.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/1D_Noise.png b/school/informatik/verkerhssimulation/media/materials/textures/1D_Noise.png new file mode 100644 index 00000000..d03ed1ee Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/1D_Noise.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/1D_Noise2.png b/school/informatik/verkerhssimulation/media/materials/textures/1D_Noise2.png new file mode 100644 index 00000000..9dfd6f84 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/1D_Noise2.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/8x8PagesSplotches2.png b/school/informatik/verkerhssimulation/media/materials/textures/8x8PagesSplotches2.png new file mode 100644 index 00000000..6a6b1051 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/8x8PagesSplotches2.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/BeachStones.jpg b/school/informatik/verkerhssimulation/media/materials/textures/BeachStones.jpg new file mode 100644 index 00000000..faaa16fe Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/BeachStones.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/BumpyMetal.jpg b/school/informatik/verkerhssimulation/media/materials/textures/BumpyMetal.jpg new file mode 100644 index 00000000..8229c0d8 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/BumpyMetal.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/Chrome.jpg b/school/informatik/verkerhssimulation/media/materials/textures/Chrome.jpg new file mode 100644 index 00000000..0ae5c526 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/Chrome.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/Dirt.jpg b/school/informatik/verkerhssimulation/media/materials/textures/Dirt.jpg new file mode 100644 index 00000000..8b74a42f Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/Dirt.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/Dr_Bunsen_Head.jpg b/school/informatik/verkerhssimulation/media/materials/textures/Dr_Bunsen_Head.jpg new file mode 100644 index 00000000..3ef969d7 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/Dr_Bunsen_Head.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/GLX_icon.png b/school/informatik/verkerhssimulation/media/materials/textures/GLX_icon.png new file mode 100644 index 00000000..a13699be Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/GLX_icon.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/GreenSkin.jpg b/school/informatik/verkerhssimulation/media/materials/textures/GreenSkin.jpg new file mode 100644 index 00000000..435dddb1 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/GreenSkin.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/HeatLookup.tga b/school/informatik/verkerhssimulation/media/materials/textures/HeatLookup.tga new file mode 100644 index 00000000..e45ec53e Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/HeatLookup.tga differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/HeatNoise.tga b/school/informatik/verkerhssimulation/media/materials/textures/HeatNoise.tga new file mode 100644 index 00000000..159e3620 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/HeatNoise.tga differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/MtlPlat2.jpg b/school/informatik/verkerhssimulation/media/materials/textures/MtlPlat2.jpg new file mode 100644 index 00000000..778aad44 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/MtlPlat2.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/NMBalls.png b/school/informatik/verkerhssimulation/media/materials/textures/NMBalls.png new file mode 100644 index 00000000..74f02e37 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/NMBalls.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/NMBumpsOut.png b/school/informatik/verkerhssimulation/media/materials/textures/NMBumpsOut.png new file mode 100644 index 00000000..b5ef61e5 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/NMBumpsOut.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/NMHollyBumps.png b/school/informatik/verkerhssimulation/media/materials/textures/NMHollyBumps.png new file mode 100644 index 00000000..ac91b020 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/NMHollyBumps.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/NMStripes.png b/school/informatik/verkerhssimulation/media/materials/textures/NMStripes.png new file mode 100644 index 00000000..40781621 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/NMStripes.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/NPRMetallic.tga b/school/informatik/verkerhssimulation/media/materials/textures/NPRMetallic.tga new file mode 100644 index 00000000..6649a6fb Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/NPRMetallic.tga differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/NoiseVolume.dds b/school/informatik/verkerhssimulation/media/materials/textures/NoiseVolume.dds new file mode 100644 index 00000000..bd8147d4 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/NoiseVolume.dds differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/RZR-002.png b/school/informatik/verkerhssimulation/media/materials/textures/RZR-002.png new file mode 100644 index 00000000..663eb05d Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/RZR-002.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/Random3D.dds b/school/informatik/verkerhssimulation/media/materials/textures/Random3D.dds new file mode 100644 index 00000000..08b61959 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/Random3D.dds differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/RustedMetal.jpg b/school/informatik/verkerhssimulation/media/materials/textures/RustedMetal.jpg new file mode 100644 index 00000000..070346d3 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/RustedMetal.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/RustyBarrel.png b/school/informatik/verkerhssimulation/media/materials/textures/RustyBarrel.png new file mode 100644 index 00000000..8448a8e7 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/RustyBarrel.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/RustySteel.jpg b/school/informatik/verkerhssimulation/media/materials/textures/RustySteel.jpg new file mode 100644 index 00000000..a2d7b9df Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/RustySteel.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/Sepia1D.tga b/school/informatik/verkerhssimulation/media/materials/textures/Sepia1D.tga new file mode 100644 index 00000000..dcc42620 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/Sepia1D.tga differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/Water01.jpg b/school/informatik/verkerhssimulation/media/materials/textures/Water01.jpg new file mode 100644 index 00000000..4ebc501b Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/Water01.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/Water02.jpg b/school/informatik/verkerhssimulation/media/materials/textures/Water02.jpg new file mode 100644 index 00000000..3efda7b6 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/Water02.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/WaterNormal1.tga b/school/informatik/verkerhssimulation/media/materials/textures/WaterNormal1.tga new file mode 100644 index 00000000..a9ca11b7 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/WaterNormal1.tga differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/WaterNormal2.tga b/school/informatik/verkerhssimulation/media/materials/textures/WaterNormal2.tga new file mode 100644 index 00000000..771d1504 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/WaterNormal2.tga differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/WeirdEye.png b/school/informatik/verkerhssimulation/media/materials/textures/WeirdEye.png new file mode 100644 index 00000000..13401729 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/WeirdEye.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/WoodPallet.png b/school/informatik/verkerhssimulation/media/materials/textures/WoodPallet.png new file mode 100644 index 00000000..7727d71a Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/WoodPallet.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/atheneNormalMap.png b/school/informatik/verkerhssimulation/media/materials/textures/atheneNormalMap.png new file mode 100644 index 00000000..00dbf15e Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/atheneNormalMap.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/aureola.png b/school/informatik/verkerhssimulation/media/materials/textures/aureola.png new file mode 100644 index 00000000..deab82cc Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/aureola.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/basic_droplet.png b/school/informatik/verkerhssimulation/media/materials/textures/basic_droplet.png new file mode 100644 index 00000000..27ca8e8a Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/basic_droplet.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/blue_jaiqua.jpg b/school/informatik/verkerhssimulation/media/materials/textures/blue_jaiqua.jpg new file mode 100644 index 00000000..6016e140 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/blue_jaiqua.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/cel_shading_diffuse.png b/school/informatik/verkerhssimulation/media/materials/textures/cel_shading_diffuse.png new file mode 100644 index 00000000..9cd4efbb Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/cel_shading_diffuse.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/cel_shading_edge.png b/school/informatik/verkerhssimulation/media/materials/textures/cel_shading_edge.png new file mode 100644 index 00000000..9cc118ab Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/cel_shading_edge.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/cel_shading_specular.png b/school/informatik/verkerhssimulation/media/materials/textures/cel_shading_specular.png new file mode 100644 index 00000000..9cc118ab Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/cel_shading_specular.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/clouds.jpg b/school/informatik/verkerhssimulation/media/materials/textures/clouds.jpg new file mode 100644 index 00000000..3d37e8e0 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/clouds.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/cursor.png b/school/informatik/verkerhssimulation/media/materials/textures/cursor.png new file mode 100644 index 00000000..3d1c756c Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/cursor.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/dirt01.jpg b/school/informatik/verkerhssimulation/media/materials/textures/dirt01.jpg new file mode 100644 index 00000000..7c7cc5eb Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/dirt01.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/dkyellow.png b/school/informatik/verkerhssimulation/media/materials/textures/dkyellow.png new file mode 100644 index 00000000..88c1d647 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/dkyellow.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/droplet.png b/school/informatik/verkerhssimulation/media/materials/textures/droplet.png new file mode 100644 index 00000000..f1cfc4a8 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/droplet.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/egyptrockyfull.jpg b/school/informatik/verkerhssimulation/media/materials/textures/egyptrockyfull.jpg new file mode 100644 index 00000000..044ce9f1 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/egyptrockyfull.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/flare.png b/school/informatik/verkerhssimulation/media/materials/textures/flare.png new file mode 100644 index 00000000..9f8a2a84 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/flare.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/flaretrail.png b/school/informatik/verkerhssimulation/media/materials/textures/flaretrail.png new file mode 100644 index 00000000..34d4bf2b Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/flaretrail.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/fw12b.jpg b/school/informatik/verkerhssimulation/media/materials/textures/fw12b.jpg new file mode 100644 index 00000000..98006054 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/fw12b.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/gras_02.png b/school/informatik/verkerhssimulation/media/materials/textures/gras_02.png new file mode 100644 index 00000000..1110724c Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/gras_02.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/grass_1024.jpg b/school/informatik/verkerhssimulation/media/materials/textures/grass_1024.jpg new file mode 100644 index 00000000..e65691b3 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/grass_1024.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/nm_bk.png b/school/informatik/verkerhssimulation/media/materials/textures/nm_bk.png new file mode 100644 index 00000000..65998a43 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/nm_bk.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/nm_dn.png b/school/informatik/verkerhssimulation/media/materials/textures/nm_dn.png new file mode 100644 index 00000000..2b50b027 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/nm_dn.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/nm_fr.png b/school/informatik/verkerhssimulation/media/materials/textures/nm_fr.png new file mode 100644 index 00000000..9df5d04b Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/nm_fr.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/nm_lf.png b/school/informatik/verkerhssimulation/media/materials/textures/nm_lf.png new file mode 100644 index 00000000..28606136 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/nm_lf.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/nm_rt.png b/school/informatik/verkerhssimulation/media/materials/textures/nm_rt.png new file mode 100644 index 00000000..9d0d5717 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/nm_rt.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/nm_up.png b/school/informatik/verkerhssimulation/media/materials/textures/nm_up.png new file mode 100644 index 00000000..670f8fc4 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/nm_up.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/normalNoiseColor.png b/school/informatik/verkerhssimulation/media/materials/textures/normalNoiseColor.png new file mode 100644 index 00000000..fc5f77bf Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/normalNoiseColor.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/nskingr.jpg b/school/informatik/verkerhssimulation/media/materials/textures/nskingr.jpg new file mode 100644 index 00000000..9397f5d9 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/nskingr.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/ogreborder.png b/school/informatik/verkerhssimulation/media/materials/textures/ogreborder.png new file mode 100644 index 00000000..9cc0d9da Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/ogreborder.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/ogreborderUp.png b/school/informatik/verkerhssimulation/media/materials/textures/ogreborderUp.png new file mode 100644 index 00000000..d1ee4a6b Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/ogreborderUp.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/ogrebordercenter.png b/school/informatik/verkerhssimulation/media/materials/textures/ogrebordercenter.png new file mode 100644 index 00000000..c62c02af Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/ogrebordercenter.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/ogregui.tga b/school/informatik/verkerhssimulation/media/materials/textures/ogregui.tga new file mode 100644 index 00000000..74f5efda Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/ogregui.tga differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/ogrelogo-small.jpg b/school/informatik/verkerhssimulation/media/materials/textures/ogrelogo-small.jpg new file mode 100644 index 00000000..9cee6474 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/ogrelogo-small.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/ogrelogo.png b/school/informatik/verkerhssimulation/media/materials/textures/ogrelogo.png new file mode 100644 index 00000000..1bc19755 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/ogrelogo.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/perlinvolume.dds b/school/informatik/verkerhssimulation/media/materials/textures/perlinvolume.dds new file mode 100644 index 00000000..bd8147d4 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/perlinvolume.dds differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/r2skin.jpg b/school/informatik/verkerhssimulation/media/materials/textures/r2skin.jpg new file mode 100644 index 00000000..3e83a124 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/r2skin.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/ribbonband.png b/school/informatik/verkerhssimulation/media/materials/textures/ribbonband.png new file mode 100644 index 00000000..e6966640 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/ribbonband.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/rockwall.tga b/school/informatik/verkerhssimulation/media/materials/textures/rockwall.tga new file mode 100644 index 00000000..5703a03a Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/rockwall.tga differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/rockwall_NH.tga b/school/informatik/verkerhssimulation/media/materials/textures/rockwall_NH.tga new file mode 100644 index 00000000..12fa50bd Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/rockwall_NH.tga differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/scr-back.png b/school/informatik/verkerhssimulation/media/materials/textures/scr-back.png new file mode 100644 index 00000000..05cf8012 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/scr-back.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/scr-down-p.png b/school/informatik/verkerhssimulation/media/materials/textures/scr-down-p.png new file mode 100644 index 00000000..31b575ea Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/scr-down-p.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/scr-down.png b/school/informatik/verkerhssimulation/media/materials/textures/scr-down.png new file mode 100644 index 00000000..d52b5475 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/scr-down.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/scr-thumb.png b/school/informatik/verkerhssimulation/media/materials/textures/scr-thumb.png new file mode 100644 index 00000000..8f05cc72 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/scr-thumb.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/scr-up-p.png b/school/informatik/verkerhssimulation/media/materials/textures/scr-up-p.png new file mode 100644 index 00000000..b9b45dcb Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/scr-up-p.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/scr-up.png b/school/informatik/verkerhssimulation/media/materials/textures/scr-up.png new file mode 100644 index 00000000..1e0f9b46 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/scr-up.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/smoke.png b/school/informatik/verkerhssimulation/media/materials/textures/smoke.png new file mode 100644 index 00000000..002a062b Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/smoke.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/smokecolors.png b/school/informatik/verkerhssimulation/media/materials/textures/smokecolors.png new file mode 100644 index 00000000..d8ab9bd1 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/smokecolors.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/snow_1024.jpg b/school/informatik/verkerhssimulation/media/materials/textures/snow_1024.jpg new file mode 100644 index 00000000..56590af4 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/snow_1024.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/spacesky.jpg b/school/informatik/verkerhssimulation/media/materials/textures/spacesky.jpg new file mode 100644 index 00000000..a7e0c570 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/spacesky.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/spheremap.png b/school/informatik/verkerhssimulation/media/materials/textures/spheremap.png new file mode 100644 index 00000000..e6b91475 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/spheremap.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/steelhead.png b/school/informatik/verkerhssimulation/media/materials/textures/steelhead.png new file mode 100644 index 00000000..4c2ba370 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/steelhead.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/terr_dirt-grass.jpg b/school/informatik/verkerhssimulation/media/materials/textures/terr_dirt-grass.jpg new file mode 100644 index 00000000..001bd3e7 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/terr_dirt-grass.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/terr_rock-dirt.jpg b/school/informatik/verkerhssimulation/media/materials/textures/terr_rock-dirt.jpg new file mode 100644 index 00000000..6fda5c7c Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/terr_rock-dirt.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/terr_rock6.jpg b/school/informatik/verkerhssimulation/media/materials/textures/terr_rock6.jpg new file mode 100644 index 00000000..3100ed74 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/terr_rock6.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/terrain.png b/school/informatik/verkerhssimulation/media/materials/textures/terrain.png new file mode 100644 index 00000000..16e853fe Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/terrain.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/terrain_detail.jpg b/school/informatik/verkerhssimulation/media/materials/textures/terrain_detail.jpg new file mode 100644 index 00000000..981e37e6 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/terrain_detail.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/terrain_texture.jpg b/school/informatik/verkerhssimulation/media/materials/textures/terrain_texture.jpg new file mode 100644 index 00000000..8d4fda5a Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/terrain_texture.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/texmap2.jpg b/school/informatik/verkerhssimulation/media/materials/textures/texmap2.jpg new file mode 100644 index 00000000..792da7fb Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/texmap2.jpg differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/waveNM.png b/school/informatik/verkerhssimulation/media/materials/textures/waveNM.png new file mode 100644 index 00000000..766e2e73 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/waveNM.png differ diff --git a/school/informatik/verkerhssimulation/media/materials/textures/waves2.dds b/school/informatik/verkerhssimulation/media/materials/textures/waves2.dds new file mode 100644 index 00000000..c379886f Binary files /dev/null and b/school/informatik/verkerhssimulation/media/materials/textures/waves2.dds differ diff --git a/school/informatik/verkerhssimulation/media/models/Barrel.mesh b/school/informatik/verkerhssimulation/media/models/Barrel.mesh new file mode 100644 index 00000000..511dbbea Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/Barrel.mesh differ diff --git a/school/informatik/verkerhssimulation/media/models/RZR-002.mesh b/school/informatik/verkerhssimulation/media/models/RZR-002.mesh new file mode 100644 index 00000000..64fc8548 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/RZR-002.mesh differ diff --git a/school/informatik/verkerhssimulation/media/models/WoodPallet.mesh b/school/informatik/verkerhssimulation/media/models/WoodPallet.mesh new file mode 100644 index 00000000..88db450a Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/WoodPallet.mesh differ diff --git a/school/informatik/verkerhssimulation/media/models/athene.mesh b/school/informatik/verkerhssimulation/media/models/athene.mesh new file mode 100644 index 00000000..46e39f19 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/athene.mesh differ diff --git a/school/informatik/verkerhssimulation/media/models/column.mesh b/school/informatik/verkerhssimulation/media/models/column.mesh new file mode 100644 index 00000000..5e9b44b1 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/column.mesh differ diff --git a/school/informatik/verkerhssimulation/media/models/cube.mesh b/school/informatik/verkerhssimulation/media/models/cube.mesh new file mode 100644 index 00000000..cf7dc84e Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/cube.mesh differ diff --git a/school/informatik/verkerhssimulation/media/models/facial.mesh b/school/informatik/verkerhssimulation/media/models/facial.mesh new file mode 100644 index 00000000..c59606d7 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/facial.mesh differ diff --git a/school/informatik/verkerhssimulation/media/models/fish.mesh b/school/informatik/verkerhssimulation/media/models/fish.mesh new file mode 100644 index 00000000..d82b06e2 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/fish.mesh differ diff --git a/school/informatik/verkerhssimulation/media/models/fish.skeleton b/school/informatik/verkerhssimulation/media/models/fish.skeleton new file mode 100644 index 00000000..7a970fda Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/fish.skeleton differ diff --git a/school/informatik/verkerhssimulation/media/models/geosphere4500.mesh b/school/informatik/verkerhssimulation/media/models/geosphere4500.mesh new file mode 100644 index 00000000..92e42e3b Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/geosphere4500.mesh differ diff --git a/school/informatik/verkerhssimulation/media/models/geosphere8000.mesh b/school/informatik/verkerhssimulation/media/models/geosphere8000.mesh new file mode 100644 index 00000000..5922ccd6 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/geosphere8000.mesh differ diff --git a/school/informatik/verkerhssimulation/media/models/jaiqua.mesh b/school/informatik/verkerhssimulation/media/models/jaiqua.mesh new file mode 100644 index 00000000..a6e3982d Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/jaiqua.mesh differ diff --git a/school/informatik/verkerhssimulation/media/models/jaiqua.skeleton b/school/informatik/verkerhssimulation/media/models/jaiqua.skeleton new file mode 100644 index 00000000..3d7622c5 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/jaiqua.skeleton differ diff --git a/school/informatik/verkerhssimulation/media/models/knot.mesh b/school/informatik/verkerhssimulation/media/models/knot.mesh new file mode 100644 index 00000000..84aa8454 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/knot.mesh differ diff --git a/school/informatik/verkerhssimulation/media/models/ninja.mesh b/school/informatik/verkerhssimulation/media/models/ninja.mesh new file mode 100644 index 00000000..46df1900 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/ninja.mesh differ diff --git a/school/informatik/verkerhssimulation/media/models/ninja.skeleton b/school/informatik/verkerhssimulation/media/models/ninja.skeleton new file mode 100644 index 00000000..787f5f75 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/ninja.skeleton differ diff --git a/school/informatik/verkerhssimulation/media/models/ogrehead.mesh b/school/informatik/verkerhssimulation/media/models/ogrehead.mesh new file mode 100644 index 00000000..936f25a4 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/ogrehead.mesh differ diff --git a/school/informatik/verkerhssimulation/media/models/razor.mesh b/school/informatik/verkerhssimulation/media/models/razor.mesh new file mode 100644 index 00000000..1177280b Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/razor.mesh differ diff --git a/school/informatik/verkerhssimulation/media/models/robot.mesh b/school/informatik/verkerhssimulation/media/models/robot.mesh new file mode 100644 index 00000000..b408e317 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/robot.mesh differ diff --git a/school/informatik/verkerhssimulation/media/models/robot.skeleton b/school/informatik/verkerhssimulation/media/models/robot.skeleton new file mode 100644 index 00000000..0aa8bde5 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/robot.skeleton differ diff --git a/school/informatik/verkerhssimulation/media/models/sphere.mesh b/school/informatik/verkerhssimulation/media/models/sphere.mesh new file mode 100644 index 00000000..286317e0 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/sphere.mesh differ diff --git a/school/informatik/verkerhssimulation/media/models/tudorhouse.mesh b/school/informatik/verkerhssimulation/media/models/tudorhouse.mesh new file mode 100644 index 00000000..1dd5ae4a Binary files /dev/null and b/school/informatik/verkerhssimulation/media/models/tudorhouse.mesh differ diff --git a/school/informatik/verkerhssimulation/media/ogre pic.bmp b/school/informatik/verkerhssimulation/media/ogre pic.bmp new file mode 100644 index 00000000..2c7918cf Binary files /dev/null and b/school/informatik/verkerhssimulation/media/ogre pic.bmp differ diff --git a/school/informatik/verkerhssimulation/media/ogre pic.xcf b/school/informatik/verkerhssimulation/media/ogre pic.xcf new file mode 100644 index 00000000..507b6867 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/ogre pic.xcf differ diff --git a/school/informatik/verkerhssimulation/media/overlays/BasicOgreGuiTemplates.inc b/school/informatik/verkerhssimulation/media/overlays/BasicOgreGuiTemplates.inc new file mode 100644 index 00000000..94290c40 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/overlays/BasicOgreGuiTemplates.inc @@ -0,0 +1,47 @@ +// Ogre overlay scripts +template container BorderPanel(SS/Templates/BasicBorderPanel) +{ + left 0 + top 0 + width 1 + height 1 + material Core/StatsBlockCenter + border_size 0.06 0.06 0.06665 0.06665 + border_material Core/StatsBlockBorder + border_topleft_uv 0.0000 0.0000 0.1914 0.2031 + border_top_uv 0.1914 0.0000 0.8086 0.2031 + border_topright_uv 0.8086 0.0000 1.0000 0.2031 + border_left_uv 0.0000 0.2031 0.1914 0.7852 + border_right_uv 0.8086 0.2031 1.0000 0.7852 + border_bottomleft_uv 0.0000 0.7852 0.1914 1.0000 + border_bottom_uv 0.1914 0.7852 0.8086 1.0000 + border_bottomright_uv 0.8086 0.7852 1.0000 1.0000 +} + +template container BorderPanel(SS/Templates/BasicSmallBorderPanel) : SS/Templates/BasicBorderPanel +{ + border_size 0.04 0.04 0.04665 0.04665 +} + + +template element TextArea(SS/Templates/BasicText) +{ + font_name Ogre + char_height 0.08 + colour_top 1 1 0 + colour_bottom 1 0.2 0.2 + left 0.03 + top 0.02 + width 0.12 + height 0.09 +} + +template container Panel(SS/Templates/BasicPanel) +{ + left 0 + top 0 + width 1 + height 1 + material Core/StatsBlockCenter +} + diff --git a/school/informatik/verkerhssimulation/media/overlays/Compositor.overlay b/school/informatik/verkerhssimulation/media/overlays/Compositor.overlay new file mode 100644 index 00000000..956778ed --- /dev/null +++ b/school/informatik/verkerhssimulation/media/overlays/Compositor.overlay @@ -0,0 +1,66 @@ +Example/CompositorOverlay +{ + zorder 500 + // Stats block + container BorderPanel(Core/CompositorPanel) + { + metrics_mode pixels + vert_align top + left 5 + top 5 + width 500 + height 55 + material Core/StatsBlockCenter + border_size 1 1 1 1 + border_material Core/StatsBlockBorder + border_topleft_uv 0.0000 1.0000 0.0039 0.9961 + border_top_uv 0.0039 1.0000 0.9961 0.9961 + border_topright_uv 0.9961 1.0000 1.0000 0.9961 + border_left_uv 0.0000 0.9961 0.0039 0.0039 + border_right_uv 0.9961 0.9961 1.0000 0.0039 + border_bottomleft_uv 0.0000 0.0039 0.0039 0.0000 + border_bottom_uv 0.0039 0.0039 0.9961 0.0000 + border_bottomright_uv 0.9961 0.0039 1.0000 0.0000 + + + element TextArea(Example/Compositor/Desc) + { + metrics_mode pixels + left 5 + top 5 + width 180 + height 30 + font_name BlueHighway + char_height 16 + caption Use keys 1-8 to toggle each compositor + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + element TextArea(Example/Compositor/ActiveLabel) + { + metrics_mode pixels + left 5 + top 20 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption Active Compositors: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + element TextArea(Example/Compositor/ActiveText) + { + metrics_mode pixels + left 155 + top 20 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption Current: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + } +} diff --git a/school/informatik/verkerhssimulation/media/overlays/DP3.overlay b/school/informatik/verkerhssimulation/media/overlays/DP3.overlay new file mode 100644 index 00000000..b6051f6e --- /dev/null +++ b/school/informatik/verkerhssimulation/media/overlays/DP3.overlay @@ -0,0 +1,105 @@ +Example/DP3Overlay +{ + zorder 500 + // Stats block + container BorderPanel(Core/DP3Panel) + { + metrics_mode pixels + vert_align top + left 5 + top 5 + width 500 + height 70 + material Core/StatsBlockCenter + border_size 1 1 1 1 + border_material Core/StatsBlockBorder + border_topleft_uv 0.0000 1.0000 0.0039 0.9961 + border_top_uv 0.0039 1.0000 0.9961 0.9961 + border_topright_uv 0.9961 1.0000 1.0000 0.9961 + border_left_uv 0.0000 0.9961 0.0039 0.0039 + border_right_uv 0.9961 0.9961 1.0000 0.0039 + border_bottomleft_uv 0.0000 0.0039 0.0039 0.0000 + border_bottom_uv 0.0039 0.0039 0.9961 0.0000 + border_bottomright_uv 0.9961 0.0039 1.0000 0.0000 + + element TextArea(Example/DP3/Light) + { + metrics_mode pixels + left 5 + top 5 + width 180 + height 30 + font_name BlueHighway + char_height 16 + caption [1,2,3] toggle lights + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/DP3/Object) + { + metrics_mode pixels + left 5 + top 20 + width 180 + height 30 + font_name BlueHighway + char_height 16 + caption [O] change objects + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + element TextArea(Example/DP3/ObjectInfo) + { + metrics_mode pixels + left 155 + top 20 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption Current: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/DP3/Materials) + { + metrics_mode pixels + left 5 + top 35 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [M] Change material + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + element TextArea(Example/DP3/MaterialInfo) + { + metrics_mode pixels + left 155 + top 35 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption Current: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + element TextArea(Example/DP3/Info) + { + metrics_mode pixels + left 5 + top 50 + width 250 + height 30 + font_name BlueHighway + char_height 16 + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + } +} diff --git a/school/informatik/verkerhssimulation/media/overlays/Example-CubeMapping.overlay b/school/informatik/verkerhssimulation/media/overlays/Example-CubeMapping.overlay new file mode 100644 index 00000000..3bcf9cc6 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/overlays/Example-CubeMapping.overlay @@ -0,0 +1,139 @@ +Example/CubeMappingOverlay +{ + zorder 500 + // Stats block + container BorderPanel(Core/CubeMappingPanel) + { + metrics_mode pixels + vert_align top + left 5 + top 5 + width 250 + height 130 + material Core/StatsBlockCenter + border_size 1 1 1 1 + border_material Core/StatsBlockBorder + border_topleft_uv 0.0000 1.0000 0.0039 0.9961 + border_top_uv 0.0039 1.0000 0.9961 0.9961 + border_topright_uv 0.9961 1.0000 1.0000 0.9961 + border_left_uv 0.0000 0.9961 0.0039 0.0039 + border_right_uv 0.9961 0.9961 1.0000 0.0039 + border_bottomleft_uv 0.0000 0.0039 0.0039 0.0000 + border_bottom_uv 0.0039 0.0039 0.9961 0.0000 + border_bottomright_uv 0.9961 0.0039 1.0000 0.0000 + + element TextArea(Example/CubeMapping/Displacement) + { + metrics_mode pixels + left 5 + top 5 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [1/2] Displacement: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/CubeMapping/Density) + { + metrics_mode pixels + left 5 + top 20 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [3/4] Noise density: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/CubeMapping/TimeDensity) + { + metrics_mode pixels + left 5 + top 35 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [5/6] Time density: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + + element TextArea(Example/CubeMapping/Noise) + { + metrics_mode pixels + left 5 + top 50 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [N] Noise: _not_set_ + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/CubeMapping/Material) + { + metrics_mode pixels + left 5 + top 65 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [M] Material: *UNIMPLEMENTED* + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/CubeMapping/Object) + { + metrics_mode pixels + left 5 + top 80 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [O] Object: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/CubeMapping/CubeMap) + { + metrics_mode pixels + left 5 + top 95 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [C] CubeMap: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/CubeMapping/Random) + { + metrics_mode pixels + left 5 + top 110 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [SPACE] Go random! + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + } +} diff --git a/school/informatik/verkerhssimulation/media/overlays/Example-DynTex.overlay b/school/informatik/verkerhssimulation/media/overlays/Example-DynTex.overlay new file mode 100644 index 00000000..9741f969 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/overlays/Example-DynTex.overlay @@ -0,0 +1,194 @@ +Example/DynTexOverlay +{ + zorder 500 + // Stats block + container BorderPanel(Core/DynTexPanel) + { + metrics_mode pixels + vert_align top + left 5 + top 5 + width 200 + height 100 + material Core/StatsBlockCenter + border_size 1 1 1 1 + border_material Core/StatsBlockBorder + border_topleft_uv 0.0000 1.0000 0.0039 0.9961 + border_top_uv 0.0039 1.0000 0.9961 0.9961 + border_topright_uv 0.9961 1.0000 1.0000 0.9961 + border_left_uv 0.0000 0.9961 0.0039 0.0039 + border_right_uv 0.9961 0.9961 1.0000 0.0039 + border_bottomleft_uv 0.0000 0.0039 0.0039 0.0000 + border_bottom_uv 0.0039 0.0039 0.9961 0.0000 + border_bottomright_uv 0.9961 0.0039 1.0000 0.0000 + + element TextArea(Example/DynTex/Note) + { + metrics_mode pixels + left 5 + top 5 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption Reaction parameters + colour_top 0.7 0.9 0.7 + colour_bottom 0.5 0.7 0.5 + } + + element TextArea(Example/DynTex/Param_K) + { + metrics_mode pixels + left 5 + top 20 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [1/2]K: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/DynTex/Param_F) + { + metrics_mode pixels + left 5 + top 35 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [3/4]F: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/DynTex/Param_A0) + { + metrics_mode pixels + left 5 + top 50 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [5/6]Diffusion 1: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/DynTex/Param_A1) + { + metrics_mode pixels + left 5 + top 65 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [7/8]Diffusion 2: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/DynTex/Zero) + { + metrics_mode pixels + left 5 + top 80 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [0]Reset initial conditions + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + + } +} +Example/VolTexOverlay +{ + zorder 500 + // Stats block + container BorderPanel(Example/VolTexPanel) + { + metrics_mode pixels + vert_align top + left 5 + top 5 + width 200 + height 70 + material Core/StatsBlockCenter + border_size 1 1 1 1 + border_material Core/StatsBlockBorder + border_topleft_uv 0.0000 1.0000 0.0039 0.9961 + border_top_uv 0.0039 1.0000 0.9961 0.9961 + border_topright_uv 0.9961 1.0000 1.0000 0.9961 + border_left_uv 0.0000 0.9961 0.0039 0.0039 + border_right_uv 0.9961 0.9961 1.0000 0.0039 + border_bottomleft_uv 0.0000 0.0039 0.0039 0.0000 + border_bottom_uv 0.0039 0.0039 0.9961 0.0000 + border_bottomright_uv 0.9961 0.0039 1.0000 0.0000 + + element TextArea(Example/VolTex/Note) + { + metrics_mode pixels + left 5 + top 5 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption Julia parameters + colour_top 0.7 0.9 0.7 + colour_bottom 0.5 0.7 0.5 + } + + element TextArea(Example/VolTex/Param_real) + { + metrics_mode pixels + left 5 + top 20 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [1/2]real: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/VolTex/Param_imag) + { + metrics_mode pixels + left 5 + top 35 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [3/4]imag: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/VolTex/Param_theta) + { + metrics_mode pixels + left 5 + top 50 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [5/6]theta: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + + } +} diff --git a/school/informatik/verkerhssimulation/media/overlays/Example-Water.overlay b/school/informatik/verkerhssimulation/media/overlays/Example-Water.overlay new file mode 100644 index 00000000..69f7e6d0 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/overlays/Example-Water.overlay @@ -0,0 +1,168 @@ +Example/WaterOverlay +{ + zorder 500 + // Stats block + container BorderPanel(Core/WaterPanel) + { + metrics_mode pixels + vert_align top + left 5 + top 5 + width 400 + height 87 + material Core/StatsBlockCenter + border_size 1 1 1 1 + border_material Core/StatsBlockBorder + border_topleft_uv 0.0000 1.0000 0.0039 0.9961 + border_top_uv 0.0039 1.0000 0.9961 0.9961 + border_topright_uv 0.9961 1.0000 1.0000 0.9961 + border_left_uv 0.0000 0.9961 0.0039 0.0039 + border_right_uv 0.9961 0.9961 1.0000 0.0039 + border_bottomleft_uv 0.0000 0.0039 0.0039 0.0000 + border_bottom_uv 0.0039 0.0039 0.9961 0.0000 + border_bottomright_uv 0.9961 0.0039 1.0000 0.0000 + + + element TextArea(Example/Water/Normals) + { + metrics_mode pixels + left 5 + top 5 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [N]Normals: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/Water/Rain) + { + metrics_mode pixels + left 5 + top 20 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [SPACE]Rain + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/Water/SkyBox) + { + metrics_mode pixels + left 5 + top 35 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [B]SkyBox: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/Water/Depth) + { + metrics_mode pixels + left 5 + top 50 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [U/J]Head depth: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/Water/Material) + { + metrics_mode pixels + left 5 + top 65 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [M]Material: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/Water/Note) + { + metrics_mode pixels + left 200 + top 5 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption Careful with these values! + colour_top 0.7 0.9 0.7 + colour_bottom 0.5 0.7 0.5 + } + + element TextArea(Example/Water/Param_C) + { + metrics_mode pixels + left 200 + top 20 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [1/2]Ripple speed: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/Water/Param_D) + { + metrics_mode pixels + left 200 + top 35 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [3/4]Distance: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/Water/Param_U) + { + metrics_mode pixels + left 200 + top 50 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [5/6]Viscosity: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/Water/Param_T) + { + metrics_mode pixels + left 200 + top 65 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [7/8]Time period: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + + } +} diff --git a/school/informatik/verkerhssimulation/media/overlays/Shadows.overlay b/school/informatik/verkerhssimulation/media/overlays/Shadows.overlay new file mode 100644 index 00000000..25f36173 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/overlays/Shadows.overlay @@ -0,0 +1,92 @@ +Example/ShadowsOverlay +{ + zorder 500 + // Stats block + container BorderPanel(Core/ShadowsPanel) + { + metrics_mode pixels + vert_align top + left 5 + top 5 + width 500 + height 55 + material Core/StatsBlockCenter + border_size 1 1 1 1 + border_material Core/StatsBlockBorder + border_topleft_uv 0.0000 1.0000 0.0039 0.9961 + border_top_uv 0.0039 1.0000 0.9961 0.9961 + border_topright_uv 0.9961 1.0000 1.0000 0.9961 + border_left_uv 0.0000 0.9961 0.0039 0.0039 + border_right_uv 0.9961 0.9961 1.0000 0.0039 + border_bottomleft_uv 0.0000 0.0039 0.0039 0.0000 + border_bottom_uv 0.0039 0.0039 0.9961 0.0000 + border_bottomright_uv 0.9961 0.0039 1.0000 0.0000 + + + element TextArea(Example/Shadows/ShadowTechnique) + { + metrics_mode pixels + left 5 + top 5 + width 180 + height 30 + font_name BlueHighway + char_height 16 + caption [O] Shadow Technique + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + element TextArea(Example/Shadows/ShadowTechniqueInfo) + { + metrics_mode pixels + left 155 + top 5 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption Current: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + + element TextArea(Example/Shadows/Materials) + { + metrics_mode pixels + left 5 + top 20 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption [M] Athene Material + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + element TextArea(Example/Shadows/MaterialInfo) + { + metrics_mode pixels + left 155 + top 20 + width 90 + height 30 + font_name BlueHighway + char_height 16 + caption Current: + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + element TextArea(Example/Shadows/Info) + { + metrics_mode pixels + left 5 + top 35 + width 250 + height 30 + font_name BlueHighway + char_height 16 + colour_top 0.5 0.7 0.5 + colour_bottom 0.3 0.5 0.3 + } + } +} diff --git a/school/informatik/verkerhssimulation/media/packs/OgreCore.zip b/school/informatik/verkerhssimulation/media/packs/OgreCore.zip new file mode 100644 index 00000000..578552c1 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/packs/OgreCore.zip differ diff --git a/school/informatik/verkerhssimulation/media/packs/chiropteraDM.pk3 b/school/informatik/verkerhssimulation/media/packs/chiropteraDM.pk3 new file mode 100644 index 00000000..ffa2c6d3 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/packs/chiropteraDM.pk3 differ diff --git a/school/informatik/verkerhssimulation/media/packs/chiropteraDM.txt b/school/informatik/verkerhssimulation/media/packs/chiropteraDM.txt new file mode 100644 index 00000000..caa7829b --- /dev/null +++ b/school/informatik/verkerhssimulation/media/packs/chiropteraDM.txt @@ -0,0 +1,99 @@ +date: September 17th 2001. +Quake3Arena DM level. + +==================================================== +title: ChiropteraDM +file: ChiropteraDM.pk3 + +authors: Alcatraz / Nunuk / Sock + +Alcatraz alcatraz@planetquake.com + http://www.planetquake.com/bighouse +Nunuk: nunuk@planetquake.com + http://www.planetquake.com/nunuk +Sock: sock@planetquake.com + http://www.planetquake.com/simland +==================================================== +Components + +Architecture: Nunuk +Gameplay: Alcatraz +Textures: Sock / Arnaud "pikouze" barros / Nunuk + +==================================================== +Play information + +tourney: yes +deathmatch: 2-6 +Bot File (aas): yes (Optimized) + +how to play place chiropteraDM.pk3 in your + /Quake III Arena/baseq3/ folder + start quake3 Arena + hit ~ + type /map chiropteraDM + type /addbot + hit ~ (to clear the console) + +Note: If the map does not start automatically after loading then make +sure you have the SV_PURE variable set to 0. I also included an arena +file in the pk3 file so that it can be loaded from the menus. + +==================================================== +Construction + +editor: Q3Radiant 197 by Id Software +build time: Original Map : 3 months, New version : 1 month +build version: 6(F) + +==================================================== +New Beta testers: Nunuk, Ttimo, NakedApe, Shallow[BAP] + +Thanks from Sock: + + Ttimo : for advice and testing. + NakedApe : for advice on TA items and testing. + alcatraz : for taking time on the level, and for his item placement. + Zed the best gf ever :P + +Additional thanks from Nunuk: + + my wife lorene. for her patience. + my son arthur.(stop slapping dad's keyboard!) + for advice and testing : nanospawn, bal, sock, shod, ttimo, spog. + auhsan - for inspiration :o) + th - too bad for the title, it will be for the next map. + just for being there : lunaran, grindspire, friction, and all at TF. + cool_ber - for being cool :> + ptit benj - always there for cool advices + bengal - for his awesome artwork + pappy-r, will, ash, and staff, @ planetquake + all the guys at qmap and terrafusion + ohz, shod and fff - for pimping and for always reminding me that i'll + become a real mapper when i'll stop doing these crappy space maps .... :oD + www.quakexpert.com + darkworks + yan "la crampe" - the only "dm17sucks" dude that passes at + least one hour a day playing in it. + arnaud "pikouse" - for allowing me to modify his own texes. + roland "poz_kak" + + +Thanx to all the other people that i could have forgot. ;) + +==================================================== +Distribution / Copyright / Permissions + +Copyright (c) 2001 sock, sock@planetquake.com +All rights reserved. + +Quake III Arena is a registered trademark of +id Software, Inc. + +This level may be electronically distributed only at +NO CHARGE to the recipient in its current state, MUST +include this .txt file, and may NOT be modified IN +ANY WAY. UNDER NO CIRCUMSTANCES IS THIS LEVEL TO BE +DISTRIBUTED ON CD-ROM WITHOUT PRIOR WRITTEN PERMISSION. + +==================================================== diff --git a/school/informatik/verkerhssimulation/media/packs/cubemap.zip b/school/informatik/verkerhssimulation/media/packs/cubemap.zip new file mode 100644 index 00000000..89917019 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/packs/cubemap.zip differ diff --git a/school/informatik/verkerhssimulation/media/packs/cubemapsJS.zip b/school/informatik/verkerhssimulation/media/packs/cubemapsJS.zip new file mode 100644 index 00000000..304e8f84 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/packs/cubemapsJS.zip differ diff --git a/school/informatik/verkerhssimulation/media/packs/dragon.zip b/school/informatik/verkerhssimulation/media/packs/dragon.zip new file mode 100644 index 00000000..8a857917 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/packs/dragon.zip differ diff --git a/school/informatik/verkerhssimulation/media/packs/fresneldemo.zip b/school/informatik/verkerhssimulation/media/packs/fresneldemo.zip new file mode 100644 index 00000000..2f54d280 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/packs/fresneldemo.zip differ diff --git a/school/informatik/verkerhssimulation/media/packs/ogretestmap.zip b/school/informatik/verkerhssimulation/media/packs/ogretestmap.zip new file mode 100644 index 00000000..63fb7860 Binary files /dev/null and b/school/informatik/verkerhssimulation/media/packs/ogretestmap.zip differ diff --git a/school/informatik/verkerhssimulation/media/packs/skybox.zip b/school/informatik/verkerhssimulation/media/packs/skybox.zip new file mode 100644 index 00000000..06f6820d Binary files /dev/null and b/school/informatik/verkerhssimulation/media/packs/skybox.zip differ diff --git a/school/informatik/verkerhssimulation/media/particle/Example-Water.particle b/school/informatik/verkerhssimulation/media/particle/Example-Water.particle new file mode 100644 index 00000000..877d3b8c --- /dev/null +++ b/school/informatik/verkerhssimulation/media/particle/Example-Water.particle @@ -0,0 +1,35 @@ +Examples/Water/Rain +{ + material Examples/Droplet + particle_width 100 + particle_height 300 + cull_each true + quota 100 + // Make common direction straight down (faster than self oriented) + billboard_type oriented_common + common_direction 0 -1 0 + + // Area emitter + emitter Box + { + angle 0 + emission_rate 20 + time_to_live 5 + direction 0 -1 0 + velocity 1000 + colour_range_start 0.3 1 0.3 + colour_range_end 0.7 1 0.7 + width 3000 + height 3000 + depth 0 + } + + // Gravity + affector LinearForce + { + force_vector 0 -1000 0 + force_application add + } + +} + diff --git a/school/informatik/verkerhssimulation/media/particle/Example.particle b/school/informatik/verkerhssimulation/media/particle/Example.particle new file mode 100644 index 00000000..ddeae9c0 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/particle/Example.particle @@ -0,0 +1,395 @@ +// Example particle systems + +// Exudes greeny particles which float upwards +Examples/GreenyNimbus +{ + material Examples/FlarePointSprite + point_rendering true + // point rendering means size is controlled by material + // provide fallback sizes for hardware that doesn't support point sprite + particle_width 30 + particle_height 30 + cull_each false + cull_each false + quota 10000 + billboard_type point + + // Area emitter + emitter Box + { + angle 30 + emission_rate 30 + time_to_live 5 + direction 0 1 0 + velocity 0 + colour_range_start 1 1 0 + colour_range_end 0.3 1 0.3 + width 60 + height 60 + depth 60 + } + + // Make em float upwards + affector LinearForce + { + force_vector 0 100 0 + force_application add + } + + // Fader + affector ColourFader + { + red -0.25 + green -0.25 + blue -0.25 + } + + +} + +// A sparkly purple fountain +Examples/PurpleFountain +{ + material Examples/Flare2 + particle_width 20 + particle_height 40 + cull_each false + quota 10000 + billboard_type oriented_self + + // Area emitter + emitter Point + { + angle 15 + emission_rate 75 + time_to_live 3 + direction 0 1 0 + velocity_min 250 + velocity_max 300 + colour_range_start 0 0 0 + colour_range_end 1 1 1 + } + + // Gravity + affector LinearForce + { + force_vector 0 -100 0 + force_application add + } + + // Fader + affector ColourFader + { + red -0.25 + green -0.25 + blue -0.25 + } +} + + +// A downpour +Examples/Rain +{ + material Examples/Droplet + particle_width 20 + particle_height 100 + cull_each true + quota 10000 + // Make common direction straight down (faster than self oriented) + billboard_type oriented_common + common_direction 0 -1 0 + + // Area emitter + emitter Box + { + angle 0 + emission_rate 100 + time_to_live 5 + direction 0 -1 0 + velocity 50 + colour_range_start 0.3 1 0.3 + colour_range_end 0.7 1 0.7 + width 1000 + height 1000 + depth 0 + } + + // Gravity + affector LinearForce + { + force_vector 0 -200 0 + force_application add + } + +} + +// A jet engine (of sorts) +Examples/JetEngine1 +{ + material Examples/Flare + particle_width 25 + particle_height 25 + cull_each false + quota 200 + billboard_type point + + emitter Point + { + angle 5 + emission_rate 100 + time_to_live 1 + direction 0 -1 0 + velocity_min 250 + velocity_max 300 + colour_range_start 1 1 0.5 + colour_range_end 1 0.8 0.3 + + } + affector ColourFader + { + red -0.25 + green -1 + blue -1 + } + +} +Examples/JetEngine2 +{ + material Examples/Flare + particle_width 15 + particle_height 15 + cull_each false + quota 200 + billboard_type point + + emitter Point + { + angle 3 + emission_rate 100 + time_to_live 1 + direction 0 -1 0 + velocity_min 350 + velocity_max 400 + colour_range_start 0.5 1 1 + colour_range_end 0.3 0.8 1 + + } + affector ColourFader + { + red -1 + green -1 + blue -0.5 + } + +} + +// Exudes aureola particles which around the model float upwards +Examples/Aureola +{ + material Examples/Aureola + particle_width 200 + particle_height 200 + cull_each false + quota 100 + billboard_type perpendicular_common + common_direction 0 1 0 + common_up_vector 0 0 1 + + // Area emitter + emitter Box + { + angle 30 + emission_rate 4 + time_to_live 5 + position 0 -100 0 + direction 0 1 0 + velocity_min 0 + velocity_max 30 + colour_range_start 0.3 0.3 0.3 0.0 + colour_range_end 0.8 0.8 0.8 0.0 + width 10 + height 10 + depth 30 + } + + // Make em float upwards + affector LinearForce + { + force_vector 0 70 0 + force_application add + } + + // Fader + affector ColourFader2 + { + red1 +0.4 + green1 +0.4 + blue1 +0.4 + alpha1 +0.7 + + red2 -0.25 + green2 -0.25 + blue2 -0.25 + alpha2 -0.3333 + + state_change 3.5 + } + + // Rotater + affector Rotator + { + rotation_range_start 0 + rotation_range_end 360 + rotation_speed_range_start 0 + rotation_speed_range_end 180 + } +} + + +Examples/Swarm +{ + quota 3000 + material Examples/Flare2 + particle_width 12 + particle_height 24 + cull_each true + renderer billboard + sorted true + local_space false + billboard_type oriented_self + + emitter Box + { + angle 180 + colour 1 1 1 1 + colour_range_start 1 1 1 1 + colour_range_end 1 1 1 1 + direction 0 1 0 + emission_rate 30 + position 0 0 0 + velocity 50 + velocity_min 50 + velocity_max 1 + time_to_live 20 + time_to_live_min 20 + time_to_live_max 20 + duration 0 + duration_min 0 + duration_max 0 + repeat_delay 0 + repeat_delay_min 0 + repeat_delay_max 0 + width 80 + height 80 + depth 80 + } + + affector ColourFader + { + red -0.05 + green 0 + blue 0 + alpha 0 + } + + affector DeflectorPlane + { + plane_point 0 -50 0 + plane_normal 0 1 0 + bounce 1 + } + + affector DeflectorPlane + { + plane_point 0 50 0 + plane_normal 0 -1 0 + bounce 1 + } + + affector DeflectorPlane + { + plane_point 50 0 0 + plane_normal -1 0 0 + bounce 1 + } + + affector DeflectorPlane + { + plane_point -50 0 0 + plane_normal 1 0 0 + bounce 1 + } + + affector DeflectorPlane + { + plane_point 0 0 50 + plane_normal 0 0 -1 + bounce 1 + } + + affector DeflectorPlane + { + plane_point 0 0 -50 + plane_normal 0 0 1 + bounce 1 + } + + affector DirectionRandomiser + { + randomness 60 + } +} + + +Examples/Snow +{ + quota 2000 + material Examples/Flare + particle_width 4 + particle_height 4 + cull_each true + renderer billboard + sorted true + local_space false + billboard_type point + + emitter Box + { + angle 0 + colour 1 1 1 1 + colour_range_start 1 1 1 1 + colour_range_end 1 1 1 1 + direction 0 -1 0 + emission_rate 100 + position 0 200 0 + velocity 20 + velocity_min 20 + velocity_max 20 + time_to_live 20 + time_to_live_min 20 + time_to_live_max 20 + duration 0 + duration_min 0 + duration_max 0 + repeat_delay 0 + repeat_delay_min 0 + repeat_delay_max 0 + width 200 + height 200 + depth 1 + } + + affector DeflectorPlane + { + plane_point 0 0 0 + plane_normal 0 1 0 + bounce 0 + } + + affector DirectionRandomiser + { + randomness 10 + } +} + + diff --git a/school/informatik/verkerhssimulation/media/particle/emitted_emitter.particle b/school/informatik/verkerhssimulation/media/particle/emitted_emitter.particle new file mode 100644 index 00000000..47b7bc48 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/particle/emitted_emitter.particle @@ -0,0 +1,56 @@ +// Example emitted emitters +Examples/Fireworks +{ + material Examples/Flare + point_rendering false + particle_width 10 + particle_height 10 + cull_each false + quota 1000 + emit_emitter_quota 10 + billboard_type point + + // Emitter that emits multiple Point emitters with name 'explosion' + emitter Box + { + name mainEmitter + emit_emitter explosion + angle 30 + emission_rate 1000 + time_to_live 3 + direction 0 1 0 + velocity 200 + } + + // This Point emitter is emitted by the Box emitter and emits billboard particles itself + emitter Point + { + name explosion + angle 360 + emission_rate 1000 + time_to_live 2 + direction 0 1 0 + velocity 80 + duration 0.1 + repeat_delay_min 2 + repeat_delay_max 3 + } + + // Make em float downwards + affector LinearForce + { + force_vector 0 -100 0 + force_application add + } + + // Give em some nice colours + affector ColourInterpolator + { + time0 0 + colour0 1 1 0 + time1 0.5 + colour1 1 0 0 + time2 0.9 + colour2 0 0 1 + } +} diff --git a/school/informatik/verkerhssimulation/media/particle/smoke.particle b/school/informatik/verkerhssimulation/media/particle/smoke.particle new file mode 100644 index 00000000..8861ddad --- /dev/null +++ b/school/informatik/verkerhssimulation/media/particle/smoke.particle @@ -0,0 +1,43 @@ +// Example particle systems + +// smoke +Examples/Smoke +{ + material Examples/Smoke + particle_width 55 + particle_height 55 + cull_each true + quota 500 + billboard_type point + sorted true + + // Area emitter + emitter Point + { + angle 11 + emission_rate 15 + time_to_live 4 + direction 0 1 0 + velocity_min 150 + velocity_max 240 + } + + affector ColourImage + { + image smokecolors.png + } + + affector Rotator + { + rotation_range_start 0 + rotation_range_end 360 + rotation_speed_range_start -60 + rotation_speed_range_end 200 + } + + affector Scaler + { + rate 100 + } + +} diff --git a/school/informatik/verkerhssimulation/media/terrain.cfg b/school/informatik/verkerhssimulation/media/terrain.cfg new file mode 100644 index 00000000..5d69f112 --- /dev/null +++ b/school/informatik/verkerhssimulation/media/terrain.cfg @@ -0,0 +1,71 @@ +# The main world texture (if you wish the terrain manager to create a material for you) +WorldTexture=terrain_texture.jpg + +# The detail texture (if you wish the terrain manager to create a material for you) +DetailTexture=terrain_detail.jpg + +#number of times the detail texture will tile in a terrain tile +DetailTile=3 + +# Heightmap source +PageSource=Heightmap + +# Heightmap-source specific settings +Heightmap.image=terrain.png + +# If you use RAW, fill in the below too +# RAW-specific setting - size (horizontal/vertical) +#Heightmap.raw.size=513 +# RAW-specific setting - bytes per pixel (1 = 8bit, 2=16bit) +#Heightmap.raw.bpp=2 + +# How large is a page of tiles (in vertices)? Must be (2^n)+1 +PageSize=513 + +# How large is each tile? Must be (2^n)+1 and be smaller than PageSize +TileSize=65 + +# The maximum error allowed when determining which LOD to use +MaxPixelError=3 + +# The size of a terrain page, in world units +PageWorldX=1500 +PageWorldZ=1500 +# Maximum height of the terrain +MaxHeight=100 + +# Upper LOD limit +MaxMipMapLevel=5 + +#VertexNormals=yes +#VertexColors=yes +#UseTriStrips=yes + +# Use vertex program to morph LODs, if available +VertexProgramMorph=yes + +# The proportional distance range at which the LOD morph starts to take effect +# This is as a proportion of the distance between the current LODs effective range, +# and the effective range of the next lower LOD +LODMorphStart=0.2 + +# This following section is for if you want to provide your own terrain shading routine +# Note that since you define your textures within the material this makes the +# WorldTexture and DetailTexture settings redundant + +# The name of the vertex program parameter you wish to bind the morph LOD factor to +# this is 0 when there is no adjustment (highest) to 1 when the morph takes it completely +# to the same position as the next lower LOD +# USE THIS IF YOU USE HIGH-LEVEL VERTEX PROGRAMS WITH LOD MORPHING +#MorphLODFactorParamName=morphFactor + +# The index of the vertex program parameter you wish to bind the morph LOD factor to +# this is 0 when there is no adjustment (highest) to 1 when the morph takes it completely +# to the same position as the next lower LOD +# USE THIS IF YOU USE ASSEMBLER VERTEX PROGRAMS WITH LOD MORPHING +#MorphLODFactorParamIndex=4 + +# The name of the material you will define to shade the terrain +#CustomMaterialName=TestTerrainMaterial + + diff --git a/school/informatik/verkerhssimulation/open project.bat b/school/informatik/verkerhssimulation/open project.bat new file mode 100644 index 00000000..c24a920a --- /dev/null +++ b/school/informatik/verkerhssimulation/open project.bat @@ -0,0 +1 @@ +start src\Verkehrssimulation.sln \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/run verkehrssimulation.bat b/school/informatik/verkerhssimulation/run verkehrssimulation.bat new file mode 100644 index 00000000..9f8d7a63 --- /dev/null +++ b/school/informatik/verkerhssimulation/run verkehrssimulation.bat @@ -0,0 +1 @@ +start bin\Verkehrssimulation.exe -ncle -pluginpath plugins\ \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/Verkehrssimulation.ncb b/school/informatik/verkerhssimulation/src/Verkehrssimulation.ncb new file mode 100644 index 00000000..7ee61746 Binary files /dev/null and b/school/informatik/verkerhssimulation/src/Verkehrssimulation.ncb differ diff --git a/school/informatik/verkerhssimulation/src/Verkehrssimulation.sln b/school/informatik/verkerhssimulation/src/Verkehrssimulation.sln new file mode 100644 index 00000000..b3972c24 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/Verkehrssimulation.sln @@ -0,0 +1,49 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Verkehrssimulation", "Verkehrssimulation.vcproj", "{B720E679-39F9-44EF-BE68-4ACEA83DC0D3}" + ProjectSection(WebsiteProperties) = preProject + Debug.AspNetCompiler.Debug = "True" + Release.AspNetCompiler.Debug = "False" + EndProjectSection + ProjectSection(ProjectDependencies) = postProject + {35AFBABB-DF05-43DE-91A7-BB828A874015} = {35AFBABB-DF05-43DE-91A7-BB828A874015} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OgreMain", "..\..\ogre\OgreMain\scripts\OgreMain_vc8.vcproj", "{35AFBABB-DF05-43DE-91A7-BB828A874015}" + ProjectSection(WebsiteProperties) = preProject + Debug.AspNetCompiler.Debug = "True" + Release.AspNetCompiler.Debug = "False" + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + DebugStaticLib|Win32 = DebugStaticLib|Win32 + Release|Win32 = Release|Win32 + ReleaseStaticLib|Win32 = ReleaseStaticLib|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B720E679-39F9-44EF-BE68-4ACEA83DC0D3}.Debug|Win32.ActiveCfg = Debug|Win32 + {B720E679-39F9-44EF-BE68-4ACEA83DC0D3}.Debug|Win32.Build.0 = Debug|Win32 + {B720E679-39F9-44EF-BE68-4ACEA83DC0D3}.DebugStaticLib|Win32.ActiveCfg = Debug|Win32 + {B720E679-39F9-44EF-BE68-4ACEA83DC0D3}.DebugStaticLib|Win32.Build.0 = Debug|Win32 + {B720E679-39F9-44EF-BE68-4ACEA83DC0D3}.Release|Win32.ActiveCfg = Release|Win32 + {B720E679-39F9-44EF-BE68-4ACEA83DC0D3}.Release|Win32.Build.0 = Release|Win32 + {B720E679-39F9-44EF-BE68-4ACEA83DC0D3}.ReleaseStaticLib|Win32.ActiveCfg = Release|Win32 + {B720E679-39F9-44EF-BE68-4ACEA83DC0D3}.ReleaseStaticLib|Win32.Build.0 = Release|Win32 + {35AFBABB-DF05-43DE-91A7-BB828A874015}.Debug|Win32.ActiveCfg = Debug|Win32 + {35AFBABB-DF05-43DE-91A7-BB828A874015}.Debug|Win32.Build.0 = Debug|Win32 + {35AFBABB-DF05-43DE-91A7-BB828A874015}.DebugStaticLib|Win32.ActiveCfg = DebugStaticLib|Win32 + {35AFBABB-DF05-43DE-91A7-BB828A874015}.DebugStaticLib|Win32.Build.0 = DebugStaticLib|Win32 + {35AFBABB-DF05-43DE-91A7-BB828A874015}.Release|Win32.ActiveCfg = Release|Win32 + {35AFBABB-DF05-43DE-91A7-BB828A874015}.Release|Win32.Build.0 = Release|Win32 + {35AFBABB-DF05-43DE-91A7-BB828A874015}.ReleaseStaticLib|Win32.ActiveCfg = ReleaseStaticLib|Win32 + {35AFBABB-DF05-43DE-91A7-BB828A874015}.ReleaseStaticLib|Win32.Build.0 = ReleaseStaticLib|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + DPBuild = 5 + EndGlobalSection +EndGlobal diff --git a/school/informatik/verkerhssimulation/src/Verkehrssimulation.suo b/school/informatik/verkerhssimulation/src/Verkehrssimulation.suo new file mode 100644 index 00000000..bbca129e Binary files /dev/null and b/school/informatik/verkerhssimulation/src/Verkehrssimulation.suo differ diff --git a/school/informatik/verkerhssimulation/src/Verkehrssimulation.vcproj b/school/informatik/verkerhssimulation/src/Verkehrssimulation.vcproj new file mode 100644 index 00000000..5ae37d41 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/Verkehrssimulation.vcproj @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/school/informatik/verkerhssimulation/src/Verkehrssimulation.vcproj.D00M2007.Rylon.user b/school/informatik/verkerhssimulation/src/Verkehrssimulation.vcproj.D00M2007.Rylon.user new file mode 100644 index 00000000..385fd2fc --- /dev/null +++ b/school/informatik/verkerhssimulation/src/Verkehrssimulation.vcproj.D00M2007.Rylon.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 1.x/ycfg.pas b/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 1.x/ycfg.pas new file mode 100644 index 00000000..d1720aca --- /dev/null +++ b/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 1.x/ycfg.pas @@ -0,0 +1,616 @@ +unit ycfg; + +//v.1.015 + +interface + +uses sysutils,classes; + +//strings +function guckenobzeichenenthaltenist(infostring,searchstring,divideparam:String):boolean; +function dividestring(str,platzhalter:string;stellenzeiger:integer):string; +function getnumberofdivides(str,platzhalter:string):integer; + +//Wert + //get + +function getYcfgStr(Filename,info,platzhalter:string):string; overload; +function getYcfgStr(Filename,info:string):string; overload; +function getYcfgStr(StringlistWithFile:Tstringlist;info,platzhalter:string):string; overload; +function getYcfgStr(StringlistWithFile:Tstringlist;info:string):string; overload; + +function getYcfgInt(Filename,info,platzhalter:string;defaultint:integer):integer; overload; +function getYcfgInt(Filename,info:string;defaultint:integer):integer; overload; +function getYcfgInt(Filename,info:string):integer; overload; +function getYcfgInt(Filename:TStringlist;info,platzhalter:string;defaultint:integer):integer;overload; +function getYcfgInt(Filename:TStringlist;info:string;defaultint:integer):integer;overload; +function getYcfgInt(Filename:TStringlist;info:string):integer;overload; + +function getYcfgBool(Filename,info,platzhalter:string):boolean; overload; +function getYcfgBool(Filename,info:string):boolean; overload; +function getYcfgBool(StringlistWithFile:Tstringlist;info,platzhalter:string):boolean; overload; +function getYcfgBool(StringlistWithFile:Tstringlist;info:string):boolean; overload; + + //set +procedure setYcfgStr(Filename,info,wert,platzhalter:string);overload; +procedure setYcfgStr(Filename,info,wert:string);overload; +function setYcfgStr(StringlistWithFile:TStringlist;info,wert,platzhalter:string):TStringlist;overload; +function setYcfgStr(StringlistWithFile:TStringlist;info,wert:string):TStringlist;overload; + +procedure setYcfgInt(Filename,info,platzhalter:string;wert:integer);overload; +procedure setYcfgInt(Filename,info:string;wert:integer);overload; +function setYcfgInt(Filename:TStringlist;info,platzhalter:string;wert:integer):Tstringlist;overload; +function setYcfgInt(Filename:TStringlist;info:string;wert:integer):Tstringlist;overload; + +procedure setYcfgBool(Filename,info,platzhalter:string;wert,writtentrue:boolean);overload; +procedure setYcfgBool(Filename,info:string;wert,writtentrue:boolean);overload; +procedure setYcfgBool(Filename,info:string;wert:boolean);overload; +function setYcfgBool(StringlistWithFile:TStringlist;info,platzhalter:string;wert,writtentrue:boolean):TStringlist;overload; +function setYcfgBool(StringlistWithFile:TStringlist;info:string;wert,writtentrue:boolean):TStringlist;overload; +function setYcfgBool(StringlistWithFile:TStringlist;info:string;wert:boolean):TStringlist;overload; + +//Liste + //get +function getYcfgListe(filepath,divideparam,ignorelist,platzhalter:string):TStringlist; overload; +function getYcfgListe(StringlistWithFile:TStringlist;divideparam,ignorelist,platzhalter:string):TStringlist; overload; + +implementation + +function guckenobzeichenenthaltenist(infostring,searchstring,divideparam:String):boolean; +var count1:integer; +begin +//bsp: +// +// Rückgabewert von guckenobzeichenenthaltenist('1,2,3,4,5,6,7,8,9','1',',') ist true +// Dagegen ist guckenobzeichenenthaltenist('1,2,3,4,5,6,7,8,9','10',',') false + + result:=false; + count1:=getnumberofdivides(infostring,divideparam); + if count1>0 then + begin + repeat + if dividestring(infostring,divideparam,count1)=searchstring then result:=true; + count1:=count1-1; + until count1<=0; + end; + +end; + +function getycfgliste(StringlistWithFile:TStringlist;divideparam,ignorelist,platzhalter:string):TStringlist; overload; +var output:TStringlist; + count1,count2:integer; + test1,ende:boolean; +begin + +//Bsp: +// +// Textfile: +// ... +// //Foren +// ---Forum--- //Achtung neue function +// //Forumname;Forumkonfigdatei;infofile;guest;icon; +// Testenisscheiße +// +// ---Forum--- +// ... +// +// temp:=divideycfgfile(wheredistextfileare,'---Forum---','#;##;(*;//',';'); +// +// Das Ergebnis der function wäre in diesem Falle: "Testenisscheiße", weil alle +// leeren Zeilen und alle Zeilen mit #,##,(* und // am Anfang ignoriert werden. +// Außerdem alle leeren Zeilen. Es wird nur zwischen "---Forum---" gesucht. +// Der Letzte Parameter (platzhalter) (in diesem Falle ";") steht für den "Trenner" +// zu ignorierenden Zeilenanfängen! + + output:=TStringlist.create; + + ende:=false; + + if StringlistWithFile.count>0 then + begin + count1:=0; + repeat + if copy(StringlistWithFile.strings[count1],1,length(divideparam))=divideparam then + begin + count1:=count1+1; + repeat + if copy(StringlistWithFile.strings[count1],1,length(divideparam))=divideparam then ende:=true else + begin + if ende=false then + begin + count2:=1; + test1:=false; + + if getnumberofdivides(ignorelist,platzhalter)<>0 then + begin + repeat + if copy(StringlistWithFile.strings[count1],1,length(dividestring(ignorelist,platzhalter,count2)))= dividestring(ignorelist,platzhalter,count2) then test1:=true; + if StringlistWithFile.Strings[count1]='' then test1:=true; + count2:=count2+1; + until count2>=getnumberofdivides(ignorelist,platzhalter); + end; + + if test1=false then output.Add(StringlistWithFile.strings[count1]); + end; + end; + count1:=count1+1; + until count1>=StringlistWithFile.count; + end; + count1:=count1+1; + until count1>=StringlistWithFile.count-1; + end; + + result:=output; + + +end; + +function getycfgliste(filepath,divideparam,ignorelist,platzhalter:string):TStringlist; overload; +var temp,output:TStringlist; + count1,count2:integer; + test1,ende:boolean; +begin + +//Bsp: +// +// Textfile: +// ... +// //Foren +// ---Forum--- //Achtung neue function +// //Forumname;Forumkonfigdatei;infofile;guest;icon; +// Testenisscheiße +// +// ---Forum--- +// ... +// +// temp:=divideycfgfile(wheredistextfileare,'---Forum---','#;##;(*;//',';'); +// +// Das Ergebnis der function wäre in diesem Falle: "Testenisscheiße", weil alle +// leeren Zeilen und alle Zeilen mit #,##,(* und // am Anfang ignoriert werden. +// Außerdem alle leeren Zeilen. Es wird nur zwischen "---Forum---" gesucht. +// Der Letzte Parameter (platzhalter) (in diesem Falle ";") steht für den "Trenner" +// zu ignorierenden Zeilenanfängen! + + if fileexists(filepath) then + begin + temp:=TStringlist.create; + output:=TStringlist.create; + temp.loadfromfile(filepath); + + ende:=false; + + if temp.count>0 then + begin + count1:=0; + repeat + if copy(temp.strings[count1],1,length(divideparam))=divideparam then + begin + count1:=count1+1; + repeat + if copy(temp.strings[count1],1,length(divideparam))=divideparam then ende:=true else + begin + if ende=false then + begin + count2:=1; + test1:=false; + + if getnumberofdivides(ignorelist,platzhalter)<>0 then + begin + repeat + if copy(temp.strings[count1],1,length(dividestring(ignorelist,platzhalter,count2)))= dividestring(ignorelist,platzhalter,count2) then test1:=true; + if temp.Strings[count1]='' then test1:=true; + count2:=count2+1; + until count2>=getnumberofdivides(ignorelist,platzhalter); + end; + + if test1=false then output.Add(temp.strings[count1]); + end; + end; + count1:=count1+1; + until count1>=temp.count; + end; + count1:=count1+1; + until count1>=temp.count-1; + end; + temp.free; + end; + + result:=output; + + +end; + +function getnumberofdivides(str,platzhalter:string):integer; +var count1,divides:integer; +begin + +//Bsp: +// +// Diese function stellt fest, wie oft der string unterteilt +// worden ist mit dem Trenner "platzhalter". +// +// getnumberofdivides('test1;test2;test3;',';') gibt den Wert 3 aus. +// getnumberofdivides('test1;test2;test3',';') gibt auch den Wert 3 aus. + + if str='' then + begin + result:=0; + exit; + end; + + divides:=0; + count1:=1; + repeat + if copy(str,count1,1)=platzhalter then divides:=divides+1; + count1:=count1+1; + until count1>length(str); + + if copy(str,length(str),1)<>platzhalter then divides:=divides+1; + + result:=divides; + +end; + +function dividestring(str,platzhalter:string;stellenzeiger:integer):string; +var text1:string; + count1:integer; +begin + +//Bsp: text1;text2;text3 ... jetzt hast du diesen String... Die Function +// kann jetzt den string aufteilen in die drei +// Teile: +// +// dividestring('text1;text2;text3;',';',1) +// Das Ergebnis ist "text1" + + if length(str)>0 then + begin + + count1:=1; + text1:=''; + repeat + if copy(str,count1,1)=platzhalter then + begin + stellenzeiger:=stellenzeiger-1; + if stellenzeiger<=0 then + begin + result:=text1; + exit; + end; + text1:=''; + end else text1:=text1+copy(str,count1,1); + if count1=length(str) then + begin + result:=text1; + exit; + end; + count1:=count1+1; + until count1>length(str); + + end; + +end; + +function getYcfgStr(Filename,info:string):string; overload; +begin + + result:=getYcfgStr(Filename,info,'='); + +end; + +function getycfgStr(Filename,info,platzhalter:string):string; overload; +var text1:string; + count1,count2:integer; + test1:boolean; + ycfg:TStringlist; +begin +//Bsp: in einer textdatei filename steht der string test=123 , dann ist die rückgabe von getycfgwert(Filename,'test','=') = '123' + + if fileexists(filename) then + begin + ycfg:=TStringlist.create; + ycfg.LoadFromFile(filename); + + if ycfg.Count>0 then + begin + count1:=0; + repeat + text1:=''; + test1:=false; + count2:=1; + repeat + if copy(ycfg.Strings[count1],count2,1)<>platzhalter then text1:=text1+copy(ycfg.Strings[count1],count2,1) else test1:=true; + if count2>=length(ycfg.Strings[count1]) then test1:=true; + count2:=count2+1; + until test1=true; + + if lowercase(text1)=lowercase(info) then result:=copy(ycfg.Strings[count1],length(text1)+2,length(ycfg.strings[count1])); + count1:=count1+1; + until count1>=ycfg.Count; + end; + end; + +end; + +function getYcfgStr(StringlistWithFile:Tstringlist;info:string):string; overload; +begin + + result:=getYcfgStr(StringlistWithFile,info,'='); + +end; + +function getycfgStr(StringlistWithFile:Tstringlist;info,platzhalter:string):string; overload; +var text1:string; + count1,count2:integer; + test1:boolean; +begin + + if StringlistWithFile.Count>0 then + begin + count1:=0; + repeat + text1:=''; + test1:=false; + count2:=1; + repeat + if copy(StringlistWithFile.Strings[count1],count2,1)<>platzhalter then text1:=text1+copy(StringlistWithFile.Strings[count1],count2,1) else test1:=true; + if count2>=length(StringlistWithFile.Strings[count1]) then test1:=true; + count2:=count2+1; + until test1=true; + + if lowercase(text1)=lowercase(info) then result:=copy(StringlistWithFile.Strings[count1],length(text1)+2,length(StringlistWithFile.strings[count1])); + + count1:=count1+1; + until count1>=StringlistWithFile.Count; + end; + +end; + +function getYcfgInt(Filename,info:string):integer; overload; +begin + + result:=getYcfgInt(filename,info,'=',-1); + +end; + +function getYcfgInt(Filename,info:string;defaultint:integer):integer; overload; +begin + + result:=getYcfgInt(filename,info,'=',defaultint); + +end; + +function getycfgInt(Filename,info,platzhalter:string;defaultint:integer):integer; overload; +begin + + result:=strtointdef(getycfgStr(Filename,info,platzhalter),defaultint); + +end; + +function getYcfgInt(Filename:TStringlist;info:string):integer;overload; +begin + + result:=getYcfgInt(filename,info,'=',-1); + +end; + +function getYcfgInt(Filename:TStringlist;info:string;defaultint:integer):integer;overload; +begin + + result:=getYcfgInt(filename,info,'=',defaultint); + +end; + +function getycfgInt(Filename:TStringlist;info,platzhalter:string;defaultint:integer):integer; overload; +begin + + result:=strtointdef(getycfgStr(Filename,info,platzhalter),defaultint); + +end; + +function getYcfgBool(Filename,info:string):boolean; overload; +begin + + result:=getYcfgBool(filename,info,'='); + +end; + +function getYcfgBool(Filename,info,platzhalter:string):boolean; overload; +begin + + if (getycfgStr(filename,info,platzhalter)='1') or (lowercase(getycfgStr(filename,info,platzhalter))='true') then result:=true else result:=false; + +end; + +function getYcfgBool(StringlistWithFile:Tstringlist;info:string):boolean; overload; +begin + + result:=getYcfgBool(StringlistWithFile,info,'='); + +end; + +function getYcfgBool(StringlistWithFile:Tstringlist;info,platzhalter:string):boolean; overload; +begin + + if (getycfgStr(StringlistWithFile,info,platzhalter)='1') or (lowercase(getycfgStr(StringlistWithFile,info,platzhalter))='true') then result:=true else result:=false; + +end; + +procedure setYcfgStr(Filename,info,wert:string);overload; +begin + + setycfgstr(filename,info,wert,'='); + +end; + +procedure setycfgStr(Filename,info,wert,platzhalter:string); +var text1:string; + count1,count2:integer; + test1,test2:boolean; + ycfg:TSTringlist; +begin + + ycfg:=TStringlist.create; + + test2:=false; + if fileexists(filename) then + begin + ycfg.LoadFromFile(filename); + + if ycfg.Count>0 then + begin + count1:=0; + repeat + text1:=''; + test1:=false; + count2:=1; + repeat + if copy(ycfg.Strings[count1],count2,1)<>platzhalter then text1:=text1+copy(ycfg.Strings[count1],count2,1) else test1:=true; + if count2>=length(ycfg.Strings[count1]) then test1:=true; + count2:=count2+1; + until test1=true; + + if lowercase(text1)=lowercase(info) then + begin + test2:=true; + ycfg.Strings[count1]:=info+platzhalter+wert; + end; + + count1:=count1+1; + until count1>=ycfg.Count; + end; + end; + + if test2=false then ycfg.Add(info+platzhalter+wert); + + ycfg.SaveToFile(filename); + + ycfg.Free; + +end; + +function setYcfgStr(StringlistWithFile:TStringlist;info,wert:string):TStringlist;overload; +begin + + result:=setycfgstr(StringlistWithFile,info,wert,'='); + +end; + +function setycfgStr(StringlistWithFile:TStringlist;info,wert,platzhalter:string):TStringlist; +var text1:string; + count1,count2:integer; + test1,test2:boolean; +begin + + test2:=false; + if StringlistWithFile.Count>0 then + begin + count1:=0; + repeat + text1:=''; + test1:=false; + count2:=1; + repeat + if copy(StringlistWithFile.Strings[count1],count2,1)<>platzhalter then text1:=text1+copy(StringlistWithFile.Strings[count1],count2,1) else test1:=true; + if count2>=length(StringlistWithFile.Strings[count1]) then test1:=true; + count2:=count2+1; + until test1=true; + + if lowercase(text1)=lowercase(info) then + begin + test2:=true; + StringlistWithFile.Strings[count1]:=info+platzhalter+wert; + end; + + count1:=count1+1; + until count1>=StringlistWithFile.Count; + end; + + if test2=false then StringlistWithFile.Add(info+platzhalter+wert); + + result:=StringlistWithFile; +end; + +procedure setYcfgInt(Filename,info:string;wert:integer);overload; +begin + + setYcfgInt(filename,info,'=',wert); + +end; + +procedure setycfgInt(Filename,info,platzhalter:string;wert:integer);overload; +begin + + setycfgStr(Filename,info,inttostr(wert),platzhalter); + +end; + +function setYcfgInt(Filename:TStringlist;info:string;wert:integer):Tstringlist;overload; +begin + + result:=setYcfgInt(filename,info,'=',wert); + +end; + +function setycfgInt(Filename:TStringlist;info,platzhalter:string;wert:integer):TStringlist; overload +begin + + result:=setycfgStr(Filename,info,inttostr(wert),platzhalter); + +end; + +procedure setYcfgBool(Filename,info:string;wert:boolean);overload; +begin + + setYcfgBool(filename,info,'=',wert,false); + +end; + +procedure setYcfgBool(Filename,info:string;wert,writtentrue:boolean);overload; +begin + + setYcfgBool(filename,info,'=',wert,writtentrue); + +end; + +procedure setYcfgBool(Filename,info,platzhalter:string;wert,writtentrue:boolean);overload; +begin + + if wert then + begin + if writtentrue then setycfgStr(Filename,info,'true',platzhalter) else setycfgStr(Filename,info,'1',platzhalter); + end else + begin + if writtentrue then setycfgStr(Filename,info,'false',platzhalter) else setycfgStr(Filename,info,'0',platzhalter); + end; + +end; + +function setYcfgBool(StringlistWithFile:TStringlist;info:string;wert:boolean):TStringlist;overload; +begin + + result:=setYcfgBool(StringlistWithFile,info,'=',wert,false); + +end; + +function setYcfgBool(StringlistWithFile:TStringlist;info:string;wert,writtentrue:boolean):TStringlist;overload; +begin + + result:=setYcfgBool(StringlistWithFile,info,'=',wert,writtentrue); + +end; + +function setYcfgBool(StringlistWithFile:TStringlist;info,platzhalter:string;wert,writtentrue:boolean):TStringlist;overload; +begin + + if wert then + begin + if writtentrue then result:=setycfgStr(StringlistWithFile,info,'true',platzhalter) else result:=setycfgStr(StringlistWithFile,info,'1',platzhalter); + end else + begin + if writtentrue then result:=setycfgStr(StringlistWithFile,info,'false',platzhalter) else result:=setycfgStr(StringlistWithFile,info,'0',platzhalter); + end; + +end; + +end. diff --git a/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/YCFGDemo.cfg b/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/YCFGDemo.cfg new file mode 100644 index 00000000..18840108 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/YCFGDemo.cfg @@ -0,0 +1,35 @@ +-$A8 +-$B- +-$C+ +-$D+ +-$E- +-$F- +-$G+ +-$H+ +-$I+ +-$J- +-$K- +-$L+ +-$M- +-$N+ +-$O+ +-$P+ +-$Q- +-$R- +-$S- +-$T- +-$U- +-$V+ +-$W- +-$X+ +-$YD +-$Z1 +-cg +-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; +-H+ +-W+ +-M +-$M16384,1048576 +-K$00400000 +-LE"c:\programme\delphi\delphi 6\Projects\Bpl" +-LN"c:\programme\delphi\delphi 6\Projects\Bpl" diff --git a/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/YCFGDemo.dof b/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/YCFGDemo.dof new file mode 100644 index 00000000..c6d31c04 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/YCFGDemo.dof @@ -0,0 +1,83 @@ +[FileVersion] +Version=6.0 +[Compiler] +A=8 +B=0 +C=1 +D=1 +E=0 +F=0 +G=1 +H=1 +I=1 +J=0 +K=0 +L=1 +M=0 +N=1 +O=1 +P=1 +Q=0 +R=0 +S=0 +T=0 +U=0 +V=1 +W=0 +X=1 +Y=1 +Z=1 +ShowHints=1 +ShowWarnings=1 +UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; +[Linker] +MapFile=0 +OutputObjs=0 +ConsoleApp=1 +DebugInfo=0 +RemoteSymbols=0 +MinStackSize=16384 +MaxStackSize=1048576 +ImageBase=4194304 +ExeDescription= +[Directories] +OutputDir= +UnitOutputDir= +PackageDLLOutputDir= +PackageDCPOutputDir= +SearchPath= +Packages= +Conditionals= +DebugSourceDirs= +UsePackages=0 +[Parameters] +RunParams= +HostApplication= +Launcher= +UseLauncher=0 +DebugCWD= +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1031 +CodePage=1252 +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= diff --git a/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/YCFGDemo.dpr b/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/YCFGDemo.dpr new file mode 100644 index 00000000..d6334cd4 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/YCFGDemo.dpr @@ -0,0 +1,13 @@ +program YCFGDemo; + +uses + Forms, + uycfgdemo in 'uycfgdemo.pas' {fMain}; + +{$R *.res} + +begin + Application.Initialize; + Application.CreateForm(TfMain, fMain); + Application.Run; +end. diff --git a/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/YCFGDemo.exe b/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/YCFGDemo.exe new file mode 100644 index 00000000..3f0e8250 Binary files /dev/null and b/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/YCFGDemo.exe differ diff --git a/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/uycfgdemo.ddp b/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/uycfgdemo.ddp new file mode 100644 index 00000000..cdc0ee8c Binary files /dev/null and b/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/uycfgdemo.ddp differ diff --git a/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/uycfgdemo.dfm b/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/uycfgdemo.dfm new file mode 100644 index 00000000..143cf196 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/uycfgdemo.dfm @@ -0,0 +1,332 @@ +object fMain: TfMain + Left = 317 + Top = 230 + Width = 870 + Height = 640 + Caption = 'YCFG DEMO' + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + OldCreateOrder = False + PixelsPerInch = 96 + TextHeight = 13 + object PageControl1: TPageControl + Left = 0 + Top = 0 + Width = 862 + Height = 613 + ActivePage = TabSheet1 + Align = alClient + TabIndex = 0 + TabOrder = 0 + object TabSheet1: TTabSheet + Caption = 'Einleitung' + object Memo1: TMemo + Left = 0 + Top = 0 + Width = 854 + Height = 585 + Align = alClient + BevelInner = bvNone + BevelOuter = bvNone + BorderStyle = bsNone + Color = cl3DLight + Lines.Strings = ( + '' + 'YCFG Demo' + 'by Rylon t.H.D. a member of Yeminy' + '' + 'Diese Demo zeigt die Funktionen der ycfg unit auf.' + '' + + 'Die ycfg unit ist zum auslesen von configfiles '#228'hnlich den ini f' + + 'iles entwickelt worden.' + 'um sie einzubinden muss sie in den uses vermerkt werden:' + '' + 'Bsp:' + 'uses' + + ' Windows, Messages, SysUtils, Variants, Classes, Graphics, Cont' + + 'rols, Forms,' + ' Dialogs, ComCtrls, {!}ycfg{!}, StdCtrls;' + '' + + 'Au'#223'erdem muss sie sich auf dem Suchpfad befinden. Bzw im Program' + + 'mordner' + '' + 'Nun zum Praktischen: Bl'#228'tere eine Seite Weiter!') + TabOrder = 0 + end + end + object TabSheet2: TTabSheet + Caption = 'Strings' + ImageIndex = 1 + object Label1: TLabel + Left = 96 + Top = 275 + Width = 151 + Height = 13 + Caption = 'dividestring(Ausgangsstring.text,' + Color = clGray + Font.Charset = DEFAULT_CHARSET + Font.Color = clRed + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentColor = False + ParentFont = False + Transparent = True + end + object Label2: TLabel + Left = 520 + Top = 275 + Width = 6 + Height = 13 + Caption = ');' + Color = clGray + Font.Charset = DEFAULT_CHARSET + Font.Color = clRed + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentColor = False + ParentFont = False + Transparent = True + end + object Label3: TLabel + Left = 387 + Top = 275 + Width = 3 + Height = 13 + Caption = ',' + Color = clGray + Font.Charset = DEFAULT_CHARSET + Font.Color = clRed + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentColor = False + ParentFont = False + Transparent = True + end + object Label4: TLabel + Left = 8 + Top = 232 + Width = 482 + Height = 20 + Caption = + 'function dividestring(str,platzhalter:string;stellenzeiger:integ' + + 'er):string;' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentFont = False + end + object Label5: TLabel + Left = 8 + Top = 328 + Width = 406 + Height = 20 + Caption = 'function getnumberofdivides(str,platzhalter:string):integer;' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentFont = False + end + object Label6: TLabel + Left = 96 + Top = 371 + Width = 190 + Height = 13 + Caption = 'getnumberofdivides(Ausgangsstring.text,' + Color = clGray + Font.Charset = DEFAULT_CHARSET + Font.Color = clRed + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentColor = False + ParentFont = False + Transparent = True + end + object Label7: TLabel + Left = 424 + Top = 371 + Width = 6 + Height = 13 + Caption = ');' + Color = clGray + Font.Charset = DEFAULT_CHARSET + Font.Color = clRed + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentColor = False + ParentFont = False + Transparent = True + end + object ausgangsstring: TLabeledEdit + Left = 8 + Top = 192 + Width = 441 + Height = 21 + EditLabel.Width = 92 + EditLabel.Height = 13 + EditLabel.Caption = 'Der Ausgangsstring' + LabelPosition = lpAbove + LabelSpacing = 3 + TabOrder = 0 + Text = 'adam;eva;m'#252'ller;hallo;test;nochnezeichenfolge;' + end + object Memo3: TMemo + Left = 0 + Top = 496 + Width = 854 + Height = 89 + Align = alBottom + BevelInner = bvNone + BevelOuter = bvNone + BorderStyle = bsNone + Color = cl3DLight + Lines.Strings = ( + 'In der Praxis sieht das dann so aus:' + '' + 'temps ist eine string variable' + 'eineconfigvariable ist eine config variable' + '' + 'eineconfigvariable:=dividestring(temps,'#39';'#39',1);') + TabOrder = 1 + end + object Button1: TButton + Left = 8 + Top = 272 + Width = 75 + Height = 25 + Caption = 'Mache es' + TabOrder = 2 + OnClick = Button1Click + end + object Platzhalter: TLabeledEdit + Left = 264 + Top = 272 + Width = 121 + Height = 21 + EditLabel.Width = 49 + EditLabel.Height = 13 + EditLabel.Caption = 'Platzhalter' + LabelPosition = lpAbove + LabelSpacing = 3 + TabOrder = 3 + Text = ';' + end + object Stellenanzeige: TLabeledEdit + Left = 392 + Top = 272 + Width = 121 + Height = 21 + EditLabel.Width = 69 + EditLabel.Height = 13 + EditLabel.Caption = 'Stellenanzeige' + LabelPosition = lpAbove + LabelSpacing = 3 + TabOrder = 4 + Text = '3' + end + object Memo4: TMemo + Left = 0 + Top = 0 + Width = 854 + Height = 153 + Align = alTop + BevelInner = bvNone + BevelOuter = bvNone + BorderStyle = bsNone + Color = cl3DLight + Lines.Strings = ( + 'Strings k'#246'nnen mit der ycfg unit geteilt werden' + '' + + 'Solte der String nicht lang genug sein, wie die angegebene Stell' + + 'enanzeige, dann wird die lezte ausgegeben.' + '' + 'Bsp:' + '' + 'showmessage(devidestring(Ausgangsstring.text,'#39';'#39',8234395));' + '' + 'Die schowmessage w'#252'rde "nochnezeichenfolge" lauten. ' + '' + + 'Au'#223'erdem ist es nicht n'#246'tig am ende nocheinmal ein ";" zu setzen' + + ' - Probiers aus!') + TabOrder = 5 + end + object Button2: TButton + Left = 8 + Top = 368 + Width = 75 + Height = 25 + Caption = 'Mach es' + TabOrder = 6 + OnClick = Button2Click + end + object Platzhalter2: TLabeledEdit + Left = 296 + Top = 368 + Width = 121 + Height = 21 + EditLabel.Width = 49 + EditLabel.Height = 13 + EditLabel.Caption = 'Platzhalter' + LabelPosition = lpAbove + LabelSpacing = 3 + TabOrder = 7 + Text = ';' + end + end + object TabSheet3: TTabSheet + Caption = 'Config: Werte auslesen' + ImageIndex = 2 + end + object TabSheet4: TTabSheet + Caption = 'Config: Werte schreiben' + ImageIndex = 3 + end + object TabSheet5: TTabSheet + Caption = 'Config: Liste auslesen' + ImageIndex = 4 + end + object TabSheet6: TTabSheet + Caption = 'Config: Liste schreiben' + ImageIndex = 5 + end + object TabSheet7: TTabSheet + Caption = 'Contact' + ImageIndex = 6 + object Memo2: TMemo + Left = 0 + Top = 0 + Width = 854 + Height = 585 + Align = alClient + BevelInner = bvNone + BevelOuter = bvNone + BorderStyle = bsNone + Color = cl3DLight + Lines.Strings = ( + 'Contact:' + '' + + 'Du kannst mich '#252'ber rylon@web.de erreichen, soltlen Fragen oder ' + + 'Probleme auftreten.') + TabOrder = 0 + end + end + end +end diff --git a/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/uycfgdemo.pas b/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/uycfgdemo.pas new file mode 100644 index 00000000..fb3ee94e --- /dev/null +++ b/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/Demo/uycfgdemo.pas @@ -0,0 +1,65 @@ +unit uycfgdemo; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, ComCtrls, ycfg, StdCtrls, ExtCtrls; + +type + TfMain = class(TForm) + PageControl1: TPageControl; + TabSheet1: TTabSheet; + Memo1: TMemo; + TabSheet2: TTabSheet; + TabSheet3: TTabSheet; + TabSheet4: TTabSheet; + TabSheet5: TTabSheet; + TabSheet6: TTabSheet; + TabSheet7: TTabSheet; + Memo2: TMemo; + ausgangsstring: TLabeledEdit; + Memo3: TMemo; + Label1: TLabel; + Button1: TButton; + Platzhalter: TLabeledEdit; + Stellenanzeige: TLabeledEdit; + Label2: TLabel; + Label3: TLabel; + Memo4: TMemo; + Label4: TLabel; + Label5: TLabel; + Button2: TButton; + Label6: TLabel; + Platzhalter2: TLabeledEdit; + Label7: TLabel; + procedure Button1Click(Sender: TObject); + procedure Button2Click(Sender: TObject); + private + { Private declarations } + public + { Public declarations } + end; + +var + fMain: TfMain; + +implementation + +{$R *.dfm} + +procedure TfMain.Button1Click(Sender: TObject); +begin + + showmessage({aus der ycfg unit ->}divideAstring(ausgangsstring.text,platzhalter.text{Daslabeled edit},strtointdef(stellenanzeige.text,1))); + +end; + +procedure TfMain.Button2Click(Sender: TObject); +begin + + showmessage(inttostr(getStringDivides(ausgangsstring.Text,platzhalter2.text))); + +end; + +end. diff --git a/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/ycfg.pas b/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/ycfg.pas new file mode 100644 index 00000000..c1765514 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/c_ycfg/ycfg 2.x/ycfg.pas @@ -0,0 +1,2167 @@ +{ + + **************************************************************************** + | YCFG Unit Version 2.00 | + | | + | Copyright (c) 2006 by Yeminy | + | Copyright (c) 2006 by Rylon | + | | + | 165 Function/Procedures | + | | + | 165 Done : 0 ToDo >>> 100,00% Done : 0,00% ToDO | + | | + | 0 Tested : 165 ToDo >>> 0,00% Done : 100,00% ToDo | + | | + **************************************************************************** + + **************************************************************************** + | License: | + | | + **************************************************************************** + + **************************************************************************** + | ToDo: Falls es viele Keys gibt, alle in einer Liste ausgeben | + | Bsp: test=2135123 | + | test=213ds435dsf | + | | + | Comments automatisch löschen und immer eine Funktion um das zu | + | unterbinden | + | | + | Leerezeile einfügen | + | | + | get Section/List text (ohne Header) | + | | + | setYcfgSection -> text hinzufügen | + | | + **************************************************************************** + + **************************************************************************** + | ChangeLog: | + | -started project ycfg 2 | + **************************************************************************** + +} + +unit ycfg; + +interface + +uses SysUtils, Classes, windows, Graphics, ycode, dialogs; + +// OTHER***************************************************************************************************************************** //-- + //-- +//strings //-- +function isStringIncluded(SourceString,SearchString,DivideParam:String):boolean; overload; //w +function isStringIncluded(SourceString,SearchString:String):boolean; overload; //w + //-- +//function delStringPart(Sourcestring,DivideParam:string;Position:integer):string; // +//function delStringPart(Sourcestring:string;Position:integer):string; // +//function delStringPart(Sourcestring,Searchstring,DivideParam:string):string; // +//function delStringPart(Sourcestring,Searchstring:string):string; // + //-- +function DivideAString(SourceString,DivideParam:string;Position:integer):string; overload; //wt +function DivideAString(SourceString:string;Position:integer):string; overload; //wt + //-- +function getStringDivides(SourceString,DivideParam:string):integer; overload; //wt +function getStringDivides(SourceString:string):integer; overload; //wt + //-- +//sections //-- +procedure delYcfgSection(YcfgFile,Section:string); overload; //w +procedure delYcfgSection(var YcfgFile:TStringlist;Section:string); overload; //w + //-- +procedure createYcfgSection(YcfgFile,Section:string); overload; //w +procedure createYcfgSection(var YcfgFile:TStringlist;Section:string); overload; //w + //-- +procedure clearYcfgSection(YcfgFile,Section:string); overload; //w +procedure clearYcfgSection(var YcfgFile:TStringlist;Section:string); overload; //w + //-- +function YcfgSectionExists(YcfgFile,Section:string):boolean; overload; //w +function YcfgSectionExists(var YcfgFile:TStringlist;Section:string):boolean; overload; //w + //-- +//Ycfg File //-- + //-- +//function delComments(YcfgFile:string):boolean; overload; // +//function delComments(YcfgFile:TStringlist):boolean; overload; // + //-- +function checkYcfgHeader(YcfgFile:string):boolean; overload; //w +function checkYcfgHeader(YcfgFile:TStringlist):boolean; overload; //w + //-- +procedure writeYcfgHeader(YcfgFile:string); overload; //w +procedure writeYcfgHeader(YcfgFile:TStringlist); overload; //w + //-- +function readYcfgHeader(YcfgFile:string):string; overload; //w +function readYcfgHeader(YcfgFile:TStringlist):string; overload; //w + //-- +//Ycfg Unit //-- + //-- +function getYcfgVersion:string; //w + //-- +// GET******************************************************************************************************************************* //-- + //-- +//sections //-- +function getYcfgSections(YcfgFile:string):TStringList; overload; //w +function getYcfgSections(YcfgFile:TStringlist):TStringList; overload; //w + //-- +function getYcfgSection(YcfgFile,Section:string):TStringList; overload; //wt +function getYcfgSection(YcfgFile:TStringlist;Section:string):TStringList; overload; //wt + //-- +function getYcfgSectionKeys(YcfgFile,Section,DivideParam:string):TStringList; overload; //w +function getYcfgSectionKeys(YcfgFile,Section:string):TStringList; overload; //w +function getYcfgSectionKeys(YcfgFile:TStringlist;Section,DivideParam:string):TStringList; overload; //w +function getYcfgSectionKeys(YcfgFile:TStringlist;Section:string):TStringList; overload; //w + //-- +function getYcfgSectionNoKeys(YcfgFile,Section,DivideParam:string):TStringList; overload; //w +function getYcfgSectionNoKeys(YcfgFile,Section:string):TStringList; overload; //w +function getYcfgSectionNoKeys(YcfgFile:TStringlist;Section,DivideParam:string):TStringList; overload; //w +function getYcfgSectionNoKeys(YcfgFile:TStringlist;Section:string):TStringList; overload; //w + //-- +function getYcfgSectionValues(YcfgFile,Section,DivideParam:string):TStringList; overload; //w +function getYcfgSectionValues(YcfgFile,Section:string):TStringList; overload; //w +function getYcfgSectionValues(YcfgFile:TStringlist;Section,DivideParam:string):TStringList; overload; //w +function getYcfgSectionValues(YcfgFile:TStringlist;Section:string):TStringList; overload; //w + //-- +function getYcfgSectionPos(YcfgFile,Section:string):TPoint; overload; //w +function getYcfgSectionPos(YcfgFile:TStringlist;Section:string):TPoint; overload; //w + //-- +//String //-- + //global //-- +function getYcfgStr(YcfgFile,SearchString,DivideParam:string):string; overload; //w +function getYcfgStr(YcfgFile,SearchString:string):string; overload; //w +function getYcfgStr(YcfgFile:TStringlist;SearchString,DivideParam:string):string; overload; //w +function getYcfgStr(YcfgFile:Tstringlist;SearchString:string):string; overload; //w + //section //-- +function getYcfgSecStr(YcfgFile,Section,SearchString,DivideParam:string):string; overload; //wt +function getYcfgSecStr(YcfgFile,Section,SearchString:string):string; overload; //wt +function getYcfgSecStr(YcfgFile:TStringlist;Section,SearchString,DivideParam:string):string; overload; //wt +function getYcfgSecStr(YcfgFile:Tstringlist;Section,SearchString:string):string; overload; //wt + //-- +//Integer //-- + //global //-- +function getYcfgInt(YcfgFile,SearchString,DivideParam:string;DefaultValue:integer):integer; overload; //w +function getYcfgInt(YcfgFile,SearchString:string;DefaultValue:integer):integer; overload; //w +function getYcfgInt(YcfgFile:TStringlist;SearchString,DivideParam:string;DefaultValue:integer):integer; overload; //w +function getYcfgInt(YcfgFile:TStringlist;SearchString:string;DefaultValue:integer):integer; overload; //w + //section //-- +function getYcfgSecInt(YcfgFile,Section,SearchString,DivideParam:string;DefaultValue:integer):integer; overload; //w +function getYcfgSecInt(YcfgFile,Section,SearchString:string;DefaultValue:integer):integer; overload; //w +function getYcfgSecInt(YcfgFile:TStringlist;Section,SearchString,DivideParam:string;DefaultValue:integer):integer; overload; //w +function getYcfgSecInt(YcfgFile:TStringlist;Section,SearchString:string;DefaultValue:integer):integer; overload; //w + //-- +//Bool //-- + //global //-- +function getYcfgBool(YcfgFile,SearchString,DivideParam:string;DefaultValue:boolean):boolean; overload; //w +function getYcfgBool(YcfgFile,SearchString:string;DefaultValue:boolean):boolean; overload; //w +function getYcfgBool(YcfgFile:TStringlist;SearchString,DivideParam:string;DefaultValue:boolean):boolean; overload; //w +function getYcfgBool(YcfgFile:TStringlist;SearchString:string;DefaultValue:boolean):boolean; overload; //w + //section //-- +function getYcfgSecBool(YcfgFile,Section,SearchString,DivideParam:string;DefaultValue:boolean):boolean; overload; //w +function getYcfgSecBool(YcfgFile,Section,SearchString:string;DefaultValue:boolean):boolean; overload; //w +function getYcfgSecBool(YcfgFile:TStringlist;Section,SearchString,DivideParam:string;DefaultValue:boolean):boolean; overload; //w +function getYcfgSecBool(YcfgFile:TStringlist;Section,SearchString:string;DefaultValue:boolean):boolean; overload; //w + //-- +//DateTime //-- + //global //-- +function getYcfgDateTime(YcfgFile,SearchString,DivideParam:string;DefaultValue:TDateTime):TDateTime; overload; //w +function getYcfgDateTime(YcfgFile,SearchString:string;DefaultValue:TDateTime):TDateTime; overload; //w +function getYcfgDateTime(YcfgFile:TStringlist;SearchString,DivideParam:string;DefaultValue:TDateTime):TDateTime; overload; //w +function getYcfgDateTime(YcfgFile:TStringlist;SearchString:string;DefaultValue:TDateTime):TDateTime; overload; //w + //section //-- +function getYcfgSecDateTime(YcfgFile,Section,SearchString,DivideParam:string;DefaultValue:TDateTime):TDateTime; overload; //w +function getYcfgSecDateTime(YcfgFile,Section,SearchString:string;DefaultValue:TDateTime):TDateTime; overload; //w +function getYcfgSecDateTime(YcfgFile:TStringlist;Section,SearchString,DivideParam:string;DefaultValue:TDateTime):TDateTime; overload; //w +function getYcfgSecDateTime(YcfgFile:TStringlist;Section,SearchString:string;DefaultValue:TDateTime):TDateTime; overload; //w + //-- +//Font //-- + //global //-- +function getYcfgFont(YcfgFile,SearchString,DivideParam:string;DefaultValue:TFont):TFont; overload; //w +function getYcfgFont(YcfgFile,SearchString:string;DefaultValue:TFont):TFont; overload; //w +function getYcfgFont(YcfgFile:TStringlist;SearchString,DivideParam:string;DefaultValue:TFont):TFont; overload; //w +function getYcfgFont(YcfgFile:TStringlist;SearchString:string;DefaultValue:TFont):TFont; overload; //w + //section //-- +function getYcfgSecFont(YcfgFile,Section,SearchString,DivideParam:string;DefaultValue:TFont):TFont; overload; //w +function getYcfgSecFont(YcfgFile,Section,SearchString:string;DefaultValue:TFont):TFont; overload; //w +function getYcfgSecFont(YcfgFile:TStringlist;Section,SearchString,DivideParam:string;DefaultValue:TFont):TFont; overload; //w +function getYcfgSecFont(YcfgFile:TStringlist;Section,SearchString:string;DefaultValue:TFont):TFont; overload; //w + //-- +//DeCrypted String //-- + //global //-- +function getYcfgStrDeCrypted(YcfgFile,SearchString,DivideParam,Key:string):string; overload; //w +function getYcfgStrDeCrypted(YcfgFile,SearchString,Key:string):string; overload; //w +function getYcfgStrDeCrypted(YcfgFile:TStringlist;SearchString,DivideParam,Key:string):string; overload; //w +function getYcfgStrDeCrypted(YcfgFile:Tstringlist;SearchString,Key:string):string; overload; //w + //section //-- +function getYcfgSecStrDeCrypted(YcfgFile,Section,SearchString,DivideParam,Key:string):string; overload; //w +function getYcfgSecStrDeCrypted(YcfgFile,Section,SearchString,Key:string):string; overload; //w +function getYcfgSecStrDeCrypted(YcfgFile:TStringlist;Section,SearchString,DivideParam,Key:string):string; overload; //w +function getYcfgSecStrDeCrypted(YcfgFile:Tstringlist;Section,SearchString,Key:string):string; overload; //w + //-- +// SET******************************************************************************************************************************* //-- + //-- +//sections //-- +function setYcfgSections(YcfgFile,Sections:string;OverrideExisting:boolean):boolean; overload; //w +function setYcfgSections(var YcfgFile:TStringlist;Sections:string;OverrideExisting:boolean):boolean; overload; //w +function setYcfgSections(YcfgFile:string;Sections:TStringList;OverrideExisting:boolean):boolean; overload; //w +function setYcfgSections(var YcfgFile,Sections:TStringlist;OverrideExisting:boolean):boolean; overload; //w + //-- +function setYcfgSection(YcfgFile,Section,Value:string;OverrideExisting:boolean):boolean; overload; //w +function setYcfgSection(var YcfgFile:TStringList;Section,Value:string;OverrideExisting:boolean):boolean; overload; //w +function setYcfgSection(YcfgFile,Section:string;Value:TStringList;OverrideExisting:Boolean):boolean; overload; //w +function setYcfgSection(var YcfgFile:TStringlist;Section:string;Value:TStringList;OverrideExisting:Boolean):boolean; overload; //w + //-- +//String //-- + //global //-- +procedure setYcfgStr(YcfgFile,SearchString,DivideParam,Value:string); overload; //w +procedure setYcfgStr(YcfgFile,SearchString,Value:string); overload; //w +procedure setYcfgStr(var YcfgFile:Tstringlist;SearchString,DivideParam,Value:string); overload; //w +procedure setYcfgStr(var YcfgFile:Tstringlist;SearchString,Value:string); overload; //w + //section //-- +procedure setYcfgSecStr(YcfgFile,Section,SearchString,DivideParam,Value:string); overload; //wt +procedure setYcfgSecStr(YcfgFile,Section,SearchString,Value:string); overload; //wt +procedure setYcfgSecStr(var YcfgFile:Tstringlist;Section,SearchString,DivideParam,Value:string); overload; //wt +procedure setYcfgSecStr(var YcfgFile:Tstringlist;Section,SearchString,Value:string); overload; //wt + //-- +//Integer //-- + //global //-- +procedure setYcfgInt(YcfgFile,SearchString,DivideParam:string;Value:integer); overload; //w +procedure setYcfgInt(YcfgFile,SearchString:string;Value:integer); overload; //w +procedure setYcfgInt(var YcfgFile:Tstringlist;SearchString,DivideParam:string;Value:integer); overload; //w +procedure setYcfgInt(var YcfgFile:Tstringlist;SearchString:string;Value:integer); overload; //w + //section //-- +procedure setYcfgSecInt(YcfgFile,Section,SearchString,DivideParam:string;Value:integer); overload; //w +procedure setYcfgSecInt(YcfgFile,Section,SearchString:string;Value:integer); overload; //w +procedure setYcfgSecInt(var YcfgFile:Tstringlist;Section,SearchString,DivideParam:string;Value:integer); overload; //w +procedure setYcfgSecInt(var YcfgFile:Tstringlist;Section,SearchString:string;Value:integer); overload; //w + //-- +//Bool //-- + //global //-- +procedure setYcfgBool(YcfgFile,SearchString,DivideParam:string;Value:boolean); overload; //w +procedure setYcfgBool(YcfgFile,SearchString:string;Value:boolean); overload; //w +procedure setYcfgBool(var YcfgFile:Tstringlist;SearchString,DivideParam:string;Value:boolean); overload; //w +procedure setYcfgBool(var YcfgFile:Tstringlist;SearchString:string;Value:boolean); overload; //w + //section //-- +procedure setYcfgSecBool(YcfgFile,Section,SearchString,DivideParam:string;Value:boolean); overload; //w +procedure setYcfgSecBool(YcfgFile,Section,SearchString:string;Value:boolean); overload; //w +procedure setYcfgSecBool(var YcfgFile:Tstringlist;Section,SearchString,DivideParam:string;Value:boolean); overload; //w +procedure setYcfgSecBool(var YcfgFile:Tstringlist;Section,SearchString:string;Value:boolean); overload; //w + //-- +//DateTime //-- + //global //-- +procedure setYcfgDateTime(YcfgFile,SearchString,DivideParam:string;Value:TDateTime); overload; //w +procedure setYcfgDateTime(YcfgFile,SearchString:string;Value:TDateTime); overload; //w +procedure setYcfgDateTime(var YcfgFile:Tstringlist;SearchString,DivideParam:string;Value:TDateTime); overload; //w +procedure setYcfgDateTime(var YcfgFile:Tstringlist;SearchString:string;Value:TDateTime); overload; //w + //section //-- +procedure setYcfgSecDateTime(YcfgFile,Section,SearchString,DivideParam:string;Value:TDateTime); overload; //w +procedure setYcfgSecDateTime(YcfgFile,Section,SearchString:string;Value:TDateTime); overload; //w +procedure setYcfgSecDateTime(var YcfgFile:Tstringlist;Section,SearchString,DivideParam:string;Value:TDateTime); overload; //w +procedure setYcfgSecDateTime(var YcfgFile:Tstringlist;Section,SearchString:string;Value:TDateTime); overload; //w + //-- +//Font //-- + //global //-- +procedure setYcfgFont(YcfgFile,SearchString,DivideParam:string;Value:TFont); overload; //w +procedure setYcfgFont(YcfgFile,SearchString:string;Value:TFont); overload; //w +procedure setYcfgFont(var YcfgFile:Tstringlist;SearchString,DivideParam:string;Value:TFont); overload; //w +procedure setYcfgFont(var YcfgFile:Tstringlist;SearchString:string;Value:TFont); overload; //w + //section //-- +procedure setYcfgSecFont(YcfgFile,Section,SearchString,DivideParam:string;Value:TFont); overload; //w +procedure setYcfgSecFont(YcfgFile,Section,SearchString:string;Value:TFont); overload; //w +procedure setYcfgSecFont(var YcfgFile:Tstringlist;Section,SearchString,DivideParam:string;Value:TFont); overload; //w +procedure setYcfgSecFont(var YcfgFile:Tstringlist;Section,SearchString:string;Value:TFont); overload; //w + //-- +//EnCrypted String //-- + //global //-- +procedure setYcfgStrEnCrypted(YcfgFile,SearchString,DivideParam,Key,Value:string); overload; //w +procedure setYcfgStrEnCrypted(YcfgFile,SearchString,Key,Value:string); overload; //w +procedure setYcfgStrEnCrypted(var YcfgFile:Tstringlist;SearchString,DivideParam,Key,Value:string); overload; //w +procedure setYcfgStrEnCrypted(var YcfgFile:Tstringlist;SearchString,Key,Value:string); overload; //w + //section //-- +procedure setYcfgSecStrEnCrypted(YcfgFile,Section,SearchString,DivideParam,Key,Value:string); overload; //w +procedure setYcfgSecStrEnCrypted(YcfgFile,Section,SearchString,Key,Value:string); overload; //w +procedure setYcfgSecStrEnCrypted(var YcfgFile:Tstringlist;Section,SearchString,DivideParam,Key,Value:string); overload; //w +procedure setYcfgSecStrEnCrypted(var YcfgFile:Tstringlist;Section,SearchString,Key,Value:string); overload; //w + //-- +// Add******************************************************************************************************************************* //-- + //-- + //global //-- +//procedure addYcfgStr(YcfgFile,Value:string); overload; // +//procedure addYcfgStr(var YcfgFile:Tstringlist); overload; // +//procedure addYcfgStr(YcfgFile:string;Position:integer); overload; // +//procedure addYcfgStr(var YcfgFile:Tstringlist;Position:integer); overload; // + //Section //-- +//procedure addYcfgStr(YcfgFile,Section:string); overload; // +//procedure addYcfgStr(var YcfgFile:Tstringlist;Section:string;); overload; // +//procedure addYcfgStr(YcfgFile,Section:string;Position:integer); overload; // +//procedure addYcfgStr(var YcfgFile:Tstringlist;Section:string;Position:integer); overload; // + //-- + //global //-- +//procedure addYcfgSpaceLine(YcfgFile:string); overload; // +//procedure addYcfgSpaceLine(var YcfgFile:Tstringlist); overload; // +//procedure addYcfgSpaceLine(YcfgFile:string;Position:integer); overload; // +//procedure addYcfgSpaceLine(var YcfgFile:Tstringlist;Position:integer); overload; // + //Section //-- +//procedure addYcfgSecSpaceLine(YcfgFile,Section:string); overload; // +//procedure addYcfgSecSpaceLine(var YcfgFile:Tstringlist;Section:string;); overload; // +//procedure addYcfgSecSpaceLine(YcfgFile,Section:string;Position:integer); overload; // +//procedure addYcfgSecSpaceLine(var YcfgFile:Tstringlist;Section:string;Position:integer); overload; // + //-- + //gloabl //-- +//procedure addYcfgComment(YcfgFile,Value:string); overload; // +//procedure addYcfgComment(var YcfgFile:Tstringlist;Value:string); overload; // +//procedure addYcfgComment(YcfgFile:string;Position:integer;Value:string); overload; // +//procedure addYcfgComment(var YcfgFile:Tstringlist;Position:integer;Value:string); overload; // + //Section //-- +//procedure addYcfgSecComment(YcfgFile,Section,Value:string); overload; // +//procedure addYcfgSecComment(var YcfgFile:Tstringlist;Section,Value:string); overload; // +//procedure addYcfgSecComment(YcfgFile,Section:string;Position:integer;Value:string); overload; // +//procedure addYcfgSecComment(var YcfgFile:Tstringlist;Section:string;Position:integer;Value:string); overload; // + //-- +// Lists***************************************************************************************************************************** //-- + //-- +//get //-- +function getYcfgList(YcfgFile,ListHeader:string):TStringList; overload; //w +function getYcfgList(YcfgFile:TStringlist;ListHeader:string):TStringList; overload; //w + //-- +//set //-- +function setYcfgList(YcfgFile,ListHeader:string;List:TStringList;OverrideExisting:boolean):Boolean; overload; //w +function setYcfgList(var YcfgFile:TStringlist;ListHeader:string;List:TStringList;OverrideExisting:boolean):Boolean; overload; //w + //-- +//add //-- +{add to an existing List} //-- +procedure addYcfgList(YcfgFile,ListHeader:string;Value:TStringList); overload; //w +procedure addYcfgList(var YcfgFile:TStringlist;ListHeader:string;Value:TStringList); overload; //w + //-- +{Add only one string/int/bool} //-- +procedure addYcfgListStr(YcfgFile,ListHeader,Value:string); overload; //w +procedure addYcfgListStr(var YcfgFile:TStringlist;ListHeader,Value:string); overload; //w + //-- +procedure addYcfgListInt(YcfgFile,ListHeader:string;Value:integer); overload; //w +procedure addYcfgListInt(var YcfgFile:TStringlist;ListHeader:string;Value:integer); overload; //w + //-- +procedure addYcfgListComment(YcfgFile,ListHeader:string;Value:string); overload; //w +procedure addYcfgListComment(var YcfgFile:TStringlist;ListHeader:string;Value:string); overload; //w + //-- +procedure addYcfgListBool(YcfgFile,ListHeader:string;Value:boolean); overload; //w +procedure addYcfgListBool(var YcfgFile:TStringlist;ListHeader:string;Value:boolean); overload; //w + //-- +//misc //-- +function getYcfgListPos(YcfgFile,ListHeader:string):TPoint; overload; //w +function getYcfgListPos(YcfgFile:TStringlist;ListHeader:string):TPoint; overload; //w + //-- +procedure clearYcfgList(YcfgFile,ListHeader:string); overload; //w +procedure clearYcfgList(var YcfgFile:TStringlist;ListHeader:string); overload; //w + //-- +procedure delYcfgList(YcfgFile,ListHeader:string); overload; //w +procedure delYcfgList(var YcfgFile:TStringlist;ListHeader:string); overload; //w + //-- +function YcfgListExists(YcfgFile,ListHeader:string):boolean; overload; //w +function YcfgListExists(YcfgFile:TStringlist;ListHeader:string):boolean; overload; //w + //-- +const //-- + YcfgHeader = '$$YcfgFile 200 $$'; //-- + YcfgComments = '// ** (* ## > flip axis + 00000000000 + 00000000000 + 00000000000 + 00000000000 + 00000000000 + originalimg + + */ + Image & flipAroundY(); + + /** Flips (mirrors) the image around the X-axis. + @remarks + An example of an original and flipped image: +
+                        flip axis
+                            |
+                originalimg|gmilanigiro
+                00000000000|00000000000
+                00000000000|00000000000
+                00000000000|00000000000
+                00000000000|00000000000
+                00000000000|00000000000
+                
+ */ + Image & flipAroundX(); + + /** Stores a pointer to raw data in memory. The pixel format has to be specified. + @remarks + This method loads an image into memory held in the object. The + pixel format will be either greyscale or RGB with an optional + Alpha component. + The type can be determined by calling getFormat(). + @note + Whilst typically your image is likely to be a simple 2D image, + you can define complex images including cube maps, volume maps, + and images including custom mip levels. The layout of the + internal memory should be: +
  • face 0, mip 0 (top), width x height (x depth)
  • +
  • face 0, mip 1, width/2 x height/2 (x depth/2)
  • +
  • face 0, mip 2, width/4 x height/4 (x depth/4)
  • +
  • .. remaining mips for face 0 ..
  • +
  • face 1, mip 0 (top), width x height (x depth)
  • .. and so on. +
+ Of course, you will never have multiple faces (cube map) and + depth too. + @param + The data pointer + @param + Width of image + @param + Height of image + @param + Image Depth (in 3d images, numbers of layers, otherwhise 1) + @param + Pixel Format + @param + if memory associated with this buffer is to be destroyed + with the Image object. + @param + the number of faces the image data has inside (6 for cubemaps, 1 otherwise) + @param + the number of mipmaps the image data has inside + @note + The memory associated with this buffer is NOT destroyed with the + Image object, unless autoDelete is set to true. + @remarks + The size of the buffer must be numFaces*PixelUtil::getMemorySize(width, height, depth, format) + */ + Image& loadDynamicImage( uchar* pData, size_t uWidth, size_t uHeight, + size_t depth, + PixelFormat eFormat, bool autoDelete = false, + size_t numFaces = 1, size_t numMipMaps = 0); + + /** Stores a pointer to raw data in memory. The pixel format has to be specified. + @remarks + This method loads an image into memory held in the object. The + pixel format will be either greyscale or RGB with an optional + Alpha component. + The type can be determined by calling getFormat(). + @note + Whilst typically your image is likely to be a simple 2D image, + you can define complex images including cube maps + and images including custom mip levels. The layout of the + internal memory should be: +
  • face 0, mip 0 (top), width x height
  • +
  • face 0, mip 1, width/2 x height/2
  • +
  • face 0, mip 2, width/4 x height/4
  • +
  • .. remaining mips for face 0 ..
  • +
  • face 1, mip 0 (top), width x height (x depth)
  • .. and so on. +
+ Of course, you will never have multiple faces (cube map) and + depth too. + @param + The data pointer + @param + Width of image + @param + Height of image + @param + Pixel Format + @note + The memory associated with this buffer is NOT destroyed with the + Image object. + @remarks This function is deprecated; one should really use the + Image::loadDynamicImage(pData, width, height, depth, format, ...) to be compatible + with future Ogre versions. + */ + Image& loadDynamicImage( uchar* pData, size_t uWidth, + size_t uHeight, PixelFormat eFormat) + { + return loadDynamicImage(pData, uWidth, uHeight, 1, eFormat); + } + /** Loads raw data from a stream. See the function + loadDynamicImage for a description of the parameters. + @remarks + The size of the buffer must be numFaces*PixelUtil::getMemorySize(width, height, depth, format) + @note + Whilst typically your image is likely to be a simple 2D image, + you can define complex images including cube maps + and images including custom mip levels. The layout of the + internal memory should be: +
  • face 0, mip 0 (top), width x height (x depth)
  • +
  • face 0, mip 1, width/2 x height/2 (x depth/2)
  • +
  • face 0, mip 2, width/4 x height/4 (x depth/4)
  • +
  • .. remaining mips for face 0 ..
  • +
  • face 1, mip 0 (top), width x height (x depth)
  • .. and so on. +
+ Of course, you will never have multiple faces (cube map) and + depth too. + */ + Image & loadRawData( + DataStreamPtr& stream, + size_t uWidth, size_t uHeight, size_t uDepth, + PixelFormat eFormat, + size_t numFaces = 1, size_t numMipMaps = 0); + /** Loads raw data from a stream. The pixel format has to be specified. + @remarks This function is deprecated; one should really use the + Image::loadRawData(stream, width, height, depth, format, ...) to be compatible + with future Ogre versions. + @note + Whilst typically your image is likely to be a simple 2D image, + you can define complex images including cube maps + and images including custom mip levels. The layout of the + internal memory should be: +
  • face 0, mip 0 (top), width x height
  • +
  • face 0, mip 1, width/2 x height/2
  • +
  • face 0, mip 2, width/4 x height/4
  • +
  • .. remaining mips for face 0 ..
  • +
  • face 1, mip 0 (top), width x height (x depth)
  • .. and so on. +
+ Of course, you will never have multiple faces (cube map) and + depth too. + */ + Image & loadRawData( + DataStreamPtr& stream, + size_t uWidth, size_t uHeight, + PixelFormat eFormat ) + { + return loadRawData(stream, uWidth, uHeight, 1, eFormat); + } + + /** Loads an image file. + @remarks + This method loads an image into memory. Any format for which + and associated ImageCodec is registered can be loaded. + This can include complex formats like DDS with embedded custom + mipmaps, cube faces and volume textures. + The type can be determined by calling getFormat(). + @param + strFileName Name of a file file to load. + @param + groupName Name of the resource group to search for the image + @note + The memory associated with this buffer is destroyed with the + Image object. + */ + Image & load( const String& strFileName, const String& groupName ); + + /** Loads an image file from a stream. + @remarks + This method works in the same way as the filename-based load + method except it loads the image from a DataStream object. + This DataStream is expected to contain the + encoded data as it would be held in a file. + Any format for which and associated ImageCodec is registered + can be loaded. + This can include complex formats like DDS with embedded custom + mipmaps, cube faces and volume textures. + The type can be determined by calling getFormat(). + @param + stream The source data. + @param + type The type of the image. Used to decide what decompression + codec to use. + @see + Image::load( const String& strFileName ) + */ + Image & load(DataStreamPtr& stream, const String& type ); + + /** Save the image as a file. */ + void save(const String& filename); + + /** Returns a pointer to the internal image buffer. + @remarks + Be careful with this method. You will almost certainly + prefer to use getPixelBox, especially with complex images + which include many faces or custom mipmaps. + */ + uchar* getData(void); + + /** Returns a const pointer to the internal image buffer. + @remarks + Be careful with this method. You will almost certainly + prefer to use getPixelBox, especially with complex images + which include many faces or custom mipmaps. + */ + const uchar * getData() const; + + /** Returns the size of the data buffer. + */ + size_t getSize() const; + + /** Returns the number of mipmaps contained in the image. + */ + size_t getNumMipmaps() const; + + /** Returns true if the image has the appropriate flag set. + */ + bool hasFlag(const ImageFlags imgFlag) const; + + /** Gets the width of the image in pixels. + */ + size_t getWidth(void) const; + + /** Gets the height of the image in pixels. + */ + size_t getHeight(void) const; + + /** Gets the depth of the image. + */ + size_t getDepth(void) const; + + /** Get the numer of faces of the image. This is usually 6 for a cubemap, and + 1 for a normal image. + */ + size_t getNumFaces(void) const; + + /** Gets the physical width in bytes of each row of pixels. + */ + size_t getRowSpan(void) const; + + /** Returns the image format. + */ + PixelFormat getFormat() const; + + /** Returns the number of bits per pixel. + */ + uchar getBPP() const; + + /** Returns true if the image has an alpha component. + */ + bool getHasAlpha() const; + + /** Does gamma adjustment. + @note + Basic algo taken from Titan Engine, copyright (c) 2000 Ignacio + Castano Iguado + */ + static void applyGamma( uchar *buffer, Real gamma, size_t size, uchar bpp ); + + /** + * Get colour value from a certain location in the image. The z coordinate + * is only valid for cubemaps and volume textures. This uses the first (largest) + * mipmap. + */ + ColourValue getColourAt(int x, int y, int z); + + /** + * Get a PixelBox encapsulating the image data of a mipmap + */ + PixelBox getPixelBox(size_t face = 0, size_t mipmap = 0) const; + + enum Filter + { + FILTER_NEAREST, + FILTER_LINEAR, + FILTER_BILINEAR, + FILTER_BOX, + FILTER_TRIANGLE, + FILTER_BICUBIC + }; + /** Scale a 1D, 2D or 3D image volume. + @param src PixelBox containing the source pointer, dimensions and format + @param dst PixelBox containing the destination pointer, dimensions and format + @param filter Which filter to use + @remarks This function can do pixel format conversion in the process. + @note dst and src can point to the same PixelBox object without any problem + */ + static void scale(const PixelBox &src, const PixelBox &dst, Filter filter = FILTER_BILINEAR); + + /** Resize a 2D image, applying the appropriate filter. */ + void resize(ushort width, ushort height, Filter filter = FILTER_BILINEAR); + + // Static function to calculate size in bytes from the number of mipmaps, faces and the dimensions + static size_t calculateSize(size_t mipmaps, size_t faces, size_t width, size_t height, size_t depth, PixelFormat format); + private: + // The width of the image in pixels + size_t m_uWidth; + // The height of the image in pixels + size_t m_uHeight; + // The depth of the image + size_t m_uDepth; + // The size of the image buffer + size_t m_uSize; + // The number of mipmaps the image contains + size_t m_uNumMipmaps; + // Image specific flags. + int m_uFlags; + + // The pixel format of the image + PixelFormat m_eFormat; + + // The number of bytes per pixel + uchar m_ucPixelSize; + uchar* m_pBuffer; + + // A bool to determine if we delete the buffer or the calling app does + bool m_bAutoDelete; + }; + + typedef std::vector ImagePtrList; + typedef std::vector ConstImagePtrList; + + +} // namespace + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreImageCodec.h b/school/informatik/verkerhssimulation/src/ogre/OgreImageCodec.h new file mode 100644 index 00000000..3b8f16cf --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreImageCodec.h @@ -0,0 +1,82 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _ImageCodec_H__ +#define _ImageCodec_H__ + +#include "OgreCodec.h" +#include "OgrePixelFormat.h" + +namespace Ogre { + + /** Codec specialized in images. + @remarks + The users implementing subclasses of ImageCodec are required to return + a valid pointer to a ImageData class from the decode(...) function. + */ + class _OgreExport ImageCodec : public Codec + { + public: + virtual ~ImageCodec(); + /** Codec return class for images. Has imformation about the size and the + pixel format of the image. */ + class _OgrePrivate ImageData : public Codec::CodecData + { + public: + ImageData(): + height(0), width(0), depth(1), size(0), + num_mipmaps(0), flags(0), format(PF_UNKNOWN) + { + } + size_t height; + size_t width; + size_t depth; + size_t size; + + ushort num_mipmaps; + uint flags; + + PixelFormat format; + + public: + String dataType() const + { + return "ImageData"; + } + }; + + public: + String getDataType() const + { + return "ImageData"; + } + }; + +} // namespace + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreInstancedGeometry.h b/school/informatik/verkerhssimulation/src/ogre/OgreInstancedGeometry.h new file mode 100644 index 00000000..e6af73c8 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreInstancedGeometry.h @@ -0,0 +1,833 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __InstancedGeometry_H__ +#define __InstancedGeometry_H__ + +#include "OgrePrerequisites.h" +#include "OgreMovableObject.h" +#include "OgreSimpleRenderable.h" +#include "OgreSkeleton.h" +#include "OgreSkeletonInstance.h" +#include "OgreAnimationTrack.h" +#include "OgreBone.h" + +namespace Ogre { + + /** Pre-transforms and batches up meshes for efficient use as instanced geometry + in a scene + @remarks + Shader instancing allows to save both memory and draw calls. While + StaticGeometry stores 500 times the same object in a batch to display 500 + objects, this shader instancing implementation stores only 80 times the object, + and then re-uses the vertex data with different shader parameter. + Although you save memory, you make more draw call. However, you still + make less draw calls than if you were rendering each object independently. + Plus, you can move the batched objects independently of one another which + you cannot do with StaticGeometry. + @par + Therefore it is important when you are rendering a lot of geometry to + batch things up into as few rendering calls as possible. This + class allows you to build a batched object from a series of entities + in order to benefit from this behaviour. + Batching has implications of it's own though: + @li Batched geometry cannot be subdivided; that means that the whole + group will be displayed, or none of it will. This obivously has + culling issues. + @li A single material must apply for each batch. In fact this class + allows you to use multiple materials, but you should be aware that + internally this means that there is one batch per material. + Therefore you won't gain as much benefit from the batching if you + use many different materials; try to keep the number down. + @par + The bounding box information is computed whith object position only. + It doesn't take account of the object orientation. + @par + The LOD settings of both the Mesh and the Materials used in + constructing this instanced geometry will be respected. This means that + if you use meshes/materials which have LOD, batches in the distance + will have a lower polygon count or material detail to those in the + foreground. Since each mesh might have different LOD distances, during + build the furthest distance at each LOD level from all meshes + in that BatchInstance is used. This means all the LOD levels change at the + same time, but at the furthest distance of any of them (so quality is + not degraded). Be aware that using Mesh LOD in this class will + further increase the memory required. Only generated LOD + is supported for meshes. + @par + There are 2 ways you can add geometry to this class; you can add + Entity objects directly with predetermined positions, scales and + orientations, or you can add an entire SceneNode and it's subtree, + including all the objects attached to it. Once you've added everthing + you need to, you have to call build() the fix the geometry in place. + @par + You should not construct instances of this class directly; instead, call + SceneManager::createInstancedGeometry, which gives the SceneManager the + option of providing you with a specialised version of this class if it + wishes, and also handles the memory management for you like other + classes. + */ + class _OgreExport InstancedGeometry + { + public: + /** Struct holding geometry optimised per SubMesh / lod level, ready + for copying to instances. + @remarks + Since we're going to be duplicating geometry lots of times, it's + far more important that we don't have redundant vertex data. If a + SubMesh uses shared geometry, or we're looking at a lower LOD, not + all the vertices are being referenced by faces on that submesh. + Therefore to duplicate them, potentially hundreds or even thousands + of times, would be extremely wasteful. Therefore, if a SubMesh at + a given LOD has wastage, we create an optimised version of it's + geometry which is ready for copying with no wastage. + */ + class _OgrePrivate OptimisedSubMeshGeometry + { + public: + OptimisedSubMeshGeometry() :vertexData(0), indexData(0) {} + ~OptimisedSubMeshGeometry() + { + delete vertexData; + delete indexData; + } + VertexData *vertexData; + IndexData *indexData; + }; + typedef std::list OptimisedSubMeshGeometryList; + /// Saved link between SubMesh at a LOD and vertex/index data + /// May point to original or optimised geometry + struct SubMeshLodGeometryLink + { + VertexData* vertexData; + IndexData* indexData; + }; + typedef std::vector SubMeshLodGeometryLinkList; + typedef std::map SubMeshGeometryLookup; + /// Structure recording a queued submesh for the build + struct QueuedSubMesh + { + SubMesh* submesh; + /// Link to LOD list of geometry, potentially optimised + SubMeshLodGeometryLinkList* geometryLodList; + String materialName; + Vector3 position; + Quaternion orientation; + Vector3 scale; + /// Pre-transformed world AABB + AxisAlignedBox worldBounds; + unsigned int ID; + }; + typedef std::vector QueuedSubMeshList; + typedef std::vector QueuedSubMeshOriginList; + /// Structure recording a queued geometry for low level builds + struct QueuedGeometry + { + SubMeshLodGeometryLink* geometry; + Vector3 position; + Quaternion orientation; + Vector3 scale; + unsigned int ID; + }; + typedef std::vector QueuedGeometryList; + + // forward declarations + class LODBucket; + class MaterialBucket; + class BatchInstance; + class InstancedObject; + + /** A GeometryBucket is a the lowest level bucket where geometry with + the same vertex & index format is stored. It also acts as the + renderable. + */ + class _OgreExport GeometryBucket : public SimpleRenderable + { + protected: + + /// Geometry which has been queued up pre-build (not for deallocation) + QueuedGeometryList mQueuedGeometry; + /// Pointer to the Batch + InstancedGeometry*mBatch; + /// Pointer to parent bucket + MaterialBucket* mParent; + /// String identifying the vertex / index format + String mFormatString; + /// Vertex information, includes current number of vertices + /// committed to be a part of this bucket + VertexData* mVertexData; + /// Index information, includes index type which limits the max + /// number of vertices which are allowed in one bucket + IndexData* mIndexData; + /// Size of indexes + HardwareIndexBuffer::IndexType mIndexType; + /// Maximum vertex indexable + size_t mMaxVertexIndex; + /// Index of the Texcoord where the index is stored + unsigned short mTexCoordIndex; + AxisAlignedBox mAABB; + + template + void copyIndexes(const T* src, T* dst, size_t count, size_t indexOffset) + { + if (indexOffset == 0) + { + memcpy(dst, src, sizeof(T) * count); + } + else + { + while(count--) + { + *dst++ = static_cast(*src++ + indexOffset); + } + } + } + public: + GeometryBucket(MaterialBucket* parent, const String& formatString, + const VertexData* vData, const IndexData* iData); + GeometryBucket(MaterialBucket* parent,const String& formatString,GeometryBucket*bucket); + virtual ~GeometryBucket(); + MaterialBucket* getParent(void) { return mParent; } + Real getBoundingRadius(void) const; + /// Get the vertex data for this geometry + const VertexData* getVertexData(void) const { return mVertexData; } + /// Get the index data for this geometry + const IndexData* getIndexData(void) const { return mIndexData; } + /// @copydoc Renderable::getMaterial + const MaterialPtr& getMaterial(void) const; + Technique* getTechnique(void) const; + void getWorldTransforms(Matrix4* xform) const; + virtual unsigned short getNumWorldTransforms(void) const ; + const Quaternion& getWorldOrientation(void) const; + const Vector3& getWorldPosition(void) const; + Real getSquaredViewDepth(const Camera* cam) const; + const LightList& getLights(void) const; + bool getCastsShadows(void) const; + String getFormatString(void) const; + /** Try to assign geometry to this bucket. + @returns false if there is no room left in this bucket + */ + bool assign(QueuedGeometry* qsm); + /// Build + void build(); + /// Dump contents for diagnostics + void dump(std::ofstream& of) const; + /// retun the BoundingBox information. Usefull when cloning the batch instance. + AxisAlignedBox & getAABB(void){return mAABB;}; + }; + class _OgreExport InstancedObject + { + friend class GeometryBucket; + public: + enum TransformSpace + { + /// Transform is relative to the local space + TS_LOCAL, + /// Transform is relative to the space of the parent node + TS_PARENT, + /// Transform is relative to world space + TS_WORLD + }; + /// list of Geometry Buckets that contains the instanced object + typedef std::vector GeometryBucketList; + protected: + GeometryBucketList mGeometryBucketList; + unsigned short mIndex; + Matrix4 mTransformation; + Quaternion mOrientation; + Vector3 mScale; + Vector3 mPosition; + SkeletonInstance* mSkeletonInstance; + /// Cached bone matrices, including any world transform + Matrix4 *mBoneWorldMatrices; + /// Cached bone matrices in skeleton local space + Matrix4 *mBoneMatrices; + /// State of animation for animable meshes + AnimationStateSet* mAnimationState; + unsigned short mNumBoneMatrices; + /// Records the last frame in which animation was updated + unsigned long mFrameAnimationLastUpdated; + public: + InstancedObject(int index); + InstancedObject(int index,SkeletonInstance *skeleton,AnimationStateSet*animations); + ~InstancedObject(); + void setPosition( Vector3 position); + Vector3 & getPosition(void); + void yaw(const Radian& angle); + void pitch(const Radian& angle); + void roll(const Radian& angle); + void rotate(const Quaternion& q); + void setScale(const Vector3& scale); + void addBucketToList(GeometryBucket* bucket); + void needUpdate(); + GeometryBucketList&getGeometryBucketList(void){return mGeometryBucketList;} + void translate(const Matrix3& axes, const Vector3& move); + void translate(const Vector3& d); + Matrix3 getLocalAxes(void) const; + void updateAnimation(void); + AnimationState* getAnimationState(const String& name) const; + SkeletonInstance*getSkeletonInstance(void){return mSkeletonInstance;} + + }; + /** A MaterialBucket is a collection of smaller buckets with the same + Material (and implicitly the same LOD). */ + class _OgreExport MaterialBucket + { + public: + /// list of Geometry Buckets in this BatchInstance + typedef std::vector GeometryBucketList; + protected: + /// Pointer to parent LODBucket + LODBucket* mParent; + /// Material being used + String mMaterialName; + /// Pointer to material being used + MaterialPtr mMaterial; + /// Active technique + Technique* mTechnique; + int mLastIndex; + /// list of Geometry Buckets in this BatchInstance + GeometryBucketList mGeometryBucketList; + // index to current Geometry Buckets for a given geometry format + typedef std::map CurrentGeometryMap; + CurrentGeometryMap mCurrentGeometryMap; + /// Get a packed string identifying the geometry format + String getGeometryFormatString(SubMeshLodGeometryLink* geom); + + public: + MaterialBucket(LODBucket* parent, const String& materialName); + virtual ~MaterialBucket(); + LODBucket* getParent(void) { return mParent; } + /// Get the material name + const String& getMaterialName(void) const { return mMaterialName; } + /// Assign geometry to this bucket + void assign(QueuedGeometry* qsm); + /// Build + void build(); + /// Add children to the render queue + void addRenderables(RenderQueue* queue, uint8 group, + Real camSquaredDist); + /// Get the material for this bucket + const MaterialPtr& getMaterial(void) const { return mMaterial; } + /// Iterator over geometry + typedef VectorIterator GeometryIterator; + /// Get an iterator over the contained geometry + GeometryIterator getGeometryIterator(void); + /// Get the current Technique + Technique* getCurrentTechnique(void) const { return mTechnique; } + /// Dump contents for diagnostics + void dump(std::ofstream& of) const; + /// Return the geometry map + MaterialBucket::CurrentGeometryMap* getMaterialBucketMap(void) const; + /// Return the geometry list + MaterialBucket::GeometryBucketList*getGeometryBucketList(void) const; + /// fill in the map and the list + void updateContainers(GeometryBucket* bucket, const String &format); + void setLastIndex(int index){mLastIndex=index;} + int getLastIndex(){return mLastIndex;} + void setMaterial(const String & name); + + }; + /** A LODBucket is a collection of smaller buckets with the same LOD. + @remarks + LOD refers to Mesh LOD here. Material LOD can change separately + at the next bucket down from this. + */ + class _OgreExport LODBucket + { + public: + /// Lookup of Material Buckets in this BatchInstance + typedef std::map MaterialBucketMap; + protected: + /// Pointer to parent BatchInstance + BatchInstance* mParent; + /// LOD level (0 == full LOD) + unsigned short mLod; + /// distance at which this LOD starts to apply (squared) + Real mSquaredDistance; + /// Lookup of Material Buckets in this BatchInstance + MaterialBucketMap mMaterialBucketMap; + /// Geometry queued for a single LOD (deallocated here) + QueuedGeometryList mQueuedGeometryList; + public: + LODBucket(BatchInstance* parent, unsigned short lod, Real lodDist); + virtual ~LODBucket(); + BatchInstance* getParent(void) { return mParent; } + /// Get the lod index + ushort getLod(void) const { return mLod; } + /// Get the lod squared distance + Real getSquaredDistance(void) const { return mSquaredDistance; } + /// Assign a queued submesh to this bucket, using specified mesh LOD + void assign(QueuedSubMesh* qsm, ushort atLod); + /// Build + void build(); + /// Add children to the render queue + void addRenderables(RenderQueue* queue, uint8 group, + Real camSquaredDistance); + /// Iterator over the materials in this LOD + typedef MapIterator MaterialIterator; + /// Get an iterator over the materials in this LOD + MaterialIterator getMaterialIterator(void); + /// Dump contents for diagnostics + void dump(std::ofstream& of) const; + /// fill the map + void updateContainers(MaterialBucket* bucket, String& name ); + + }; + /** The details of a topological BatchInstance which is the highest level of + partitioning for this class. + @remarks + The size & shape of BatchInstances entirely depends on the SceneManager + specific implementation. It is a MovableObject since it will be + attached to a node based on the local centre - in practice it + won't actually move (although in theory it could). + */ + class _OgreExport BatchInstance : public MovableObject + { + public: + + + /// list of LOD Buckets in this BatchInstance + typedef std::vector LODBucketList; + typedef std::map ObjectsMap; + protected: + + /// Parent static geometry + InstancedGeometry* mParent; + /// Scene manager link + SceneManager* mSceneMgr; + /// Scene node + SceneNode* mNode; + /// Local list of queued meshes (not used for deallocation) + QueuedSubMeshList mQueuedSubMeshes; + /// Unique identifier for the BatchInstance + uint32 mBatchInstanceID; + + ObjectsMap mInstancesMap; + public: + /// LOD distances (squared) as built up - use the max at each level + std::vector mLodSquaredDistances; + /// Local AABB relative to BatchInstance centre + AxisAlignedBox mAABB; + /// Local bounding radius + Real mBoundingRadius; + /// The current lod level, as determined from the last camera + ushort mCurrentLod; + /// Current camera distance, passed on to do material lod later + Real mCamDistanceSquared; + protected: + /// List of LOD buckets + LODBucketList mLodBucketList; + + public: + BatchInstance(InstancedGeometry* parent, const String& name, SceneManager* mgr, + uint32 BatchInstanceID); + virtual ~BatchInstance(); + // more fields can be added in subclasses + InstancedGeometry* getParent(void) const { return mParent;} + /// Assign a queued mesh to this BatchInstance, read for final build + void assign(QueuedSubMesh* qmesh); + /// Build this BatchInstance + void build(); + /// Get the BatchInstance ID of this BatchInstance + uint32 getID(void) const { return mBatchInstanceID; } + /// Get the centre point of the BatchInstance +// const Vector3& getCentre(void) const { return mCentre; } + const String& getMovableType(void) const; + void _notifyCurrentCamera(Camera* cam); + const AxisAlignedBox& getBoundingBox(void) const; + void setBoundingBox(AxisAlignedBox& box); + Real getBoundingRadius(void) const; + void _updateRenderQueue(RenderQueue* queue); + bool isVisible(void) const; + // uint32 getTypeFlags(void) const; + + typedef VectorIterator LODIterator; + /// Get an iterator over the LODs in this BatchInstance + LODIterator getLODIterator(void); + /// Shared set of lights for all GeometryBuckets + const LightList& getLights(void) const; + + /// update the bounding box of the BatchInstance according to the positions of the objects + void updateBoundingBox(); + + /// Dump contents for diagnostics + void dump(std::ofstream& of) const; + /// fill in the list + void updateContainers(LODBucket* bucket ); + /// attach the BatchInstance to the scene + void attachToScene(); + void addInstancedObject(int index, InstancedObject* object); + InstancedObject* isInstancedObjectPresent(int index); + InstancedObject** getObjectsAsArray(unsigned short & size); + SceneNode*getSceneNode(void){return mNode;} + ObjectsMap&getInstancesMap(void){return mInstancesMap;}; + /// change the shader used to render the batch instance + + }; + /** Indexed BatchInstance map based on packed x/y/z BatchInstance index, 10 bits for + each axis. + */ + typedef std::map BatchInstanceMap; + /** Simple vectors where are stored all the renderoperations of the Batch. + This vector is used when we want to delete the batch, in order to delete only one time each + render operation. + + */ + typedef std::vector RenderOperationVector; + protected: + // General state & settings + SceneManager* mOwner; + String mName; + bool mBuilt; + Real mUpperDistance; + Real mSquaredUpperDistance; + bool mCastShadows; + Vector3 mBatchInstanceDimensions; + Vector3 mHalfBatchInstanceDimensions; + Vector3 mOrigin; + bool mVisible; + /// The render queue to use when rendering this object + uint8 mRenderQueueID; + /// Flags whether the RenderQueue's default should be used. + bool mRenderQueueIDSet; + /// number of objects in the batch + unsigned int mObjectCount; + QueuedSubMeshList mQueuedSubMeshes; + BatchInstance*mInstancedGeometryInstance; + /**this is just a pointer to the base skeleton that will be used for each animated object in the batches + This pointer has a value only during the creation of the InstancedGeometry + */ + SkeletonPtr mBaseSkeleton; + SkeletonInstance *mSkeletonInstance; + /**This is the main animation state. All "objects" in the batch will use an instance of this animation + state + */ + AnimationStateSet* mAnimationState; + /// List of geometry which has been optimised for SubMesh use + /// This is the primary storage used for cleaning up later + OptimisedSubMeshGeometryList mOptimisedSubMeshGeometryList; + + /** Cached links from SubMeshes to (potentially optimised) geometry + This is not used for deletion since the lookup may reference + original vertex data + */ + SubMeshGeometryLookup mSubMeshGeometryLookup; + + /// Map of BatchInstances + BatchInstanceMap mBatchInstanceMap; + /** This vector stores all the renderOperation used in the batch. + See the type definition for more details. + */ + RenderOperationVector mRenderOps; + /** Virtual method for getting a BatchInstance most suitable for the + passed in bounds. Can be overridden by subclasses. + */ + virtual BatchInstance* getBatchInstance(const AxisAlignedBox& bounds, bool autoCreate); + /** Get the BatchInstance within which a point lies */ + virtual BatchInstance* getBatchInstance(const Vector3& point, bool autoCreate); + /** Get the BatchInstance using indexes */ + virtual BatchInstance* getBatchInstance(ushort x, ushort y, ushort z, bool autoCreate); + /** Get the BatchInstance using a packed index, returns null if it doesn't exist. */ + virtual BatchInstance* getBatchInstance(uint32 index); + /** Get the BatchInstance indexes for a point. + */ + virtual void getBatchInstanceIndexes(const Vector3& point, + ushort& x, ushort& y, ushort& z); + /** get the first BatchInstance or create on if it does not exists. + */ + virtual BatchInstance* getInstancedGeometryInstance(void); + /** Pack 3 indexes into a single index value + */ + virtual uint32 packIndex(ushort x, ushort y, ushort z); + /** Get the volume intersection for an indexed BatchInstance with some bounds. + */ + virtual Real getVolumeIntersection(const AxisAlignedBox& box, + ushort x, ushort y, ushort z); + /** Get the bounds of an indexed BatchInstance. + */ + virtual AxisAlignedBox getBatchInstanceBounds(ushort x, ushort y, ushort z); + /** Get the centre of an indexed BatchInstance. + */ + virtual Vector3 getBatchInstanceCentre(ushort x, ushort y, ushort z); + /** Calculate world bounds from a set of vertex data. */ + virtual AxisAlignedBox calculateBounds(VertexData* vertexData, + const Vector3& position, const Quaternion& orientation, + const Vector3& scale); + /** Look up or calculate the geometry data to use for this SubMesh */ + SubMeshLodGeometryLinkList* determineGeometry(SubMesh* sm); + /** Split some shared geometry into dedicated geometry. */ + void splitGeometry(VertexData* vd, IndexData* id, + SubMeshLodGeometryLink* targetGeomLink); + + typedef std::map IndexRemap; + /** Method for figuring out which vertices are used by an index buffer + and calculating a remap lookup for a vertex buffer just containing + those vertices. + */ + template + void buildIndexRemap(T* pBuffer, size_t numIndexes, IndexRemap& remap) + { + remap.clear(); + for (size_t i = 0; i < numIndexes; ++i) + { + // use insert since duplicates are silently discarded + remap.insert(IndexRemap::value_type(*pBuffer++, remap.size())); + // this will have mapped oldindex -> new index IF oldindex + // wasn't already there + } + } + /** Method for altering indexes based on a remap. */ + template + void remapIndexes(T* src, T* dst, const IndexRemap& remap, + size_t numIndexes) + { + for (size_t i = 0; i < numIndexes; ++i) + { + // look up original and map to target + IndexRemap::const_iterator ix = remap.find(*src++); + assert(ix != remap.end()); + *dst++ = static_cast(ix->second); + } + } + + public: + /// Constructor; do not use directly (@see SceneManager::createInstancedGeometry) + InstancedGeometry(SceneManager* owner, const String& name); + /// Destructor + virtual ~InstancedGeometry(); + + /// Get the name of this object + const String& getName(void) const { return mName; } + /** Adds an Entity to the static geometry. + @remarks + This method takes an existing Entity and adds its details to the + list of elements to include when building. Note that the Entity + itself is not copied or referenced in this method; an Entity is + passed simply so that you can change the materials of attached + SubEntity objects if you want. You can add the same Entity + instance multiple times with different material settings + completely safely, and destroy the Entity before destroying + this InstancedGeometry if you like. The Entity passed in is simply + used as a definition. + @note Must be called before 'build'. + @param ent The Entity to use as a definition (the Mesh and Materials + referenced will be recorded for the build call). + @param position The world position at which to add this Entity + @param orientation The world orientation at which to add this Entity + @param scale The scale at which to add this entity + */ + virtual void addEntity(Entity* ent, const Vector3& position, + const Quaternion& orientation = Quaternion::IDENTITY, + const Vector3& scale = Vector3::UNIT_SCALE); + + /** Adds all the Entity objects attached to a SceneNode and all it's + children to the static geometry. + @remarks + This method performs just like addEntity, except it adds all the + entities attached to an entire sub-tree to the geometry. + The position / orientation / scale parameters are taken from the + node structure instead of being specified manually. + @note + The SceneNode you pass in will not be automatically detached from + it's parent, so if you have this node already attached to the scene + graph, you will need to remove it if you wish to avoid the overhead + of rendering both the original objects and their new static + versions! We don't do this for you incase you are preparing this + in advance and so don't want the originals detached yet. + @note Must be called before 'build'. + @param node Pointer to the node to use to provide a set of Entity + templates + */ + virtual void addSceneNode(const SceneNode* node); + + /** Build the geometry. + @remarks + Based on all the entities which have been added, and the batching + options which have been set, this method constructs the batched + geometry structures required. The batches are added to the scene + and will be rendered unless you specifically hide them. + @note + Once you have called this method, you can no longer add any more + entities. + */ + virtual void build(void); + /** Add a new batch instance + @remarks + This method add a new instance of the whole batch, by creating a new + BatchInstance, containing new lod buckets, material buckets and geometry buckets. + The new geometry bukets will use the same buffers as the base bucket. + @note + no note + */ + void addBatchInstance(void); + /** Destroys all the built geometry state (reverse of build). + @remarks + You can call build() again after this and it will pick up all the + same entities / nodes you queued last time. + */ + virtual void destroy(void); + + /** Clears any of the entities / nodes added to this geometry and + destroys anything which has already been built. + */ + virtual void reset(void); + + /** Sets the distance at which batches are no longer rendered. + @remarks + This lets you turn off batches at a given distance. This can be + useful for things like detail meshes (grass, foliage etc) and could + be combined with a shader which fades the geometry out beforehand + to lessen the effect. + @param dist Distance beyond which the batches will not be rendered + (the default is 0, which means batches are always rendered). + */ + virtual void setRenderingDistance(Real dist) { + mUpperDistance = dist; + mSquaredUpperDistance = mUpperDistance * mUpperDistance; + } + + /** Gets the distance at which batches are no longer rendered. */ + virtual Real getRenderingDistance(void) const { return mUpperDistance; } + + /** Gets the squared distance at which batches are no longer rendered. */ + virtual Real getSquaredRenderingDistance(void) const + { return mSquaredUpperDistance; } + + /** Hides or shows all the batches. */ + virtual void setVisible(bool visible); + + /** Are the batches visible? */ + virtual bool isVisible(void) const { return mVisible; } + + /** Sets whether this geometry should cast shadows. + @remarks + No matter what the settings on the original entities, + the InstancedGeometry class defaults to not casting shadows. + This is because, being static, unless you have moving lights + you'd be better to use precalculated shadows of some sort. + However, if you need them, you can enable them using this + method. If the SceneManager is set up to use stencil shadows, + edge lists will be copied from the underlying meshes on build. + It is essential that all meshes support stencil shadows in this + case. + @note If you intend to use stencil shadows, you must set this to + true before calling 'build' as well as making sure you set the + scene's shadow type (that should always be the first thing you do + anyway). You can turn shadows off temporarily but they can never + be turned on if they were not at the time of the build. + */ + virtual void setCastShadows(bool castShadows); + /// Will the geometry from this object cast shadows? + virtual bool getCastShadows(void) { return mCastShadows; } + + /** Sets the size of a single BatchInstance of geometry. + @remarks + This method allows you to configure the physical world size of + each BatchInstance, so you can balance culling against batch size. Entities + will be fitted within the batch they most closely fit, and the + eventual bounds of each batch may well be slightly larger than this + if they overlap a little. The default is Vector3(1000, 1000, 1000). + @note Must be called before 'build'. + @param size Vector3 expressing the 3D size of each BatchInstance. + */ + virtual void setBatchInstanceDimensions(const Vector3& size) { + mBatchInstanceDimensions = size; + mHalfBatchInstanceDimensions = size * 0.5; + } + /** Gets the size of a single batch of geometry. */ + virtual const Vector3& getBatchInstanceDimensions(void) const { return mBatchInstanceDimensions; } + /** Sets the origin of the geometry. + @remarks + This method allows you to configure the world centre of the geometry, + thus the place which all BatchInstances surround. You probably don't need + to mess with this unless you have a seriously large world, since the + default set up can handle an area 1024 * mBatchInstanceDimensions, and + the sparseness of population is no issue when it comes to rendering. + The default is Vector3(0,0,0). + @note Must be called before 'build'. + @param size Vector3 expressing the 3D origin of the geometry. + */ + virtual void setOrigin(const Vector3& origin) { mOrigin = origin; } + /** Gets the origin of this geometry. */ + virtual const Vector3& getOrigin(void) const { return mOrigin; } + + /** Sets the render queue group this object will be rendered through. + @remarks + Render queues are grouped to allow you to more tightly control the ordering + of rendered objects. If you do not call this method, all objects default + to the default queue (RenderQueue::getDefaultQueueGroup), which is fine for + most objects. You may want to alter this if you want to perform more complex + rendering. + @par + See RenderQueue for more details. + @param queueID Enumerated value of the queue group to use. + */ + virtual void setRenderQueueGroup(uint8 queueID); + + /** Gets the queue group for this entity, see setRenderQueueGroup for full details. */ + virtual uint8 getRenderQueueGroup(void) const; + /// Iterator for iterating over contained BatchInstances + typedef MapIterator BatchInstanceIterator; + /// Get an iterator over the BatchInstances in this geometry + BatchInstanceIterator getBatchInstanceIterator(void); + /// get the mRenderOps vector. + RenderOperationVector& getRenderOperationVector(){return mRenderOps;} + /** Dump the contents of this InstancedGeometry to a file for diagnostic + purposes. + */ + virtual void dump(const String& filename) const; + /** + @remarks + Return the skeletonInstance that will be used + */ + SkeletonInstance *getBaseSkeletonInstance(void){return mSkeletonInstance;} + /** + @remarks + Return the skeleton that is shared by all instanced objects. + */ + SkeletonPtr getBaseSkeleton(void){return mBaseSkeleton;} + /** + @remarks + Return the animation state that will be cloned each time an InstancedObject is made + */ + AnimationStateSet* getBaseAnimationState(void){return mAnimationState;} + /** + @remarks + return the total number of object that are in all the batches + */ + unsigned int getObjectCount(void){return mObjectCount;} + + + + }; + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreIteratorWrappers.h b/school/informatik/verkerhssimulation/src/ogre/OgreIteratorWrappers.h new file mode 100644 index 00000000..ef732f89 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreIteratorWrappers.h @@ -0,0 +1,359 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __IteratorWrappers_H__ +#define __IteratorWrappers_H__ + +#include "OgrePrerequisites.h" + +namespace Ogre { + + /** Wraps iteration over a vector. + @remarks + This class is here just to allow clients to iterate over an internal + vector of a class without having to have access to the vector itself + (typically to iterate you need both the iterator and the end() iterator + to test for the end condition, which is messy). + No updates are allowed through this interface, it is purely for + iterating and reading. + @par + Note that like STL iterators, these iterators are only valid whilst no + updates are made to the underlying collection. You should not attempt to + use this iterator if a change is made to the collection. In fact, treat this + iterator as a transient object, do NOT store it and try to use it repeatedly. + */ + template + class VectorIterator + { + private: + typename T::iterator mCurrent; + typename T::iterator mEnd; + /// Private constructor since only the parameterised constructor should be used + VectorIterator() {}; + public: + typedef typename T::value_type ValueType; + + /** Constructor. + @remarks + Provide a start and end iterator to initialise. + */ + VectorIterator(typename T::iterator start, typename T::iterator end) + : mCurrent(start), mEnd(end) + { + } + + /** Constructor. + @remarks + Provide a container to initialise. + */ + explicit VectorIterator(T& c) + : mCurrent(c.begin()), mEnd(c.end()) + { + } + + /** Returns true if there are more items in the collection. */ + bool hasMoreElements(void) const + { + return mCurrent != mEnd; + } + + /** Returns the next element in the collection, and advances to the next. */ + typename T::value_type getNext(void) + { + return *mCurrent++; + } + /** Returns the next element in the collection, without advancing to the next. */ + typename T::value_type peekNext(void) + { + return *mCurrent; + } + /** Returns a pointer to the next element in the collection, without advancing to the next afterwards. */ + typename T::pointer peekNextPtr(void) + { + return &(*mCurrent); + } + /** Moves the iterator on one element. */ + void moveNext(void) + { + ++mCurrent; + } + + + + }; + + /** Wraps iteration over a map. + @remarks + This class is here just to allow clients to iterate over an internal + map of a class without having to have access to the map itself + (typically to iterate you need both the iterator and the end() iterator + to test for the end condition, which is messy). + No updates are allowed through this interface, it is purely for + iterating and reading. + @par + Note that like STL iterators, these iterators are only valid whilst no + updates are made to the underlying collection. You should not attempt to + use this iterator if a change is made to the collection. In fact, treat this + iterator as a transient object, do NOT store it and try to use it repeatedly. + */ + template + class MapIterator + { + private: + typename T::iterator mCurrent; + typename T::iterator mEnd; + /// Private constructor since only the parameterised constructor should be used + MapIterator() {}; + public: + typedef typename T::mapped_type MappedType; + typedef typename T::key_type KeyType; + + /** Constructor. + @remarks + Provide a start and end iterator to initialise. + */ + MapIterator(typename T::iterator start, typename T::iterator end) + : mCurrent(start), mEnd(end) + { + } + + /** Constructor. + @remarks + Provide a container to initialise. + */ + explicit MapIterator(T& c) + : mCurrent(c.begin()), mEnd(c.end()) + { + } + + /** Returns true if there are more items in the collection. */ + bool hasMoreElements(void) const + { + return mCurrent != mEnd; + } + + /** Returns the next value element in the collection, and advances to the next. */ + typename T::mapped_type getNext(void) + { + return (mCurrent++)->second; + } + /** Returns the next value element in the collection, without advancing to the next. */ + typename T::mapped_type peekNextValue(void) + { + return mCurrent->second; + } + /** Returns the next key element in the collection, without advancing to the next. */ + typename T::key_type peekNextKey(void) + { + return mCurrent->first; + } + /** Required to overcome intermittent bug */ + MapIterator & operator=( MapIterator &rhs ) + { + mCurrent = rhs.mCurrent; + mEnd = rhs.mEnd; + return *this; + } + /** Returns a pointer to the next value element in the collection, without + advancing to the next afterwards. */ + typename T::mapped_type* peekNextValuePtr(void) + { + return &(mCurrent->second); + } + /** Moves the iterator on one element. */ + void moveNext(void) + { + ++mCurrent; + } + + + + }; + /** Wraps iteration over a const vector. + @remarks + This class is here just to allow clients to iterate over an internal + vector of a class without having to have access to the vector itself + (typically to iterate you need both the iterator and the end() iterator + to test for the end condition, which is messy). + No updates are allowed through this interface, it is purely for + iterating and reading. + @par + Note that like STL iterators, these iterators are only valid whilst no + updates are made to the underlying collection. You should not attempt to + use this iterator if a change is made to the collection. In fact, treat this + iterator as a transient object, do NOT store it and try to use it repeatedly. + */ + template + class ConstVectorIterator + { + private: + mutable typename T::const_iterator mCurrent; + typename T::const_iterator mEnd; + /// Private constructor since only the parameterised constructor should be used + ConstVectorIterator() {}; + public: + typedef typename T::value_type ValueType; + + /** Constructor. + @remarks + Provide a start and end iterator to initialise. + */ + ConstVectorIterator(typename T::const_iterator start, typename T::const_iterator end) + : mCurrent(start), mEnd(end) + { + } + + /** Constructor. + @remarks + Provide a container to initialise. + */ + explicit ConstVectorIterator(const T& c) + : mCurrent(c.begin()), mEnd(c.end()) + { + } + + /** Returns true if there are more items in the collection. */ + bool hasMoreElements(void) const + { + return mCurrent != mEnd; + } + + /** Returns the next element in the collection, and advances to the next. */ + typename T::value_type getNext(void) + { + return *mCurrent++; + } + /** Returns the next element in the collection, without advancing to the next. */ + typename T::value_type peekNext(void) const + { + return *mCurrent; + } + /** Returns a pointer to the next element in the collection, without advancing to the next afterwards. */ + typename T::const_pointer peekNextPtr(void) const + { + return &(*mCurrent); + } + /** Moves the iterator on one element. */ + void moveNext(void) const + { + ++mCurrent; + } + + + + }; + + /** Wraps iteration over a const map. + @remarks + This class is here just to allow clients to iterate over an internal + map of a class without having to have access to the map itself + (typically to iterate you need both the iterator and the end() iterator + to test for the end condition, which is messy). + No updates are allowed through this interface, it is purely for + iterating and reading. + @par + Note that like STL iterators, these iterators are only valid whilst no + updates are made to the underlying collection. You should not attempt to + use this iterator if a change is made to the collection. In fact, treat this + iterator as a transient object, do NOT store it and try to use it repeatedly. + */ + template + class ConstMapIterator + { + private: + mutable typename T::const_iterator mCurrent; + typename T::const_iterator mEnd; + /// Private constructor since only the parameterised constructor should be used + ConstMapIterator() {}; + public: + typedef typename T::mapped_type MappedType; + typedef typename T::key_type KeyType; + + /** Constructor. + @remarks + Provide a start and end iterator to initialise. + */ + ConstMapIterator(typename T::const_iterator start, typename T::const_iterator end) + : mCurrent(start), mEnd(end) + { + } + + /** Constructor. + @remarks + Provide a container to initialise. + */ + explicit ConstMapIterator(const T& c) + : mCurrent(c.begin()), mEnd(c.end()) + { + } + + /** Returns true if there are more items in the collection. */ + bool hasMoreElements(void) const + { + return mCurrent != mEnd; + } + + /** Returns the next value element in the collection, and advances to the next. */ + typename T::mapped_type getNext(void) + { + return (mCurrent++)->second; + } + /** Returns the next value element in the collection, without advancing to the next. */ + typename T::mapped_type peekNextValue(void) const + { + return mCurrent->second; + } + /** Returns the next key element in the collection, without advancing to the next. */ + typename T::key_type peekNextKey(void) const + { + return mCurrent->first; + } + /** Required to overcome intermittent bug */ + ConstMapIterator & operator=( ConstMapIterator &rhs ) + { + mCurrent = rhs.mCurrent; + mEnd = rhs.mEnd; + return *this; + } + /** Returns a pointer to the next value element in the collection, without + advancing to the next afterwards. */ + const typename T::mapped_type* peekNextValuePtr(void) const + { + return &(mCurrent->second); + } + /** Moves the iterator on one element. */ + void moveNext(void) const + { + ++mCurrent; + } + + + + }; +} +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreKeyFrame.h b/school/informatik/verkerhssimulation/src/ogre/OgreKeyFrame.h new file mode 100644 index 00000000..0b159246 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreKeyFrame.h @@ -0,0 +1,248 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __KeyFrame_H__ +#define __KeyFrame_H__ + +#include "OgrePrerequisites.h" +#include "OgreVector3.h" +#include "OgreQuaternion.h" +#include "OgreAny.h" +#include "OgreHardwareVertexBuffer.h" +#include "OgreIteratorWrappers.h" + +namespace Ogre +{ + + /** A key frame in an animation sequence defined by an AnimationTrack. + @remarks + This class can be used as a basis for all kinds of key frames. + The unifying principle is that multiple KeyFrames define an + animation sequence, with the exact state of the animation being an + interpolation between these key frames. + */ + class _OgreExport KeyFrame + { + public: + + /** Default constructor, you should not call this but use AnimationTrack::createKeyFrame instead. */ + KeyFrame(const AnimationTrack* parent, Real time); + + virtual ~KeyFrame() {} + + /** Gets the time of this keyframe in the animation sequence. */ + Real getTime(void) const { return mTime; } + + /** Clone a keyframe (internal use only) */ + virtual KeyFrame* _clone(AnimationTrack* newParent) const; + + + protected: + Real mTime; + const AnimationTrack* mParentTrack; + }; + + + /** Specialised KeyFrame which stores any numeric value. + */ + class _OgreExport NumericKeyFrame : public KeyFrame + { + public: + /** Default constructor, you should not call this but use AnimationTrack::createKeyFrame instead. */ + NumericKeyFrame(const AnimationTrack* parent, Real time); + ~NumericKeyFrame() {} + + /** Get the value at this keyframe. */ + virtual const AnyNumeric& getValue(void) const; + /** Set the value at this keyframe. + @remarks + All keyframe values must have a consistent type. + */ + virtual void setValue(const AnyNumeric& val); + + /** Clone a keyframe (internal use only) */ + KeyFrame* _clone(AnimationTrack* newParent) const; + protected: + AnyNumeric mValue; + }; + + + /** Specialised KeyFrame which stores a full transform. */ + class _OgreExport TransformKeyFrame : public KeyFrame + { + public: + /** Default constructor, you should not call this but use AnimationTrack::createKeyFrame instead. */ + TransformKeyFrame(const AnimationTrack* parent, Real time); + ~TransformKeyFrame() {} + /** Sets the translation associated with this keyframe. + @remarks + The translation factor affects how much the keyframe translates (moves) it's animable + object at it's time index. + @param trans The vector to translate by + */ + virtual void setTranslate(const Vector3& trans); + + /** Gets the translation applied by this keyframe. */ + const Vector3& getTranslate(void) const; + + /** Sets the scaling factor applied by this keyframe to the animable + object at it's time index. + @param scale The vector to scale by (beware of supplying zero values for any component of this + vector, it will scale the object to zero dimensions) + */ + virtual void setScale(const Vector3& scale); + + /** Gets the scaling factor applied by this keyframe. */ + virtual const Vector3& getScale(void) const; + + /** Sets the rotation applied by this keyframe. + @param rot The rotation applied; use Quaternion methods to convert from angle/axis or Matrix3 if + you don't like using Quaternions directly. + */ + virtual void setRotation(const Quaternion& rot); + + /** Gets the rotation applied by this keyframe. */ + virtual const Quaternion& getRotation(void) const; + + /** Clone a keyframe (internal use only) */ + KeyFrame* _clone(AnimationTrack* newParent) const; + protected: + Vector3 mTranslate; + Vector3 mScale; + Quaternion mRotate; + + + }; + + + + /** Specialised KeyFrame which stores absolute vertex positions for a complete + buffer, designed to be interpolated with other keys in the same track. + */ + class _OgreExport VertexMorphKeyFrame : public KeyFrame + { + public: + /** Default constructor, you should not call this but use AnimationTrack::createKeyFrame instead. */ + VertexMorphKeyFrame(const AnimationTrack* parent, Real time); + ~VertexMorphKeyFrame() {} + /** Sets the vertex buffer containing the source positions for this keyframe. + @remarks + We assume that positions are the first 3 float elements in this buffer, + although we don't necessarily assume they're the only ones in there. + @param buf Vertex buffer link; will not be modified so can be shared + read-only data + */ + void setVertexBuffer(const HardwareVertexBufferSharedPtr& buf); + + /** Gets the vertex buffer containing positions for this keyframe. */ + const HardwareVertexBufferSharedPtr& getVertexBuffer(void) const; + + /** Clone a keyframe (internal use only) */ + KeyFrame* _clone(AnimationTrack* newParent) const; + + protected: + HardwareVertexBufferSharedPtr mBuffer; + + }; + + /** Specialised KeyFrame which references a Mesh::Pose at a certain influence + level, which stores offsets for a subset of the vertices + in a buffer to provide a blendable pose. + */ + class _OgreExport VertexPoseKeyFrame : public KeyFrame + { + public: + /** Default constructor, you should not call this but use AnimationTrack::createKeyFrame instead. */ + VertexPoseKeyFrame(const AnimationTrack* parent, Real time); + ~VertexPoseKeyFrame() {} + + /** Reference to a pose at a given influence level + @remarks + Each keyframe can refer to many poses each at a given influence level. + **/ + struct PoseRef + { + /** The linked pose index. + @remarks + The Mesh contains all poses for all vertex data in one list, both + for the shared vertex data and the dedicated vertex data on submeshes. + The 'target' on the parent track must match the 'target' on the + linked pose. + */ + ushort poseIndex; + /** Influence level of the linked pose. + 1.0 for full influence (full offset), 0.0 for no influence. + */ + Real influence; + + PoseRef(ushort p, Real i) : poseIndex(p), influence(i) {} + }; + typedef std::vector PoseRefList; + + /** Add a new pose reference. + @see PoseRef + */ + void addPoseReference(ushort poseIndex, Real influence); + /** Update the influence of a pose reference. + @see PoseRef + */ + void updatePoseReference(ushort poseIndex, Real influence); + /** Remove reference to a given pose. + @param poseIndex The pose index (not the index of the reference) + */ + void removePoseReference(ushort poseIndex); + /** Remove all pose references. */ + void removeAllPoseReferences(void); + + + /** Get a const reference to the list of pose references. */ + const PoseRefList& getPoseReferences(void) const; + + typedef VectorIterator PoseRefIterator; + typedef ConstVectorIterator ConstPoseRefIterator; + + /** Get an iterator over the pose references. */ + PoseRefIterator getPoseReferenceIterator(void); + + /** Get a const iterator over the pose references. */ + ConstPoseRefIterator getPoseReferenceIterator(void) const; + + /** Clone a keyframe (internal use only) */ + KeyFrame* _clone(AnimationTrack* newParent) const; + + protected: + PoseRefList mPoseRefs; + + }; + +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreLight.h b/school/informatik/verkerhssimulation/src/ogre/OgreLight.h new file mode 100644 index 00000000..1302211e --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreLight.h @@ -0,0 +1,433 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _LIGHT_H__ +#define _LIGHT_H__ + +#include "OgrePrerequisites.h" + +#include "OgreColourValue.h" +#include "OgreVector3.h" +#include "OgreVector4.h" +#include "OgreString.h" +#include "OgreMovableObject.h" +#include "OgrePlaneBoundedVolume.h" +#include "OgreShadowCameraSetup.h" + +namespace Ogre { + + + /** Representation of a dynamic light source in the scene. + @remarks + Lights are added to the scene like any other object. They contain various + parameters like type, position, attenuation (how light intensity fades with + distance), colour etc. + @par + The defaults when a light is created is pure white diffues light, with no + attenuation (does not decrease with distance) and a range of 1000 world units. + @par + Lights are created by using the SceneManager::createLight method. They can subsequently be + added to a SceneNode if required to allow them to move relative to a node in the scene. A light attached + to a SceneNode is assumed to havea base position of (0,0,0) and a direction of (0,0,1) before modification + by the SceneNode's own orientation. If not attached to a SceneNode, + the light's position and direction is as set using setPosition and setDirection. + @par + Remember also that dynamic lights rely on modifying the colour of vertices based on the position of + the light compared to an object's vertex normals. Dynamic lighting will only look good if the + object being lit has a fair level of tesselation and the normals are properly set. This is particularly + true for the spotlight which will only look right on highly tesselated models. In the future OGRE may be + extended for certain scene types so an alternative to the standard dynamic lighting may be used, such + as dynamic lightmaps. + */ + class _OgreExport Light : public MovableObject + { + public: + /// Temp tag used for sorting + Real tempSquareDist; + + /// Defines the type of light + enum LightTypes + { + /// Point light sources give off light equally in all directions, so require only position not direction + LT_POINT, + /// Directional lights simulate parallel light beams from a distant source, hence have direction but no position + LT_DIRECTIONAL, + /// Spotlights simulate a cone of light from a source so require position and direction, plus extra values for falloff + LT_SPOTLIGHT + }; + + /** Default constructor (for Python mainly). + */ + Light(); + + /** Normal constructor. Should not be called directly, but rather the SceneManager::createLight method should be used. + */ + Light(const String& name); + + /** Standard destructor. + */ + ~Light(); + + /** Sets the type of light - see LightTypes for more info. + */ + void setType(LightTypes type); + + /** Returns the light type. + */ + LightTypes getType(void) const; + + /** Sets the colour of the diffuse light given off by this source. + @remarks + Material objects have ambient, diffuse and specular values which indicate how much of each type of + light an object reflects. This value denotes the amount and colour of this type of light the light + exudes into the scene. The actual appearance of objects is a combination of the two. + @par + Diffuse light simulates the typical light emenating from light sources and affects the base colour + of objects together with ambient light. + */ + void setDiffuseColour(Real red, Real green, Real blue); + + /** Sets the colour of the diffuse light given off by this source. + @remarks + Material objects have ambient, diffuse and specular values which indicate how much of each type of + light an object reflects. This value denotes the amount and colour of this type of light the light + exudes into the scene. The actual appearance of objects is a combination of the two. + @par + Diffuse light simulates the typical light emenating from light sources and affects the base colour + of objects together with ambient light. + */ + void setDiffuseColour(const ColourValue& colour); + + /** Returns the colour of the diffuse light given off by this light source (see setDiffuseColour for more info). + */ + const ColourValue& getDiffuseColour(void) const; + + /** Sets the colour of the specular light given off by this source. + @remarks + Material objects have ambient, diffuse and specular values which indicate how much of each type of + light an object reflects. This value denotes the amount and colour of this type of light the light + exudes into the scene. The actual appearance of objects is a combination of the two. + @par + Specular light affects the appearance of shiny highlights on objects, and is also dependent on the + 'shininess' Material value. + */ + void setSpecularColour(Real red, Real green, Real blue); + + /** Sets the colour of the specular light given off by this source. + @remarks + Material objects have ambient, diffuse and specular values which indicate how much of each type of + light an object reflects. This value denotes the amount and colour of this type of light the light + exudes into the scene. The actual appearance of objects is a combination of the two. + @par + Specular light affects the appearance of shiny highlights on objects, and is also dependent on the + 'shininess' Material value. + */ + void setSpecularColour(const ColourValue& colour); + + /** Returns the colour of specular light given off by this light source. + */ + const ColourValue& getSpecularColour(void) const; + + /** Sets the attenuation parameters of the light source ie how it diminishes with distance. + @remarks + Lights normally get fainter the further they are away. Also, each light is given a maximum range + beyond which it cannot affect any objects. + @par + Light attentuation is not applicable to directional lights since they have an infinite range and + constant intensity. + @par + This follows a standard attenuation approach - see any good 3D text for the details of what they mean + since i don't have room here! + @param + range The absolute upper range of the light in world units + @param + constant The constant factor in the attenuation formula: 1.0 means never attenuate, 0.0 is complete attenuation + @param + linear The linear factor in the attenuation formula: 1 means attenuate evenly over the distance + @param + quadratic The quadratic factor in the attenuation formula: adds a curvature to the attenuation formula. + */ + void setAttenuation(Real range, Real constant, Real linear, Real quadratic); + + /** Returns the absolute upper range of the light. + */ + Real getAttenuationRange(void) const; + + /** Returns the constant factor in the attenuation formula. + */ + Real getAttenuationConstant(void) const; + + /** Returns the linear factor in the attenuation formula. + */ + Real getAttenuationLinear(void) const; + + /** Returns the quadric factor in the attenuation formula. + */ + Real getAttenuationQuadric(void) const; + + /** Sets the position of the light. + @remarks + Applicable to point lights and spotlights only. + @note + This will be overridden if the light is attached to a SceneNode. + */ + void setPosition(Real x, Real y, Real z); + + /** Sets the position of the light. + @remarks + Applicable to point lights and spotlights only. + @note + This will be overridden if the light is attached to a SceneNode. + */ + void setPosition(const Vector3& vec); + + /** Returns the position of the light. + @note + Applicable to point lights and spotlights only. + */ + const Vector3& getPosition(void) const; + + /** Sets the direction in which a light points. + @remarks + Applicable only to the spotlight and directional light types. + @note + This will be overridden if the light is attached to a SceneNode. + */ + void setDirection(Real x, Real y, Real z); + + /** Sets the direction in which a light points. + @remarks + Applicable only to the spotlight and directional light types. + @note + This will be overridden if the light is attached to a SceneNode. + */ + void setDirection(const Vector3& vec); + + /** Returns the light's direction. + @remarks + Applicable only to the spotlight and directional light types. + */ + const Vector3& getDirection(void) const; + + /** Sets the range of a spotlight, i.e. the angle of the inner and outer cones and the rate of falloff between them. + @param + innerAngle Angle covered by the bright inner cone + @node + The inner cone applicable only to Direct3D, it'll always treat as zero in OpenGL. + @param + outerAngle Angle covered by the outer cone + @param + falloff The rate of falloff between the inner and outer cones. 1.0 means a linear falloff, less means slower falloff, higher means faster falloff. + */ + void setSpotlightRange(const Radian& innerAngle, const Radian& outerAngle, Real falloff = 1.0); +#ifndef OGRE_FORCE_ANGLE_TYPES + inline void setSpotlightRange(Real innerAngle, Real outerAngle, Real falloff = 1.0) { + setSpotlightRange ( Angle(innerAngle), Angle(outerAngle), falloff ); + } +#endif//OGRE_FORCE_ANGLE_TYPES + + /** Returns the angle covered by the spotlights inner cone. + */ + const Radian& getSpotlightInnerAngle(void) const; + + /** Returns the angle covered by the spotlights outer cone. + */ + const Radian& getSpotlightOuterAngle(void) const; + + /** Returns the falloff between the inner and outer cones of the spotlight. + */ + Real getSpotlightFalloff(void) const; + + /** Sets the angle covered by the spotlights inner cone. + */ + void setSpotlightInnerAngle(const Radian& val); + + /** Sets the angle covered by the spotlights outer cone. + */ + void setSpotlightOuterAngle(const Radian& val); + + /** Sets the falloff between the inner and outer cones of the spotlight. + */ + void setSpotlightFalloff(Real val); + + /** Set a scaling factor to indicate the relative power of a light. + @remarks + This factor is only useful in High Dynamic Range (HDR) rendering. + You can bind it to a shader variable to take it into account, + @see GpuProgramParameters + @param power The power rating of this light, default is 1.0. + */ + void setPowerScale(Real power); + + /** Set the scaling factor which indicates the relative power of a + light. + */ + Real getPowerScale(void) const; + + /** Overridden from MovableObject */ + void _notifyAttached(Node* parent, bool isTagPoint = false); + + /** Overridden from MovableObject */ + void _notifyMoved(void); + + /** Overridden from MovableObject */ + const AxisAlignedBox& getBoundingBox(void) const; + + /** Overridden from MovableObject */ + void _updateRenderQueue(RenderQueue* queue); + + /** Overridden from MovableObject */ + const String& getMovableType(void) const; + + /** Retrieves the position of the light including any transform from nodes it is attached to. */ + const Vector3& getDerivedPosition(void) const; + + /** Retrieves the direction of the light including any transform from nodes it is attached to. */ + const Vector3& getDerivedDirection(void) const; + + /** Overridden from MovableObject. + @remarks + Although lights themselves are not 'visible', setting a light to invisible + means it no longer affects the scene. + */ + void setVisible(bool visible); + + /** Overridden from MovableObject */ + Real getBoundingRadius(void) const { return 0; /* not visible */ } + + /** Gets the details of this light as a 4D vector. + @remarks + Getting details of a light as a 4D vector can be useful for + doing general calculations between different light types; for + example the vector can represent both position lights (w=1.0f) + and directional lights (w=0.0f) and be used in the same + calculations. + */ + Vector4 getAs4DVector(void) const; + + /** Internal method for calculating the 'near clip volume', which is + the volume formed between the near clip rectangle of the + camera and the light. + @remarks This volume is a pyramid for a point/spot light and + a cuboid for a directional light. It can used to detect whether + an object could be casting a shadow on the viewport. Note that + the reference returned is to a shared volume which will be + reused across calls to this method. + */ + virtual const PlaneBoundedVolume& _getNearClipVolume(const Camera* const cam) const; + + /** Internal method for calculating the clip volumes outside of the + frustum which can be used to determine which objects are casting + shadow on the frustum as a whole. + @remarks Each of the volumes is a pyramid for a point/spot light and + a cuboid for a directional light. + */ + virtual const PlaneBoundedVolumeList& _getFrustumClipVolumes(const Camera* const cam) const; + + /// Override to return specific type flag + uint32 getTypeFlags(void) const; + + /// @copydoc AnimableObject::createAnimableValue + AnimableValuePtr createAnimableValue(const String& valueName); + + /** Set this light to use a custom shadow camera when rendering texture shadows. + @remarks + This changes the shadow camera setup for just this light, you can set + the shadow camera setup globally using SceneManager::setShadowCameraSetup + @see ShadowCameraSetup + */ + void setCustomShadowCameraSetup(const ShadowCameraSetupPtr& customShadowSetup); + + /** Reset the shadow camera setup to the default. + @see ShadowCameraSetup + */ + void resetCustomShadowCameraSetup(void); + + /** return a pointer to the custom shadow camera setup (null means use SceneManager global version). */ + const ShadowCameraSetupPtr& getCustomShadowCameraSetup(void) const; + + protected: + /// internal method for synchronising with parent node (if any) + virtual void update(void) const; + + /// @copydoc AnimableObject::getAnimableDictionaryName + const String& getAnimableDictionaryName(void) const; + /// @copydoc AnimableObject::initialiseAnimableDictionary + void initialiseAnimableDictionary(StringVector& vec) const; + + LightTypes mLightType; + Vector3 mPosition; + ColourValue mDiffuse; + ColourValue mSpecular; + + Vector3 mDirection; + + Radian mSpotOuter; + Radian mSpotInner; + Real mSpotFalloff; + Real mRange; + Real mAttenuationConst; + Real mAttenuationLinear; + Real mAttenuationQuad; + Real mPowerScale; + + + mutable Vector3 mDerivedPosition; + mutable Vector3 mDerivedDirection; + + /// Shared class-level name for Movable type + static String msMovableType; + + mutable PlaneBoundedVolume mNearClipVolume; + mutable PlaneBoundedVolumeList mFrustumClipVolumes; + /// Is the derived transform dirty? + mutable bool mDerivedTransformDirty; + + /// Pointer to a custom shadow camera setup + mutable ShadowCameraSetupPtr mCustomShadowCameraSetup; + + }; + + /** Factory object for creating Light instances */ + class _OgreExport LightFactory : public MovableObjectFactory + { + protected: + MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params); + public: + LightFactory() {} + ~LightFactory() {} + + static String FACTORY_TYPE_NAME; + + const String& getType(void) const; + void destroyInstance( MovableObject* obj); + + }; + +} // Namespace +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreLog.h b/school/informatik/verkerhssimulation/src/ogre/OgreLog.h new file mode 100644 index 00000000..dc488a67 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreLog.h @@ -0,0 +1,149 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __Log_H__ +#define __Log_H__ + +#include "OgrePrerequisites.h" + +namespace Ogre { + + // LogMessageLevel + LoggingLevel > OGRE_LOG_THRESHOLD = message logged + #define OGRE_LOG_THRESHOLD 4 + + /** The level of detail to which the log will go into. + */ + enum LoggingLevel + { + LL_LOW = 1, + LL_NORMAL = 2, + LL_BOREME = 3 + }; + + /** The importance of a logged message. + */ + enum LogMessageLevel + { + LML_TRIVIAL = 1, + LML_NORMAL = 2, + LML_CRITICAL = 3 + }; + + /** @remarks Pure Abstract class, derive this class and register to the Log to listen to log messages */ + class LogListener + { + public: + virtual ~LogListener() {}; + + /** + @remarks + This is called whenever the log recieves a message and is about to write it out + @param message + The message to be logged + @param lml + The message level the log is using + @param maskDebug + If we are printing to the console or not + @param logName + the name of this log (so you can have several listeners for different logs, and identify them) + */ + virtual void messageLogged( const String& message, LogMessageLevel lml, bool maskDebug, const String &logName ) = 0; + }; + + /** + @remarks + Log class for writing debug/log data to files. + @note +
Should not be used directly, but trough the LogManager class. + */ + class _OgreExport Log + { + protected: + std::ofstream mfpLog; + LoggingLevel mLogLevel; + bool mDebugOut; + bool mSuppressFile; + String mLogName; + + typedef std::vector mtLogListener; + mtLogListener mListeners; + + public: + OGRE_AUTO_MUTEX // public to allow external locking + /** + @remarks + Usual constructor - called by LogManager. + */ + Log( const String& name, bool debugOutput = true, bool suppressFileOutput = false); + + /** + @remarks + Default destructor. + */ + ~Log(); + + /// Return the name of the log + const String& getName() const { return mLogName; } + /// Get whether debug output is enabled for this log + bool isDebugOutputEnabled() const { return mDebugOut; } + /// Get whether file output is suppressed for this log + bool isFileOutputSuppressed() const { return mSuppressFile; } + + /** Log a message to the debugger and to log file (the default is + "OGRE.log"), + */ + void logMessage( const String& message, LogMessageLevel lml = LML_NORMAL, bool maskDebug = false ); + + /** + @remarks + Sets the level of the log detail. + */ + void setLogDetail(LoggingLevel ll); + /** Gets the level of the log detail. + */ + LoggingLevel getLogDetail() const { return mLogLevel; } + /** + @remarks + Register a listener to this log + @param + A valid listener derived class + */ + void addListener(LogListener* listener); + + /** + @remarks + Unregister a listener from this log + @param + A valid listener derived class + */ + void removeListener(LogListener* listener); + }; +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreLogManager.h b/school/informatik/verkerhssimulation/src/ogre/OgreLogManager.h new file mode 100644 index 00000000..efd385fd --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreLogManager.h @@ -0,0 +1,163 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __LogManager_H__ +#define __LogManager_H__ + +#include "OgrePrerequisites.h" + +#include "OgreLog.h" +#include "OgreSingleton.h" +#include "OgreString.h" + +namespace Ogre +{ + /** The log manager handles the creation and retrieval of logs for the + application. + @remarks + This class will create new log files and will retrieve instances + of existing ones. Other classes wishing to log output can either + create a fresh log or retrieve an existing one to output to. + One log is the default log, and is the one written to when the + logging methods of this class are called. + @par + By default, Root will instantiate a LogManager (which becomes the + Singleton instance) on construction, and will create a default log + based on the Root construction parameters. If you want more control, + for example redirecting log output right from the start or suppressing + debug output, you need to create a LogManager yourself before creating + a Root instance, then create a default log. Root will detect that + you've created one yourself and won't create one of its own, thus + using all your logging preferences from the first instance. + */ + class _OgreExport LogManager : public Singleton + { + protected: + typedef std::map > LogList; + + /// A list of all the logs the manager can access + LogList mLogs; + + /// The default log to which output is done + Log* mDefaultLog; + + public: + OGRE_AUTO_MUTEX // public to allow external locking + + LogManager(); + ~LogManager(); + + /** Creates a new log with the given name. + @param + name The name to give the log e.g. 'Ogre.log' + @param + defaultLog If true, this is the default log output will be + sent to if the generic logging methods on this class are + used. The first log created is always the default log unless + this parameter is set. + @param + debuggerOutput If true, output to this log will also be + routed to the debugger's output window. + @param + suppressFileOutput If true, this is a logical rather than a physical + log and no file output will be written. If you do this you should + register a LogListener so log output is not lost. + */ + Log* createLog( const String& name, bool defaultLog = false, bool debuggerOutput = true, + bool suppressFileOutput = false); + + /** Retrieves a log managed by this class. + */ + Log* getLog( const String& name); + + /** Returns a pointer to the default log. + */ + Log* getDefaultLog(); + + /** Closes and removes a named log. */ + void destroyLog(const String& name); + /** Closes and removes a log. */ + void destroyLog(Log* log); + + /** Sets the passed in log as the default log. + @returns The previous default log. + */ + Log* setDefaultLog(Log* newLog); + + /** Log a message to the default log. + */ + void logMessage( const String& message, LogMessageLevel lml = LML_NORMAL, + bool maskDebug = false); + + /** Log a message to the default log (signature for backward compatibility). + */ + void logMessage( LogMessageLevel lml, const String& message, + bool maskDebug = false) { logMessage(message, lml, maskDebug); } + + /** Sets the level of detail of the default log. + */ + void setLogDetail(LoggingLevel ll); + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static LogManager& getSingleton(void); + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static LogManager* getSingletonPtr(void); + + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreManualObject.h b/school/informatik/verkerhssimulation/src/ogre/OgreManualObject.h new file mode 100644 index 00000000..d7625501 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreManualObject.h @@ -0,0 +1,513 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __OgreManualObject_H__ +#define __OgreManualObject_H__ + +#include "OgrePrerequisites.h" +#include "OgreMovableObject.h" +#include "OgreRenderable.h" +#include "OgreResourceGroupManager.h" + + +namespace Ogre +{ + /** Class providing a much simplified interface to generating manual + objects with custom geometry. + @remarks + Building one-off geometry objects manually usually requires getting + down and dirty with the vertex buffer and vertex declaration API, + which some people find a steep learning curve. This class gives you + a simpler interface specifically for the purpose of building a + 3D object simply and quickly. Note that if you intend to instance your + object you will still need to become familiar with the Mesh class. + @par + This class draws heavily on the interface for OpenGL + immediate-mode (glBegin, glVertex, glNormal etc), since this + is generally well-liked by people. There are a couple of differences + in the results though - internally this class still builds hardware + buffers which can be re-used, so you can render the resulting object + multiple times without re-issuing all the same commands again. + Secondly, the rendering is not immediate, it is still queued just like + all OGRE objects. This makes this object more efficient than the + equivalent GL immediate-mode commands, so it's feasible to use it for + large objects if you really want to. + @par + To construct some geometry with this object: + -# If you know roughly how many vertices (and indices, if you use them) + you're going to submit, call estimateVertexCount and estimateIndexCount. + This is not essential but will make the process more efficient by saving + memory reallocations. + -# Call begin() to begin entering data + -# For each vertex, call position(), normal(), textureCoord(), colour() + to define your vertex data. Note that each time you call position() + you start a new vertex. Note that the first vertex defines the + components of the vertex - you can't add more after that. For example + if you didn't call normal() in the first vertex, you cannot call it + in any others. You ought to call the same combination of methods per + vertex. + -# If you want to define triangles (or lines/points) by indexing into the vertex list, + you can call index() as many times as you need to define them. + If you don't do this, the class will assume you want triangles drawn + directly as defined by the vertex list, ie non-indexed geometry. Note + that stencil shadows are only supported on indexed geometry, and that + indexed geometry is a little faster; so you should try to use it. + -# Call end() to finish entering data. + -# Optionally repeat the begin-end cycle if you want more geometry + using different rendering operation types, or different materials + After calling end(), the class will organise the data for that section + internally and make it ready to render with. Like any other + MovableObject you should attach the object to a SceneNode to make it + visible. Other aspects like the relative render order can be controlled + using standard MovableObject methods like setRenderQueueGroup. + @par + You can also use beginUpdate() to alter the geometry later on if you wish. + If you do this, you should call setDynamic(true) before your first call + to begin(), and also consider using estimateVertexCount / estimateIndexCount + if your geometry is going to be growing, to avoid buffer recreation during + growth. + @par + Note that like all OGRE geometry, triangles should be specified in + anti-clockwise winding order (whether you're doing it with just + vertices, or using indexes too). That is to say that the front of the + face is the one where the vertices are listed in anti-clockwise order. + */ + class _OgreExport ManualObject : public MovableObject + { + public: + ManualObject(const String& name); + virtual ~ManualObject(); + + //pre-declare ManualObjectSection + class ManualObjectSection; + + /** Completely clear the contents of the object. + @remarks + Clearing the contents of this object and rebuilding from scratch + is not the optimal way to manage dynamic vertex data, since the + buffers are recreated. If you want to keep the same structure but + update the content within that structure, use beginUpdate() instead + of clear() begin(). However if you do want to modify the structure + from time to time you can do so by clearing and re-specifying the data. + */ + virtual void clear(void); + + /** Estimate the number of vertices ahead of time. + @remarks + Calling this helps to avoid memory reallocation when you define + vertices. Also very handy when using beginUpdate() to manage dynamic + data - you can make the vertex buffers a little larger than their + initial needs to allow for growth later with this method. + */ + virtual void estimateVertexCount(size_t vcount); + + /** Estimate the number of indices ahead of time. + @remarks + Calling this helps to avoid memory reallocation when you define + indices. Also very handy when using beginUpdate() to manage dynamic + data - you can make the index buffer a little larger than the + initial need to allow for growth later with this method. + */ + virtual void estimateIndexCount(size_t icount); + + /** Start defining a part of the object. + @remarks + Each time you call this method, you start a new section of the + object with its own material and potentially its own type of + rendering operation (triangles, points or lines for example). + @param materialName The name of the material to render this part of the + object with. + @param opType The type of operation to use to render. + */ + virtual void begin(const String& materialName, + RenderOperation::OperationType opType = RenderOperation::OT_TRIANGLE_LIST); + + /** Use before defining gometry to indicate that you intend to update the + geometry regularly and want the internal structure to reflect that. + */ + virtual void setDynamic(bool dyn) { mDynamic = dyn; } + /** Gets whether this object is marked as dynamic */ + virtual bool getDynamic() const { return mDynamic; } + + /** Start the definition of an update to a part of the object. + @remarks + Using this method, you can update an existing section of the object + efficiently. You do not have the option of changing the operation type + obviously, since it must match the one that was used before. + @note If your sections are changing size, particularly growing, use + estimateVertexCount and estimateIndexCount to pre-size the buffers a little + larger than the initial needs to avoid buffer reconstruction. + @param sectionIndex The index of the section you want to update. The first + call to begin() would have created section 0, the second section 1, etc. + */ + virtual void beginUpdate(size_t sectionIndex); + /** Add a vertex position, starting a new vertex at the same time. + @remarks A vertex position is slightly special among the other vertex data + methods like normal() and textureCoord(), since calling it indicates + the start of a new vertex. All other vertex data methods you call + after this are assumed to be adding more information (like normals or + texture coordinates) to the last vertex started with position(). + */ + virtual void position(const Vector3& pos); + /// @copydoc ManualObject::position(const Vector3&) + virtual void position(Real x, Real y, Real z); + + /** Add a vertex normal to the current vertex. + @remarks + Vertex normals are most often used for dynamic lighting, and + their components should be normalised. + */ + virtual void normal(const Vector3& norm); + /// @copydoc ManualObject::normal(const Vector3&) + virtual void normal(Real x, Real y, Real z); + + /** Add a texture coordinate to the current vertex. + @remarks + You can call this method multiple times between position() calls + to add multiple texture coordinates to a vertex. Each one can have + between 1 and 3 dimensions, depending on your needs, although 2 is + most common. There are several versions of this method for the + variations in number of dimensions. + */ + virtual void textureCoord(Real u); + /// @copydoc ManualObject::textureCoord(Real) + virtual void textureCoord(Real u, Real v); + /// @copydoc ManualObject::textureCoord(Real) + virtual void textureCoord(Real u, Real v, Real w); + /// @copydoc ManualObject::textureCoord(Real) + virtual void textureCoord(const Vector2& uv); + /// @copydoc ManualObject::textureCoord(Real) + virtual void textureCoord(const Vector3& uvw); + + /** Add a vertex colour to a vertex. + */ + virtual void colour(const ColourValue& col); + /** Add a vertex colour to a vertex. + @param r,g,b,a Colour components expressed as floating point numbers from 0-1 + */ + virtual void colour(Real r, Real g, Real b, Real a = 1.0f); + + /** Add a vertex index to construct faces / lines / points via indexing + rather than just by a simple list of vertices. + @remarks + You will have to call this 3 times for each face for a triangle list, + or use the alternative 3-parameter version. Other operation types + require different numbers of indexes, @see RenderOperation::OperationType. + @note + 32-bit indexes are not supported on all cards which is why this + class only allows 16-bit indexes, for simplicity and ease of use. + @param idx A vertex index from 0 to 65535. + */ + virtual void index(uint16 idx); + /** Add a set of 3 vertex indices to construct a triangle; this is a + shortcut to calling index() 3 times. It is only valid for triangle + lists. + @note + 32-bit indexes are not supported on all cards which is why this + class only allows 16-bit indexes, for simplicity and ease of use. + @param i1, i2, i3 3 vertex indices from 0 to 65535 defining a face. + */ + virtual void triangle(uint16 i1, uint16 i2, uint16 i3); + /** Add a set of 4 vertex indices to construct a quad (out of 2 + triangles); this is a shortcut to calling index() 6 times, + or triangle() twice. It's only valid for triangle list operations. + @note + 32-bit indexes are not supported on all cards which is why this + class only allows 16-bit indexes, for simplicity and ease of use. + @param i1, i2, i3 3 vertex indices from 0 to 65535 defining a face. + */ + virtual void quad(uint16 i1, uint16 i2, uint16 i3, uint16 i4); + + /** Finish defining the object and compile the final renderable version. + @note + Will return a pointer to the finished section or NULL if the section was discarded (i.e. has zero vertices/indices). + */ + virtual ManualObjectSection* end(void); + + /** Alter the material for a subsection of this object after it has been + specified. + @remarks + You specify the material to use on a section of this object during the + call to begin(), however if you want to change the material afterwards + you can do so by calling this method. + @param subIndex The index of the subsection to alter + @param name The name of the new material to use + */ + virtual void setMaterialName(size_t subindex, const String& name); + + /** Convert this object to a Mesh. + @remarks + After you've finished building this object, you may convert it to + a Mesh if you want in order to be able to create many instances of + it in the world (via Entity). This is optional, since this instance + can be directly attached to a SceneNode itself, but of course only + one instance of it can exist that way. + @note Only objects which use indexed geometry may be converted to a mesh. + @param meshName The name to give the mesh + @param groupName The resource group to create the mesh in + */ + virtual MeshPtr convertToMesh(const String& meshName, + const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); + + /** Sets whether or not to use an 'identity' projection. + @remarks + Usually ManualObjects will use a projection matrix as determined + by the active camera. However, if they want they can cancel this out + and use an identity projection, which effectively projects in 2D using + a {-1, 1} view space. Useful for overlay rendering. Normally you don't + need to change this. The default is false. + @see ManualObject::getUseIdentityProjection + */ + void setUseIdentityProjection(bool useIdentityProjection); + + /** Returns whether or not to use an 'identity' projection. + @remarks + Usually ManualObjects will use a projection matrix as determined + by the active camera. However, if they want they can cancel this out + and use an identity projection, which effectively projects in 2D using + a {-1, 1} view space. Useful for overlay rendering. Normally you don't + need to change this. + @see ManualObject::setUseIdentityProjection + */ + bool getUseIdentityProjection(void) const { return mUseIdentityProjection; } + + /** Sets whether or not to use an 'identity' view. + @remarks + Usually ManualObjects will use a view matrix as determined + by the active camera. However, if they want they can cancel this out + and use an identity matrix, which means all geometry is assumed + to be relative to camera space already. Useful for overlay rendering. + Normally you don't need to change this. The default is false. + @see ManualObject::getUseIdentityView + */ + void setUseIdentityView(bool useIdentityView); + + /** Returns whether or not to use an 'identity' view. + @remarks + Usually ManualObjects will use a view matrix as determined + by the active camera. However, if they want they can cancel this out + and use an identity matrix, which means all geometry is assumed + to be relative to camera space already. Useful for overlay rendering. + Normally you don't need to change this. + @see ManualObject::setUseIdentityView + */ + bool getUseIdentityView(void) const { return mUseIdentityView; } + + /** Sets the bounding box. + @remarks Call this after having finished creating sections to modify the + bounding box. E.g. if you're using ManualObject to create 2D overlays + you can call things function to set an infinite bounding box so that + the object always stays visible when attached. + @see ManualObject::setUseIdentityProjection, ManualObject::setUseIdentityView, + AxisAlignedBox::setInfinite */ + void setBoundingBox(const AxisAlignedBox& box) { mAABB = box; } + + /** Gets a pointer to a ManualObjectSection, ie a part of a ManualObject. + */ + ManualObjectSection* getSection(unsigned int index) const; + + /** Retrieves the number of ManualObjectSection objects making up this ManualObject. + */ + unsigned int getNumSections(void) const; + + // MovableObject overrides + + /** @copydoc MovableObject::getMovableType. */ + const String& getMovableType(void) const; + /** @copydoc MovableObject::getBoundingBox. */ + const AxisAlignedBox& getBoundingBox(void) const; + /** @copydoc MovableObject::getBoundingRadius. */ + Real getBoundingRadius(void) const; + /** @copydoc MovableObject::_updateRenderQueue. */ + void _updateRenderQueue(RenderQueue* queue); + /** Implement this method to enable stencil shadows. */ + EdgeData* getEdgeList(void); + /** Overridden member from ShadowCaster. */ + bool hasEdgeList(void); + /** Implement this method to enable stencil shadows. */ + ShadowRenderableListIterator getShadowVolumeRenderableIterator( + ShadowTechnique shadowTechnique, const Light* light, + HardwareIndexBufferSharedPtr* indexBuffer, + bool extrudeVertices, Real extrusionDist, unsigned long flags = 0); + + + /// Built, renderable section of geometry + class _OgreExport ManualObjectSection : public Renderable + { + protected: + ManualObject* mParent; + String mMaterialName; + mutable MaterialPtr mMaterial; + RenderOperation mRenderOperation; + + public: + ManualObjectSection(ManualObject* parent, const String& materialName, + RenderOperation::OperationType opType); + virtual ~ManualObjectSection(); + + /// Retrieve render operation for manipulation + RenderOperation* getRenderOperation(void); + /// Retrieve the material name in use + const String& getMaterialName(void) const { return mMaterialName; } + /// update the material name in use + void setMaterialName(const String& name); + + // Renderable overrides + /** @copydoc Renderable::getMaterial. */ + const MaterialPtr& getMaterial(void) const; + /** @copydoc Renderable::getRenderOperation. */ + void getRenderOperation(RenderOperation& op); + /** @copydoc Renderable::getWorldTransforms. */ + void getWorldTransforms(Matrix4* xform) const; + /** @copydoc Renderable::getWorldOrientation. */ + const Quaternion& getWorldOrientation(void) const; + /** @copydoc Renderable::getWorldPosition. */ + const Vector3& getWorldPosition(void) const; + /** @copydoc Renderable::getSquaredViewDepth. */ + Real getSquaredViewDepth(const Ogre::Camera *) const; + /** @copydoc Renderable::getLights. */ + const LightList &getLights(void) const; + + }; + /** Nested class to allow shadows. */ + class _OgreExport ManualObjectSectionShadowRenderable : public ShadowRenderable + { + protected: + ManualObject* mParent; + // Shared link to position buffer + HardwareVertexBufferSharedPtr mPositionBuffer; + // Shared link to w-coord buffer (optional) + HardwareVertexBufferSharedPtr mWBuffer; + + public: + ManualObjectSectionShadowRenderable(ManualObject* parent, + HardwareIndexBufferSharedPtr* indexBuffer, const VertexData* vertexData, + bool createSeparateLightCap, bool isLightCap = false); + ~ManualObjectSectionShadowRenderable(); + /// Overridden from ShadowRenderable + void getWorldTransforms(Matrix4* xform) const; + /// Overridden from ShadowRenderable + const Quaternion& getWorldOrientation(void) const; + /// Overridden from ShadowRenderable + const Vector3& getWorldPosition(void) const; + HardwareVertexBufferSharedPtr getPositionBuffer(void) { return mPositionBuffer; } + HardwareVertexBufferSharedPtr getWBuffer(void) { return mWBuffer; } + + }; + + typedef std::vector SectionList; + + protected: + /// Dynamic? + bool mDynamic; + /// List of subsections + SectionList mSectionList; + /// Current section + ManualObjectSection* mCurrentSection; + /// Are we updating? + bool mCurrentUpdating; + /// Temporary vertex structure + struct TempVertex + { + Vector3 position; + Vector3 normal; + Vector3 texCoord[OGRE_MAX_TEXTURE_COORD_SETS]; + ushort texCoordDims[OGRE_MAX_TEXTURE_COORD_SETS]; + ColourValue colour; + }; + /// Temp storage + TempVertex mTempVertex; + /// First vertex indicator + bool mFirstVertex; + /// Temp vertex data to copy? + bool mTempVertexPending; + /// System-memory buffer whilst we establish the size required + char* mTempVertexBuffer; + /// System memory allocation size, in bytes + size_t mTempVertexSize; + /// System-memory buffer whilst we establish the size required + uint16* mTempIndexBuffer; + /// System memory allocation size, in bytes + size_t mTempIndexSize; + /// Current declaration vertex size + size_t mDeclSize; + /// Estimated vertex count + size_t mEstVertexCount; + /// Estimated index count + size_t mEstIndexCount; + /// Current texture coordinate + ushort mTexCoordIndex; + /// Bounding box + AxisAlignedBox mAABB; + /// Bounding sphere + Real mRadius; + /// Any indexed geoemtry on any sections? + bool mAnyIndexed; + /// Edge list, used if stencil shadow casting is enabled + EdgeData* mEdgeList; + /// List of shadow renderables + ShadowRenderableList mShadowRenderables; + /// Whether to use identity projection for sections + bool mUseIdentityProjection; + /// Whether to use identity view for sections + bool mUseIdentityView; + + + /// Delete temp buffers and reset init counts + virtual void resetTempAreas(void); + /// Resize the temp vertex buffer? + virtual void resizeTempVertexBufferIfNeeded(size_t numVerts); + /// Resize the temp index buffer? + virtual void resizeTempIndexBufferIfNeeded(size_t numInds); + + /// Copy current temp vertex into buffer + virtual void copyTempVertexToBuffer(void); + + }; + + + /** Factory object for creating ManualObject instances */ + class _OgreExport ManualObjectFactory : public MovableObjectFactory + { + protected: + MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params); + public: + ManualObjectFactory() {} + ~ManualObjectFactory() {} + + static String FACTORY_TYPE_NAME; + + const String& getType(void) const; + void destroyInstance( MovableObject* obj); + + }; +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreMaterial.h b/school/informatik/verkerhssimulation/src/ogre/OgreMaterial.h new file mode 100644 index 00000000..688c4b53 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreMaterial.h @@ -0,0 +1,680 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _Material_H__ +#define _Material_H__ + +#include "OgrePrerequisites.h" + +#include "OgreResource.h" +#include "OgreIteratorWrappers.h" +#include "OgreCommon.h" +#include "OgreColourValue.h" +#include "OgreBlendMode.h" + + +namespace Ogre { + + // Forward declaration + class MaterialPtr; + + /** Class encapsulates rendering properties of an object. + @remarks + Ogre's material class encapsulates ALL aspects of the visual appearance, + of an object. It also includes other flags which + might not be traditionally thought of as material properties such as + culling modes and depth buffer settings, but these affect the + appearance of the rendered object and are convenient to attach to the + material since it keeps all the settings in one place. This is + different to Direct3D which treats a material as just the colour + components (diffuse, specular) and not texture maps etc. An Ogre + Material can be thought of as equivalent to a 'Shader'. + @par + A Material can be rendered in multiple different ways depending on the + hardware available. You may configure a Material to use high-complexity + fragment shaders, but these won't work on every card; therefore a Technique + is an approach to creating the visual effect you are looking for. You are advised + to create fallback techniques with lower hardware requirements if you decide to + use advanced features. In addition, you also might want lower-detail techniques + for distant geometry. + @par + Each technique can be made up of multiple passes. A fixed-function pass + may combine multiple texture layers using multitexrtuing, but Ogre can + break that into multiple passes automatically if the active card cannot + handle that many simultaneous textures. Programmable passes, however, cannot + be split down automatically, so if the active graphics card cannot handle the + technique which contains these passes, OGRE will try to find another technique + which the card can do. If, at the end of the day, the card cannot handle any of the + techniques which are listed for the material, the engine will render the + geometry plain white, which should alert you to the problem. + @par + Ogre comes configured with a number of default settings for a newly + created material. These can be changed if you wish by retrieving the + default material settings through + SceneManager::getDefaultMaterialSettings. Any changes you make to the + Material returned from this method will apply to any materials created + from this point onward. + */ + class _OgreExport Material : public Resource + { + friend class SceneManager; + friend class MaterialManager; + + public: + /// distance list used to specify LOD + typedef std::vector LodDistanceList; + typedef ConstVectorIterator LodDistanceIterator; + protected: + + + /** Internal method which sets the material up from the default settings. + */ + void applyDefaults(void); + + typedef std::vector Techniques; + /// All techniques, supported and unsupported + Techniques mTechniques; + /// Supported techniques of any sort + Techniques mSupportedTechniques; + typedef std::map LodTechniques; + typedef std::map BestTechniquesBySchemeList; + /** Map of scheme -> list of LOD techniques. + Current scheme is set on MaterialManager, + and can be set per Viewport for auto activation. + */ + BestTechniquesBySchemeList mBestTechniquesBySchemeList; + + LodDistanceList mLodDistances; + bool mReceiveShadows; + bool mTransparencyCastsShadows; + /// Does this material require compilation? + bool mCompilationRequired; + /// Text description of why any techniques are not supported + String mUnsupportedReasons; + + /** Insert a supported technique into the local collections. */ + void insertSupportedTechnique(Technique* t); + + /** Clear the best technique list. + */ + void clearBestTechniqueList(void); + + /** Overridden from Resource. + */ + void loadImpl(void); + + /** Unloads the material, frees resources etc. + @see + Resource + */ + void unloadImpl(void); + /// @copydoc Resource::calculateSize + size_t calculateSize(void) const { return 0; } // TODO + public: + + /** Constructor - use resource manager's create method rather than this. + */ + Material(ResourceManager* creator, const String& name, ResourceHandle handle, + const String& group, bool isManual = false, ManualResourceLoader* loader = 0); + + ~Material(); + /** Assignment operator to allow easy copying between materials. + */ + Material& operator=( const Material& rhs ); + + /** Determines if the material has any transparency with the rest of the scene (derived from + whether any Techniques say they involve transparency). + */ + bool isTransparent(void) const; + + /** Sets whether objects using this material will receive shadows. + @remarks + This method allows a material to opt out of receiving shadows, if + it would otherwise do so. Shadows will not be cast on any objects + unless the scene is set up to support shadows + (@see SceneManager::setShadowTechnique), and not all techniques cast + shadows on all objects. In any case, if you have a need to prevent + shadows being received by material, this is the method you call to + do it. + @note + Transparent materials never receive shadows despite this setting. + The default is to receive shadows. + */ + void setReceiveShadows(bool enabled) { mReceiveShadows = enabled; } + /** Returns whether or not objects using this material will receive shadows. */ + bool getReceiveShadows(void) const { return mReceiveShadows; } + + /** Sets whether objects using this material be classified as opaque to the shadow caster system. + @remarks + This method allows a material to cast a shadow, even if it is transparent. + By default, transparent materials neither cast nor receive shadows. Shadows + will not be cast on any objects unless the scene is set up to support shadows + (@see SceneManager::setShadowTechnique), and not all techniques cast + shadows on all objects. + */ + void setTransparencyCastsShadows(bool enabled) { mTransparencyCastsShadows = enabled; } + /** Returns whether or not objects using this material be classified as opaque to the shadow caster system. */ + bool getTransparencyCastsShadows(void) const { return mTransparencyCastsShadows; } + + /** Creates a new Technique for this Material. + @remarks + A Technique is a single way of rendering geometry in order to achieve the effect + you are intending in a material. There are many reason why you would want more than + one - the main one being to handle variable graphics card abilities; you might have + one technique which is impressive but only runs on 4th-generation graphics cards, + for example. In this case you will want to create at least one fallback Technique. + OGRE will work out which Techniques a card can support and pick the best one. + @par + If multiple Techniques are available, the order in which they are created is + important - the engine will consider lower-indexed Techniques to be preferable + to higher-indexed Techniques, ie when asked for the 'best' technique it will + return the first one in the technique list which is supported by the hardware. + */ + Technique* createTechnique(void); + /** Gets the indexed technique. */ + Technique* getTechnique(unsigned short index); + /** searches for the named technique. + Return 0 if technique with name is not found + */ + Technique* getTechnique(const String& name); + /** Retrieves the number of techniques. */ + unsigned short getNumTechniques(void) const; + /** Removes the technique at the given index. */ + void removeTechnique(unsigned short index); + /** Removes all the techniques in this Material. */ + void removeAllTechniques(void); + typedef VectorIterator TechniqueIterator; + /** Get an iterator over the Techniques in this Material. */ + TechniqueIterator getTechniqueIterator(void); + /** Gets an iterator over all the Techniques which are supported by the current card. + @remarks + The supported technique list is only available after this material has been compiled, + which typically happens on loading the material. Therefore, if this method returns + an empty list, try calling Material::load. + */ + TechniqueIterator getSupportedTechniqueIterator(void); + + /** Gets the indexed supported technique. */ + Technique* getSupportedTechnique(unsigned short index); + /** Retrieves the number of supported techniques. */ + unsigned short getNumSupportedTechniques(void) const; + /** Gets a string explaining why any techniques are not supported. */ + const String& getUnsupportedTechniquesExplanation() const { return mUnsupportedReasons; } + + /** Gets the number of levels-of-detail this material has in the + given scheme, based on Technique::setLodIndex. + @remarks + Note that this will not be up to date until the material has been compiled. + */ + unsigned short getNumLodLevels(unsigned short schemeIndex) const; + /** Gets the number of levels-of-detail this material has in the + given scheme, based on Technique::setLodIndex. + @remarks + Note that this will not be up to date until the material has been compiled. + */ + unsigned short getNumLodLevels(const String& schemeName) const; + + /** Gets the best supported technique. + @remarks + This method returns the lowest-index supported Technique in this material + (since lower-indexed Techniques are considered to be better than higher-indexed + ones). + @par + The best supported technique is only available after this material has been compiled, + which typically happens on loading the material. Therefore, if this method returns + NULL, try calling Material::load. + @param lodIndex The material lod index to use + */ + Technique* getBestTechnique(unsigned short lodIndex = 0); + + + /** Creates a new copy of this material with the same settings but a new name. + @param newName The name for the cloned material + @param changeGroup If true, the resource group of the clone is changed + @param newGroup Only required if changeGroup is true; the new group to assign + */ + MaterialPtr clone(const String& newName, bool changeGroup = false, + const String& newGroup = StringUtil::BLANK) const; + + /** Copies the details of this material into another, preserving the target's handle and name + (unlike operator=) but copying everything else. + @param mat Weak reference to material which will receive this material's settings. + */ + void copyDetailsTo(MaterialPtr& mat) const; + + /** 'Compiles' this Material. + @remarks + Compiling a material involves determining which Techniques are supported on the + card on which OGRE is currently running, and for fixed-function Passes within those + Techniques, splitting the passes down where they contain more TextureUnitState + instances than the current card has texture units. + @par + This process is automatically done when the Material is loaded, but may be + repeated if you make some procedural changes. + @param + autoManageTextureUnits If true, when a fixed function pass has too many TextureUnitState + entries than the card has texture units, the Pass in question will be split into + more than one Pass in order to emulate the Pass. If you set this to false and + this situation arises, an Exception will be thrown. + */ + void compile(bool autoManageTextureUnits = true); + + // ------------------------------------------------------------------------------- + // The following methods are to make migration from previous versions simpler + // and to make code easier to write when dealing with simple materials + // They set the properties which have been moved to Pass for all Techniques and all Passes + + /** Sets the point size properties for every Pass in every Technique. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setPointSize + */ + void setPointSize(Real ps); + + /** Sets the ambient colour reflectance properties for every Pass in every Technique. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setAmbient + */ + void setAmbient(Real red, Real green, Real blue); + + /** Sets the ambient colour reflectance properties for every Pass in every Technique. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setAmbient + */ + void setAmbient(const ColourValue& ambient); + + /** Sets the diffuse colour reflectance properties of every Pass in every Technique. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setDiffuse + */ + void setDiffuse(Real red, Real green, Real blue, Real alpha); + + /** Sets the diffuse colour reflectance properties of every Pass in every Technique. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setDiffuse + */ + void setDiffuse(const ColourValue& diffuse); + + /** Sets the specular colour reflectance properties of every Pass in every Technique. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setSpecular + */ + void setSpecular(Real red, Real green, Real blue, Real alpha); + + /** Sets the specular colour reflectance properties of every Pass in every Technique. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setSpecular + */ + void setSpecular(const ColourValue& specular); + + /** Sets the shininess properties of every Pass in every Technique. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setShininess + */ + void setShininess(Real val); + + /** Sets the amount of self-illumination of every Pass in every Technique. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setSelfIllumination + */ + void setSelfIllumination(Real red, Real green, Real blue); + + /** Sets the amount of self-illumination of every Pass in every Technique. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setSelfIllumination + */ + void setSelfIllumination(const ColourValue& selfIllum); + + /** Sets whether or not each Pass renders with depth-buffer checking on or not. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setDepthCheckEnabled + */ + void setDepthCheckEnabled(bool enabled); + + /** Sets whether or not each Pass renders with depth-buffer writing on or not. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setDepthWriteEnabled + */ + void setDepthWriteEnabled(bool enabled); + + /** Sets the function used to compare depth values when depth checking is on. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setDepthFunction + */ + void setDepthFunction( CompareFunction func ); + + /** Sets whether or not colour buffer writing is enabled for each Pass. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setColourWriteEnabled + */ + void setColourWriteEnabled(bool enabled); + + /** Sets the culling mode for each pass based on the 'vertex winding'. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setCullingMode + */ + void setCullingMode( CullingMode mode ); + + /** Sets the manual culling mode, performed by CPU rather than hardware. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setManualCullingMode + */ + void setManualCullingMode( ManualCullingMode mode ); + + /** Sets whether or not dynamic lighting is enabled for every Pass. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setLightingEnabled + */ + void setLightingEnabled(bool enabled); + + /** Sets the type of light shading required + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setShadingMode + */ + void setShadingMode( ShadeOptions mode ); + + /** Sets the fogging mode applied to each pass. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setFog + */ + void setFog( + bool overrideScene, + FogMode mode = FOG_NONE, + const ColourValue& colour = ColourValue::White, + Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 ); + + /** Sets the depth bias to be used for each Pass. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setDepthBias + */ + void setDepthBias(float constantBias, float slopeScaleBias); + + /** Set texture filtering for every texture unit in every Technique and Pass + @note + This property has been moved to the TextureUnitState class, which is accessible via the + Technique and Pass. For simplicity, this method allows you to set these properties for + every current TeextureUnitState, If you need more precision, retrieve the Technique, + Pass and TextureUnitState instances and set the property there. + @see TextureUnitState::setTextureFiltering + */ + void setTextureFiltering(TextureFilterOptions filterType); + /** Sets the anisotropy level to be used for all textures. + @note + This property has been moved to the TextureUnitState class, which is accessible via the + Technique and Pass. For simplicity, this method allows you to set these properties for + every current TeextureUnitState, If you need more precision, retrieve the Technique, + Pass and TextureUnitState instances and set the property there. + @see TextureUnitState::setTextureAnisotropy + */ + void setTextureAnisotropy(int maxAniso); + + /** Sets the kind of blending every pass has with the existing contents of the scene. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setSceneBlending + */ + void setSceneBlending( const SceneBlendType sbt ); + + /** Allows very fine control of blending every Pass with the existing contents of the scene. + @note + This property has been moved to the Pass class, which is accessible via the + Technique. For simplicity, this method allows you to set these properties for + every current Technique, and for every current Pass within those Techniques. If + you need more precision, retrieve the Technique and Pass instances and set the + property there. + @see Pass::setSceneBlending + */ + void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor); + + + /** Tells the material that it needs recompilation. */ + void _notifyNeedsRecompile(void); + + /** Sets the distance at which level-of-detail (LOD) levels come into effect. + @remarks + You should only use this if you have assigned LOD indexes to the Technique + instances attached to this Material. If you have done so, you should call this + method to determine the distance at which the lowe levels of detail kick in. + The decision about what distance is actually used is a combination of this + and the LOD bias applied to both the current Camera and the current Entity. + @param lodDistances A vector of Reals which indicate the distance at which to + switch to lower details. They are listed in LOD index order, starting at index + 1 (ie the first level down from the highest level 0, which automatically applies + from a distance of 0). + */ + void setLodLevels(const LodDistanceList& lodDistances); + /** Gets an iterator over the list of distances at which each LOD comes into effect. + @remarks + Note that the iterator returned from this method is not totally anagolous to + the one passed in by calling setLodLevels - the list includes a zero + entry at the start (since the highest LOD starts at distance 0), and + the other distances are held as their squared value for efficiency. + */ + LodDistanceIterator getLodDistanceIterator(void) const; + + /** Gets the LOD index to use at the given distance. */ + unsigned short getLodIndex(Real d) const; + /** Gets the LOD index to use at the given squared distance. */ + unsigned short getLodIndexSquaredDepth(Real squaredDepth) const; + + /** @copydoc Resource::touch + */ + void touch(void) + { + if (mCompilationRequired) + compile(); + // call superclass + Resource::touch(); + } + + /** Applies texture names to Texture Unit State with matching texture name aliases. + All techniques, passes, and Texture Unit States within the material are checked. + If matching texture aliases are found then true is returned. + + @param + aliasList is a map container of texture alias, texture name pairs + @param + apply set true to apply the texture aliases else just test to see if texture alias matches are found. + @return + True if matching texture aliases were found in the material. + */ + bool applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply = true) const; + + /** Gets the compilation status of the material. + @return True if the material needs recompilation. + */ + bool getCompilationRequired() const + { + return mCompilationRequired; + } + + + }; + + /** Specialisation of SharedPtr to allow SharedPtr to be assigned to MaterialPtr + @note Has to be a subclass since we need operator=. + We could templatise this instead of repeating per Resource subclass, + except to do so requires a form VC6 does not support i.e. + ResourceSubclassPtr : public SharedPtr + */ + class _OgreExport MaterialPtr : public SharedPtr + { + public: + MaterialPtr() : SharedPtr() {} + explicit MaterialPtr(Material* rep) : SharedPtr(rep) {} + MaterialPtr(const MaterialPtr& r) : SharedPtr(r) {} + MaterialPtr(const ResourcePtr& r) : SharedPtr() + { + // lock & copy other mutex pointer + OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME) + { + OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME) + OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME) + pRep = static_cast(r.getPointer()); + pUseCount = r.useCountPointer(); + if (pUseCount) + { + ++(*pUseCount); + } + } + } + + /// Operator used to convert a ResourcePtr to a MaterialPtr + MaterialPtr& operator=(const ResourcePtr& r) + { + if (pRep == static_cast(r.getPointer())) + return *this; + release(); + // lock & copy other mutex pointer + OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME) + { + OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME) + OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME) + pRep = static_cast(r.getPointer()); + pUseCount = r.useCountPointer(); + if (pUseCount) + { + ++(*pUseCount); + } + } + else + { + // RHS must be a null pointer + assert(r.isNull() && "RHS must be null if it has no mutex!"); + setNull(); + } + return *this; + } + }; + +} //namespace + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreMaterialManager.h b/school/informatik/verkerhssimulation/src/ogre/OgreMaterialManager.h new file mode 100644 index 00000000..b183b679 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreMaterialManager.h @@ -0,0 +1,242 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __MATERIALMANAGER_H__ +#define __MATERIALMANAGER_H__ + +#include "OgrePrerequisites.h" + +#include "OgreSingleton.h" +#include "OgreResourceManager.h" +#include "OgreMaterial.h" +#include "OgreStringVector.h" +#include "OgreMaterialSerializer.h" + +#if OGRE_THREAD_SUPPORT +// boost::thread_specific_ptr has 'new' in header but delete in lib +// so if we use our memory manager it reports leaks incorrectly +# include "OgreNoMemoryMacros.h" +# include +# include "OgreMemoryMacros.h" +#endif + +namespace Ogre { + + + /** Class for managing Material settings for Ogre. + @remarks + Materials control the eventual surface rendering properties of geometry. This class + manages the library of materials, dealing with programmatic registrations and lookups, + as well as loading predefined Material settings from scripts. + @par + When loaded from a script, a Material is in an 'unloaded' state and only stores the settings + required. It does not at that stage load any textures. This is because the material settings may be + loaded 'en masse' from bulk material script files, but only a subset will actually be required. + @par + Because this is a subclass of ResourceManager, any files loaded will be searched for in any path or + archive added to the resource paths/archives. See ResourceManager for details. + @par + For a definition of the material script format, see the Tutorials/MaterialScript.html file. + */ + class _OgreExport MaterialManager : public ResourceManager, public Singleton + { + protected: + + /// Default Texture filtering - minification + FilterOptions mDefaultMinFilter; + /// Default Texture filtering - magnification + FilterOptions mDefaultMagFilter; + /// Default Texture filtering - mipmapping + FilterOptions mDefaultMipFilter; + /// Default Texture anisotropy + unsigned int mDefaultMaxAniso; + /// New material compiler. Hold instance per thread if necessary + OGRE_THREAD_POINTER(MaterialScriptCompiler, mScriptCompiler); + /// Serializer - Hold instance per thread if necessary + OGRE_THREAD_POINTER(MaterialSerializer, mSerializer); + /// Default settings + MaterialPtr mDefaultSettings; + /// Overridden from ResourceManager + Resource* createImpl(const String& name, ResourceHandle handle, + const String& group, bool isManual, ManualResourceLoader* loader, + const NameValuePairList* params); + + /// Scheme name -> index. Never shrinks! Should be pretty static anyway + typedef std::map SchemeMap; + /// List of material schemes + SchemeMap mSchemes; + /// Current material scheme + String mActiveSchemeName; + /// Current material scheme + unsigned short mActiveSchemeIndex; + + public: + /// Default material scheme + static String DEFAULT_SCHEME_NAME; + + /** Default constructor. + */ + MaterialManager(); + + /** Default destructor. + */ + virtual ~MaterialManager(); + + /** Intialises the material manager, which also triggers it to + * parse all available .program and .material scripts. */ + void initialise(void); + + /** @see ScriptLoader::parseScript + */ + void parseScript(DataStreamPtr& stream, const String& groupName); + + + /** Sets the default texture filtering to be used for loaded textures, for when textures are + loaded automatically (e.g. by Material class) or when 'load' is called with the default + parameters by the application. + @note + The default value is TFO_BILINEAR. + */ + virtual void setDefaultTextureFiltering(TextureFilterOptions fo); + /** Sets the default texture filtering to be used for loaded textures, for when textures are + loaded automatically (e.g. by Material class) or when 'load' is called with the default + parameters by the application. + */ + virtual void setDefaultTextureFiltering(FilterType ftype, FilterOptions opts); + /** Sets the default texture filtering to be used for loaded textures, for when textures are + loaded automatically (e.g. by Material class) or when 'load' is called with the default + parameters by the application. + */ + virtual void setDefaultTextureFiltering(FilterOptions minFilter, FilterOptions magFilter, FilterOptions mipFilter); + + /// get the default texture filtering + virtual FilterOptions getDefaultTextureFiltering(FilterType ftype) const; + + /** Sets the default anisotropy level to be used for loaded textures, for when textures are + loaded automatically (e.g. by Material class) or when 'load' is called with the default + parameters by the application. + @note + The default value is 1 (no anisotropy). + */ + void setDefaultAnisotropy(unsigned int maxAniso); + /// get the default maxAnisotropy + unsigned int getDefaultAnisotropy() const; + + /** Returns a pointer to the default Material settings. + @remarks + Ogre comes configured with a set of defaults for newly created + materials. If you wish to have a different set of defaults, + simply call this method and change the returned Material's + settings. All materials created from then on will be configured + with the new defaults you have specified. + @par + The default settings begin as a single Technique with a single, non-programmable Pass: +
    +
  • ambient = ColourValue::White
  • +
  • diffuse = ColourValue::White
  • +
  • specular = ColourValue::Black
  • +
  • emmissive = ColourValue::Black
  • +
  • shininess = 0
  • +
  • No texture unit settings (& hence no textures)
  • +
  • SourceBlendFactor = SBF_ONE
  • +
  • DestBlendFactor = SBF_ZERO (no blend, replace with new + colour)
  • +
  • Depth buffer checking on
  • +
  • Depth buffer writing on
  • +
  • Depth buffer comparison function = CMPF_LESS_EQUAL
  • +
  • Colour buffer writing on for all channels
  • +
  • Culling mode = CULL_CLOCKWISE
  • +
  • Ambient lighting = ColourValue(0.5, 0.5, 0.5) (mid-grey)
  • +
  • Dynamic lighting enabled
  • +
  • Gourad shading mode
  • +
  • Bilinear texture filtering
  • +
+ */ + virtual MaterialPtr getDefaultSettings(void) const { return mDefaultSettings; } + + /** Internal method - returns index for a given material scheme name. + @see Technique::setSchemeName + */ + virtual unsigned short _getSchemeIndex(const String& name); + /** Internal method - returns name for a given material scheme index. + @see Technique::setSchemeName + */ + virtual const String& _getSchemeName(unsigned short index); + /** Internal method - returns the active scheme index. + @see Technique::setSchemeName + */ + virtual unsigned short _getActiveSchemeIndex(void) const; + + /** Returns the name of the active material scheme. + @see Technique::setSchemeName + */ + virtual const String& getActiveScheme(void) const; + + /** Sets the name of the active material scheme. + @see Technique::setSchemeName + */ + virtual void setActiveScheme(const String& schemeName); + + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static MaterialManager& getSingleton(void); + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static MaterialManager* getSingletonPtr(void); + + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreMaterialScriptCompiler.h b/school/informatik/verkerhssimulation/src/ogre/OgreMaterialScriptCompiler.h new file mode 100644 index 00000000..d52a0199 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreMaterialScriptCompiler.h @@ -0,0 +1,330 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __MaterialScriptScompiler_H__ +#define __MaterialScriptScompiler_H__ + +#include "OgreCompiler2Pass.h" +#include "OgreTextureUnitState.h" +#include "OgreMaterial.h" +#include "OgreGpuProgram.h" +#include "OgreStringVector.h" + +namespace Ogre { + + class _OgreExport MaterialScriptCompiler : public Compiler2Pass + { + + public: + MaterialScriptCompiler(void); + ~MaterialScriptCompiler(void); + + /** gets BNF Grammer for Compositor script. + */ + virtual const String& getClientBNFGrammer(void) const; + + /** get the name of the BNF grammer. + */ + virtual const String& getClientGrammerName(void) const; + + /** Compile a material script from a data stream using a specific resource group name. + @param stream Weak reference to a data stream which is the source of the material script + @param groupName The name of the resource group that resources which are + parsed are to become a member of. If this group is loaded or unloaded, + then the resources discovered in this script will be loaded / unloaded + with it. + @param allowOverride if material or gpu program name already exists then use definition + in the material script being parsed to override the existing instance. The default + value is false which causes an exception to be thrown if a duplicate is found. + */ + void parseScript(DataStreamPtr& stream, const String& groupName, const bool allowOverride = false); + + protected: + // Token ID enumeration + enum TokenID { + // Terminal Tokens section + ID_UNKOWN = 0, + // GPU Program + ID_VERTEX_PROGRAM, ID_FRAGMENT_PROGRAM, + + // material + ID_CLONE, + + // technique + + // pass + + ID_VERTEXCOLOUR, + // scene blend + ID_COLOUR_BLEND, ID_DEST_COLOUR, + ID_SRC_COLOUR, ID_ONE_MINUS_DEST_COLOUR, ID_ONE_MINUS_SRC_COLOUR, + ID_DEST_ALPHA, ID_SRC_ALPHA, ID_ONE_MINUS_DEST_ALPHA, ID_ONE_MINUS_SRC_ALPHA, + // Depth + ID_ALWAYS_FAIL, ID_ALWAYS_PASS, + ID_LESS_EQUAL, ID_LESS, ID_EQUAL, ID_NOT_EQUAL, ID_GREATER_EQUAL, ID_GREATER, + // culling + ID_CLOCKWISE, ID_ANTICLOCKWISE, + ID_CULL_BACK, ID_CULL_FRONT, + // shading + ID_FLAT, ID_GOURAUD, ID_PHONG, + // polygon mode + ID_SOLID, ID_WIREFRAME, ID_POINTS, + // fog overide + ID_EXP, ID_EXP2, + // iteration + ID_ONCE, ID_ONCE_PER_LIGHT, ID_PER_LIGHT, ID_PER_N_LIGHTS, ID_DIRECTIONAL, ID_SPOT, + + // texture unit state + // texture + ID_1D, ID_2D, ID_3D, ID_CUBIC, ID_UNLIMITED, ID_ALPHA, + // cubic texture + ID_SEPARATE_UV, ID_COMBINED_UVW, + // address mode + ID_WRAP, ID_CLAMP, ID_MIRROR, ID_BORDER, + // filtering + ID_BILINEAR, ID_TRILINEAR, ID_ANISOTROPIC, + // color op + ID_REPLACE, + ID_SOURCE1, ID_SOURCE2, ID_MODULATE_X2, ID_MODULATE_X4, ID_ADD_SIGNED, + ID_ADD_SMOOTH, ID_SUBTRACT, ID_BLEND_DIFFUSE_COLOUR, ID_BLEND_DIFFUSE_ALPHA, + ID_BLEND_TEXTURE_ALPHA, ID_BLEND_CURRENT_ALPHA, ID_BLEND_MANUAL, ID_DOTPRODUCT, + ID_SRC_CURRENT, ID_SRC_TEXTURE, ID_SRC_DIFFUSE, ID_SRC_SPECULAR, ID_SRC_MANUAL, + + // env map + ID_SPHERICAL, ID_PLANAR, ID_CUBIC_REFLECTION, ID_CUBIC_NORMAL, + // wave transform + ID_SCROLL_X, ID_SCROLL_Y, ID_SCALE_X, ID_SCALE_Y, ID_SINE, ID_TRIANGLE, + ID_SQUARE, ID_SAWTOOTH, ID_INVERSE_SAWTOOTH, ID_ROTATE, + // content type + ID_NAMED, ID_SHADOW, + + // GPU program references + // GPU Parameters + + // general + ID_ON, ID_OFF, ID_TRUE, ID_FALSE, ID_NONE, ID_POINT, ID_LINEAR, ID_ADD, ID_MODULATE, ID_ALPHA_BLEND, + ID_ONE, ID_ZERO, ID_VERTEX, ID_FRAGMENT, + + // where auto generated tokens start so donot remove + ID_AUTOTOKENSTART + }; + + /** Enum to identify material sections. */ + enum MaterialScriptSection + { + MSS_NONE, + MSS_MATERIAL, + MSS_TECHNIQUE, + MSS_PASS, + MSS_TEXTUREUNIT, + MSS_PROGRAM_REF, + MSS_PROGRAM, + MSS_DEFAULT_PARAMETERS, + MSS_TEXTURESOURCE + }; + /** Struct for holding a program definition which is in progress. */ + struct MaterialScriptProgramDefinition + { + String name; + GpuProgramType progType; + String language; + String source; + String syntax; + bool supportsSkeletalAnimation; + bool supportsMorphAnimation; + ushort supportsPoseAnimation; // number of simultaneous poses supported + bool usesVertexTextureFetch; + std::vector > customParameters; + }; + /** Struct for holding the script context while parsing. */ + struct MaterialScriptContext + { + MaterialScriptSection section; + String groupName; + MaterialPtr material; + Technique* technique; + Pass* pass; + TextureUnitState* textureUnit; + GpuProgramPtr program; // used when referencing a program, not when defining it + bool isProgramShadowCaster; // when referencing, are we in context of shadow caster + bool isVertexProgramShadowReceiver; // when referencing, are we in context of shadow caster + bool isFragmentProgramShadowReceiver; // when referencing, are we in context of shadow caster + bool allowOverride; // if true then allow existing materials and gpu programs to be overriden + GpuProgramParametersSharedPtr programParams; + ushort numAnimationParametrics; + MaterialScriptProgramDefinition* programDef; // this is used while defining a program + + int techLev, //Keep track of what tech, pass, and state level we are in + passLev, + stateLev; + // container of token que positions for default params that require pass 2 processing + std::vector pendingDefaultParams; + + AliasTextureNamePairList textureAliases; + }; + + MaterialScriptContext mScriptContext; + + typedef void (MaterialScriptCompiler::* MSC_Action)(void); + typedef std::map TokenActionMap; + typedef TokenActionMap::iterator TokenActionIterator; + /** Map of Token value as key to an Action. An Action converts tokens into + the final format. + All instances use the same Token Action Map. + */ + static TokenActionMap mTokenActionMap; + + /** Execute an Action associated with a token. Gets called when the compiler finishes tokenizing a + section of the source that has been parsed. + **/ + virtual void executeTokenAction(const size_t tokenID); + /** Get the start position of auto generated token IDs. + */ + virtual size_t getAutoTokenIDStart() const {return ID_AUTOTOKENSTART;} + + /** Associate all the lexemes used in a material script with their corresponding tokens and actions. + **/ + virtual void setupTokenDefinitions(void); + void addLexemeTokenAction(const String& lexeme, const size_t token, const MSC_Action action = 0); + /** Associate all the lexemes used in a material script with their corresponding actions and have + token IDs auto-generated. + **/ + void addLexemeAction(const String& lexeme, const MSC_Action action) {addLexemeTokenAction(lexeme, 0, action);} + + void logParseError(const String& error); + + // support methods that convert tokens + ColourValue _parseColourValue(void); + CompareFunction convertCompareFunction(void); + + // Token Actions which get called when tokens are created during parsing. + void parseOpenBrace(void); + void parseCloseBrace(void); + // material section Actions + void parseMaterial(void); + void parseLodDistances(void); + void parseReceiveShadows(void); + void parseTransparencyCastsShadows(void); + void parseSetTextureAlias(void); + // Technique related actions + void parseTechnique(void); + void parseScheme(void); + void parseLodIndex(void); + // Pass related Actions + void parsePass(void); + void parseAmbient(void); + void parseDiffuse(void); + void parseSpecular(void); + void parseEmissive(void); + void parseSceneBlend(void); + SceneBlendFactor convertBlendFactor(void); + void parseDepthCheck(void); + void parseDepthWrite(void); + void parseDepthFunc(void); + void parseDepthBias(void); + void parseAlphaRejection(void); + void parseCullHardware(void); + void parseCullSoftware(void); + void parseLighting(void); + void parseShading(void); + void parsePolygonMode(void); + void parseFogOverride(void); + void parseMaxLights(void); + void parseStartLight(void); + void parseIteration(void); + void parseIterationLightTypes(void); + void parseColourWrite(void); + void parsePointSize(void); + void parsePointSprites(void); + void parsePointSizeMin(void); + void parsePointSizeMax(void); + void parsePointSizeAttenuation(void); + // Texture Unit related Actions + void parseTextureUnit(void); + void parseTextureAlias(void); + void parseTexture(void); + void parseAnimTexture(void); + void parseCubicTexture(void); + void parseTexCoord(void); + TextureUnitState::TextureAddressingMode convTexAddressMode(void); + void parseTexAddressMode(void); + void parseTexBorderColour(void); + void parseFiltering(void); + FilterOptions convertFiltering(); + void parseMaxAnisotropy(void); + void parseMipMapBias(void); + void parseColourOp(void); + void parseColourOpEx(void); + LayerBlendOperationEx convertBlendOpEx(void); + LayerBlendSource convertBlendSource(void); + void parseColourOpMultipassFallback(void); + void parseAlphaOpEx(void); + void parseEnvMap(void); + void parseScroll(void); + void parseScrollAnim(void); + void parseRotate(void); + void parseRotateAnim(void); + void parseScale(void); + void parseWaveXform(void); + void parseTransform(void); + void parseTextureCustomParameter(void); + void parseBindingType(void); + void parseContentType(void); + + // GPU Program + void parseGPUProgram(void); + void parseProgramSource(void); + void parseProgramSyntax(void); + void parseProgramCustomParameter(void); + void parseDefaultParams(void); + void parseProgramSkeletalAnimation(void); + void parseProgramMorphAnimation(void); + void parseProgramPoseAnimation(void); + void parseProgramVertexTextureFetch(void); + void parseVertexProgramRef(void); + void parseFragmentProgramRef(void); + void parseShadowCasterVertexProgramRef(void); + void parseShadowReceiverVertexProgramRef(void); + void parseShadowReceiverFragmentProgramRef(void); + void parseParamIndexed(void); + void parseParamIndexedAuto(void); + void parseParamNamed(void); + void parseParamNamedAuto(void); + void processManualProgramParam(bool isNamed, const String commandName, + size_t index = 0, const String& paramName = StringUtil::BLANK); + void processAutoProgramParam(bool isNamed, const String commandName, + size_t index, const String& paramName = StringUtil::BLANK); + + + void finishProgramDefinition(void); + + }; +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreMaterialSerializer.h b/school/informatik/verkerhssimulation/src/ogre/OgreMaterialSerializer.h new file mode 100644 index 00000000..9fa963aa --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreMaterialSerializer.h @@ -0,0 +1,278 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __MaterialSerializer_H__ +#define __MaterialSerializer_H__ + +#include "OgrePrerequisites.h" +#include "OgreMaterial.h" +#include "OgreBlendMode.h" +#include "OgreTextureUnitState.h" +#include "OgreGpuProgram.h" +#include "OgreStringVector.h" + +namespace Ogre { + + /** Enum to identify material sections. */ + enum MaterialScriptSection + { + MSS_NONE, + MSS_MATERIAL, + MSS_TECHNIQUE, + MSS_PASS, + MSS_TEXTUREUNIT, + MSS_PROGRAM_REF, + MSS_PROGRAM, + MSS_DEFAULT_PARAMETERS, + MSS_TEXTURESOURCE + }; + /** Struct for holding a program definition which is in progress. */ + struct MaterialScriptProgramDefinition + { + String name; + GpuProgramType progType; + String language; + String source; + String syntax; + bool supportsSkeletalAnimation; + bool supportsMorphAnimation; + ushort supportsPoseAnimation; // number of simultaneous poses supported + bool usesVertexTextureFetch; + std::vector > customParameters; + }; + /** Struct for holding the script context while parsing. */ + struct MaterialScriptContext + { + MaterialScriptSection section; + String groupName; + MaterialPtr material; + Technique* technique; + Pass* pass; + TextureUnitState* textureUnit; + GpuProgramPtr program; // used when referencing a program, not when defining it + bool isProgramShadowCaster; // when referencing, are we in context of shadow caster + bool isVertexProgramShadowReceiver; // when referencing, are we in context of shadow caster + bool isFragmentProgramShadowReceiver; // when referencing, are we in context of shadow caster + GpuProgramParametersSharedPtr programParams; + ushort numAnimationParametrics; + MaterialScriptProgramDefinition* programDef; // this is used while defining a program + + int techLev, //Keep track of what tech, pass, and state level we are in + passLev, + stateLev; + StringVector defaultParamLines; + + // Error reporting state + size_t lineNo; + String filename; + AliasTextureNamePairList textureAliases; + }; + /// Function def for material attribute parser; return value determines if the next line should be { + typedef bool (*ATTRIBUTE_PARSER)(String& params, MaterialScriptContext& context); + + /** Class for serializing Materials to / from a .material script.*/ + class _OgreExport MaterialSerializer + { + protected: + /// Keyword-mapped attribute parsers. + typedef std::map AttribParserList; + + MaterialScriptContext mScriptContext; + + /** internal method for parsing a material + @returns true if it expects the next line to be a { + */ + bool parseScriptLine(String& line); + /** internal method for finding & invoking an attribute parser. */ + bool invokeParser(String& line, AttribParserList& parsers); + /** Internal method for saving a program definition which has been + built up. + */ + void finishProgramDefinition(void); + /// Parsers for the root of the material script + AttribParserList mRootAttribParsers; + /// Parsers for the material section of a script + AttribParserList mMaterialAttribParsers; + /// Parsers for the technique section of a script + AttribParserList mTechniqueAttribParsers; + /// Parsers for the pass section of a script + AttribParserList mPassAttribParsers; + /// Parsers for the texture unit section of a script + AttribParserList mTextureUnitAttribParsers; + /// Parsers for the program reference section of a script + AttribParserList mProgramRefAttribParsers; + /// Parsers for the program definition section of a script + AttribParserList mProgramAttribParsers; + /// Parsers for the program definition section of a script + AttribParserList mProgramDefaultParamAttribParsers; + + void writeMaterial(const MaterialPtr& pMat); + void writeTechnique(const Technique* pTech); + void writePass(const Pass* pPass); + void writeVertexProgramRef(const Pass* pPass); + void writeShadowCasterVertexProgramRef(const Pass* pPass); + void writeShadowReceiverVertexProgramRef(const Pass* pPass); + void writeShadowReceiverFragmentProgramRef(const Pass* pPass); + void writeFragmentProgramRef(const Pass* pPass); + void writeGpuProgramRef(const String& attrib, const GpuProgramPtr& program, const GpuProgramParametersSharedPtr& params); + void writeGpuPrograms(void); + void writeGPUProgramParameters(const GpuProgramParametersSharedPtr& params, GpuProgramParameters* defaultParams, + const int level = 4, const bool useMainBuffer = true); + void writeNamedGpuProgramParameters(const GpuProgramParametersSharedPtr& params, GpuProgramParameters* defaultParams, + const int level = 4, const bool useMainBuffer = true); + void writeLowLevelGpuProgramParameters(const GpuProgramParametersSharedPtr& params, GpuProgramParameters* defaultParams, + const int level = 4, const bool useMainBuffer = true); + void writeGpuProgramParameter( + const String& commandName, const String& identifier, + const GpuProgramParameters::AutoConstantEntry* autoEntry, + const GpuProgramParameters::AutoConstantEntry* defaultAutoEntry, + bool isFloat, size_t physicalIndex, size_t physicalSize, + const GpuProgramParametersSharedPtr& params, GpuProgramParameters* defaultParams, + const int level, const bool useMainBuffer); + void writeTextureUnit(const TextureUnitState *pTex); + void writeSceneBlendFactor(const SceneBlendFactor sbf_src, const SceneBlendFactor sbf_dest); + void writeSceneBlendFactor(const SceneBlendFactor sbf); + void writeCompareFunction(const CompareFunction cf); + void writeColourValue(const ColourValue &colour, bool writeAlpha = false); + void writeLayerBlendOperationEx(const LayerBlendOperationEx op); + void writeLayerBlendSource(const LayerBlendSource lbs); + + typedef std::multimap EffectMap; + + void writeRotationEffect(const TextureUnitState::TextureEffect& effect, const TextureUnitState *pTex); + void writeTransformEffect(const TextureUnitState::TextureEffect& effect, const TextureUnitState *pTex); + void writeScrollEffect(const TextureUnitState::TextureEffect& effect, const TextureUnitState *pTex); + void writeEnvironmentMapEffect(const TextureUnitState::TextureEffect& effect, const TextureUnitState *pTex); + + String convertFiltering(FilterOptions fo); + public: + /** default constructor*/ + MaterialSerializer(); + /** default destructor*/ + virtual ~MaterialSerializer() {}; + + /** Queue an in-memory Material to the internal buffer for export. + @param pMat Material pointer + @param clearQueued If true, any materials already queued will be removed + @param exportDefaults If true, attributes which are defaulted will be + included in the script exported, otherwise they will be omitted + */ + void queueForExport(const MaterialPtr& pMat, bool clearQueued = false, + bool exportDefaults = false); + /** Exports queued material(s) to a named material script file. + @param filename the file name of the material script to be exported + @param includeProgDef If true, vertex program and fragment program + definitions will be written at the top of the material script + @param programFilename the file name of the vertex / fragment program + script to be exported. This is only used if there are program definitions + to be exported and includeProgDef is false + when calling queueForExport. + */ + void exportQueued(const String& filename, const bool includeProgDef = false, const String& programFilename = ""); + /** Exports a single in-memory Material to the named material script file. + @param exportDefaults if true then exports all values including defaults + @param includeProgDef if true includes Gpu shader program definitions in the + export material script otherwise if false then program definitions will + be exported to a seperate file with name programFilename if + programFilename is not empty + @param programFilename the file name of the vertex / fragment program + script to be exported. This is only used if includeProgDef is false. + */ + void exportMaterial(const MaterialPtr& pMat, const String& filename, bool exportDefaults = false, + const bool includeProgDef = false, const String& programFilename = ""); + /** Returns a string representing the parsed material(s) */ + const String &getQueuedAsString() const; + /** Clears the internal buffer */ + void clearQueue(); + + /** Parses a Material script file passed as a stream. + */ + void parseScript(DataStreamPtr& stream, const String& groupName); + + + + private: + String mBuffer; + String mGpuProgramBuffer; + typedef std::set GpuProgramDefinitionContainer; + typedef GpuProgramDefinitionContainer::iterator GpuProgramDefIterator; + GpuProgramDefinitionContainer mGpuProgramDefinitionContainer; + bool mDefaults; + + void beginSection(unsigned short level, const bool useMainBuffer = true) + { + String& buffer = (useMainBuffer ? mBuffer : mGpuProgramBuffer); + buffer += "\n"; + for (unsigned short i = 0; i < level; ++i) + { + buffer += "\t"; + } + buffer += "{"; + } + void endSection(unsigned short level, const bool useMainBuffer = true) + { + String& buffer = (useMainBuffer ? mBuffer : mGpuProgramBuffer); + buffer += "\n"; + for (unsigned short i = 0; i < level; ++i) + { + buffer += "\t"; + } + buffer += "}"; + } + + void writeAttribute(unsigned short level, const String& att, const bool useMainBuffer = true) + { + String& buffer = (useMainBuffer ? mBuffer : mGpuProgramBuffer); + buffer += "\n"; + for (unsigned short i = 0; i < level; ++i) + { + buffer += "\t"; + } + buffer += att; + } + + void writeValue(const String& val, const bool useMainBuffer = true) + { + String& buffer = (useMainBuffer ? mBuffer : mGpuProgramBuffer); + buffer += (" " + val); + } + + void writeComment(unsigned short level, const String& comment, const bool useMainBuffer = true) + { + String& buffer = (useMainBuffer ? mBuffer : mGpuProgramBuffer); + buffer += "\n"; + for (unsigned short i = 0; i < level; ++i) + { + buffer += "\t"; + } + buffer += "// " + comment; + } + + }; +} +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreMath.h b/school/informatik/verkerhssimulation/src/ogre/OgreMath.h new file mode 100644 index 00000000..ff9ee34f --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreMath.h @@ -0,0 +1,606 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Math_H__ +#define __Math_H__ + +#include "OgrePrerequisites.h" + +namespace Ogre +{ + /** Wrapper class which indicates a given angle value is in Radians. + @remarks + Radian values are interchangeable with Degree values, and conversions + will be done automatically between them. + */ + class Radian + { + Real mRad; + + public: + explicit Radian ( Real r=0 ) : mRad(r) {} + Radian ( const Degree& d ); + Radian& operator = ( const Real& f ) { mRad = f; return *this; } + Radian& operator = ( const Radian& r ) { mRad = r.mRad; return *this; } + Radian& operator = ( const Degree& d ); + + Real valueDegrees() const; // see bottom of this file + Real valueRadians() const { return mRad; } + Real valueAngleUnits() const; + + const Radian& operator + () const { return *this; } + Radian operator + ( const Radian& r ) const { return Radian ( mRad + r.mRad ); } + Radian operator + ( const Degree& d ) const; + Radian& operator += ( const Radian& r ) { mRad += r.mRad; return *this; } + Radian& operator += ( const Degree& d ); + Radian operator - () const { return Radian(-mRad); } + Radian operator - ( const Radian& r ) const { return Radian ( mRad - r.mRad ); } + Radian operator - ( const Degree& d ) const; + Radian& operator -= ( const Radian& r ) { mRad -= r.mRad; return *this; } + Radian& operator -= ( const Degree& d ); + Radian operator * ( Real f ) const { return Radian ( mRad * f ); } + Radian operator * ( const Radian& f ) const { return Radian ( mRad * f.mRad ); } + Radian& operator *= ( Real f ) { mRad *= f; return *this; } + Radian operator / ( Real f ) const { return Radian ( mRad / f ); } + Radian& operator /= ( Real f ) { mRad /= f; return *this; } + + bool operator < ( const Radian& r ) const { return mRad < r.mRad; } + bool operator <= ( const Radian& r ) const { return mRad <= r.mRad; } + bool operator == ( const Radian& r ) const { return mRad == r.mRad; } + bool operator != ( const Radian& r ) const { return mRad != r.mRad; } + bool operator >= ( const Radian& r ) const { return mRad >= r.mRad; } + bool operator > ( const Radian& r ) const { return mRad > r.mRad; } + }; + + /** Wrapper class which indicates a given angle value is in Degrees. + @remarks + Degree values are interchangeable with Radian values, and conversions + will be done automatically between them. + */ + class Degree + { + Real mDeg; // if you get an error here - make sure to define/typedef 'Real' first + + public: + explicit Degree ( Real d=0 ) : mDeg(d) {} + Degree ( const Radian& r ) : mDeg(r.valueDegrees()) {} + Degree& operator = ( const Real& f ) { mDeg = f; return *this; } + Degree& operator = ( const Degree& d ) { mDeg = d.mDeg; return *this; } + Degree& operator = ( const Radian& r ) { mDeg = r.valueDegrees(); return *this; } + + Real valueDegrees() const { return mDeg; } + Real valueRadians() const; // see bottom of this file + Real valueAngleUnits() const; + + const Degree& operator + () const { return *this; } + Degree operator + ( const Degree& d ) const { return Degree ( mDeg + d.mDeg ); } + Degree operator + ( const Radian& r ) const { return Degree ( mDeg + r.valueDegrees() ); } + Degree& operator += ( const Degree& d ) { mDeg += d.mDeg; return *this; } + Degree& operator += ( const Radian& r ) { mDeg += r.valueDegrees(); return *this; } + Degree operator - () const { return Degree(-mDeg); } + Degree operator - ( const Degree& d ) const { return Degree ( mDeg - d.mDeg ); } + Degree operator - ( const Radian& r ) const { return Degree ( mDeg - r.valueDegrees() ); } + Degree& operator -= ( const Degree& d ) { mDeg -= d.mDeg; return *this; } + Degree& operator -= ( const Radian& r ) { mDeg -= r.valueDegrees(); return *this; } + Degree operator * ( Real f ) const { return Degree ( mDeg * f ); } + Degree operator * ( const Degree& f ) const { return Degree ( mDeg * f.mDeg ); } + Degree& operator *= ( Real f ) { mDeg *= f; return *this; } + Degree operator / ( Real f ) const { return Degree ( mDeg / f ); } + Degree& operator /= ( Real f ) { mDeg /= f; return *this; } + + bool operator < ( const Degree& d ) const { return mDeg < d.mDeg; } + bool operator <= ( const Degree& d ) const { return mDeg <= d.mDeg; } + bool operator == ( const Degree& d ) const { return mDeg == d.mDeg; } + bool operator != ( const Degree& d ) const { return mDeg != d.mDeg; } + bool operator >= ( const Degree& d ) const { return mDeg >= d.mDeg; } + bool operator > ( const Degree& d ) const { return mDeg > d.mDeg; } + }; + + /** Wrapper class which identifies a value as the currently default angle + type, as defined by Math::setAngleUnit. + @remarks + Angle values will be automatically converted between radians and degrees, + as appropriate. + */ + class Angle + { + Real mAngle; + public: + explicit Angle ( Real angle ) : mAngle(angle) {} + operator Radian() const; + operator Degree() const; + }; + + // these functions could not be defined within the class definition of class + // Radian because they required class Degree to be defined + inline Radian::Radian ( const Degree& d ) : mRad(d.valueRadians()) { + } + inline Radian& Radian::operator = ( const Degree& d ) { + mRad = d.valueRadians(); return *this; + } + inline Radian Radian::operator + ( const Degree& d ) const { + return Radian ( mRad + d.valueRadians() ); + } + inline Radian& Radian::operator += ( const Degree& d ) { + mRad += d.valueRadians(); + return *this; + } + inline Radian Radian::operator - ( const Degree& d ) const { + return Radian ( mRad - d.valueRadians() ); + } + inline Radian& Radian::operator -= ( const Degree& d ) { + mRad -= d.valueRadians(); + return *this; + } + + /** Class to provide access to common mathematical functions. + @remarks + Most of the maths functions are aliased versions of the C runtime + library functions. They are aliased here to provide future + optimisation opportunities, either from faster RTLs or custom + math approximations. + @note +
This is based on MgcMath.h from + Wild Magic. + */ + class _OgreExport Math + { + public: + /** The angular units used by the API. This functionality is now deprecated in favor + of discreet angular unit types ( see Degree and Radian above ). The only place + this functionality is actually still used is when parsing files. Search for + usage of the Angle class for those instances + */ + enum AngleUnit + { + AU_DEGREE, + AU_RADIAN + }; + + protected: + // angle units used by the api + static AngleUnit msAngleUnit; + + /// Size of the trig tables as determined by constructor. + static int mTrigTableSize; + + /// Radian -> index factor value ( mTrigTableSize / 2 * PI ) + static Real mTrigTableFactor; + static Real* mSinTable; + static Real* mTanTable; + + /** Private function to build trig tables. + */ + void buildTrigTables(); + + static Real SinTable (Real fValue); + static Real TanTable (Real fValue); + public: + /** Default constructor. + @param + trigTableSize Optional parameter to set the size of the + tables used to implement Sin, Cos, Tan + */ + Math(unsigned int trigTableSize = 4096); + + /** Default destructor. + */ + ~Math(); + + static inline int IAbs (int iValue) { return ( iValue >= 0 ? iValue : -iValue ); } + static inline int ICeil (float fValue) { return int(ceil(fValue)); } + static inline int IFloor (float fValue) { return int(floor(fValue)); } + static int ISign (int iValue); + + static inline Real Abs (Real fValue) { return Real(fabs(fValue)); } + static inline Degree Abs (const Degree& dValue) { return Degree(fabs(dValue.valueDegrees())); } + static inline Radian Abs (const Radian& rValue) { return Radian(fabs(rValue.valueRadians())); } + static Radian ACos (Real fValue); + static Radian ASin (Real fValue); + static inline Radian ATan (Real fValue) { return Radian(atan(fValue)); } + static inline Radian ATan2 (Real fY, Real fX) { return Radian(atan2(fY,fX)); } + static inline Real Ceil (Real fValue) { return Real(ceil(fValue)); } + + /** Cosine function. + @param + fValue Angle in radians + @param + useTables If true, uses lookup tables rather than + calculation - faster but less accurate. + */ + static inline Real Cos (const Radian& fValue, bool useTables = false) { + return (!useTables) ? Real(cos(fValue.valueRadians())) : SinTable(fValue.valueRadians() + HALF_PI); + } + /** Cosine function. + @param + fValue Angle in radians + @param + useTables If true, uses lookup tables rather than + calculation - faster but less accurate. + */ + static inline Real Cos (Real fValue, bool useTables = false) { + return (!useTables) ? Real(cos(fValue)) : SinTable(fValue + HALF_PI); + } + + static inline Real Exp (Real fValue) { return Real(exp(fValue)); } + + static inline Real Floor (Real fValue) { return Real(floor(fValue)); } + + static inline Real Log (Real fValue) { return Real(log(fValue)); } + + static inline Real Pow (Real fBase, Real fExponent) { return Real(pow(fBase,fExponent)); } + + static Real Sign (Real fValue); + static inline Radian Sign ( const Radian& rValue ) + { + return Radian(Sign(rValue.valueRadians())); + } + static inline Degree Sign ( const Degree& dValue ) + { + return Degree(Sign(dValue.valueDegrees())); + } + + /** Sine function. + @param + fValue Angle in radians + @param + useTables If true, uses lookup tables rather than + calculation - faster but less accurate. + */ + static inline Real Sin (const Radian& fValue, bool useTables = false) { + return (!useTables) ? Real(sin(fValue.valueRadians())) : SinTable(fValue.valueRadians()); + } + /** Sine function. + @param + fValue Angle in radians + @param + useTables If true, uses lookup tables rather than + calculation - faster but less accurate. + */ + static inline Real Sin (Real fValue, bool useTables = false) { + return (!useTables) ? Real(sin(fValue)) : SinTable(fValue); + } + + static inline Real Sqr (Real fValue) { return fValue*fValue; } + + static inline Real Sqrt (Real fValue) { return Real(sqrt(fValue)); } + + static inline Radian Sqrt (const Radian& fValue) { return Radian(sqrt(fValue.valueRadians())); } + + static inline Degree Sqrt (const Degree& fValue) { return Degree(sqrt(fValue.valueDegrees())); } + + /** Inverse square root i.e. 1 / Sqrt(x), good for vector + normalisation. + */ + static Real InvSqrt(Real fValue); + + static Real UnitRandom (); // in [0,1] + + static Real RangeRandom (Real fLow, Real fHigh); // in [fLow,fHigh] + + static Real SymmetricRandom (); // in [-1,1] + + /** Tangent function. + @param + fValue Angle in radians + @param + useTables If true, uses lookup tables rather than + calculation - faster but less accurate. + */ + static inline Real Tan (const Radian& fValue, bool useTables = false) { + return (!useTables) ? Real(tan(fValue.valueRadians())) : TanTable(fValue.valueRadians()); + } + /** Tangent function. + @param + fValue Angle in radians + @param + useTables If true, uses lookup tables rather than + calculation - faster but less accurate. + */ + static inline Real Tan (Real fValue, bool useTables = false) { + return (!useTables) ? Real(tan(fValue)) : TanTable(fValue); + } + + static inline Real DegreesToRadians(Real degrees) { return degrees * fDeg2Rad; } + static inline Real RadiansToDegrees(Real radians) { return radians * fRad2Deg; } + + /** These functions used to set the assumed angle units (radians or degrees) + expected when using the Angle type. + @par + You can set this directly after creating a new Root, and also before/after resource creation, + depending on whether you want the change to affect resource files. + */ + static void setAngleUnit(AngleUnit unit); + /** Get the unit being used for angles. */ + static AngleUnit getAngleUnit(void); + + /** Convert from the current AngleUnit to radians. */ + static Real AngleUnitsToRadians(Real units); + /** Convert from radians to the current AngleUnit . */ + static Real RadiansToAngleUnits(Real radians); + /** Convert from the current AngleUnit to degrees. */ + static Real AngleUnitsToDegrees(Real units); + /** Convert from degrees to the current AngleUnit. */ + static Real DegreesToAngleUnits(Real degrees); + + /** Checks whether a given point is inside a triangle, in a + 2-dimensional (Cartesian) space. + @remarks + The vertices of the triangle must be given in either + trigonometrical (anticlockwise) or inverse trigonometrical + (clockwise) order. + @param + p The point. + @param + a The triangle's first vertex. + @param + b The triangle's second vertex. + @param + c The triangle's third vertex. + @returns + If the point resides in the triangle, true is + returned. + @par + If the point is outside the triangle, false is + returned. + */ + static bool pointInTri2D(const Vector2& p, const Vector2& a, + const Vector2& b, const Vector2& c); + + /** Checks whether a given 3D point is inside a triangle. + @remarks + The vertices of the triangle must be given in either + trigonometrical (anticlockwise) or inverse trigonometrical + (clockwise) order, and the point must be guaranteed to be in the + same plane as the triangle + @param + p The point. + @param + a The triangle's first vertex. + @param + b The triangle's second vertex. + @param + c The triangle's third vertex. + @param + normal The triangle plane's normal (passed in rather than calculated + on demand since the callermay already have it) + @returns + If the point resides in the triangle, true is + returned. + @par + If the point is outside the triangle, false is + returned. + */ + static bool pointInTri3D(const Vector3& p, const Vector3& a, + const Vector3& b, const Vector3& c, const Vector3& normal); + /** Ray / plane intersection, returns boolean result and distance. */ + static std::pair intersects(const Ray& ray, const Plane& plane); + + /** Ray / sphere intersection, returns boolean result and distance. */ + static std::pair intersects(const Ray& ray, const Sphere& sphere, + bool discardInside = true); + + /** Ray / box intersection, returns boolean result and distance. */ + static std::pair intersects(const Ray& ray, const AxisAlignedBox& box); + + /** Ray / box intersection, returns boolean result and two intersection distance. + @param + ray The ray. + @param + box The box. + @param + d1 A real pointer to retrieve the near intersection distance + from the ray origin, maybe null which means don't care + about the near intersection distance. + @param + d2 A real pointer to retrieve the far intersection distance + from the ray origin, maybe null which means don't care + about the far intersection distance. + @returns + If the ray is intersects the box, true is returned, and + the near intersection distance is return by d1, the + far intersection distance is return by d2. Guarantee + 0 <= d1 <= d2. + @par + If the ray isn't intersects the box, false is returned, and + d1 and d2 is unmodified. + */ + static bool intersects(const Ray& ray, const AxisAlignedBox& box, + Real* d1, Real* d2); + + /** Ray / triangle intersection, returns boolean result and distance. + @param + ray The ray. + @param + a The triangle's first vertex. + @param + b The triangle's second vertex. + @param + c The triangle's third vertex. + @param + normal The triangle plane's normal (passed in rather than calculated + on demand since the callermay already have it), doesn't need + normalised since we don't care. + @param + positiveSide Intersect with "positive side" of the triangle + @param + negativeSide Intersect with "negative side" of the triangle + @returns + If the ray is intersects the triangle, a pair of true and the + distance between intersection point and ray origin returned. + @par + If the ray isn't intersects the triangle, a pair of false and + 0 returned. + */ + static std::pair intersects(const Ray& ray, const Vector3& a, + const Vector3& b, const Vector3& c, const Vector3& normal, + bool positiveSide = true, bool negativeSide = true); + + /** Ray / triangle intersection, returns boolean result and distance. + @param + ray The ray. + @param + a The triangle's first vertex. + @param + b The triangle's second vertex. + @param + c The triangle's third vertex. + @param + positiveSide Intersect with "positive side" of the triangle + @param + negativeSide Intersect with "negative side" of the triangle + @returns + If the ray is intersects the triangle, a pair of true and the + distance between intersection point and ray origin returned. + @par + If the ray isn't intersects the triangle, a pair of false and + 0 returned. + */ + static std::pair intersects(const Ray& ray, const Vector3& a, + const Vector3& b, const Vector3& c, + bool positiveSide = true, bool negativeSide = true); + + /** Sphere / box intersection test. */ + static bool intersects(const Sphere& sphere, const AxisAlignedBox& box); + + /** Plane / box intersection test. */ + static bool intersects(const Plane& plane, const AxisAlignedBox& box); + + /** Ray / convex plane list intersection test. + @param ray The ray to test with + @param plaeList List of planes which form a convex volume + @param normalIsOutside Does the normal point outside the volume + */ + static std::pair intersects( + const Ray& ray, const std::vector& planeList, + bool normalIsOutside); + /** Ray / convex plane list intersection test. + @param ray The ray to test with + @param plaeList List of planes which form a convex volume + @param normalIsOutside Does the normal point outside the volume + */ + static std::pair intersects( + const Ray& ray, const std::list& planeList, + bool normalIsOutside); + + /** Sphere / plane intersection test. + @remarks NB just do a plane.getDistance(sphere.getCenter()) for more detail! + */ + static bool intersects(const Sphere& sphere, const Plane& plane); + + /** Compare 2 reals, using tolerance for inaccuracies. + */ + static bool RealEqual(Real a, Real b, + Real tolerance = std::numeric_limits::epsilon()); + + /** Calculates the tangent space vector for a given set of positions / texture coords. */ + static Vector3 calculateTangentSpaceVector( + const Vector3& position1, const Vector3& position2, const Vector3& position3, + Real u1, Real v1, Real u2, Real v2, Real u3, Real v3); + + /** Build a reflection matrix for the passed in plane. */ + static Matrix4 buildReflectionMatrix(const Plane& p); + /** Calculate a face normal, including the w component which is the offset from the origin. */ + static Vector4 calculateFaceNormal(const Vector3& v1, const Vector3& v2, const Vector3& v3); + /** Calculate a face normal, no w-information. */ + static Vector3 calculateBasicFaceNormal(const Vector3& v1, const Vector3& v2, const Vector3& v3); + /** Calculate a face normal without normalize, including the w component which is the offset from the origin. */ + static Vector4 calculateFaceNormalWithoutNormalize(const Vector3& v1, const Vector3& v2, const Vector3& v3); + /** Calculate a face normal without normalize, no w-information. */ + static Vector3 calculateBasicFaceNormalWithoutNormalize(const Vector3& v1, const Vector3& v2, const Vector3& v3); + + /** Generates a value based on the gaussian (normal) distribution function + with the given offset and scale parameters. + */ + static Real gaussianDistribution(Real x, Real offset = 0.0f, Real scale = 1.0f); + + static const Real POS_INFINITY; + static const Real NEG_INFINITY; + static const Real PI; + static const Real TWO_PI; + static const Real HALF_PI; + static const Real fDeg2Rad; + static const Real fRad2Deg; + + }; + + // these functions must be defined down here, because they rely on the + // angle unit conversion functions in class Math: + + inline Real Radian::valueDegrees() const + { + return Math::RadiansToDegrees ( mRad ); + } + + inline Real Radian::valueAngleUnits() const + { + return Math::RadiansToAngleUnits ( mRad ); + } + + inline Real Degree::valueRadians() const + { + return Math::DegreesToRadians ( mDeg ); + } + + inline Real Degree::valueAngleUnits() const + { + return Math::DegreesToAngleUnits ( mDeg ); + } + + inline Angle::operator Radian() const + { + return Radian(Math::AngleUnitsToRadians(mAngle)); + } + + inline Angle::operator Degree() const + { + return Degree(Math::AngleUnitsToDegrees(mAngle)); + } + + inline Radian operator * ( Real a, const Radian& b ) + { + return Radian ( a * b.valueRadians() ); + } + + inline Radian operator / ( Real a, const Radian& b ) + { + return Radian ( a / b.valueRadians() ); + } + + inline Degree operator * ( Real a, const Degree& b ) + { + return Degree ( a * b.valueDegrees() ); + } + + inline Degree operator / ( Real a, const Degree& b ) + { + return Degree ( a / b.valueDegrees() ); + } + +} +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreMatrix3.h b/school/informatik/verkerhssimulation/src/ogre/OgreMatrix3.h new file mode 100644 index 00000000..5786a644 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreMatrix3.h @@ -0,0 +1,306 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Matrix3_H__ +#define __Matrix3_H__ + +#include "OgrePrerequisites.h" + +#include "OgreVector3.h" + +// NB All code adapted from Wild Magic 0.2 Matrix math (free source code) +// http://www.geometrictools.com/ + +// NOTE. The (x,y,z) coordinate system is assumed to be right-handed. +// Coordinate axis rotation matrices are of the form +// RX = 1 0 0 +// 0 cos(t) -sin(t) +// 0 sin(t) cos(t) +// where t > 0 indicates a counterclockwise rotation in the yz-plane +// RY = cos(t) 0 sin(t) +// 0 1 0 +// -sin(t) 0 cos(t) +// where t > 0 indicates a counterclockwise rotation in the zx-plane +// RZ = cos(t) -sin(t) 0 +// sin(t) cos(t) 0 +// 0 0 1 +// where t > 0 indicates a counterclockwise rotation in the xy-plane. + +namespace Ogre +{ + /** A 3x3 matrix which can represent rotations around axes. + @note + All the code is adapted from the Wild Magic 0.2 Matrix + library (http://www.geometrictools.com/). + @par + The coordinate system is assumed to be right-handed. + */ + class _OgreExport Matrix3 + { + public: + /** Default constructor. + @note + It does NOT initialize the matrix for efficiency. + */ + inline Matrix3 () {}; + inline explicit Matrix3 (const Real arr[3][3]) + { + memcpy(m,arr,9*sizeof(Real)); + } + inline Matrix3 (const Matrix3& rkMatrix) + { + memcpy(m,rkMatrix.m,9*sizeof(Real)); + } + Matrix3 (Real fEntry00, Real fEntry01, Real fEntry02, + Real fEntry10, Real fEntry11, Real fEntry12, + Real fEntry20, Real fEntry21, Real fEntry22) + { + m[0][0] = fEntry00; + m[0][1] = fEntry01; + m[0][2] = fEntry02; + m[1][0] = fEntry10; + m[1][1] = fEntry11; + m[1][2] = fEntry12; + m[2][0] = fEntry20; + m[2][1] = fEntry21; + m[2][2] = fEntry22; + } + + // member access, allows use of construct mat[r][c] + inline Real* operator[] (size_t iRow) const + { + return (Real*)m[iRow]; + } + /*inline operator Real* () + { + return (Real*)m[0]; + }*/ + Vector3 GetColumn (size_t iCol) const; + void SetColumn(size_t iCol, const Vector3& vec); + void FromAxes(const Vector3& xAxis, const Vector3& yAxis, const Vector3& zAxis); + + // assignment and comparison + inline Matrix3& operator= (const Matrix3& rkMatrix) + { + memcpy(m,rkMatrix.m,9*sizeof(Real)); + return *this; + } + bool operator== (const Matrix3& rkMatrix) const; + inline bool operator!= (const Matrix3& rkMatrix) const + { + return !operator==(rkMatrix); + } + + // arithmetic operations + Matrix3 operator+ (const Matrix3& rkMatrix) const; + Matrix3 operator- (const Matrix3& rkMatrix) const; + Matrix3 operator* (const Matrix3& rkMatrix) const; + Matrix3 operator- () const; + + // matrix * vector [3x3 * 3x1 = 3x1] + Vector3 operator* (const Vector3& rkVector) const; + + // vector * matrix [1x3 * 3x3 = 1x3] + _OgreExport friend Vector3 operator* (const Vector3& rkVector, + const Matrix3& rkMatrix); + + // matrix * scalar + Matrix3 operator* (Real fScalar) const; + + // scalar * matrix + _OgreExport friend Matrix3 operator* (Real fScalar, const Matrix3& rkMatrix); + + // utilities + Matrix3 Transpose () const; + bool Inverse (Matrix3& rkInverse, Real fTolerance = 1e-06) const; + Matrix3 Inverse (Real fTolerance = 1e-06) const; + Real Determinant () const; + + // singular value decomposition + void SingularValueDecomposition (Matrix3& rkL, Vector3& rkS, + Matrix3& rkR) const; + void SingularValueComposition (const Matrix3& rkL, + const Vector3& rkS, const Matrix3& rkR); + + // Gram-Schmidt orthonormalization (applied to columns of rotation matrix) + void Orthonormalize (); + + // orthogonal Q, diagonal D, upper triangular U stored as (u01,u02,u12) + void QDUDecomposition (Matrix3& rkQ, Vector3& rkD, + Vector3& rkU) const; + + Real SpectralNorm () const; + + // matrix must be orthonormal + void ToAxisAngle (Vector3& rkAxis, Radian& rfAngle) const; + inline void ToAxisAngle (Vector3& rkAxis, Degree& rfAngle) const { + Radian r; + ToAxisAngle ( rkAxis, r ); + rfAngle = r; + } + void FromAxisAngle (const Vector3& rkAxis, const Radian& fRadians); +#ifndef OGRE_FORCE_ANGLE_TYPES + inline void ToAxisAngle (Vector3& rkAxis, Real& rfRadians) const { + Radian r; + ToAxisAngle ( rkAxis, r ); + rfRadians = r.valueRadians(); + } + inline void FromAxisAngle (const Vector3& rkAxis, Real fRadians) { + FromAxisAngle ( rkAxis, Radian(fRadians) ); + } +#endif//OGRE_FORCE_ANGLE_TYPES + + // The matrix must be orthonormal. The decomposition is yaw*pitch*roll + // where yaw is rotation about the Up vector, pitch is rotation about the + // Right axis, and roll is rotation about the Direction axis. + bool ToEulerAnglesXYZ (Radian& rfYAngle, Radian& rfPAngle, + Radian& rfRAngle) const; + bool ToEulerAnglesXZY (Radian& rfYAngle, Radian& rfPAngle, + Radian& rfRAngle) const; + bool ToEulerAnglesYXZ (Radian& rfYAngle, Radian& rfPAngle, + Radian& rfRAngle) const; + bool ToEulerAnglesYZX (Radian& rfYAngle, Radian& rfPAngle, + Radian& rfRAngle) const; + bool ToEulerAnglesZXY (Radian& rfYAngle, Radian& rfPAngle, + Radian& rfRAngle) const; + bool ToEulerAnglesZYX (Radian& rfYAngle, Radian& rfPAngle, + Radian& rfRAngle) const; + void FromEulerAnglesXYZ (const Radian& fYAngle, const Radian& fPAngle, const Radian& fRAngle); + void FromEulerAnglesXZY (const Radian& fYAngle, const Radian& fPAngle, const Radian& fRAngle); + void FromEulerAnglesYXZ (const Radian& fYAngle, const Radian& fPAngle, const Radian& fRAngle); + void FromEulerAnglesYZX (const Radian& fYAngle, const Radian& fPAngle, const Radian& fRAngle); + void FromEulerAnglesZXY (const Radian& fYAngle, const Radian& fPAngle, const Radian& fRAngle); + void FromEulerAnglesZYX (const Radian& fYAngle, const Radian& fPAngle, const Radian& fRAngle); +#ifndef OGRE_FORCE_ANGLE_TYPES + inline bool ToEulerAnglesXYZ (float& rfYAngle, float& rfPAngle, + float& rfRAngle) const { + Radian y, p, r; + bool b = ToEulerAnglesXYZ(y,p,r); + rfYAngle = y.valueRadians(); + rfPAngle = p.valueRadians(); + rfRAngle = r.valueRadians(); + return b; + } + inline bool ToEulerAnglesXZY (float& rfYAngle, float& rfPAngle, + float& rfRAngle) const { + Radian y, p, r; + bool b = ToEulerAnglesXZY(y,p,r); + rfYAngle = y.valueRadians(); + rfPAngle = p.valueRadians(); + rfRAngle = r.valueRadians(); + return b; + } + inline bool ToEulerAnglesYXZ (float& rfYAngle, float& rfPAngle, + float& rfRAngle) const { + Radian y, p, r; + bool b = ToEulerAnglesYXZ(y,p,r); + rfYAngle = y.valueRadians(); + rfPAngle = p.valueRadians(); + rfRAngle = r.valueRadians(); + return b; + } + inline bool ToEulerAnglesYZX (float& rfYAngle, float& rfPAngle, + float& rfRAngle) const { + Radian y, p, r; + bool b = ToEulerAnglesYZX(y,p,r); + rfYAngle = y.valueRadians(); + rfPAngle = p.valueRadians(); + rfRAngle = r.valueRadians(); + return b; + } + inline bool ToEulerAnglesZXY (float& rfYAngle, float& rfPAngle, + float& rfRAngle) const { + Radian y, p, r; + bool b = ToEulerAnglesZXY(y,p,r); + rfYAngle = y.valueRadians(); + rfPAngle = p.valueRadians(); + rfRAngle = r.valueRadians(); + return b; + } + inline bool ToEulerAnglesZYX (float& rfYAngle, float& rfPAngle, + float& rfRAngle) const { + Radian y, p, r; + bool b = ToEulerAnglesZYX(y,p,r); + rfYAngle = y.valueRadians(); + rfPAngle = p.valueRadians(); + rfRAngle = r.valueRadians(); + return b; + } + inline void FromEulerAnglesXYZ (float fYAngle, float fPAngle, float fRAngle) { + FromEulerAnglesXYZ ( Radian(fYAngle), Radian(fPAngle), Radian(fRAngle) ); + } + inline void FromEulerAnglesXZY (float fYAngle, float fPAngle, float fRAngle) { + FromEulerAnglesXZY ( Radian(fYAngle), Radian(fPAngle), Radian(fRAngle) ); + } + inline void FromEulerAnglesYXZ (float fYAngle, float fPAngle, float fRAngle) { + FromEulerAnglesYXZ ( Radian(fYAngle), Radian(fPAngle), Radian(fRAngle) ); + } + inline void FromEulerAnglesYZX (float fYAngle, float fPAngle, float fRAngle) { + FromEulerAnglesYZX ( Radian(fYAngle), Radian(fPAngle), Radian(fRAngle) ); + } + inline void FromEulerAnglesZXY (float fYAngle, float fPAngle, float fRAngle) { + FromEulerAnglesZXY ( Radian(fYAngle), Radian(fPAngle), Radian(fRAngle) ); + } + inline void FromEulerAnglesZYX (float fYAngle, float fPAngle, float fRAngle) { + FromEulerAnglesZYX ( Radian(fYAngle), Radian(fPAngle), Radian(fRAngle) ); + } +#endif//OGRE_FORCE_ANGLE_TYPES + // eigensolver, matrix must be symmetric + void EigenSolveSymmetric (Real afEigenvalue[3], + Vector3 akEigenvector[3]) const; + + static void TensorProduct (const Vector3& rkU, const Vector3& rkV, + Matrix3& rkProduct); + + static const Real EPSILON; + static const Matrix3 ZERO; + static const Matrix3 IDENTITY; + + protected: + // support for eigensolver + void Tridiagonal (Real afDiag[3], Real afSubDiag[3]); + bool QLAlgorithm (Real afDiag[3], Real afSubDiag[3]); + + // support for singular value decomposition + static const Real ms_fSvdEpsilon; + static const unsigned int ms_iSvdMaxIterations; + static void Bidiagonalize (Matrix3& kA, Matrix3& kL, + Matrix3& kR); + static void GolubKahanStep (Matrix3& kA, Matrix3& kL, + Matrix3& kR); + + // support for spectral norm + static Real MaxCubicRoot (Real afCoeff[3]); + + Real m[3][3]; + + // for faster access + friend class Matrix4; + }; +} +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreMatrix4.h b/school/informatik/verkerhssimulation/src/ogre/OgreMatrix4.h new file mode 100644 index 00000000..3063bdac --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreMatrix4.h @@ -0,0 +1,603 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Matrix4__ +#define __Matrix4__ + +// Precompiler options +#include "OgrePrerequisites.h" + +#include "OgreVector3.h" +#include "OgreMatrix3.h" +#include "OgreVector4.h" +#include "OgrePlane.h" +namespace Ogre +{ + /** Class encapsulating a standard 4x4 homogenous matrix. + @remarks + OGRE uses column vectors when applying matrix multiplications, + This means a vector is represented as a single column, 4-row + matrix. This has the effect that the tranformations implemented + by the matrices happens right-to-left e.g. if vector V is to be + transformed by M1 then M2 then M3, the calculation would be + M3 * M2 * M1 * V. The order that matrices are concatenated is + vital since matrix multiplication is not cummatative, i.e. you + can get a different result if you concatenate in the wrong order. + @par + The use of column vectors and right-to-left ordering is the + standard in most mathematical texts, and id the same as used in + OpenGL. It is, however, the opposite of Direct3D, which has + inexplicably chosen to differ from the accepted standard and uses + row vectors and left-to-right matrix multiplication. + @par + OGRE deals with the differences between D3D and OpenGL etc. + internally when operating through different render systems. OGRE + users only need to conform to standard maths conventions, i.e. + right-to-left matrix multiplication, (OGRE transposes matrices it + passes to D3D to compensate). + @par + The generic form M * V which shows the layout of the matrix + entries is shown below: +
+                [ m[0][0]  m[0][1]  m[0][2]  m[0][3] ]   {x}
+                | m[1][0]  m[1][1]  m[1][2]  m[1][3] | * {y}
+                | m[2][0]  m[2][1]  m[2][2]  m[2][3] |   {z}
+                [ m[3][0]  m[3][1]  m[3][2]  m[3][3] ]   {1}
+            
+ */ + class _OgreExport Matrix4 + { + protected: + /// The matrix entries, indexed by [row][col]. + union { + Real m[4][4]; + Real _m[16]; + }; + public: + /** Default constructor. + @note + It does NOT initialize the matrix for efficiency. + */ + inline Matrix4() + { + } + + inline Matrix4( + Real m00, Real m01, Real m02, Real m03, + Real m10, Real m11, Real m12, Real m13, + Real m20, Real m21, Real m22, Real m23, + Real m30, Real m31, Real m32, Real m33 ) + { + m[0][0] = m00; + m[0][1] = m01; + m[0][2] = m02; + m[0][3] = m03; + m[1][0] = m10; + m[1][1] = m11; + m[1][2] = m12; + m[1][3] = m13; + m[2][0] = m20; + m[2][1] = m21; + m[2][2] = m22; + m[2][3] = m23; + m[3][0] = m30; + m[3][1] = m31; + m[3][2] = m32; + m[3][3] = m33; + } + + /** Creates a standard 4x4 transformation matrix with a zero translation part from a rotation/scaling 3x3 matrix. + */ + + inline Matrix4(const Matrix3& m3x3) + { + operator=(IDENTITY); + operator=(m3x3); + } + + /** Creates a standard 4x4 transformation matrix with a zero translation part from a rotation/scaling Quaternion. + */ + + inline Matrix4(const Quaternion& rot) + { + Matrix3 m3x3; + rot.ToRotationMatrix(m3x3); + operator=(IDENTITY); + operator=(m3x3); + } + + + inline Real* operator [] ( size_t iRow ) + { + assert( iRow < 4 ); + return m[iRow]; + } + + inline const Real *const operator [] ( size_t iRow ) const + { + assert( iRow < 4 ); + return m[iRow]; + } + + inline Matrix4 concatenate(const Matrix4 &m2) const + { + Matrix4 r; + r.m[0][0] = m[0][0] * m2.m[0][0] + m[0][1] * m2.m[1][0] + m[0][2] * m2.m[2][0] + m[0][3] * m2.m[3][0]; + r.m[0][1] = m[0][0] * m2.m[0][1] + m[0][1] * m2.m[1][1] + m[0][2] * m2.m[2][1] + m[0][3] * m2.m[3][1]; + r.m[0][2] = m[0][0] * m2.m[0][2] + m[0][1] * m2.m[1][2] + m[0][2] * m2.m[2][2] + m[0][3] * m2.m[3][2]; + r.m[0][3] = m[0][0] * m2.m[0][3] + m[0][1] * m2.m[1][3] + m[0][2] * m2.m[2][3] + m[0][3] * m2.m[3][3]; + + r.m[1][0] = m[1][0] * m2.m[0][0] + m[1][1] * m2.m[1][0] + m[1][2] * m2.m[2][0] + m[1][3] * m2.m[3][0]; + r.m[1][1] = m[1][0] * m2.m[0][1] + m[1][1] * m2.m[1][1] + m[1][2] * m2.m[2][1] + m[1][3] * m2.m[3][1]; + r.m[1][2] = m[1][0] * m2.m[0][2] + m[1][1] * m2.m[1][2] + m[1][2] * m2.m[2][2] + m[1][3] * m2.m[3][2]; + r.m[1][3] = m[1][0] * m2.m[0][3] + m[1][1] * m2.m[1][3] + m[1][2] * m2.m[2][3] + m[1][3] * m2.m[3][3]; + + r.m[2][0] = m[2][0] * m2.m[0][0] + m[2][1] * m2.m[1][0] + m[2][2] * m2.m[2][0] + m[2][3] * m2.m[3][0]; + r.m[2][1] = m[2][0] * m2.m[0][1] + m[2][1] * m2.m[1][1] + m[2][2] * m2.m[2][1] + m[2][3] * m2.m[3][1]; + r.m[2][2] = m[2][0] * m2.m[0][2] + m[2][1] * m2.m[1][2] + m[2][2] * m2.m[2][2] + m[2][3] * m2.m[3][2]; + r.m[2][3] = m[2][0] * m2.m[0][3] + m[2][1] * m2.m[1][3] + m[2][2] * m2.m[2][3] + m[2][3] * m2.m[3][3]; + + r.m[3][0] = m[3][0] * m2.m[0][0] + m[3][1] * m2.m[1][0] + m[3][2] * m2.m[2][0] + m[3][3] * m2.m[3][0]; + r.m[3][1] = m[3][0] * m2.m[0][1] + m[3][1] * m2.m[1][1] + m[3][2] * m2.m[2][1] + m[3][3] * m2.m[3][1]; + r.m[3][2] = m[3][0] * m2.m[0][2] + m[3][1] * m2.m[1][2] + m[3][2] * m2.m[2][2] + m[3][3] * m2.m[3][2]; + r.m[3][3] = m[3][0] * m2.m[0][3] + m[3][1] * m2.m[1][3] + m[3][2] * m2.m[2][3] + m[3][3] * m2.m[3][3]; + + return r; + } + + /** Matrix concatenation using '*'. + */ + inline Matrix4 operator * ( const Matrix4 &m2 ) const + { + return concatenate( m2 ); + } + + /** Vector transformation using '*'. + @remarks + Transforms the given 3-D vector by the matrix, projecting the + result back into w = 1. + @note + This means that the initial w is considered to be 1.0, + and then all the tree elements of the resulting 3-D vector are + divided by the resulting w. + */ + inline Vector3 operator * ( const Vector3 &v ) const + { + Vector3 r; + + Real fInvW = 1.0 / ( m[3][0] * v.x + m[3][1] * v.y + m[3][2] * v.z + m[3][3] ); + + r.x = ( m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3] ) * fInvW; + r.y = ( m[1][0] * v.x + m[1][1] * v.y + m[1][2] * v.z + m[1][3] ) * fInvW; + r.z = ( m[2][0] * v.x + m[2][1] * v.y + m[2][2] * v.z + m[2][3] ) * fInvW; + + return r; + } + inline Vector4 operator * (const Vector4& v) const + { + return Vector4( + m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3] * v.w, + m[1][0] * v.x + m[1][1] * v.y + m[1][2] * v.z + m[1][3] * v.w, + m[2][0] * v.x + m[2][1] * v.y + m[2][2] * v.z + m[2][3] * v.w, + m[3][0] * v.x + m[3][1] * v.y + m[3][2] * v.z + m[3][3] * v.w + ); + } + inline Plane operator * (const Plane& p) const + { + Plane ret; + Matrix4 invTrans = inverse().transpose(); + Vector4 v4( p.normal.x, p.normal.y, p.normal.z, p.d ); + v4 = invTrans * v4; + ret.normal.x = v4.x; + ret.normal.y = v4.y; + ret.normal.z = v4.z; + ret.d = v4.w / ret.normal.normalise(); + + return ret; + } + + + /** Matrix addition. + */ + inline Matrix4 operator + ( const Matrix4 &m2 ) const + { + Matrix4 r; + + r.m[0][0] = m[0][0] + m2.m[0][0]; + r.m[0][1] = m[0][1] + m2.m[0][1]; + r.m[0][2] = m[0][2] + m2.m[0][2]; + r.m[0][3] = m[0][3] + m2.m[0][3]; + + r.m[1][0] = m[1][0] + m2.m[1][0]; + r.m[1][1] = m[1][1] + m2.m[1][1]; + r.m[1][2] = m[1][2] + m2.m[1][2]; + r.m[1][3] = m[1][3] + m2.m[1][3]; + + r.m[2][0] = m[2][0] + m2.m[2][0]; + r.m[2][1] = m[2][1] + m2.m[2][1]; + r.m[2][2] = m[2][2] + m2.m[2][2]; + r.m[2][3] = m[2][3] + m2.m[2][3]; + + r.m[3][0] = m[3][0] + m2.m[3][0]; + r.m[3][1] = m[3][1] + m2.m[3][1]; + r.m[3][2] = m[3][2] + m2.m[3][2]; + r.m[3][3] = m[3][3] + m2.m[3][3]; + + return r; + } + + /** Matrix subtraction. + */ + inline Matrix4 operator - ( const Matrix4 &m2 ) const + { + Matrix4 r; + r.m[0][0] = m[0][0] - m2.m[0][0]; + r.m[0][1] = m[0][1] - m2.m[0][1]; + r.m[0][2] = m[0][2] - m2.m[0][2]; + r.m[0][3] = m[0][3] - m2.m[0][3]; + + r.m[1][0] = m[1][0] - m2.m[1][0]; + r.m[1][1] = m[1][1] - m2.m[1][1]; + r.m[1][2] = m[1][2] - m2.m[1][2]; + r.m[1][3] = m[1][3] - m2.m[1][3]; + + r.m[2][0] = m[2][0] - m2.m[2][0]; + r.m[2][1] = m[2][1] - m2.m[2][1]; + r.m[2][2] = m[2][2] - m2.m[2][2]; + r.m[2][3] = m[2][3] - m2.m[2][3]; + + r.m[3][0] = m[3][0] - m2.m[3][0]; + r.m[3][1] = m[3][1] - m2.m[3][1]; + r.m[3][2] = m[3][2] - m2.m[3][2]; + r.m[3][3] = m[3][3] - m2.m[3][3]; + + return r; + } + + /** Tests 2 matrices for equality. + */ + inline bool operator == ( const Matrix4& m2 ) const + { + if( + m[0][0] != m2.m[0][0] || m[0][1] != m2.m[0][1] || m[0][2] != m2.m[0][2] || m[0][3] != m2.m[0][3] || + m[1][0] != m2.m[1][0] || m[1][1] != m2.m[1][1] || m[1][2] != m2.m[1][2] || m[1][3] != m2.m[1][3] || + m[2][0] != m2.m[2][0] || m[2][1] != m2.m[2][1] || m[2][2] != m2.m[2][2] || m[2][3] != m2.m[2][3] || + m[3][0] != m2.m[3][0] || m[3][1] != m2.m[3][1] || m[3][2] != m2.m[3][2] || m[3][3] != m2.m[3][3] ) + return false; + return true; + } + + /** Tests 2 matrices for inequality. + */ + inline bool operator != ( const Matrix4& m2 ) const + { + if( + m[0][0] != m2.m[0][0] || m[0][1] != m2.m[0][1] || m[0][2] != m2.m[0][2] || m[0][3] != m2.m[0][3] || + m[1][0] != m2.m[1][0] || m[1][1] != m2.m[1][1] || m[1][2] != m2.m[1][2] || m[1][3] != m2.m[1][3] || + m[2][0] != m2.m[2][0] || m[2][1] != m2.m[2][1] || m[2][2] != m2.m[2][2] || m[2][3] != m2.m[2][3] || + m[3][0] != m2.m[3][0] || m[3][1] != m2.m[3][1] || m[3][2] != m2.m[3][2] || m[3][3] != m2.m[3][3] ) + return true; + return false; + } + + /** Assignment from 3x3 matrix. + */ + inline void operator = ( const Matrix3& mat3 ) + { + m[0][0] = mat3.m[0][0]; m[0][1] = mat3.m[0][1]; m[0][2] = mat3.m[0][2]; + m[1][0] = mat3.m[1][0]; m[1][1] = mat3.m[1][1]; m[1][2] = mat3.m[1][2]; + m[2][0] = mat3.m[2][0]; m[2][1] = mat3.m[2][1]; m[2][2] = mat3.m[2][2]; + } + + inline Matrix4 transpose(void) const + { + return Matrix4(m[0][0], m[1][0], m[2][0], m[3][0], + m[0][1], m[1][1], m[2][1], m[3][1], + m[0][2], m[1][2], m[2][2], m[3][2], + m[0][3], m[1][3], m[2][3], m[3][3]); + } + + /* + ----------------------------------------------------------------------- + Translation Transformation + ----------------------------------------------------------------------- + */ + /** Sets the translation transformation part of the matrix. + */ + inline void setTrans( const Vector3& v ) + { + m[0][3] = v.x; + m[1][3] = v.y; + m[2][3] = v.z; + } + + /** Extracts the translation transformation part of the matrix. + */ + inline Vector3 getTrans() const + { + return Vector3(m[0][3], m[1][3], m[2][3]); + } + + + /** Builds a translation matrix + */ + inline void makeTrans( const Vector3& v ) + { + m[0][0] = 1.0; m[0][1] = 0.0; m[0][2] = 0.0; m[0][3] = v.x; + m[1][0] = 0.0; m[1][1] = 1.0; m[1][2] = 0.0; m[1][3] = v.y; + m[2][0] = 0.0; m[2][1] = 0.0; m[2][2] = 1.0; m[2][3] = v.z; + m[3][0] = 0.0; m[3][1] = 0.0; m[3][2] = 0.0; m[3][3] = 1.0; + } + + inline void makeTrans( Real tx, Real ty, Real tz ) + { + m[0][0] = 1.0; m[0][1] = 0.0; m[0][2] = 0.0; m[0][3] = tx; + m[1][0] = 0.0; m[1][1] = 1.0; m[1][2] = 0.0; m[1][3] = ty; + m[2][0] = 0.0; m[2][1] = 0.0; m[2][2] = 1.0; m[2][3] = tz; + m[3][0] = 0.0; m[3][1] = 0.0; m[3][2] = 0.0; m[3][3] = 1.0; + } + + /** Gets a translation matrix. + */ + inline static Matrix4 getTrans( const Vector3& v ) + { + Matrix4 r; + + r.m[0][0] = 1.0; r.m[0][1] = 0.0; r.m[0][2] = 0.0; r.m[0][3] = v.x; + r.m[1][0] = 0.0; r.m[1][1] = 1.0; r.m[1][2] = 0.0; r.m[1][3] = v.y; + r.m[2][0] = 0.0; r.m[2][1] = 0.0; r.m[2][2] = 1.0; r.m[2][3] = v.z; + r.m[3][0] = 0.0; r.m[3][1] = 0.0; r.m[3][2] = 0.0; r.m[3][3] = 1.0; + + return r; + } + + /** Gets a translation matrix - variation for not using a vector. + */ + inline static Matrix4 getTrans( Real t_x, Real t_y, Real t_z ) + { + Matrix4 r; + + r.m[0][0] = 1.0; r.m[0][1] = 0.0; r.m[0][2] = 0.0; r.m[0][3] = t_x; + r.m[1][0] = 0.0; r.m[1][1] = 1.0; r.m[1][2] = 0.0; r.m[1][3] = t_y; + r.m[2][0] = 0.0; r.m[2][1] = 0.0; r.m[2][2] = 1.0; r.m[2][3] = t_z; + r.m[3][0] = 0.0; r.m[3][1] = 0.0; r.m[3][2] = 0.0; r.m[3][3] = 1.0; + + return r; + } + + /* + ----------------------------------------------------------------------- + Scale Transformation + ----------------------------------------------------------------------- + */ + /** Sets the scale part of the matrix. + */ + inline void setScale( const Vector3& v ) + { + m[0][0] = v.x; + m[1][1] = v.y; + m[2][2] = v.z; + } + + /** Gets a scale matrix. + */ + inline static Matrix4 getScale( const Vector3& v ) + { + Matrix4 r; + r.m[0][0] = v.x; r.m[0][1] = 0.0; r.m[0][2] = 0.0; r.m[0][3] = 0.0; + r.m[1][0] = 0.0; r.m[1][1] = v.y; r.m[1][2] = 0.0; r.m[1][3] = 0.0; + r.m[2][0] = 0.0; r.m[2][1] = 0.0; r.m[2][2] = v.z; r.m[2][3] = 0.0; + r.m[3][0] = 0.0; r.m[3][1] = 0.0; r.m[3][2] = 0.0; r.m[3][3] = 1.0; + + return r; + } + + /** Gets a scale matrix - variation for not using a vector. + */ + inline static Matrix4 getScale( Real s_x, Real s_y, Real s_z ) + { + Matrix4 r; + r.m[0][0] = s_x; r.m[0][1] = 0.0; r.m[0][2] = 0.0; r.m[0][3] = 0.0; + r.m[1][0] = 0.0; r.m[1][1] = s_y; r.m[1][2] = 0.0; r.m[1][3] = 0.0; + r.m[2][0] = 0.0; r.m[2][1] = 0.0; r.m[2][2] = s_z; r.m[2][3] = 0.0; + r.m[3][0] = 0.0; r.m[3][1] = 0.0; r.m[3][2] = 0.0; r.m[3][3] = 1.0; + + return r; + } + + /** Extracts the rotation / scaling part of the Matrix as a 3x3 matrix. + @param m3x3 Destination Matrix3 + */ + inline void extract3x3Matrix(Matrix3& m3x3) const + { + m3x3.m[0][0] = m[0][0]; + m3x3.m[0][1] = m[0][1]; + m3x3.m[0][2] = m[0][2]; + m3x3.m[1][0] = m[1][0]; + m3x3.m[1][1] = m[1][1]; + m3x3.m[1][2] = m[1][2]; + m3x3.m[2][0] = m[2][0]; + m3x3.m[2][1] = m[2][1]; + m3x3.m[2][2] = m[2][2]; + + } + + /** Extracts the rotation / scaling part as a quaternion from the Matrix. + */ + inline Quaternion extractQuaternion() const + { + Matrix3 m3x3; + extract3x3Matrix(m3x3); + return Quaternion(m3x3); + } + + static const Matrix4 ZERO; + static const Matrix4 IDENTITY; + /** Useful little matrix which takes 2D clipspace {-1, 1} to {0,1} + and inverts the Y. */ + static const Matrix4 CLIPSPACE2DTOIMAGESPACE; + + inline Matrix4 operator*(Real scalar) const + { + return Matrix4( + scalar*m[0][0], scalar*m[0][1], scalar*m[0][2], scalar*m[0][3], + scalar*m[1][0], scalar*m[1][1], scalar*m[1][2], scalar*m[1][3], + scalar*m[2][0], scalar*m[2][1], scalar*m[2][2], scalar*m[2][3], + scalar*m[3][0], scalar*m[3][1], scalar*m[3][2], scalar*m[3][3]); + } + + /** Function for writing to a stream. + */ + inline _OgreExport friend std::ostream& operator << + ( std::ostream& o, const Matrix4& m ) + { + o << "Matrix4("; + for (size_t i = 0; i < 4; ++i) + { + o << " row" << (unsigned)i << "{"; + for(size_t j = 0; j < 4; ++j) + { + o << m[i][j] << " "; + } + o << "}"; + } + o << ")"; + return o; + } + + Matrix4 adjoint() const; + Real determinant() const; + Matrix4 inverse() const; + + /** Building a Matrix4 from orientation / scale / position. + @remarks + Transform is performed in the order scale, rotate, translation, i.e. translation is independent + of orientation axes, scale does not affect size of translation, rotation and scaling are always + centered on the origin. + */ + void makeTransform(const Vector3& position, const Vector3& scale, const Quaternion& orientation); + + /** Building an inverse Matrix4 from orientation / scale / position. + @remarks + As makeTransform except it build the inverse given the same data as makeTransform, so + performing -translation, -rotate, 1/scale in that order. + */ + void makeInverseTransform(const Vector3& position, const Vector3& scale, const Quaternion& orientation); + + /** Check whether or not the matrix is affine matrix. + @remarks + An affine matrix is a 4x4 matrix with row 3 equal to (0, 0, 0, 1), + e.g. no projective coefficients. + */ + inline bool isAffine(void) const + { + return m[3][0] == 0 && m[3][1] == 0 && m[3][2] == 0 && m[3][3] == 1; + } + + /** Returns the inverse of the affine matrix. + @note + The matrix must be an affine matrix. @see Matrix4::isAffine. + */ + Matrix4 inverseAffine(void) const; + + /** Concatenate two affine matrix. + @note + The matrices must be affine matrix. @see Matrix4::isAffine. + */ + inline Matrix4 concatenateAffine(const Matrix4 &m2) const + { + assert(isAffine() && m2.isAffine()); + + return Matrix4( + m[0][0] * m2.m[0][0] + m[0][1] * m2.m[1][0] + m[0][2] * m2.m[2][0], + m[0][0] * m2.m[0][1] + m[0][1] * m2.m[1][1] + m[0][2] * m2.m[2][1], + m[0][0] * m2.m[0][2] + m[0][1] * m2.m[1][2] + m[0][2] * m2.m[2][2], + m[0][0] * m2.m[0][3] + m[0][1] * m2.m[1][3] + m[0][2] * m2.m[2][3] + m[0][3], + + m[1][0] * m2.m[0][0] + m[1][1] * m2.m[1][0] + m[1][2] * m2.m[2][0], + m[1][0] * m2.m[0][1] + m[1][1] * m2.m[1][1] + m[1][2] * m2.m[2][1], + m[1][0] * m2.m[0][2] + m[1][1] * m2.m[1][2] + m[1][2] * m2.m[2][2], + m[1][0] * m2.m[0][3] + m[1][1] * m2.m[1][3] + m[1][2] * m2.m[2][3] + m[1][3], + + m[2][0] * m2.m[0][0] + m[2][1] * m2.m[1][0] + m[2][2] * m2.m[2][0], + m[2][0] * m2.m[0][1] + m[2][1] * m2.m[1][1] + m[2][2] * m2.m[2][1], + m[2][0] * m2.m[0][2] + m[2][1] * m2.m[1][2] + m[2][2] * m2.m[2][2], + m[2][0] * m2.m[0][3] + m[2][1] * m2.m[1][3] + m[2][2] * m2.m[2][3] + m[2][3], + + 0, 0, 0, 1); + } + + /** 3-D Vector transformation specially for affine matrix. + @remarks + Transforms the given 3-D vector by the matrix, projecting the + result back into w = 1. + @note + The matrix must be an affine matrix. @see Matrix4::isAffine. + */ + inline Vector3 transformAffine(const Vector3& v) const + { + assert(isAffine()); + + return Vector3( + m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3], + m[1][0] * v.x + m[1][1] * v.y + m[1][2] * v.z + m[1][3], + m[2][0] * v.x + m[2][1] * v.y + m[2][2] * v.z + m[2][3]); + } + + /** 4-D Vector transformation specially for affine matrix. + @note + The matrix must be an affine matrix. @see Matrix4::isAffine. + */ + inline Vector4 transformAffine(const Vector4& v) const + { + assert(isAffine()); + + return Vector4( + m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3] * v.w, + m[1][0] * v.x + m[1][1] * v.y + m[1][2] * v.z + m[1][3] * v.w, + m[2][0] * v.x + m[2][1] * v.y + m[2][2] * v.z + m[2][3] * v.w, + v.w); + } + }; + + /* Removed from Vector4 and made a non-member here because otherwise + OgreMatrix4.h and OgreVector4.h have to try to include and inline each + other, which frankly doesn't work ;) + */ + inline Vector4 operator * (const Vector4& v, const Matrix4& mat) + { + return Vector4( + v.x*mat[0][0] + v.y*mat[1][0] + v.z*mat[2][0] + v.w*mat[3][0], + v.x*mat[0][1] + v.y*mat[1][1] + v.z*mat[2][1] + v.w*mat[3][1], + v.x*mat[0][2] + v.y*mat[1][2] + v.z*mat[2][2] + v.w*mat[3][2], + v.x*mat[0][3] + v.y*mat[1][3] + v.z*mat[2][3] + v.w*mat[3][3] + ); + } + +} +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreMemoryMacros.h b/school/informatik/verkerhssimulation/src/ogre/OgreMemoryMacros.h new file mode 100644 index 00000000..b4908276 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreMemoryMacros.h @@ -0,0 +1,69 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +//---- ORIGINAL COPYRIGHT FOLLOWS ------------------------------------------- +// --------------------------------------------------------------------------------------------------------------------------------- +// Copyright 2000, Paul Nettle. All rights reserved. +// +// You are free to use this source code in any commercial or non-commercial product. +// +// mmgr.cpp - Memory manager & tracking software +// +// The most recent version of this software can be found at: ftp://ftp.GraphicsPapers.com/pub/ProgrammingTools/MemoryManagers/ +// +// [NOTE: Best when viewed with 8-character tabs] +// +// --------------------------------------------------------------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// How does this work? +// Remember that before the compiler starts to process a source file, it runs +// a neat tool called a preprocessor on it. What this preprocessor does in +// this case is replace all the instances of *alloc/free with the expanded +// macros - this way we cleverly replace all the calls to the standard C +// memory (de)allocation functions. The same is done for new/delete +// +// Of course, we have the drawback that we can't name a member function of +// a class *alloc or free and we can't overload the new/delete operators without +// first undefining these macros - ah, a C++ preprocessor with RE replacement, +// that would be a dream come true :) +// +#ifndef OGRE_MEMORY_MACROS +#define OGRE_MEMORY_MACROS + +#if OGRE_DEBUG_MEMORY_MANAGER && OGRE_DEBUG_MODE +# define new (::Ogre::MemoryManager::instance().setOwner(__FILE__,__LINE__,__FUNCTION__),false) ? NULL : new +# define delete (::Ogre::MemoryManager::instance().setOwner(__FILE__,__LINE__,__FUNCTION__),false) ? ::Ogre::MemoryManager::instance().setOwner("",0,"") : delete +# define malloc(sz) ::Ogre::MemoryManager::instance().allocMem(__FILE__,__LINE__,__FUNCTION__, ::Ogre::m_alloc_malloc, sz, gProcessID) +# define calloc(num,sz) ::Ogre::MemoryManager::instance().allocMem(__FILE__,__LINE__,__FUNCTION__, ::Ogre::m_alloc_calloc, num*sz, gProcessID) +# define realloc(ptr,sz) ::Ogre::MemoryManager::instance().rllocMem(__FILE__,__LINE__,__FUNCTION__, ::Ogre::m_alloc_realloc,sz, ptr, gProcessID) +# define free(ptr) ::Ogre::MemoryManager::instance().dllocMem(__FILE__,__LINE__,__FUNCTION__, ::Ogre::m_alloc_free, ptr, gProcessID) +#endif // OGRE_DEBUG_MEMORY_MANAGER + +#endif // OGRE_MEMORY_MACROS +//----------------------------------------------------------------------------- diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreMemoryManager.h b/school/informatik/verkerhssimulation/src/ogre/OgreMemoryManager.h new file mode 100644 index 00000000..03931b7d --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreMemoryManager.h @@ -0,0 +1,422 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +//---- ORIGINAL COPYRIGHT FOLLOWS ------------------------------------------- +// --------------------------------------------------------------------------------------------------------------------------------- +// Copyright 2000, Paul Nettle. All rights reserved. +// +// You are free to use this source code in any commercial or non-commercial product. +// +// mmgr.cpp - Memory manager & tracking software +// +// The most recent version of this software can be found at: ftp://ftp.GraphicsPapers.com/pub/ProgrammingTools/MemoryManagers/ +// +// [NOTE: Best when viewed with 8-character tabs] +// +// --------------------------------------------------------------------------------------------------------------------------------- +#ifndef __MemoryManager_H__ +#define __MemoryManager_H__ + +#include "OgrePlatform.h" +#include "OgreStdHeaders.h" + +namespace Ogre { + + /** @page memory_manager The memory manager information page + + @subsection desc Description + The memory manager is a class that handles memory (de)allocation requests. + @par + This class works like a wrapper between the actual C memory allocation + functions (*alloc, free) and the memory (de)allocation requests of the + application. + @par + Why would such a class be needed? First of all, because we had some + major issues with memory getting misued (read: deleted) over DLL + boundaries. One thing this memory manager does is solve the problem by + allocating all the memory in the OgreMain.dll/so process. + @par + Another use would be leak detection and memory misuse detection. With + a custom memory manager, calls to new/delete and *alloc/free could be + overseed and logged. + @par + Yet another use is the optimization of memory allocation for certain + object types. One of the most common examples is a small object + allocator. + @subsection types Manager types + There actually are two classes, one is the standard memory manager + which only addresses memory allocation problems when deallocating + across processes. + @par + The other is a modified version of the debugging memory manager written + by Paul 'MidNight' Nettle (aka. the Fluid Studios Memory Manager). + Obviously, the second one should be used only when debugging your + application as it adds some visible overhead. + @par + You can switch between the two memory managers by setting the value of + the OGRE_DEBUG_MEMORY_MANAGER macro in OgreConfig.h + @subsection notes Implementation Note + The class contains a static member of type MemoryManager. That is + because we want the memory manager to be created even before we + override the new([])/delete([]) operators. + @subsection see See also + Paul Nettle's Memory Manager page at flipCode - you can get the original source form here. + */ + +#if OGRE_DEBUG_MEMORY_MANAGER && OGRE_DEBUG_MODE + +#ifndef __FUNCTION__ +#define __FUNCTION__ "???" +#endif + +} + +//----------------------------------------------------------------------------- +// We have to declare the global new([])/delete([]) operators before declaring +// the Ogre::MemoryManager class since it lists them as friend functions +void *operator new(size_t reportedSize); +void *operator new[](size_t reportedSize); +void operator delete(void *reportedAddress); +void operator delete[](void *reportedAddress); +//----------------------------------------------------------------------------- + +namespace Ogre { + + /** For internal use only. + \internal. + @remarks + This structure holds the allocation tracking information. So, + for each allocation made, the overhead this memory manager adds + is the size of this structure, the lengths of the names of the + file and function in which the allocation was made and the + padding size (which can be adjusted). + */ + typedef struct tag_au + { + size_t actualSize; + size_t reportedSize; + + void *actualAddress; + void *reportedAddress; + + char sourceFile[40]; + char sourceFunc[40]; + + unsigned int sourceLine; + unsigned int allocationType; + + bool breakOnDealloc; + bool breakOnRealloc; + + unsigned int allocationNumber; + unsigned int processID; + + struct tag_au *next; + struct tag_au *prev; + } sAllocUnit; + + typedef struct + { + size_t totalReportedMemory; + size_t totalActualMemory; + + size_t peakReportedMemory; + size_t peakActualMemory; + + size_t accumulatedReportedMemory; + size_t accumulatedActualMemory; + size_t accumulatedAllocUnitCount; + + size_t totalAllocUnitCount; + size_t peakAllocUnitCount; + } sMStats; + + enum + { + m_alloc_unknown = 0, + m_alloc_new = 1, + m_alloc_new_array = 2, + m_alloc_malloc = 3, + m_alloc_calloc = 4, + m_alloc_realloc = 5, + m_alloc_delete = 6, + m_alloc_delete_array = 7, + m_alloc_free = 8 + }; + + /** See the \ref memory_manager. + */ + class _OgreExport MemoryManager + { + friend void * ::operator new(size_t); + friend void * ::operator new[](size_t); + friend void ::operator delete(void*); + friend void ::operator delete[](void*); + + public: + static MemoryManager& instance(void); + + private: + /// This is used in the process tracking part of the memory manager. + unsigned m_uProcessIDs; + /// This is set to true when deinitialization takes place. + bool m_bDeinitTime; + +#ifndef __BORLANDC__ + private: +#else + public: +#endif + //------------------------------------------------------------------------- + // Wrappers for the new/delete functions + void *op_new_sc( size_t reportedSize, unsigned processID ); + void *op_new_vc( size_t reportedSize, unsigned processID ); + + void *op_new_sc( size_t reportedSize, const char *sourceFile, int sourceLine, unsigned processID ); + void *op_new_vc( size_t reportedSize, const char *sourceFile, int sourceLine, unsigned processID ); + + void op_del_sc( void *reportedAddress, unsigned processID ); + void op_del_vc( void *reportedAddress, unsigned processID ); + //------------------------------------------------------------------------- + + /** This function is intended for internal use only. + \internal + @remarks + This function is used to return an unique handle for each process + calling it. The returned unsigned int is then passed to the memory + manager every time a re/de/allocation request is made, in order + to check that deallocations don't occur in processes other than the + ones in which allcations were made and so on. + @par + Actually, the problem of re/de/allocating in other processes was + solved with the addition of the new memory manager, but you may + want to limit the occurence of such events anyway, and this function + helps you do just that. + */ + unsigned _getProcessID(); + + public: + MemoryManager(); + ~MemoryManager(); + + //------------------------------------------------------------------------- + // Used by the macros + void setOwner(const char *file, const unsigned int line, const char *func); + //------------------------------------------------------------------------- + + //------------------------------------------------------------------------- + // Allocation breakpoints + bool &breakOnRealloc(void *reportedAddress); + bool &breakOnDealloc( void *reportedAddress ); + void breakOnAlloc( unsigned int count ); + //------------------------------------------------------------------------- + + //------------------------------------------------------------------------- + // The meat & potatoes of the memory tracking software + + /** This function is intended for internal use only. + \internal + @remarks + This function is the actual memory allocator and acts as a bridge + between OGRE and the C/C++ alloc/calloc functions. + @par + While memory allocation requests are made trough this function, + the tracking of memory addresses is possible. Therefore, attempting + to deallocate a portion of memory that was not allocated using + this function will result in a warning given by the deallocator, + dllocMem. + */ + void * allocMem( + const char *sourceFile, + const unsigned int sourceLine, + const char *sourceFunc, + const unsigned int allocationType, + const size_t reportedSize, + const unsigned processID ); + + /** This function is intended for internal use only. + \internal + @remarks + This function is the actual memory reallocator and acts as a bridge + between OGRE and the C/C++ realloc function. + @par + While memory reallocation requests are made trough this function, + the tracking of memory addresses is possible. Therefore, attempting + to deallocate a portion of memory that was not reallocated using + this function will result in a warning given by the deallocator, + dllocMem. + @par + As well, trying to reallocate memory that was not allocated using + mallc/calloc will result in a warning. + */ + void * rllocMem( + const char *sourceFile, + const unsigned int sourceLine, + const char *sourceFunc, + const unsigned int reallocationType, + const size_t reportedSize, + void *reportedAddress, + const unsigned processID ); + + /** This function is intended for internal use only. + \internal + @remarks + This function is the actual memory deallocator and acts as a + bridge between OGRE and the C/C++ free function. + @par + While memory deallocation requests are made trough this function, + the tracking of memory addresses is possible. Therefore, attempting + to deallocate a portion of memory that was not allocated using + allocMem or rllocMem, trying to deallocate memory that was + allocated with malloc using delete (and the corresponding + permutations) or trying to deallocate memory allocated from from + process will result in a warning. + @note + Actually, memory can be allocated in one process and deallocated + in another, since the actual (de)allocation takes place in the + memory space of the OgreMain library. + @par + Tracking this kind of (possible) errors exists because users may + want to write their own memory allocator later on or they'd like + to get rid of OGRE's memory allocator. + */ + void dllocMem( + const char *sourceFile, + const unsigned int sourceLine, + const char *sourceFunc, + const unsigned int deallocationType, + const void *reportedAddress, + const unsigned processID ); + //------------------------------------------------------------------------- + + //------------------------------------------------------------------------- + // Utilitarian functions + bool validateAddr(const void *reportedAddress); + bool validateAlloc(const sAllocUnit *allocUnit); + bool validateAllAllocs(); + //------------------------------------------------------------------------- + + //------------------------------------------------------------------------- + // Unused RAM calculations + unsigned int calcUnused( const sAllocUnit *allocUnit ); + unsigned int calcAllUnused(); + //------------------------------------------------------------------------- + + //------------------------------------------------------------------------- + // Logging and reporting + void dumpAllocUnit( const sAllocUnit *allocUnit, const char *prefix = "" ); + void dumpMemReport( const char *filename = "memreport.log", const bool overwrite = true ); + sMStats getMemStats(); + //------------------------------------------------------------------------- + }; +} + +/** This variable exists separately in each module that links to the OGRE library + and is used to track the ID of the current process from the perspective + of the memory manager. + @see + unsigned Ogre::MemoryManager::_getProcessID() +*/ +static unsigned gProcessID = 0; + +// When compiling in Visual C++ (occuring in VS2005 Express but not for VC 7.1) with +// managed C++, should put the new([])/delete([]) overrides inside unmanaged context, +// otherwise Visual C++ will link with overridden version of new([]) and CRT version +// of delete([]), thus, mess up both of OGRE memory manager and CRT memory manager. +#if defined(__cplusplus_cli) +#pragma managed(push, off) +#endif +//----------------------------------------------------------------------------- +// Overridden global new([])/delete([]) functions +// +inline void *operator new(size_t reportedSize) +{ + if( !gProcessID ) + gProcessID = Ogre::MemoryManager::instance()._getProcessID(); + return Ogre::MemoryManager::instance().op_new_sc( reportedSize, gProcessID ); +} +inline void *operator new[](size_t reportedSize) +{ + if( !gProcessID ) + gProcessID = Ogre::MemoryManager::instance()._getProcessID(); + return Ogre::MemoryManager::instance().op_new_vc( reportedSize, gProcessID ); +} + +inline void operator delete(void *reportedAddress) +{ + Ogre::MemoryManager::instance().op_del_sc( reportedAddress, gProcessID ); +} +inline void operator delete[](void *reportedAddress) +{ + Ogre::MemoryManager::instance().op_del_vc( reportedAddress, gProcessID ); +} +//----------------------------------------------------------------------------- +#if defined(__cplusplus_cli) +#pragma managed(pop) +#endif + +//----------------------------------------------------------------------------- +// This header adds the *alloc/free macros, wrapping the C functions +#include "OgreMemoryMacros.h" +//----------------------------------------------------------------------------- + +#else + + /** See the \ref memory_manager. + */ + class _OgreExport MemoryManager + { + public: + static MemoryManager& instance(void); + + MemoryManager(); + ~MemoryManager(); + + /** Memory allocator - uses plain old malloc. + */ + void *allocMem( const char *szFile, size_t uLine, size_t count ) throw ( ); + + /** Memory re-allocator - uses plain old realloc. + */ + void *rllocMem( const char *szFile, size_t uLine, void *ptr , size_t count ) throw ( ); + + /** Memory allocator - uses plain old calloc. + */ + void *cllocMem( const char *szFile, size_t uLine, size_t num, size_t size ) throw ( ); + + /** Memory de-allocator - uses plain old free. + */ + void dllocMem( const char *szFile, size_t uLine, void *ptr ) throw ( ); + }; + +} + +#endif + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreMesh.h b/school/informatik/verkerhssimulation/src/ogre/OgreMesh.h new file mode 100644 index 00000000..fd5edaa6 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreMesh.h @@ -0,0 +1,875 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Mesh_H__ +#define __Mesh_H__ + +#include "OgrePrerequisites.h" + +#include "OgreResource.h" +#include "OgreVertexIndexData.h" +#include "OgreAxisAlignedBox.h" +#include "OgreVertexBoneAssignment.h" +#include "OgreIteratorWrappers.h" +#include "OgreProgressiveMesh.h" +#include "OgreHardwareVertexBuffer.h" +#include "OgreSkeleton.h" +#include "OgreAnimationTrack.h" +#include "OgrePose.h" + + +namespace Ogre { + + + /** Resource holding data about 3D mesh. + @remarks + This class holds the data used to represent a discrete + 3-dimensional object. Mesh data usually contains more + than just vertices and triangle information; it also + includes references to materials (and the faces which use them), + level-of-detail reduction information, convex hull definition, + skeleton/bones information, keyframe animation etc. + However, it is important to note the emphasis on the word + 'discrete' here. This class does not cover the large-scale + sprawling geometry found in level / landscape data. + @par + Multiple world objects can (indeed should) be created from a + single mesh object - see the Entity class for more info. + The mesh object will have it's own default + material properties, but potentially each world instance may + wish to customise the materials from the original. When the object + is instantiated into a scene node, the mesh material properties + will be taken by default but may be changed. These properties + are actually held at the SubMesh level since a single mesh may + have parts with different materials. + @par + As described above, because the mesh may have sections of differing + material properties, a mesh is inherently a compound contruct, + consisting of one or more SubMesh objects. + However, it strongly 'owns' it's SubMeshes such that they + are loaded / unloaded at the same time. This is contrary to + the approach taken to hierarchically related (but loosely owned) + scene nodes, where data is loaded / unloaded separately. Note + also that mesh sub-sections (when used in an instantiated object) + share the same scene node as the parent. + */ + + + struct MeshLodUsage; + + class _OgreExport Mesh: public Resource + { + friend class SubMesh; + friend class MeshSerializerImpl; + friend class MeshSerializerImpl_v1_2; + friend class MeshSerializerImpl_v1_1; + + public: + typedef std::vector LodDistanceList; + /// Multimap of vertex bone assignments (orders by vertex index) + typedef std::multimap VertexBoneAssignmentList; + typedef MapIterator BoneAssignmentIterator; + typedef std::vector SubMeshList; + typedef std::vector IndexMap; + + protected: + /** A list of submeshes which make up this mesh. + Each mesh is made up of 1 or more submeshes, which + are each based on a single material and can have their + own vertex data (they may not - they can share vertex data + from the Mesh, depending on preference). + */ + SubMeshList mSubMeshList; + + /** Internal method for making the space for a vertex element to hold tangents. */ + void organiseTangentsBuffer(VertexData *vertexData, + VertexElementSemantic targetSemantic, unsigned short index, + unsigned short sourceTexCoordSet); + + public: + /** A hashmap used to store optional SubMesh names. + Translates a name into SubMesh index + */ + typedef HashMap SubMeshNameMap ; + + + protected: + SubMeshNameMap mSubMeshNameMap ; + + /// Local bounding box volume + AxisAlignedBox mAABB; + /// Local bounding sphere radius (centered on object) + Real mBoundRadius; + + /// Optional linked skeleton + String mSkeletonName; + SkeletonPtr mSkeleton; + + + VertexBoneAssignmentList mBoneAssignments; + + /// Flag indicating that bone assignments need to be recompiled + bool mBoneAssignmentsOutOfDate; + + /** Build the index map between bone index and blend index */ + void buildIndexMap(const VertexBoneAssignmentList& boneAssignments, + IndexMap& boneIndexToBlendIndexMap, IndexMap& blendIndexToBoneIndexMap); + /** Compile bone assignments into blend index and weight buffers. */ + void compileBoneAssignments(const VertexBoneAssignmentList& boneAssignments, + unsigned short numBlendWeightsPerVertex, + IndexMap& blendIndexToBoneIndexMap, + VertexData* targetVertexData); + + bool mIsLodManual; + ushort mNumLods; + typedef std::vector MeshLodUsageList; + MeshLodUsageList mMeshLodUsageList; + + HardwareBuffer::Usage mVertexBufferUsage; + HardwareBuffer::Usage mIndexBufferUsage; + bool mVertexBufferShadowBuffer; + bool mIndexBufferShadowBuffer; + + + bool mPreparedForShadowVolumes; + bool mEdgeListsBuilt; + bool mAutoBuildEdgeLists; + + /// Storage of morph animations, lookup by name + typedef std::map AnimationList; + AnimationList mAnimationsList; + /// The vertex animation type associated with the shared vertex data + mutable VertexAnimationType mSharedVertexDataAnimationType; + /// Do we need to scan animations for animation types? + mutable bool mAnimationTypesDirty; + + /// List of available poses for shared and dedicated geometryPoseList + PoseList mPoseList; + + + /// @copydoc Resource::loadImpl + void loadImpl(void); + /// @copydoc Resource::postLoadImpl + void postLoadImpl(void); + /// @copydoc Resource::unloadImpl + void unloadImpl(void); + /// @copydoc Resource::calculateSize + size_t calculateSize(void) const; + + + + public: + /** Default constructor - used by MeshManager + @warning + Do not call this method directly. + */ + Mesh(ResourceManager* creator, const String& name, ResourceHandle handle, + const String& group, bool isManual = false, ManualResourceLoader* loader = 0); + ~Mesh(); + + // NB All methods below are non-virtual since they will be + // called in the rendering loop - speed is of the essence. + + /** Creates a new SubMesh. + @remarks + Method for manually creating geometry for the mesh. + Note - use with extreme caution - you must be sure that + you have set up the geometry properly. + */ + SubMesh* createSubMesh(void); + + /** Creates a new SubMesh and gives it a name + */ + SubMesh* createSubMesh(const String& name); + + /** Gives a name to a SubMesh + */ + void nameSubMesh(const String& name, ushort index); + + /** Gets the index of a submesh with a given name. + @remarks + Useful if you identify the SubMeshes by name (using nameSubMesh) + but wish to have faster repeat access. + */ + ushort _getSubMeshIndex(const String& name) const; + + /** Gets the number of sub meshes which comprise this mesh. + */ + unsigned short getNumSubMeshes(void) const; + + /** Gets a pointer to the submesh indicated by the index. + */ + SubMesh* getSubMesh(unsigned short index) const; + + /** Gets a SubMesh by name + */ + SubMesh* getSubMesh(const String& name) const ; + + typedef VectorIterator SubMeshIterator; + /// Gets an iterator over the available submeshes + SubMeshIterator getSubMeshIterator(void) + { return SubMeshIterator(mSubMeshList.begin(), mSubMeshList.end()); } + + /** Shared vertex data. + @remarks + This vertex data can be shared among multiple submeshes. SubMeshes may not have + their own VertexData, they may share this one. + @par + The use of shared or non-shared buffers is determined when + model data is converted to the OGRE .mesh format. + */ + VertexData *sharedVertexData; + + /** Shared index map for translating blend index to bone index. + @remarks + This index map can be shared among multiple submeshes. SubMeshes might not have + their own IndexMap, they might share this one. + @par + We collect actually used bones of all bone assignments, and build the + blend index in 'packed' form, then the range of the blend index in vertex + data VES_BLEND_INDICES element is continuous, with no gaps. Thus, by + minimising the world matrix array constants passing to GPU, we can support + more bones for a mesh when hardware skinning is used. The hardware skinning + support limit is applied to each set of vertex data in the mesh, in other words, the + hardware skinning support limit is applied only to the actually used bones of each + SubMeshes, not all bones across the entire Mesh. + @par + Because the blend index is different to the bone index, therefore, we use + the index map to translate the blend index to bone index. + @par + The use of shared or non-shared index map is determined when + model data is converted to the OGRE .mesh format. + */ + IndexMap sharedBlendIndexToBoneIndexMap; + + /** Makes a copy of this mesh object and gives it a new name. + @remarks + This is useful if you want to tweak an existing mesh without affecting the original one. The + newly cloned mesh is registered with the MeshManager under the new name. + @param newName The name to give the clone + @param newGroup Optional name of the new group to assign the clone to; + if you leave this blank, the clone will be assigned to the same + group as this Mesh. + */ + MeshPtr clone(const String& newName, const String& newGroup = StringUtil::BLANK); + + /** Get the axis-aligned bounding box for this mesh. + */ + const AxisAlignedBox& getBounds(void) const; + + /** Gets the radius of the bounding sphere surrounding this mesh. */ + Real getBoundingSphereRadius(void) const; + + /** Manually set the bounding box for this Mesh. + @remarks + Calling this method is required when building manual meshes now, because OGRE can no longer + update the bounds for you, because it cannot necessarily read vertex data back from + the vertex buffers which this mesh uses (they very well might be write-only, and even + if they are not, reading data from a hardware buffer is a bottleneck). + @param pad If true, a certain padding will be added to the bounding box to separate it from the mesh + */ + void _setBounds(const AxisAlignedBox& bounds, bool pad = true); + + /** Manually set the bounding radius. + @remarks + Calling this method is required when building manual meshes now, because OGRE can no longer + update the bounds for you, because it cannot necessarily read vertex data back from + the vertex buffers which this mesh uses (they very well might be write-only, and even + if they are not, reading data from a hardware buffer is a bottleneck). + */ + void _setBoundingSphereRadius(Real radius); + + /** Sets the name of the skeleton this Mesh uses for animation. + @remarks + Meshes can optionally be assigned a skeleton which can be used to animate + the mesh through bone assignments. The default is for the Mesh to use no + skeleton. Calling this method with a valid skeleton filename will cause the + skeleton to be loaded if it is not already (a single skeleton can be shared + by many Mesh objects). + @param skelName The name of the .skeleton file to use, or an empty string to use + no skeleton + */ + void setSkeletonName(const String& skelName); + + /** Returns true if this Mesh has a linked Skeleton. */ + bool hasSkeleton(void) const; + + /** Returns whether or not this mesh has some kind of vertex animation. + */ + bool hasVertexAnimation(void) const; + + /** Gets a pointer to any linked Skeleton. + @returns Weak reference to the skeleton - copy this if you want to hold a strong pointer. + */ + const SkeletonPtr& getSkeleton(void) const; + + /** Gets the name of any linked Skeleton */ + const String& getSkeletonName(void) const; + /** Initialise an animation set suitable for use with this mesh. + @remarks + Only recommended for use inside the engine, not by applications. + */ + void _initAnimationState(AnimationStateSet* animSet); + + /** Refresh an animation set suitable for use with this mesh. + @remarks + Only recommended for use inside the engine, not by applications. + */ + void _refreshAnimationState(AnimationStateSet* animSet); + /** Assigns a vertex to a bone with a given weight, for skeletal animation. + @remarks + This method is only valid after calling setSkeletonName. + Since this is a one-off process there exists only 'addBoneAssignment' and + 'clearBoneAssignments' methods, no 'editBoneAssignment'. You should not need + to modify bone assignments during rendering (only the positions of bones) and OGRE + reserves the right to do some internal data reformatting of this information, depending + on render system requirements. + @par + This method is for assigning weights to the shared geometry of the Mesh. To assign + weights to the per-SubMesh geometry, see the equivalent methods on SubMesh. + */ + void addBoneAssignment(const VertexBoneAssignment& vertBoneAssign); + + /** Removes all bone assignments for this mesh. + @remarks + This method is for modifying weights to the shared geometry of the Mesh. To assign + weights to the per-SubMesh geometry, see the equivalent methods on SubMesh. + */ + void clearBoneAssignments(void); + + /** Internal notification, used to tell the Mesh which Skeleton to use without loading it. + @remarks + This is only here for unusual situation where you want to manually set up a + Skeleton. Best to let OGRE deal with this, don't call it yourself unless you + really know what you're doing. + */ + void _notifySkeleton(SkeletonPtr& pSkel); + + + /** Gets an iterator for access all bone assignments. + */ + BoneAssignmentIterator getBoneAssignmentIterator(void); + + + /** Automatically generates lower level of detail versions of this mesh for use + when a simpler version of the model is acceptable for rendering. + @remarks + There are 2 ways that you can create level-of-detail (LOD) versions of a mesh; + the first is to call this method, which does fairly extensive calculations to + work out how to simplify the mesh whilst having the minimum affect on the model. + The alternative is to actually create simpler versions of the mesh yourself in + a modelling tool, and having exported them, tell the 'master' mesh to use these + alternative meshes for lower detail versions; this is done by calling the + createManualLodLevel method. + @par + As well as creating the lower detail versions of the mesh, this method will + also associate them with depth values. As soon as an object is at least as far + away from the camera as the depth value associated with it's LOD, it will drop + to that level of detail. + @par + I recommend calling this method before mesh export, not at runtime. + @param lodDistances A list of depth values indicating the distances at which new lods should be + generated. + @param reductionMethod The way to determine the number of vertices collapsed per LOD + @param reductionValue Meaning depends on reductionMethod, typically either the proportion + of remaining vertices to collapse or a fixed number of vertices. + */ + void generateLodLevels(const LodDistanceList& lodDistances, + ProgressiveMesh::VertexReductionQuota reductionMethod, Real reductionValue); + + /** Returns the number of levels of detail that this mesh supports. + @remarks + This number includes the original model. + */ + ushort getNumLodLevels(void) const; + /** Gets details of the numbered level of detail entry. */ + const MeshLodUsage& getLodLevel(ushort index) const; + /** Adds a new manual level-of-detail entry to this Mesh. + @remarks + As an alternative to generating lower level of detail versions of a mesh, you can + use your own manually modelled meshes as lower level versions. This lets you + have complete control over the LOD, and in addition lets you scale down other + aspects of the model which cannot be done using the generated method; for example, + you could use less detailed materials and / or use less bones in the skeleton if + this is an animated mesh. Therefore for complex models you are likely to be better off + modelling your LODs yourself and using this method, whilst for models with fairly + simple materials and no animation you can just use the generateLodLevels method. + @param fromDepth The z value from which this Lod will apply. + @param meshName The name of the mesh which will be the lower level detail version. + */ + void createManualLodLevel(Real fromDepth, const String& meshName); + + /** Changes the alternate mesh to use as a manual LOD at the given index. + @remarks + Note that the index of a LOD may change if you insert other LODs. If in doubt, + use getLodIndex(). + @param index The index of the level to be changed + @param meshName The name of the mesh which will be the lower level detail version. + */ + void updateManualLodLevel(ushort index, const String& meshName); + + /** Retrieves the level of detail index for the given depth value. + */ + ushort getLodIndex(Real depth) const; + + /** Retrieves the level of detail index for the given squared depth value. + @remarks + Internally the lods are stored at squared depths to avoid having to perform + square roots when determining the lod. This method allows you to provide a + squared length depth value to avoid having to do your own square roots. + */ + ushort getLodIndexSquaredDepth(Real squaredDepth) const; + + /** Returns true if this mesh is using manual LOD. + @remarks + A mesh can either use automatically generated LOD, or it can use alternative + meshes as provided by an artist. A mesh can only use either all manual LODs + or all generated LODs, not a mixture of both. + */ + bool isLodManual(void) const { return mIsLodManual; } + + /** Internal methods for loading LOD, do not use. */ + void _setLodInfo(unsigned short numLevels, bool isManual); + /** Internal methods for loading LOD, do not use. */ + void _setLodUsage(unsigned short level, MeshLodUsage& usage); + /** Internal methods for loading LOD, do not use. */ + void _setSubMeshLodFaceList(unsigned short subIdx, unsigned short level, IndexData* facedata); + + /** Removes all LOD data from this Mesh. */ + void removeLodLevels(void); + + /** Sets the policy for the vertex buffers to be used when loading + this Mesh. + @remarks + By default, when loading the Mesh, static, write-only vertex and index buffers + will be used where possible in order to improve rendering performance. + However, such buffers + cannot be manipulated on the fly by CPU code (although shader code can). If you + wish to use the CPU to modify these buffers, you should call this method. Note, + however, that it only takes effect after the Mesh has been reloaded. Note that you + still have the option of manually repacing the buffers in this mesh with your + own if you see fit too, in which case you don't need to call this method since it + only affects buffers created by the mesh itself. + @par + You can define the approach to a Mesh by changing the default parameters to + MeshManager::load if you wish; this means the Mesh is loaded with those options + the first time instead of you having to reload the mesh after changing these options. + @param usage The usage flags, which by default are + HardwareBuffer::HBU_STATIC_WRITE_ONLY + @param shadowBuffer If set to true, the vertex buffers will be created with a + system memory shadow buffer. You should set this if you want to be able to + read from the buffer, because reading from a hardware buffer is a no-no. + */ + void setVertexBufferPolicy(HardwareBuffer::Usage usage, bool shadowBuffer = false); + /** Sets the policy for the index buffers to be used when loading + this Mesh. + @remarks + By default, when loading the Mesh, static, write-only vertex and index buffers + will be used where possible in order to improve rendering performance. + However, such buffers + cannot be manipulated on the fly by CPU code (although shader code can). If you + wish to use the CPU to modify these buffers, you should call this method. Note, + however, that it only takes effect after the Mesh has been reloaded. Note that you + still have the option of manually repacing the buffers in this mesh with your + own if you see fit too, in which case you don't need to call this method since it + only affects buffers created by the mesh itself. + @par + You can define the approach to a Mesh by changing the default parameters to + MeshManager::load if you wish; this means the Mesh is loaded with those options + the first time instead of you having to reload the mesh after changing these options. + @param usage The usage flags, which by default are + HardwareBuffer::HBU_STATIC_WRITE_ONLY + @param shadowBuffer If set to true, the index buffers will be created with a + system memory shadow buffer. You should set this if you want to be able to + read from the buffer, because reading from a hardware buffer is a no-no. + */ + void setIndexBufferPolicy(HardwareBuffer::Usage usage, bool shadowBuffer = false); + /** Gets the usage setting for this meshes vertex buffers. */ + HardwareBuffer::Usage getVertexBufferUsage(void) const { return mVertexBufferUsage; } + /** Gets the usage setting for this meshes index buffers. */ + HardwareBuffer::Usage getIndexBufferUsage(void) const { return mIndexBufferUsage; } + /** Gets whether or not this meshes vertex buffers are shadowed. */ + bool isVertexBufferShadowed(void) const { return mVertexBufferShadowBuffer; } + /** Gets whether or not this meshes index buffers are shadowed. */ + bool isIndexBufferShadowed(void) const { return mIndexBufferShadowBuffer; } + + + /** Rationalises the passed in bone assignment list. + @remarks + OGRE supports up to 4 bone assignments per vertex. The reason for this limit + is that this is the maximum number of assignments that can be passed into + a hardware-assisted blending algorithm. This method identifies where there are + more than 4 bone assignments for a given vertex, and eliminates the bone + assignments with the lowest weights to reduce to this limit. The remaining + weights are then re-balanced to ensure that they sum to 1.0. + @param vertexCount The number of vertices. + @param assignments The bone assignment list to rationalise. This list will be modified and + entries will be removed where the limits are exceeded. + @returns The maximum number of bone assignments per vertex found, clamped to [1-4] + */ + unsigned short _rationaliseBoneAssignments(size_t vertexCount, VertexBoneAssignmentList& assignments); + + /** Internal method, be called once to compile bone assignments into geometry buffer. + @remarks + The OGRE engine calls this method automatically. It compiles the information + submitted as bone assignments into a format usable in realtime. It also + eliminates excessive bone assignments (max is OGRE_MAX_BLEND_WEIGHTS) + and re-normalises the remaining assignments. + */ + void _compileBoneAssignments(void); + + /** Internal method, be called once to update the compiled bone assignments. + @remarks + The OGRE engine calls this method automatically. It updates the compiled bone + assignments if requested. + */ + void _updateCompiledBoneAssignments(void); + + /** This method builds a set of tangent vectors for a given mesh into a 3D texture coordinate buffer. + @remarks + Tangent vectors are vectors representing the local 'X' axis for a given vertex based + on the orientation of the 2D texture on the geometry. They are built from a combination + of existing normals, and from the 2D texture coordinates already baked into the model. + They can be used for a number of things, but most of all they are useful for + vertex and fragment programs, when you wish to arrive at a common space for doing + per-pixel calculations. + @par + The prerequisites for calling this method include that the vertex data used by every + SubMesh has both vertex normals and 2D texture coordinates. + @param targetSemantic The semantic to store the tangents in. Defaults to + the explicit tangent binding, but note that this is only usable on more + modern hardware (Shader Model 2), so if you need portability with older + cards you should change this to a texture coordinate binding instead. + @param sourceTexCoordSet The texture coordinate index which should be used as the source + of 2D texture coordinates, with which to calculate the tangents. + @param index The element index, ie the texture coordinate set which should be used to store the 3D + coordinates representing a tangent vector per vertex, if targetSemantic is + VES_TEXTURE_COORDINATES. If this already exists, it will be overwritten. + */ + void buildTangentVectors(VertexElementSemantic targetSemantic = VES_TANGENT, + unsigned short sourceTexCoordSet = 0, unsigned short index = 0); + + /** Ask the mesh to suggest parameters to a future buildTangentVectors call, + should you wish to use texture coordinates to store the tangents. + @remarks + This helper method will suggest source and destination texture coordinate sets + for a call to buildTangentVectors. It will detect when there are inappropriate + conditions (such as multiple geometry sets which don't agree). + Moreover, it will return 'true' if it detects that there are aleady 3D + coordinates in the mesh, and therefore tangents may have been prepared already. + @param targetSemantic The semantic you intend to use to store the tangents + if they are not already present; + most likely options are VES_TEXTURE_COORDINATES or VES_TANGENT; you should + use texture coordinates if you want compatibility with older, pre-SM2 + graphics cards, and the tangent binding otherwise. + @param outSourceCoordSet Reference to a source texture coordinate set which + will be populated + @param outIndex Reference to a destination element index (e.g. texture coord set) + which will be populated + */ + bool suggestTangentVectorBuildParams(VertexElementSemantic targetSemantic, + unsigned short& outSourceCoordSet, unsigned short& outIndex); + + /** Builds an edge list for this mesh, which can be used for generating a shadow volume + among other things. + */ + void buildEdgeList(void); + /** Destroys and frees the edge lists this mesh has built. */ + void freeEdgeList(void); + + /** This method prepares the mesh for generating a renderable shadow volume. + @remarks + Preparing a mesh to generate a shadow volume involves firstly ensuring that the + vertex buffer containing the positions for the mesh is a standalone vertex buffer, + with no other components in it. This method will therefore break apart any existing + vertex buffers this mesh holds if position is sharing a vertex buffer. + Secondly, it will double the size of this vertex buffer so that there are 2 copies of + the position data for the mesh. The first half is used for the original, and the second + half is used for the 'extruded' version of the mesh. The vertex count of the main + VertexData used to render the mesh will remain the same though, so as not to add any + overhead to regular rendering of the object. + Both copies of the position are required in one buffer because shadow volumes stretch + from the original mesh to the extruded version. + @par + Because shadow volumes are rendered in turn, no additional + index buffer space is allocated by this method, a shared index buffer allocated by the + shadow rendering algorithm is used for addressing this extended vertex buffer. + */ + void prepareForShadowVolume(void); + + /** Return the edge list for this mesh, building it if required. + @remarks + You must ensure that the Mesh as been prepared for shadow volume + rendering if you intend to use this information for that purpose. + @lodIndex The LOD at which to get the edge list, 0 being the highest. + */ + EdgeData* getEdgeList(unsigned int lodIndex = 0); + + /** Return the edge list for this mesh, building it if required. + @remarks + You must ensure that the Mesh as been prepared for shadow volume + rendering if you intend to use this information for that purpose. + @lodIndex The LOD at which to get the edge list, 0 being the highest. + */ + const EdgeData* getEdgeList(unsigned int lodIndex = 0) const; + + /** Returns whether this mesh has already had it's geometry prepared for use in + rendering shadow volumes. */ + bool isPreparedForShadowVolumes(void) const { return mPreparedForShadowVolumes; } + + /** Returns whether this mesh has an attached edge list. */ + bool isEdgeListBuilt(void) const { return mEdgeListsBuilt; } + + /** Prepare matrices for software indexed vertex blend. + @remarks + This function organise bone indexed matrices to blend indexed matrices, + so software vertex blending can access to the matrix via blend index + directly. + @param blendMatrices Pointer to an array of matrix pointers to store + prepared results, which indexed by blend index + @param boneMatrices Pointer to an array of matrices to be used to blend, + which indexed by bone index + @param indexMap The index map used to translate blend index to bone index + */ + static void prepareMatricesForVertexBlend(const Matrix4** blendMatrices, + const Matrix4* boneMatrices, const IndexMap& indexMap); + + /** Performs a software indexed vertex blend, of the kind used for + skeletal animation although it can be used for other purposes. + @remarks + This function is supplied to update vertex data with blends + done in software, either because no hardware support is available, + or that you need the results of the blend for some other CPU operations. + @param sourceVertexData VertexData class containing positions, normals, + blend indices and blend weights. + @param targetVertexData VertexData class containing target position + and normal buffers which will be updated with the blended versions. + Note that the layout of the source and target position / normal + buffers must be identical, ie they must use the same buffer indexes + @param blendMatrices Pointer to an array of matrix pointers to be used to blend, + indexed by blend indices in the sourceVertexData + @param numMatrices Number of matrices in the blendMatrices, it might be used + as a hint for optimisation. + @param blendNormals If true, normals are blended as well as positions + */ + static void softwareVertexBlend(const VertexData* sourceVertexData, + const VertexData* targetVertexData, + const Matrix4* const* blendMatrices, size_t numMatrices, + bool blendNormals); + + /** Performs a software vertex morph, of the kind used for + morph animation although it can be used for other purposes. + @remarks + This function will linearly interpolate positions between two + source buffers, into a third buffer. + @param t Parametric distance between the start and end buffer positions + @param b1 Vertex buffer containing VET_FLOAT3 entries for the start positions + @param b2 Vertex buffer containing VET_FLOAT3 entries for the end positions + @param targetVertexData VertexData destination; assumed to have a separate position + buffer already bound, and the number of vertices must agree with the + number in start and end + */ + static void softwareVertexMorph(Real t, + const HardwareVertexBufferSharedPtr& b1, + const HardwareVertexBufferSharedPtr& b2, + VertexData* targetVertexData); + + /** Performs a software vertex pose blend, of the kind used for + morph animation although it can be used for other purposes. + @remarks + This function will apply a weighted offset to the positions in the + incoming vertex data (therefore this is a read/write operation, and + if you expect to call it more than once with the same data, then + you would be best to suppress hardware uploads of the position buffer + for the duration) + @param weight Parametric weight to scale the offsets by + @param vertexOffsetMap Potentially sparse map of vertex index -> offset + @param targetVertexData VertexData destination; assumed to have a separate position + buffer already bound, and the number of vertices must agree with the + number in start and end + */ + static void softwareVertexPoseBlend(Real weight, + const std::map& vertexOffsetMap, + VertexData* targetVertexData); + /** Gets a reference to the optional name assignments of the SubMeshes. */ + const SubMeshNameMap& getSubMeshNameMap(void) const { return mSubMeshNameMap; } + + /** Sets whether or not this Mesh should automatically build edge lists + when asked for them, or whether it should never build them if + they are not already provided. + @remarks + This allows you to create meshes which do not have edge lists calculated, + because you never want to use them. This value defaults to 'true' + for mesh formats which did not include edge data, and 'false' for + newer formats, where edge lists are expected to have been generated + in advance. + */ + void setAutoBuildEdgeLists(bool autobuild) { mAutoBuildEdgeLists = autobuild; } + /** Sets whether or not this Mesh should automatically build edge lists + when asked for them, or whether it should never build them if + they are not already provided. + */ + bool getAutoBuildEdgeLists(void) const { return mAutoBuildEdgeLists; } + + /** Gets the type of vertex animation the shared vertex data of this mesh supports. + */ + virtual VertexAnimationType getSharedVertexDataAnimationType(void) const; + + /** Creates a new Animation object for vertex animating this mesh. + @param name The name of this animation + @param length The length of the animation in seconds + */ + virtual Animation* createAnimation(const String& name, Real length); + + /** Returns the named vertex Animation object. + @param name The name of the animation + */ + virtual Animation* getAnimation(const String& name) const; + + /** Internal access to the named vertex Animation object - returns null + if it does not exist. + @param name The name of the animation + */ + virtual Animation* _getAnimationImpl(const String& name) const; + + /** Returns whether this mesh contains the named vertex animation. */ + virtual bool hasAnimation(const String& name); + + /** Removes vertex Animation from this mesh. */ + virtual void removeAnimation(const String& name); + + /** Gets the number of morph animations in this mesh. */ + virtual unsigned short getNumAnimations(void) const; + + /** Gets a single morph animation by index. + */ + virtual Animation* getAnimation(unsigned short index) const; + + /** Removes all morph Animations from this mesh. */ + virtual void removeAllAnimations(void); + /** Gets a pointer to a vertex data element based on a morph animation + track handle. + @remarks + 0 means the shared vertex data, 1+ means a submesh vertex data (index+1) + */ + VertexData* getVertexDataByTrackHandle(unsigned short handle); + /** Iterates through all submeshes and requests them + to apply their texture aliases to the material they use. + @remarks + The submesh will only apply texture aliases to the material if matching + texture alias names are found in the material. If a match is found, the + submesh will automatically clone the original material and then apply its + texture to the new material. + @par + This method is normally called by the protected method loadImpl when a + mesh if first loaded. + */ + void updateMaterialForAllSubMeshes(void); + + /** Internal method which, if animation types have not been determined, + scans any vertex animations and determines the type for each set of + vertex data (cannot have 2 different types). + */ + void _determineAnimationTypes(void) const; + /** Are the derived animation types out of date? */ + bool _getAnimationTypesDirty(void) const { return mAnimationTypesDirty; } + + /** Create a new Pose for this mesh or one of its submeshes. + @param target The target geometry index; 0 is the shared Mesh geometry, 1+ is the + dedicated SubMesh geometry belonging to submesh index + 1. + @param name Name to give the pose, which is optional + @returns A new Pose ready for population + */ + Pose* createPose(ushort target, const String& name = StringUtil::BLANK); + /** Get the number of poses.*/ + size_t getPoseCount(void) const { return mPoseList.size(); } + /** Retrieve an existing Pose by index.*/ + Pose* getPose(ushort index); + /** Retrieve an existing Pose by name.*/ + Pose* getPose(const String& name); + /** Destroy a pose by index. + @note This will invalidate any animation tracks referring to this pose or those after it. + */ + void removePose(ushort index); + /** Destroy a pose by name. + @note This will invalidate any animation tracks referring to this pose or those after it. + */ + void removePose(const String& name); + /** Destroy all poses */ + void removeAllPoses(void); + + typedef VectorIterator PoseIterator; + typedef ConstVectorIterator ConstPoseIterator; + + /** Get an iterator over all the poses defined. */ + PoseIterator getPoseIterator(void); + /** Get an iterator over all the poses defined. */ + ConstPoseIterator getPoseIterator(void) const; + /** Get pose list */ + const PoseList& getPoseList(void) const; + + }; + + /** Specialisation of SharedPtr to allow SharedPtr to be assigned to MeshPtr + @note Has to be a subclass since we need operator=. + We could templatise this instead of repeating per Resource subclass, + except to do so requires a form VC6 does not support i.e. + ResourceSubclassPtr : public SharedPtr + */ + class _OgreExport MeshPtr : public SharedPtr + { + public: + MeshPtr() : SharedPtr() {} + explicit MeshPtr(Mesh* rep) : SharedPtr(rep) {} + MeshPtr(const MeshPtr& r) : SharedPtr(r) {} + MeshPtr(const ResourcePtr& r); + /// Operator used to convert a ResourcePtr to a MeshPtr + MeshPtr& operator=(const ResourcePtr& r); + protected: + /// Override destroy since we need to delete Mesh after fully defined + void destroy(void); + }; + + /** A way of recording the way each LODs is recorded this Mesh. */ + struct MeshLodUsage + { + /// squared Z value from which this LOD will apply + Real fromDepthSquared; + /// Only relevant if mIsLodManual is true, the name of the alternative mesh to use + String manualName; + /// Hard link to mesh to avoid looking up each time + mutable MeshPtr manualMesh; + /// Edge list for this LOD level (may be derived from manual mesh) + mutable EdgeData* edgeData; + }; + + + +} // namespace + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreMeshFileFormat.h b/school/informatik/verkerhssimulation/src/ogre/OgreMeshFileFormat.h new file mode 100644 index 00000000..c9134f42 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreMeshFileFormat.h @@ -0,0 +1,277 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __MeshFileFormat_H__ +#define __MeshFileFormat_H__ + +#include "OgrePrerequisites.h" + +namespace Ogre { + +/** Definition of the OGRE .mesh file format + + .mesh files are binary files (for read efficiency at runtime) and are arranged into chunks + of data, very like 3D Studio's format. + A chunk always consists of: + unsigned short CHUNK_ID : one of the following chunk ids identifying the chunk + unsigned long LENGTH : length of the chunk in bytes, including this header + void* DATA : the data, which may contain other sub-chunks (various data types) + + A .mesh file can contain both the definition of the Mesh itself, and optionally the definitions + of the materials is uses (although these can be omitted, if so the Mesh assumes that at runtime the + Materials referred to by name in the Mesh are loaded/created from another source) + + A .mesh file only contains a single mesh, which can itself have multiple submeshes. + +*/ + + enum MeshChunkID { + M_HEADER = 0x1000, + // char* version : Version number check + M_MESH = 0x3000, + // bool skeletallyAnimated // important flag which affects h/w buffer policies + // Optional M_GEOMETRY chunk + M_SUBMESH = 0x4000, + // char* materialName + // bool useSharedVertices + // unsigned int indexCount + // bool indexes32Bit + // unsigned int* faceVertexIndices (indexCount) + // OR + // unsigned short* faceVertexIndices (indexCount) + // M_GEOMETRY chunk (Optional: present only if useSharedVertices = false) + M_SUBMESH_OPERATION = 0x4010, // optional, trilist assumed if missing + // unsigned short operationType + M_SUBMESH_BONE_ASSIGNMENT = 0x4100, + // Optional bone weights (repeating section) + // unsigned int vertexIndex; + // unsigned short boneIndex; + // float weight; + // Optional chunk that matches a texture name to an alias + // a texture alias is sent to the submesh material to use this texture name + // instead of the one in the texture unit with a matching alias name + M_SUBMESH_TEXTURE_ALIAS = 0x4200, // Repeating section + // char* aliasName; + // char* textureName; + + M_GEOMETRY = 0x5000, // NB this chunk is embedded within M_MESH and M_SUBMESH + // unsigned int vertexCount + M_GEOMETRY_VERTEX_DECLARATION = 0x5100, + M_GEOMETRY_VERTEX_ELEMENT = 0x5110, // Repeating section + // unsigned short source; // buffer bind source + // unsigned short type; // VertexElementType + // unsigned short semantic; // VertexElementSemantic + // unsigned short offset; // start offset in buffer in bytes + // unsigned short index; // index of the semantic (for colours and texture coords) + M_GEOMETRY_VERTEX_BUFFER = 0x5200, // Repeating section + // unsigned short bindIndex; // Index to bind this buffer to + // unsigned short vertexSize; // Per-vertex size, must agree with declaration at this index + M_GEOMETRY_VERTEX_BUFFER_DATA = 0x5210, + // raw buffer data + M_MESH_SKELETON_LINK = 0x6000, + // Optional link to skeleton + // char* skeletonName : name of .skeleton to use + M_MESH_BONE_ASSIGNMENT = 0x7000, + // Optional bone weights (repeating section) + // unsigned int vertexIndex; + // unsigned short boneIndex; + // float weight; + M_MESH_LOD = 0x8000, + // Optional LOD information + // unsigned short numLevels; + // bool manual; (true for manual alternate meshes, false for generated) + M_MESH_LOD_USAGE = 0x8100, + // Repeating section, ordered in increasing depth + // NB LOD 0 (full detail from 0 depth) is omitted + // float fromSquaredDepth; + M_MESH_LOD_MANUAL = 0x8110, + // Required if M_MESH_LOD section manual = true + // String manualMeshName; + M_MESH_LOD_GENERATED = 0x8120, + // Required if M_MESH_LOD section manual = false + // Repeating section (1 per submesh) + // unsigned int indexCount; + // bool indexes32Bit + // unsigned short* faceIndexes; (indexCount) + // OR + // unsigned int* faceIndexes; (indexCount) + M_MESH_BOUNDS = 0x9000, + // float minx, miny, minz + // float maxx, maxy, maxz + // float radius + + // Added By DrEvil + // optional chunk that contains a table of submesh indexes and the names of + // the sub-meshes. + M_SUBMESH_NAME_TABLE = 0xA000, + // Subchunks of the name table. Each chunk contains an index & string + M_SUBMESH_NAME_TABLE_ELEMENT = 0xA100, + // short index + // char* name + + // Optional chunk which stores precomputed edge data + M_EDGE_LISTS = 0xB000, + // Each LOD has a separate edge list + M_EDGE_LIST_LOD = 0xB100, + // unsigned short lodIndex + // bool isManual // If manual, no edge data here, loaded from manual mesh + // bool isClosed + // unsigned long numTriangles + // unsigned long numEdgeGroups + // Triangle* triangleList + // unsigned long indexSet + // unsigned long vertexSet + // unsigned long vertIndex[3] + // unsigned long sharedVertIndex[3] + // float normal[4] + + M_EDGE_GROUP = 0xB110, + // unsigned long vertexSet + // unsigned long triStart + // unsigned long triCount + // unsigned long numEdges + // Edge* edgeList + // unsigned long triIndex[2] + // unsigned long vertIndex[2] + // unsigned long sharedVertIndex[2] + // bool degenerate + + // Optional poses section, referred to by pose keyframes + M_POSES = 0xC000, + M_POSE = 0xC100, + // char* name (may be blank) + // unsigned short target // 0 for shared geometry, + // 1+ for submesh index + 1 + M_POSE_VERTEX = 0xC111, + // unsigned long vertexIndex + // float xoffset, yoffset, zoffset + // Optional vertex animation chunk + M_ANIMATIONS = 0xD000, + M_ANIMATION = 0xD100, + // char* name + // float length + M_ANIMATION_TRACK = 0xD110, + // unsigned short type // 1 == morph, 2 == pose + // unsigned short target // 0 for shared geometry, + // 1+ for submesh index + 1 + M_ANIMATION_MORPH_KEYFRAME = 0xD111, + // float time + // float x,y,z // repeat by number of vertices in original geometry + M_ANIMATION_POSE_KEYFRAME = 0xD112, + // float time + M_ANIMATION_POSE_REF = 0xD113, // repeat for number of referenced poses + // unsigned short poseIndex + // float influence + + // Optional submesh extreme vertex list chink + M_TABLE_EXTREMES = 0xE000, + // unsigned short submesh_index; + // float extremes [n_extremes][3]; + + /* Version 1.2 of the .mesh fornmat (deprecated) + enum MeshChunkID { + M_HEADER = 0x1000, + // char* version : Version number check + M_MESH = 0x3000, + // bool skeletallyAnimated // important flag which affects h/w buffer policies + // Optional M_GEOMETRY chunk + M_SUBMESH = 0x4000, + // char* materialName + // bool useSharedVertices + // unsigned int indexCount + // bool indexes32Bit + // unsigned int* faceVertexIndices (indexCount) + // OR + // unsigned short* faceVertexIndices (indexCount) + // M_GEOMETRY chunk (Optional: present only if useSharedVertices = false) + M_SUBMESH_OPERATION = 0x4010, // optional, trilist assumed if missing + // unsigned short operationType + M_SUBMESH_BONE_ASSIGNMENT = 0x4100, + // Optional bone weights (repeating section) + // unsigned int vertexIndex; + // unsigned short boneIndex; + // float weight; + M_GEOMETRY = 0x5000, // NB this chunk is embedded within M_MESH and M_SUBMESH + */ + // unsigned int vertexCount + // float* pVertices (x, y, z order x numVertices) + M_GEOMETRY_NORMALS = 0x5100, //(Optional) + // float* pNormals (x, y, z order x numVertices) + M_GEOMETRY_COLOURS = 0x5200, //(Optional) + // unsigned long* pColours (RGBA 8888 format x numVertices) + M_GEOMETRY_TEXCOORDS = 0x5300, //(Optional, REPEATABLE, each one adds an extra set) + // unsigned short dimensions (1 for 1D, 2 for 2D, 3 for 3D) + // float* pTexCoords (u [v] [w] order, dimensions x numVertices) + /* + M_MESH_SKELETON_LINK = 0x6000, + // Optional link to skeleton + // char* skeletonName : name of .skeleton to use + M_MESH_BONE_ASSIGNMENT = 0x7000, + // Optional bone weights (repeating section) + // unsigned int vertexIndex; + // unsigned short boneIndex; + // float weight; + M_MESH_LOD = 0x8000, + // Optional LOD information + // unsigned short numLevels; + // bool manual; (true for manual alternate meshes, false for generated) + M_MESH_LOD_USAGE = 0x8100, + // Repeating section, ordered in increasing depth + // NB LOD 0 (full detail from 0 depth) is omitted + // float fromSquaredDepth; + M_MESH_LOD_MANUAL = 0x8110, + // Required if M_MESH_LOD section manual = true + // String manualMeshName; + M_MESH_LOD_GENERATED = 0x8120, + // Required if M_MESH_LOD section manual = false + // Repeating section (1 per submesh) + // unsigned int indexCount; + // bool indexes32Bit + // unsigned short* faceIndexes; (indexCount) + // OR + // unsigned int* faceIndexes; (indexCount) + M_MESH_BOUNDS = 0x9000 + // float minx, miny, minz + // float maxx, maxy, maxz + // float radius + + // Added By DrEvil + // optional chunk that contains a table of submesh indexes and the names of + // the sub-meshes. + M_SUBMESH_NAME_TABLE, + // Subchunks of the name table. Each chunk contains an index & string + M_SUBMESH_NAME_TABLE_ELEMENT, + // short index + // char* name + + */ + }; +} // namespace + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreMeshManager.h b/school/informatik/verkerhssimulation/src/ogre/OgreMeshManager.h new file mode 100644 index 00000000..377da0bf --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreMeshManager.h @@ -0,0 +1,431 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __MeshManager_H__ +#define __MeshManager_H__ + +#include "OgrePrerequisites.h" + +#include "OgreResourceManager.h" +#include "OgreSingleton.h" +#include "OgreVector3.h" +#include "OgreHardwareBuffer.h" +#include "OgreMesh.h" +#include "OgrePatchMesh.h" + +namespace Ogre { + + /** Handles the management of mesh resources. + @remarks + This class deals with the runtime management of + mesh data; like other resource managers it handles + the creation of resources (in this case mesh data), + working within a fixed memory budget. + */ + class _OgreExport MeshManager: public ResourceManager, public Singleton, + public ManualResourceLoader + { + public: + MeshManager(); + ~MeshManager(); + + /** Initialises the manager, only to be called by OGRE internally. */ + void _initialise(void); + + /** Loads a mesh from a file, making it immediately available for use. + @note + If the model has already been loaded, the existing instance + will be returned. + @remarks + Ogre loads model files from it's own proprietary + format called .mesh. This is because having a single file + format is better for runtime performance, and we also have + control over pre-processed data (such as + collision boxes, LOD reductions etc). + @param filename The name of the .mesh file + @param groupName The name of the resource group to assign the mesh to + @param vertexBufferUsage The usage flags with which the vertex buffer(s) + will be created + @param indexBufferUsage The usage flags with which the index buffer(s) created for + this mesh will be created with. + @param vertexBufferShadowed If true, the vertex buffers will be shadowed by system memory + copies for faster read access + @param indexBufferShadowed If true, the index buffers will be shadowed by system memory + copies for faster read access + @param priority The priority of this mesh in the resource system + */ + MeshPtr load( const String& filename, const String& groupName, + HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, + HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, + bool vertexBufferShadowed = true, bool indexBufferShadowed = true); + + + /** Creates a new Mesh specifically for manual definition rather + than loading from an object file. + @remarks + Note that once you've defined your mesh, you must call Mesh::_setBounds and + Mesh::_setBoundingRadius in order to define the bounds of your mesh. In previous + versions of OGRE you could call Mesh::_updateBounds, but OGRE's support of + write-only vertex buffers makes this no longer appropriate. + @param name The name to give the new mesh + @param groupName The name of the resource group to assign the mesh to + @param loader ManualResourceLoader which will be called to load this mesh + when the time comes. It is recommended that you populate this field + in order that the mesh can be rebuilt should the need arise + */ + MeshPtr createManual( const String& name, const String& groupName, + ManualResourceLoader* loader = 0); + + /** Creates a basic plane, by default majoring on the x/y axes facing positive Z. + @param + name The name to give the resulting mesh + @param + groupName The name of the resource group to assign the mesh to + @param + plane The orientation of the plane and distance from the origin + @param + width The width of the plane in world coordinates + @param + height The height of the plane in world coordinates + @param + xsegments The number of segements to the plane in the x direction + @param + ysegments The number of segements to the plane in the y direction + @param + normals If true, normals are created perpendicular to the plane + @param + numTexCoordSets The number of 2D texture coordinate sets created - by default the corners + are created to be the corner of the texture. + @param + uTile The number of times the texture should be repeated in the u direction + @param + vTile The number of times the texture should be repeated in the v direction + @param + upVector The 'Up' direction of the plane. + @param + vertexBufferUsage The usage flag with which the vertex buffer for this plane will be created + @param + indexBufferUsage The usage flag with which the index buffer for this plane will be created + @param + vertexShadowBuffer If this flag is set to true, the vertex buffer will be created + with a system memory shadow buffer, + allowing you to read it back more efficiently than if it is in hardware + @param + indexShadowBuffer If this flag is set to true, the index buffer will be + created with a system memory shadow buffer, + allowing you to read it back more efficiently than if it is in hardware + */ + MeshPtr createPlane( + const String& name, const String& groupName, const Plane& plane, + Real width, Real height, + int xsegments = 1, int ysegments = 1, + bool normals = true, int numTexCoordSets = 1, + Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y, + HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, + HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, + bool vertexShadowBuffer = true, bool indexShadowBuffer = true); + + + /** Creates a plane, which because of it's texture coordinates looks like a curved + surface, useful for skies in a skybox. + @param + name The name to give the resulting mesh + @param + groupName The name of the resource group to assign the mesh to + @param + plane The orientation of the plane and distance from the origin + @param + width The width of the plane in world coordinates + @param + height The height of the plane in world coordinates + @param + curvature The curvature of the plane. Good values are + between 2 and 65. Higher values are more curved leading to + a smoother effect, lower values are less curved meaning + more distortion at the horizons but a better distance effect. + @param + xsegments The number of segements to the plane in the x direction + @param + ysegments The number of segements to the plane in the y direction + @param + normals If true, normals are created perpendicular to the plane + @param + numTexCoordSets The number of 2D texture coordinate sets created - by default the corners + are created to be the corner of the texture. + @param + uTile The number of times the texture should be repeated in the u direction + @param + vTile The number of times the texture should be repeated in the v direction + @param + upVector The 'Up' direction of the plane. + @param + orientation The orientation of the overall sphere that's used to create the illusion + @param + vertexBufferUsage The usage flag with which the vertex buffer for this plane will be created + @param + indexBufferUsage The usage flag with which the index buffer for this plane will be created + @param + vertexShadowBuffer If this flag is set to true, the vertex buffer will be created + with a system memory shadow buffer, + allowing you to read it back more efficiently than if it is in hardware + @param + indexShadowBuffer If this flag is set to true, the index buffer will be + created with a system memory shadow buffer, + allowing you to read it back more efficiently than if it is in hardware + @param ySegmentsToKeep The number of segments from the top of the dome + downwards to keep. -1 keeps all of them. This can save fillrate if + you cannot see much of the sky lower down. + */ + MeshPtr createCurvedIllusionPlane( + const String& name, const String& groupName, const Plane& plane, + Real width, Real height, Real curvature, + int xsegments = 1, int ysegments = 1, + bool normals = true, int numTexCoordSets = 1, + Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y, + const Quaternion& orientation = Quaternion::IDENTITY, + HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, + HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, + bool vertexShadowBuffer = true, bool indexShadowBuffer = true, + int ySegmentsToKeep = -1); + + /** Creates a genuinely curved plane, by default majoring on the x/y axes facing positive Z. + @param + name The name to give the resulting mesh + @param + groupName The name of the resource group to assign the mesh to + @param + plane The orientation of the plane and distance from the origin + @param + width The width of the plane in world coordinates + @param + height The height of the plane in world coordinates + @param + bow The amount of 'bow' in the curved plane. (Could also be concidered the depth.) + @param + xsegments The number of segements to the plane in the x direction + @param + ysegments The number of segements to the plane in the y direction + @param + normals If true, normals are created perpendicular to the plane + @param + numTexCoordSets The number of 2D texture coordinate sets created - by default the corners + are created to be the corner of the texture. + @param + uTile The number of times the texture should be repeated in the u direction + @param + vTile The number of times the texture should be repeated in the v direction + @param + upVector The 'Up' direction of the plane. + @param + vertexBufferUsage The usage flag with which the vertex buffer for this plane will be created + @param + indexBufferUsage The usage flag with which the index buffer for this plane will be created + @param + vertexShadowBuffer If this flag is set to true, the vertex buffer will be created + with a system memory shadow buffer, + allowing you to read it back more efficiently than if it is in hardware + @param + indexShadowBuffer If this flag is set to true, the index buffer will be + created with a system memory shadow buffer, + allowing you to read it back more efficiently than if it is in hardware + */ + MeshPtr createCurvedPlane( + const String& name, const String& groupName, const Plane& plane, + Real width, Real height, Real bow = 0.5f, + int xsegments = 1, int ysegments = 1, + bool normals = false, int numTexCoordSets = 1, + Real xTile = 1.0f, Real yTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y, + HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, + HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, + bool vertexShadowBuffer = true, bool indexShadowBuffer = true); + + /** Creates a Bezier patch based on an array of control vertices. + @param + name The name to give the newly created mesh. + @param + groupName The name of the resource group to assign the mesh to + @param + controlPointBuffer A pointer to a buffer containing the vertex data which defines control points + of the curves rather than actual vertices. Note that you are expected to provide not + just position information, but potentially normals and texture coordinates too. The + format of the buffer is defined in the VertexDeclaration parameter + @param + decaration VertexDeclaration describing the contents of the buffer. + Note this declaration must _only_ draw on buffer source 0! + @param + width Specifies the width of the patch in control points. + Note this parameter must greater than or equal to 3. + @param + height Specifies the height of the patch in control points. + Note this parameter must greater than or equal to 3. + @param + uMaxSubdivisionLevel,vMaxSubdivisionLevel If you want to manually set the top level of subdivision, + do it here, otherwise let the system decide. + @param + visibleSide Determines which side of the patch (or both) triangles are generated for. + @param + vbUsage Vertex buffer usage flags. Recommend the default since vertex buffer should be static. + @param + ibUsage Index buffer usage flags. Recommend the default since index buffer should + be dynamic to change levels but not readable. + @param + vbUseShadow Flag to determine if a shadow buffer is generated for the vertex buffer. See + HardwareBuffer for full details. + @param + ibUseShadow Flag to determine if a shadow buffer is generated for the index buffer. See + HardwareBuffer for full details. + */ + PatchMeshPtr createBezierPatch( + const String& name, const String& groupName, void* controlPointBuffer, + VertexDeclaration *declaration, size_t width, size_t height, + size_t uMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL, + size_t vMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL, + PatchSurface::VisibleSide visibleSide = PatchSurface::VS_FRONT, + HardwareBuffer::Usage vbUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, + HardwareBuffer::Usage ibUsage = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, + bool vbUseShadow = true, bool ibUseShadow = true); + + /** Tells the mesh manager that all future meshes should prepare themselves for + shadow volumes on loading. + */ + void setPrepareAllMeshesForShadowVolumes(bool enable); + /** Retrieves whether all Meshes should prepare themselves for shadow volumes. */ + bool getPrepareAllMeshesForShadowVolumes(void); + + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static MeshManager& getSingleton(void); + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static MeshManager* getSingletonPtr(void); + + /** Gets the factor by which the bounding box of an entity is padded. + Default is 0.01 + */ + Real getBoundsPaddingFactor(void); + + /** Sets the factor by which the bounding box of an entity is padded + */ + void setBoundsPaddingFactor(Real paddingFactor); + + /** @see ManualResourceLoader::loadResource */ + void loadResource(Resource* res); + + protected: + /// @copydoc ResourceManager::createImpl + Resource* createImpl(const String& name, ResourceHandle handle, + const String& group, bool isManual, ManualResourceLoader* loader, + const NameValuePairList* createParams); + + /** Utility method for tesselating 2D meshes. + */ + void tesselate2DMesh(SubMesh* pSub, int meshWidth, int meshHeight, + bool doubleSided = false, + HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, + bool indexSysMem = false); + + void createPrefabPlane(void); + void createPrefabCube(void); + void createPrefabSphere(void); + + /** Enum identifying the types of manual mesh built by this manager */ + enum MeshBuildType + { + MBT_PLANE, + MBT_CURVED_ILLUSION_PLANE, + MBT_CURVED_PLANE + }; + /** Saved parameters used to (re)build a manual mesh built by this class */ + struct MeshBuildParams + { + MeshBuildType type; + Plane plane; + Real width; + Real height; + Real curvature; + int xsegments; + int ysegments; + bool normals; + int numTexCoordSets; + Real xTile; + Real yTile; + Vector3 upVector; + Quaternion orientation; + HardwareBuffer::Usage vertexBufferUsage; + HardwareBuffer::Usage indexBufferUsage; + bool vertexShadowBuffer; + bool indexShadowBuffer; + int ySegmentsToKeep; + }; + /** Map from resource pointer to parameter set */ + typedef std::map MeshBuildParamsMap; + MeshBuildParamsMap mMeshBuildParams; + + /** Utility method for manual loading a plane */ + void loadManualPlane(Mesh* pMesh, MeshBuildParams& params); + /** Utility method for manual loading a curved plane */ + void loadManualCurvedPlane(Mesh* pMesh, MeshBuildParams& params); + /** Utility method for manual loading a curved illusion plane */ + void loadManualCurvedIllusionPlane(Mesh* pMesh, MeshBuildParams& params); + + bool mPrepAllMeshesForShadowVolumes; + + //the factor by which the bounding box of an entity is padded + Real mBoundsPaddingFactor; + }; + + +} //namespace + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreMeshSerializer.h b/school/informatik/verkerhssimulation/src/ogre/OgreMeshSerializer.h new file mode 100644 index 00000000..ccf7b966 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreMeshSerializer.h @@ -0,0 +1,99 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __MeshSerializer_H__ +#define __MeshSerializer_H__ + +#include "OgrePrerequisites.h" +#include "OgreMeshSerializerImpl.h" +#include "OgreSerializer.h" + +namespace Ogre { + + /** Class for serialising mesh data to/from an OGRE .mesh file. + @remarks + This class allows exporters to write OGRE .mesh files easily, and allows the + OGRE engine to import .mesh files into instatiated OGRE Meshes. + Note that a .mesh file can include not only the Mesh, but also definitions of + any Materials it uses (although this is optional, the .mesh can rely on the + Material being loaded from another source, especially useful if you want to + take advantage of OGRE's advanced Material properties which may not be available + in your modeller). + @par + To export a Mesh:
    +
  1. Use the MaterialManager methods to create any dependent Material objects, if you want + to export them with the Mesh.
  2. +
  3. Create a Mesh object and populate it using it's methods.
  4. +
  5. Call the exportMesh method
  6. +
+ @par + It's important to realise that this exporter uses OGRE terminology. In this context, + 'Mesh' means a top-level mesh structure which can actually contain many SubMeshes, each + of which has only one Material. Modelling packages may refer to these differently, for + example in Milkshape, it says 'Model' instead of 'Mesh' and 'Mesh' instead of 'SubMesh', + but the theory is the same. + */ + class _OgreExport MeshSerializer : public Serializer + { + public: + MeshSerializer(); + virtual ~MeshSerializer(); + + + /** Exports a mesh to the file specified. + @remarks + This method takes an externally created Mesh object, and exports both it + and optionally the Materials it uses to a .mesh file. + @param pMesh Pointer to the Mesh to export + @param filename The destination filename + @param endianMode The endian mode of the written file + */ + void exportMesh(const Mesh* pMesh, const String& filename, + Endian endianMode = ENDIAN_NATIVE); + + /** Imports Mesh and (optionally) Material data from a .mesh file DataStream. + @remarks + This method imports data from a DataStream opened from a .mesh file and places it's + contents into the Mesh object which is passed in. + @param stream The DataStream holding the .mesh data. Must be initialised (pos at the start of the buffer). + @param pDest Pointer to the Mesh object which will receive the data. Should be blank already. + */ + void importMesh(DataStreamPtr& stream, Mesh* pDest); + protected: + static String msCurrentVersion; + + typedef std::map MeshSerializerImplMap; + MeshSerializerImplMap mImplementations; + + }; + +} + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreMeshSerializerImpl.h b/school/informatik/verkerhssimulation/src/ogre/OgreMeshSerializerImpl.h new file mode 100644 index 00000000..c5d1330e --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreMeshSerializerImpl.h @@ -0,0 +1,218 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __MeshSerializerImpl_H__ +#define __MeshSerializerImpl_H__ + +#include "OgrePrerequisites.h" +#include "OgreString.h" +#include "OgreSerializer.h" +#include "OgreMaterial.h" +#include "OgreMesh.h" +#include "OgreEdgeListBuilder.h" + +namespace Ogre { + + + /** Internal implementation of Mesh reading / writing for the latest version of the + .mesh format. + @remarks + In order to maintain compatibility with older versions of the .mesh format, there + will be alternative subclasses of this class to load older versions, whilst this class + will remain to load the latest version. + */ + class _OgrePrivate MeshSerializerImpl : public Serializer + { + public: + MeshSerializerImpl(); + virtual ~MeshSerializerImpl(); + /** Exports a mesh to the file specified. + @remarks + This method takes an externally created Mesh object, and exports both it + and optionally the Materials it uses to a .mesh file. + @param pMesh Pointer to the Mesh to export + @param filename The destination filename + @param endianMode The endian mode for the written file + */ + void exportMesh(const Mesh* pMesh, const String& filename, + Endian endianMode = ENDIAN_NATIVE); + + /** Imports Mesh and (optionally) Material data from a .mesh file DataStream. + @remarks + This method imports data from a DataStream opened from a .mesh file and places it's + contents into the Mesh object which is passed in. + @param stream The DataStream holding the .mesh data. Must be initialised (pos at the start of the buffer). + @param pDest Pointer to the Mesh object which will receive the data. Should be blank already. + */ + void importMesh(DataStreamPtr& stream, Mesh* pDest); + + protected: + + // Internal methods + virtual void writeSubMeshNameTable(const Mesh* pMesh); + virtual void writeMesh(const Mesh* pMesh); + virtual void writeSubMesh(const SubMesh* s); + virtual void writeSubMeshOperation(const SubMesh* s); + virtual void writeSubMeshTextureAliases(const SubMesh* s); + virtual void writeGeometry(const VertexData* pGeom); + virtual void writeSkeletonLink(const String& skelName); + virtual void writeMeshBoneAssignment(const VertexBoneAssignment& assign); + virtual void writeSubMeshBoneAssignment(const VertexBoneAssignment& assign); + virtual void writeLodInfo(const Mesh* pMesh); + virtual void writeLodSummary(unsigned short numLevels, bool manual); + virtual void writeLodUsageManual(const MeshLodUsage& usage); + virtual void writeLodUsageGenerated(const Mesh* pMesh, const MeshLodUsage& usage, unsigned short lodNum); + virtual void writeBoundsInfo(const Mesh* pMesh); + virtual void writeEdgeList(const Mesh* pMesh); + virtual void writeAnimations(const Mesh* pMesh); + virtual void writeAnimation(const Animation* anim); + virtual void writePoses(const Mesh* pMesh); + virtual void writePose(const Pose* pose); + virtual void writeAnimationTrack(const VertexAnimationTrack* track); + virtual void writeMorphKeyframe(const VertexMorphKeyFrame* kf, size_t vertexCount); + virtual void writePoseKeyframe(const VertexPoseKeyFrame* kf); + virtual void writePoseKeyframePoseRef(const VertexPoseKeyFrame::PoseRef& poseRef); + virtual void writeExtremes(const Mesh *pMesh); + virtual void writeSubMeshExtremes(unsigned short idx, const SubMesh* s); + + virtual size_t calcMeshSize(const Mesh* pMesh); + virtual size_t calcSubMeshSize(const SubMesh* pSub); + virtual size_t calcGeometrySize(const VertexData* pGeom); + virtual size_t calcSkeletonLinkSize(const String& skelName); + virtual size_t calcBoneAssignmentSize(void); + virtual size_t calcSubMeshOperationSize(const SubMesh* pSub); + virtual size_t calcSubMeshNameTableSize(const Mesh* pMesh); + virtual size_t calcEdgeListSize(const Mesh* pMesh); + virtual size_t calcEdgeListLodSize(const EdgeData* data, bool isManual); + virtual size_t calcEdgeGroupSize(const EdgeData::EdgeGroup& group); + virtual size_t calcPosesSize(const Mesh* pMesh); + virtual size_t calcPoseSize(const Pose* pose); + virtual size_t calcAnimationsSize(const Mesh* pMesh); + virtual size_t calcAnimationSize(const Animation* anim); + virtual size_t calcAnimationTrackSize(const VertexAnimationTrack* track); + virtual size_t calcMorphKeyframeSize(const VertexMorphKeyFrame* kf, size_t vertexCount); + virtual size_t calcPoseKeyframeSize(const VertexPoseKeyFrame* kf); + virtual size_t calcPoseKeyframePoseRefSize(void); + virtual size_t calcPoseVertexSize(void); + virtual size_t calcSubMeshTextureAliasesSize(const SubMesh* pSub); + + + virtual void readTextureLayer(DataStreamPtr& stream, Mesh* pMesh, MaterialPtr& pMat); + virtual void readSubMeshNameTable(DataStreamPtr& stream, Mesh* pMesh); + virtual void readMesh(DataStreamPtr& stream, Mesh* pMesh); + virtual void readSubMesh(DataStreamPtr& stream, Mesh* pMesh); + virtual void readSubMeshOperation(DataStreamPtr& stream, Mesh* pMesh, SubMesh* sub); + virtual void readSubMeshTextureAlias(DataStreamPtr& stream, Mesh* pMesh, SubMesh* sub); + virtual void readGeometry(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest); + virtual void readGeometryVertexDeclaration(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest); + virtual void readGeometryVertexElement(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest); + virtual void readGeometryVertexBuffer(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest); + + virtual void readSkeletonLink(DataStreamPtr& stream, Mesh* pMesh); + virtual void readMeshBoneAssignment(DataStreamPtr& stream, Mesh* pMesh); + virtual void readSubMeshBoneAssignment(DataStreamPtr& stream, Mesh* pMesh, + SubMesh* sub); + virtual void readMeshLodInfo(DataStreamPtr& stream, Mesh* pMesh); + virtual void readMeshLodUsageManual(DataStreamPtr& stream, Mesh* pMesh, + unsigned short lodNum, MeshLodUsage& usage); + virtual void readMeshLodUsageGenerated(DataStreamPtr& stream, Mesh* pMesh, + unsigned short lodNum, MeshLodUsage& usage); + virtual void readBoundsInfo(DataStreamPtr& stream, Mesh* pMesh); + virtual void readEdgeList(DataStreamPtr& stream, Mesh* pMesh); + virtual void readEdgeListLodInfo(DataStreamPtr& stream, EdgeData* edgeData); + virtual void readPoses(DataStreamPtr& stream, Mesh* pMesh); + virtual void readPose(DataStreamPtr& stream, Mesh* pMesh); + virtual void readAnimations(DataStreamPtr& stream, Mesh* pMesh); + virtual void readAnimation(DataStreamPtr& stream, Mesh* pMesh); + virtual void readAnimationTrack(DataStreamPtr& stream, Animation* anim, + Mesh* pMesh); + virtual void readMorphKeyFrame(DataStreamPtr& stream, VertexAnimationTrack* track); + virtual void readPoseKeyFrame(DataStreamPtr& stream, VertexAnimationTrack* track); + virtual void readExtremes(DataStreamPtr& stream, Mesh *pMesh); + + + /// Flip an entire vertex buffer from little endian + virtual void flipFromLittleEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems); + /// Flip an entire vertex buffer to little endian + virtual void flipToLittleEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems); + /// Flip the endianness of an entire vertex buffer, passed in as a + /// pointer to locked or temporary memory + virtual void flipEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems); + + + + }; + + /** Class for providing backwards-compatibility for loading version 1.3 of the .mesh format. */ + class _OgrePrivate MeshSerializerImpl_v1_3 : public MeshSerializerImpl + { + public: + MeshSerializerImpl_v1_3(); + ~MeshSerializerImpl_v1_3(); + protected: + virtual void readEdgeListLodInfo(DataStreamPtr& stream, EdgeData* edgeData); + + /// Reorganise triangles of the edge list to group by vertex set + virtual void reorganiseTriangles(EdgeData* edgeData); + }; + + /** Class for providing backwards-compatibility for loading version 1.2 of the .mesh format. */ + class _OgrePrivate MeshSerializerImpl_v1_2 : public MeshSerializerImpl_v1_3 + { + public: + MeshSerializerImpl_v1_2(); + ~MeshSerializerImpl_v1_2(); + protected: + virtual void readMesh(DataStreamPtr& stream, Mesh* pMesh); + virtual void readGeometry(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest); + virtual void readGeometryPositions(unsigned short bindIdx, DataStreamPtr& stream, + Mesh* pMesh, VertexData* dest); + virtual void readGeometryNormals(unsigned short bindIdx, DataStreamPtr& stream, + Mesh* pMesh, VertexData* dest); + virtual void readGeometryColours(unsigned short bindIdx, DataStreamPtr& stream, + Mesh* pMesh, VertexData* dest); + virtual void readGeometryTexCoords(unsigned short bindIdx, DataStreamPtr& stream, + Mesh* pMesh, VertexData* dest, unsigned short set); + }; + + /** Class for providing backwards-compatibility for loading version 1.1 of the .mesh format. */ + class _OgrePrivate MeshSerializerImpl_v1_1 : public MeshSerializerImpl_v1_2 + { + public: + MeshSerializerImpl_v1_1(); + ~MeshSerializerImpl_v1_1(); + protected: + void readGeometryTexCoords(unsigned short bindIdx, DataStreamPtr& stream, + Mesh* pMesh, VertexData* dest, unsigned short set); + }; + + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreMovableObject.h b/school/informatik/verkerhssimulation/src/ogre/OgreMovableObject.h new file mode 100644 index 00000000..3474972a --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreMovableObject.h @@ -0,0 +1,530 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __MovableObject_H__ +#define __MovableObject_H__ + +// Precompiler options +#include "OgrePrerequisites.h" +#include "OgreRenderQueue.h" +#include "OgreAxisAlignedBox.h" +#include "OgreSphere.h" +#include "OgreShadowCaster.h" +#include "OgreFactoryObj.h" +#include "OgreAnimable.h" +#include "OgreAny.h" +#include "OgreUserDefinedObject.h" + +namespace Ogre { + + // Forward declaration + class MovableObjectFactory; + + /** Abstract class definining a movable object in a scene. + @remarks + Instances of this class are discrete, relatively small, movable objects + which are attached to SceneNode objects to define their position. + */ + class _OgreExport MovableObject : public ShadowCaster, public AnimableObject + { + public: + /** Listener which gets called back on MovableObject events. + */ + class _OgreExport Listener + { + public: + Listener(void) {} + virtual ~Listener() {} + /** MovableObject is being destroyed */ + virtual void objectDestroyed(MovableObject*) {} + /** MovableObject has been attached to a node */ + virtual void objectAttached(MovableObject*) {} + /** MovableObject has been detached from a node */ + virtual void objectDetached(MovableObject*) {} + /** MovableObject has been moved */ + virtual void objectMoved(MovableObject*) {} + /** Called when the movable object of the camera to be used for rendering. + @returns + true if allows queue for rendering, false otherwise. + */ + virtual bool objectRendering(const MovableObject*, const Camera*) { return true; } + /** Called when the movable object needs to query a light list. + @remarks + If you want to customize light finding for this object, you should override + this method and hook into MovableObject via MovableObject::setListener. + Be aware that the default method caches results within a frame to + prevent unnecessary recalculation, so if you override this you + should provide your own cacheing to maintain performance. + @note + If you use texture shadows, there is an additional restriction - + since the lights which should have shadow textures rendered for + them are determined based on the entire frustum, and not per-object, + it is important that the lights returned at the start of this + list (up to the number of shadow textures available) are the same + lights that were used to generate the shadow textures, + and they are in the same order (particularly for additive effects). + @returns + A pointer to a light list if you populated the light list yourself, or + NULL to fall back on the default finding process. + */ + virtual const LightList* objectQueryLights(const MovableObject*) { return 0; } + }; + + protected: + /// Name of this object + String mName; + /// Creator of this object (if created by a factory) + MovableObjectFactory* mCreator; + /// SceneManager holding this object (if applicable) + SceneManager* mManager; + /// node to which this object is attached + Node* mParentNode; + bool mParentIsTagPoint; + /// Is this object visible? + bool mVisible; + /// Upper distance to still render + Real mUpperDistance; + Real mSquaredUpperDistance; + /// Hidden because of distance? + bool mBeyondFarDistance; + /// User defined link to another object / value / whatever + Any mUserAny; + /// The render queue to use when rendering this object + uint8 mRenderQueueID; + /// Flags whether the RenderQueue's default should be used. + bool mRenderQueueIDSet; + /// Flags determining whether this object is included / excluded from scene queries + uint32 mQueryFlags; + /// Flags determining whether this object is visible (compared to SceneManager mask) + uint32 mVisibilityFlags; + /// Cached world AABB of this object + mutable AxisAlignedBox mWorldAABB; + // Cached world bounding sphere + mutable Sphere mWorldBoundingSphere; + /// World space AABB of this object's dark cap + mutable AxisAlignedBox mWorldDarkCapBounds; + /// Does this object cast shadows? + bool mCastShadows; + + /// Does rendering this object disabled by listener? + bool mRenderingDisabled; + /// MovableObject listener - only one allowed (no list) for size & performance reasons. */ + Listener* mListener; + + /// List of lights for this object + mutable LightList mLightList; + /// The last frame that this light list was updated in + mutable ulong mLightListUpdated; + + // Static members + /// Default query flags + static uint32 msDefaultQueryFlags; + /// Default visibility flags + static uint32 msDefaultVisibilityFlags; + + + + public: + /// Constructor + MovableObject(); + + /// Named constructor + MovableObject(const String& name); + /** Virtual destructor - read Scott Meyers if you don't know why this is needed. + */ + virtual ~MovableObject(); + + /** Notify the object of it's creator (internal use only) */ + virtual void _notifyCreator(MovableObjectFactory* fact) { mCreator = fact; } + /** Get the creator of this object, if any (internal use only) */ + virtual MovableObjectFactory* _getCreator(void) const { return mCreator; } + /** Notify the object of it's manager (internal use only) */ + virtual void _notifyManager(SceneManager* man) { mManager = man; } + /** Get the manager of this object, if any (internal use only) */ + virtual SceneManager* _getManager(void) const { return mManager; } + + /** Returns the name of this object. */ + virtual const String& getName(void) const { return mName; } + + /** Returns the type name of this object. */ + virtual const String& getMovableType(void) const = 0; + + /** Returns the node to which this object is attached. + @remarks + A MovableObject may be attached to either a SceneNode or to a TagPoint, + the latter case if it's attached to a bone on an animated entity. + Both are Node subclasses so this method will return either. + */ + virtual Node* getParentNode(void) const; + + /** Returns the scene node to which this object is attached. + @remarks + A MovableObject may be attached to either a SceneNode or to a TagPoint, + the latter case if it's attached to a bone on an animated entity. + This method will return the scene node of the parent entity + if the latter is true. + */ + virtual SceneNode* getParentSceneNode(void) const; + + /** Internal method called to notify the object that it has been attached to a node. + */ + virtual void _notifyAttached(Node* parent, bool isTagPoint = false); + + /** Returns true if this object is attached to a SceneNode or TagPoint. */ + virtual bool isAttached(void) const; + + /** Returns true if this object is attached to a SceneNode or TagPoint, + and this SceneNode / TagPoint is currently in an active part of the + scene graph. */ + virtual bool isInScene(void) const; + + /** Internal method called to notify the object that it has been moved. + */ + virtual void _notifyMoved(void); + + /** Internal method to notify the object of the camera to be used for the next rendering operation. + @remarks + Certain objects may want to do specific processing based on the camera position. This method notifies + them incase they wish to do this. + */ + virtual void _notifyCurrentCamera(Camera* cam); + + /** Retrieves the local axis-aligned bounding box for this object. + @remarks + This bounding box is in local coordinates. + */ + virtual const AxisAlignedBox& getBoundingBox(void) const = 0; + + /** Retrieves the radius of the origin-centered bounding sphere + for this object. + */ + virtual Real getBoundingRadius(void) const = 0; + + /** Retrieves the axis-aligned bounding box for this object in world coordinates. */ + virtual const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const; + /** Retrieves the worldspace bounding sphere for this object. */ + virtual const Sphere& getWorldBoundingSphere(bool derive = false) const; + /** Internal method by which the movable object must add Renderable subclass instances to the rendering queue. + @remarks + The engine will call this method when this object is to be rendered. The object must then create one or more + Renderable subclass instances which it places on the passed in Queue for rendering. + */ + virtual void _updateRenderQueue(RenderQueue* queue) = 0; + + /** Tells this object whether to be visible or not, if it has a renderable component. + @note An alternative approach of making an object invisible is to detach it + from it's SceneNode, or to remove the SceneNode entirely. + Detaching a node means that structurally the scene graph changes. + Once this change has taken place, the objects / nodes that have been + removed have less overhead to the visbility detection pass than simply + making the object invisible, so if you do this and leave the objects + out of the tree for a long time, it's faster. However, the act of + detaching / reattaching nodes is in itself more expensive than + setting an object visibility flag, since in the latter case + structural changes are not made. Therefore, small or frequent visbility + changes are best done using this method; large or more longer term + changes are best done by detaching. + */ + virtual void setVisible(bool visible); + + /** Gets this object whether to be visible or not, if it has a renderable component. + @remarks + Returns the value set by MovableObject::setVisible only. + */ + virtual bool getVisible(void) const; + + /** Returns whether or not this object is supposed to be visible or not. + @remarks + Takes into account both upper rendering distance and visible flag. + */ + virtual bool isVisible(void) const; + + /** Sets the distance at which the object is no longer rendered. + @param dist Distance beyond which the object will not be rendered + (the default is 0, which means objects are always rendered). + */ + virtual void setRenderingDistance(Real dist) { + mUpperDistance = dist; + mSquaredUpperDistance = mUpperDistance * mUpperDistance; + } + + /** Gets the distance at which batches are no longer rendered. */ + virtual Real getRenderingDistance(void) const { return mUpperDistance; } + + /** Call this to associate your own custom user object instance with this MovableObject. + @remarks + By simply making your game / application object a subclass of UserDefinedObject, you + can establish a link between an OGRE instance of MovableObject and your own application + classes. Call this method to establish the link. + */ + virtual void setUserObject(UserDefinedObject* obj) { mUserAny = Any(obj); } + /** Retrieves a pointer to a custom application object associated with this movable by an earlier + call to setUserObject. + */ + virtual UserDefinedObject* getUserObject(void) + { + return mUserAny.isEmpty() ? 0 : any_cast(mUserAny); + } + + /** Sets any kind of user value on this object. + @remarks + This method allows you to associate any user value you like with + this MovableObject. This can be a pointer back to one of your own + classes for instance. + @note This value is shared with setUserObject so don't use both! + */ + virtual void setUserAny(const Any& anything) { mUserAny = anything; } + + /** Retrieves the custom user value associated with this object. + */ + virtual const Any& getUserAny(void) const { return mUserAny; } + + /** Sets the render queue group this entity will be rendered through. + @remarks + Render queues are grouped to allow you to more tightly control the ordering + of rendered objects. If you do not call this method, all Entity objects default + to the default queue (RenderQueue::getDefaultQueueGroup), which is fine for most objects. You may want to alter this + if you want this entity to always appear in front of other objects, e.g. for + a 3D menu system or such. + @par + See RenderQueue for more details. + @param queueID Enumerated value of the queue group to use. + */ + virtual void setRenderQueueGroup(uint8 queueID); + + /** Gets the queue group for this entity, see setRenderQueueGroup for full details. */ + virtual uint8 getRenderQueueGroup(void) const; + + /// return the full transformation of the parent sceneNode or the attachingPoint node + virtual const Matrix4& _getParentNodeFullTransform(void) const; + + /** Sets the query flags for this object. + @remarks + When performing a scene query, this object will be included or excluded according + to flags on the object and flags on the query. This is a bitwise value, so only when + a bit on these flags is set, will it be included in a query asking for that flag. The + meaning of the bits is application-specific. + */ + virtual void setQueryFlags(uint32 flags) { mQueryFlags = flags; } + + /** As setQueryFlags, except the flags passed as parameters are appended to the + existing flags on this object. */ + virtual void addQueryFlags(uint32 flags) { mQueryFlags |= flags; } + + /** As setQueryFlags, except the flags passed as parameters are removed from the + existing flags on this object. */ + virtual void removeQueryFlags(unsigned long flags) { mQueryFlags &= ~flags; } + + /// Returns the query flags relevant for this object + virtual uint32 getQueryFlags(void) const { return mQueryFlags; } + + /** Set the default query flags for all future MovableObject instances. + */ + static void setDefaultQueryFlags(uint32 flags) { msDefaultQueryFlags = flags; } + + /** Get the default query flags for all future MovableObject instances. + */ + static uint32 getDefaultQueryFlags() { return msDefaultQueryFlags; } + + + /** Sets the visiblity flags for this object. + @remarks + As well as a simple true/false value for visibility (as seen in setVisible), + you can also set visiblity flags which when 'and'ed with the SceneManager's + visibility mask can also make an object invisible. + */ + virtual void setVisibilityFlags(uint32 flags) { mVisibilityFlags = flags; } + + /** As setVisibilityFlags, except the flags passed as parameters are appended to the + existing flags on this object. */ + virtual void addVisibilityFlags(uint32 flags) { mVisibilityFlags |= flags; } + + /** As setVisibilityFlags, except the flags passed as parameters are removed from the + existing flags on this object. */ + virtual void removeVisibilityFlags(uint32 flags) { mVisibilityFlags &= ~flags; } + + /// Returns the visibility flags relevant for this object + virtual uint32 getVisibilityFlags(void) const { return mVisibilityFlags; } + + /** Set the default visibility flags for all future MovableObject instances. + */ + static void setDefaultVisibilityFlags(uint32 flags) { msDefaultVisibilityFlags = flags; } + + /** Get the default visibility flags for all future MovableObject instances. + */ + static uint32 getDefaultVisibilityFlags() { return msDefaultVisibilityFlags; } + + /** Sets a listener for this object. + @remarks + Note for size and performance reasons only one listener per object + is allowed. + */ + virtual void setListener(Listener* listener) { mListener = listener; } + + /** Gets the current listener for this object. + */ + virtual Listener* getListener(void) const { return mListener; } + + /** Gets a list of lights, ordered relative to how close they are to this movable object. + @remarks + By default, this method gives the listener a chance to populate light list first, + if there is no listener or Listener::objectQueryLights returns NULL, it'll + query the light list from parent entity if it is present, or returns + SceneNode::findLights if it has parent scene node, otherwise it just returns + an empty list. + @par + The object internally caches the light list, so it will recalculate + it only when object is moved, or lights that affect the frustum have + been changed (@see SceneManager::_getLightsDirtyCounter), + but if listener exists, it will be called each time, so the listener + should implement their own cache mechanism to optimise performance. + @par + This method can be useful when implementing Renderable::getLights in case + the renderable is a part of the movable. + @returns The list of lights use to lighting this object. + */ + virtual const LightList& queryLights(void) const; + + /// Define a default implementation of method from ShadowCaster which implements no shadows + EdgeData* getEdgeList(void) { return NULL; } + /// Define a default implementation of method from ShadowCaster which implements no shadows + bool hasEdgeList(void) { return false; } + /// Define a default implementation of method from ShadowCaster which implements no shadows + ShadowRenderableListIterator getShadowVolumeRenderableIterator( + ShadowTechnique shadowTechnique, const Light* light, + HardwareIndexBufferSharedPtr* indexBuffer, + bool extrudeVertices, Real extrusionDist, unsigned long flags = 0); + + /** Overridden member from ShadowCaster. */ + const AxisAlignedBox& getLightCapBounds(void) const; + /** Overridden member from ShadowCaster. */ + const AxisAlignedBox& getDarkCapBounds(const Light& light, Real dirLightExtrusionDist) const; + /** Sets whether or not this object will cast shadows. + @remarks + This setting simply allows you to turn on/off shadows for a given object. + An object will not cast shadows unless the scene supports it in any case + (see SceneManager::setShadowTechnique), and also the material which is + in use must also have shadow casting enabled. By default all entities cast + shadows. If, however, for some reason you wish to disable this for a single + object then you can do so using this method. + @note This method normally refers to objects which block the light, but + since Light is also a subclass of MovableObject, in that context it means + whether the light causes shadows itself. + */ + void setCastShadows(bool enabled) { mCastShadows = enabled; } + /** Returns whether shadow casting is enabled for this object. */ + bool getCastShadows(void) const { return mCastShadows; } + /** Get the distance to extrude for a point/spot light */ + Real getPointExtrusionDistance(const Light* l) const; + /** Get the 'type flags' for this MovableObject. + @remarks + A type flag identifies the type of the MovableObject as a bitpattern. + This is used for categorical inclusion / exclusion in SceneQuery + objects. By default, this method returns all ones for objects not + created by a MovableObjectFactory (hence always including them); + otherwise it returns the value assigned to the MovableObjectFactory. + Custom objects which don't use MovableObjectFactory will need to + override this if they want to be included in queries. + */ + virtual uint32 getTypeFlags(void) const; + + + + + + }; + + /** Interface definition for a factory class which produces a certain + kind of MovableObject, and can be registered with Root in order + to allow all clients to produce new instances of this object, integrated + with the standard Ogre processing. + */ + class _OgreExport MovableObjectFactory + { + protected: + /// Type flag, allocated if requested + unsigned long mTypeFlag; + + /// Internal implementation of create method - must be overridden + virtual MovableObject* createInstanceImpl( + const String& name, const NameValuePairList* params = 0) = 0; + public: + MovableObjectFactory() : mTypeFlag(0xFFFFFFFF) {} + virtual ~MovableObjectFactory() {} + /// Get the type of the object to be created + virtual const String& getType(void) const = 0; + + /** Create a new instance of the object. + @param name The name of the new object + @param manager The SceneManager instance that will be holding the + instance once created. + @param params Name/value pair list of additional parameters required to + construct the object (defined per subtype). Optional. + */ + virtual MovableObject* createInstance( + const String& name, SceneManager* manager, + const NameValuePairList* params = 0); + /** Destroy an instance of the object */ + virtual void destroyInstance(MovableObject* obj) = 0; + + /** Does this factory require the allocation of a 'type flag', used to + selectively include / exclude this type from scene queries? + @remarks + The default implementation here is to return 'false', ie not to + request a unique type mask from Root. For objects that + never need to be excluded in SceneQuery results, that's fine, since + the default implementation of MovableObject::getTypeFlags is to return + all ones, hence matching any query type mask. However, if you want the + objects created by this factory to be filterable by queries using a + broad type, you have to give them a (preferably unique) type mask - + and given that you don't know what other MovableObject types are + registered, Root will allocate you one. + */ + virtual bool requestTypeFlags(void) const { return false; } + /** Notify this factory of the type mask to apply. + @remarks + This should normally only be called by Root in response to + a 'true' result from requestTypeMask. However, you can actually use + it yourself if you're careful; for example to assign the same mask + to a number of different types of object, should you always wish them + to be treated the same in queries. + */ + void _notifyTypeFlags(unsigned long flag) { mTypeFlag = flag; } + + /** Gets the type flag for this factory. + @remarks + A type flag is like a query flag, except that it applies to all instances + of a certain type of object. + */ + unsigned long getTypeFlags(void) const { return mTypeFlag; } + + }; + +} +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreMovablePlane.h b/school/informatik/verkerhssimulation/src/ogre/OgreMovablePlane.h new file mode 100644 index 00000000..48b8da97 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreMovablePlane.h @@ -0,0 +1,87 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +// Original free version by: +// Magic Software, Inc. +// http://www.geometrictools.com/ +// Copyright (c) 2000, All Rights Reserved + +#ifndef __MovablePlane_H__ +#define __MovablePlane_H__ + +#include "OgrePrerequisites.h" + +#include "OgrePlane.h" +#include "OgreMovableObject.h" + +namespace Ogre { + + + /** Definition of a Plane that may be attached to a node, and the derived + details of it retrieved simply. + @remarks + This plane is not here for rendering purposes, it's to allow you to attach + planes to the scene in order to have them move and follow nodes on their + own, which is useful if you're using the plane for some kind of calculation, + e.g. reflection. + */ + class _OgreExport MovablePlane : public Plane, public MovableObject + { + protected: + mutable Plane mDerivedPlane; + mutable Vector3 mLastTranslate; + mutable Quaternion mLastRotate; + AxisAlignedBox mNullBB; + mutable bool mDirty; + static String msMovableType; + public: + + MovablePlane(const String& name); + MovablePlane (const Plane& rhs); + /** Construct a plane through a normal, and a distance to move the plane along the normal.*/ + MovablePlane (const Vector3& rkNormal, Real fConstant); + MovablePlane (const Vector3& rkNormal, const Vector3& rkPoint); + MovablePlane (const Vector3& rkPoint0, const Vector3& rkPoint1, + const Vector3& rkPoint2); + ~MovablePlane() {} + /// Overridden from MovableObject + void _notifyCurrentCamera(Camera*) { /* don't care */ } + /// Overridden from MovableObject + const AxisAlignedBox& getBoundingBox(void) const { return mNullBB; } + /// Overridden from MovableObject + Real getBoundingRadius(void) const { return Math::POS_INFINITY; } + /// Overridden from MovableObject + void _updateRenderQueue(RenderQueue*) { /* do nothing */} + /// Overridden from MovableObject + const String& getMovableType(void) const; + /// Get the derived plane as transformed by its parent node. + const Plane& _getDerivedPlane(void) const; + + }; +} +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreNoMemoryMacros.h b/school/informatik/verkerhssimulation/src/ogre/OgreNoMemoryMacros.h new file mode 100644 index 00000000..fa2f41ab --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreNoMemoryMacros.h @@ -0,0 +1,42 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +//----------------------------------------------------------------------------- +// If you want to use the real C(++) *alloc/free/new/delete functions, you must +// include this header before the section that uses them. +#ifdef OGRE_MEMORY_MACROS +#undef OGRE_MEMORY_MACROS +#undef new +#undef delete +#undef malloc +#undef calloc +#undef realloc +#undef free +#endif +//----------------------------------------------------------------------------- diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreNode.h b/school/informatik/verkerhssimulation/src/ogre/OgreNode.h new file mode 100644 index 00000000..7a4606ac --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreNode.h @@ -0,0 +1,736 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _Node_H__ +#define _Node_H__ + +#include "OgrePrerequisites.h" + +#include "OgreMatrix3.h" +#include "OgreMatrix4.h" +#include "OgreQuaternion.h" +#include "OgreString.h" +#include "OgreRenderable.h" +#include "OgreIteratorWrappers.h" + +namespace Ogre { + + + /** Class representing a general-purpose node an articulated scene graph. + @remarks + A node in the scene graph is a node in a structured tree. A node contains + information about the transformation which will apply to + it and all of it's children. Child nodes can have transforms of their own, which + are combined with their parent's transformations. + @par + This is an abstract class - concrete classes are based on this for specific purposes, + e.g. SceneNode, Bone + */ + class _OgreExport Node : public Renderable + { + public: + /** Enumeration denoting the spaces which a transform can be relative to. + */ + enum TransformSpace + { + /// Transform is relative to the local space + TS_LOCAL, + /// Transform is relative to the space of the parent node + TS_PARENT, + /// Transform is relative to world space + TS_WORLD + }; + typedef HashMap ChildNodeMap; + typedef MapIterator ChildNodeIterator; + typedef ConstMapIterator ConstChildNodeIterator; + + /** Listener which gets called back on Node events. + */ + class _OgreExport Listener + { + public: + Listener() {} + virtual ~Listener() {} + /** Called when a node gets updated. + @remarks + Note that this happens when the node's derived update happens, + not every time a method altering it's state occurs. There may + be several state-changing calls but only one of these calls, + when the node graph is fully updated. + */ + virtual void nodeUpdated(const Node*) {} + /** Node is being destroyed */ + virtual void nodeDestroyed(const Node*) {}; + /** Node has been attached to a parent */ + virtual void nodeAttached(const Node*) {}; + /** Node has been detached from a parent */ + virtual void nodeDetached(const Node*) {}; + }; + + protected: + /// Pointer to parent node + Node* mParent; + /// Collection of pointers to direct children; hashmap for efficiency + ChildNodeMap mChildren; + + typedef std::set ChildUpdateSet; + /// List of children which need updating, used if self is not out of date but children are + mutable ChildUpdateSet mChildrenToUpdate; + /// Flag to indicate own transform from parent is out of date + mutable bool mNeedParentUpdate; + /// Flag indicating that all children need to be updated + mutable bool mNeedChildUpdate; + /// Flag indicating that parent has been notified about update request + mutable bool mParentNotified ; + /// Flag indicating that the node has been queued for update + mutable bool mQueuedForUpdate; + + /// Friendly name of this node, can be automatically generated if you don't care + String mName; + + /// Incremented count for next name extension + static unsigned long msNextGeneratedNameExt; + + /// Stores the orientation of the node relative to it's parent. + Quaternion mOrientation; + + /// Stores the position/translation of the node relative to its parent. + Vector3 mPosition; + + /// Stores the scaling factor applied to this node + Vector3 mScale; + + /// Stores whether this node inherits orientation from it's parent + bool mInheritOrientation; + + /// Stores whether this node inherits scale from it's parent + bool mInheritScale; + + /// Material pointer should this node be rendered + mutable MaterialPtr mpMaterial; + + /// Only available internally - notification of parent. + virtual void setParent(Node* parent); + + /** Cached combined orientation. + @par + This member is the orientation derived by combining the + local transformations and those of it's parents. + This is updated when _updateFromParent is called by the + SceneManager or the nodes parent. + */ + mutable Quaternion mDerivedOrientation; + + /** Cached combined position. + @par + This member is the position derived by combining the + local transformations and those of it's parents. + This is updated when _updateFromParent is called by the + SceneManager or the nodes parent. + */ + mutable Vector3 mDerivedPosition; + + /** Cached combined scale. + @par + This member is the position derived by combining the + local transformations and those of it's parents. + This is updated when _updateFromParent is called by the + SceneManager or the nodes parent. + */ + mutable Vector3 mDerivedScale; + + /** Triggers the node to update it's combined transforms. + @par + This method is called internally by Ogre to ask the node + to update it's complete transformation based on it's parents + derived transform. + */ + virtual void _updateFromParent(void) const; + + /** Class-specific implementation of _updateFromParent. + @remarks + Splitting the implementation of the update away from the update call + itself allows the detail to be overridden without disrupting the + general sequence of updateFromParent (e.g. raising events) + */ + virtual void updateFromParentImpl(void) const; + + + /** Internal method for creating a new child node - must be overridden per subclass. */ + virtual Node* createChildImpl(void) = 0; + + /** Internal method for creating a new child node - must be overridden per subclass. */ + virtual Node* createChildImpl(const String& name) = 0; + + /// The position to use as a base for keyframe animation + Vector3 mInitialPosition; + /// The orientation to use as a base for keyframe animation + Quaternion mInitialOrientation; + /// The scale to use as a base for keyframe animation + Vector3 mInitialScale; + + /// Cached derived transform as a 4x4 matrix + mutable Matrix4 mCachedTransform; + mutable bool mCachedTransformOutOfDate; + + /** Node listener - only one allowed (no list) for size & performance reasons. */ + Listener* mListener; + + typedef std::vector QueuedUpdates; + static QueuedUpdates msQueuedUpdates; + + + public: + /** Constructor, should only be called by parent, not directly. + @remarks + Generates a name. + */ + Node(); + /** Constructor, should only be called by parent, not directly. + @remarks + Assigned a name. + */ + Node(const String& name); + + virtual ~Node(); + + /** Returns the name of the node. */ + const String& getName(void) const; + + /** Gets this node's parent (NULL if this is the root). + */ + virtual Node* getParent(void) const; + + /** Returns a quaternion representing the nodes orientation. + */ + virtual const Quaternion & getOrientation() const; + + /** Sets the orientation of this node via a quaternion. + @remarks + Orientatings, unlike other transforms, are not always inherited by child nodes. + Whether or not orientatings affect the orientation of the child nodes depends on + the setInheritOrientation option of the child. In some cases you want a orientating + of a parent node to apply to a child node (e.g. where the child node is a part of + the same object, so you want it to be the same relative orientation based on the + parent's orientation), but not in other cases (e.g. where the child node is just + for positioning another object, you want it to maintain it's own orientation). + The default is to inherit as with other transforms. + @par + Note that rotations are oriented around the node's origin. + */ + virtual void setOrientation( const Quaternion& q ); + + /** Sets the orientation of this node via quaternion parameters. + @remarks + Orientatings, unlike other transforms, are not always inherited by child nodes. + Whether or not orientatings affect the orientation of the child nodes depends on + the setInheritOrientation option of the child. In some cases you want a orientating + of a parent node to apply to a child node (e.g. where the child node is a part of + the same object, so you want it to be the same relative orientation based on the + parent's orientation), but not in other cases (e.g. where the child node is just + for positioning another object, you want it to maintain it's own orientation). + The default is to inherit as with other transforms. + @par + Note that rotations are oriented around the node's origin. + */ + virtual void setOrientation( Real w, Real x, Real y, Real z); + + /** Resets the nodes orientation (local axes as world axes, no rotation). + @remarks + Orientatings, unlike other transforms, are not always inherited by child nodes. + Whether or not orientatings affect the orientation of the child nodes depends on + the setInheritOrientation option of the child. In some cases you want a orientating + of a parent node to apply to a child node (e.g. where the child node is a part of + the same object, so you want it to be the same relative orientation based on the + parent's orientation), but not in other cases (e.g. where the child node is just + for positioning another object, you want it to maintain it's own orientation). + The default is to inherit as with other transforms. + @par + Note that rotations are oriented around the node's origin. + */ + virtual void resetOrientation(void); + + /** Sets the position of the node relative to it's parent. + */ + virtual void setPosition(const Vector3& pos); + + /** Sets the position of the node relative to it's parent. + */ + virtual void setPosition(Real x, Real y, Real z); + + /** Gets the position of the node relative to it's parent. + */ + virtual const Vector3 & getPosition(void) const; + + /** Sets the scaling factor applied to this node. + @remarks + Scaling factors, unlike other transforms, are not always inherited by child nodes. + Whether or not scalings affect the size of the child nodes depends on the setInheritScale + option of the child. In some cases you want a scaling factor of a parent node to apply to + a child node (e.g. where the child node is a part of the same object, so you want it to be + the same relative size based on the parent's size), but not in other cases (e.g. where the + child node is just for positioning another object, you want it to maintain it's own size). + The default is to inherit as with other transforms. + @par + Note that like rotations, scalings are oriented around the node's origin. + */ + virtual void setScale(const Vector3& scale); + + /** Sets the scaling factor applied to this node. + @remarks + Scaling factors, unlike other transforms, are not always inherited by child nodes. + Whether or not scalings affect the size of the child nodes depends on the setInheritScale + option of the child. In some cases you want a scaling factor of a parent node to apply to + a child node (e.g. where the child node is a part of the same object, so you want it to be + the same relative size based on the parent's size), but not in other cases (e.g. where the + child node is just for positioning another object, you want it to maintain it's own size). + The default is to inherit as with other transforms. + @par + Note that like rotations, scalings are oriented around the node's origin. + */ + virtual void setScale(Real x, Real y, Real z); + + /** Gets the scaling factor of this node. + */ + virtual const Vector3 & getScale(void) const; + + /** Tells the node whether it should inherit orientation from it's parent node. + @remarks + Orientatings, unlike other transforms, are not always inherited by child nodes. + Whether or not orientatings affect the orientation of the child nodes depends on + the setInheritOrientation option of the child. In some cases you want a orientating + of a parent node to apply to a child node (e.g. where the child node is a part of + the same object, so you want it to be the same relative orientation based on the + parent's orientation), but not in other cases (e.g. where the child node is just + for positioning another object, you want it to maintain it's own orientation). + The default is to inherit as with other transforms. + @param inherit If true, this node's orientation will be affected by its parent's orientation. + If false, it will not be affected. + */ + virtual void setInheritOrientation(bool inherit); + + /** Returns true if this node is affected by orientation applied to the parent node. + @remarks + Orientatings, unlike other transforms, are not always inherited by child nodes. + Whether or not orientatings affect the orientation of the child nodes depends on + the setInheritOrientation option of the child. In some cases you want a orientating + of a parent node to apply to a child node (e.g. where the child node is a part of + the same object, so you want it to be the same relative orientation based on the + parent's orientation), but not in other cases (e.g. where the child node is just + for positioning another object, you want it to maintain it's own orientation). + The default is to inherit as with other transforms. + @remarks + See setInheritOrientation for more info. + */ + virtual bool getInheritOrientation(void) const; + + /** Tells the node whether it should inherit scaling factors from it's parent node. + @remarks + Scaling factors, unlike other transforms, are not always inherited by child nodes. + Whether or not scalings affect the size of the child nodes depends on the setInheritScale + option of the child. In some cases you want a scaling factor of a parent node to apply to + a child node (e.g. where the child node is a part of the same object, so you want it to be + the same relative size based on the parent's size), but not in other cases (e.g. where the + child node is just for positioning another object, you want it to maintain it's own size). + The default is to inherit as with other transforms. + @param inherit If true, this node's scale will be affected by its parent's scale. If false, + it will not be affected. + */ + virtual void setInheritScale(bool inherit); + + /** Returns true if this node is affected by scaling factors applied to the parent node. + @remarks + See setInheritScale for more info. + */ + virtual bool getInheritScale(void) const; + + /** Scales the node, combining it's current scale with the passed in scaling factor. + @remarks + This method applies an extra scaling factor to the node's existing scale, (unlike setScale + which overwrites it) combining it's current scale with the new one. E.g. calling this + method twice with Vector3(2,2,2) would have the same effect as setScale(Vector3(4,4,4)) if + the existing scale was 1. + @par + Note that like rotations, scalings are oriented around the node's origin. + */ + virtual void scale(const Vector3& scale); + + /** Scales the node, combining it's current scale with the passed in scaling factor. + @remarks + This method applies an extra scaling factor to the node's existing scale, (unlike setScale + which overwrites it) combining it's current scale with the new one. E.g. calling this + method twice with Vector3(2,2,2) would have the same effect as setScale(Vector3(4,4,4)) if + the existing scale was 1. + @par + Note that like rotations, scalings are oriented around the node's origin. + */ + virtual void scale(Real x, Real y, Real z); + + /** Moves the node along the cartesian axes. + @par + This method moves the node by the supplied vector along the + world cartesian axes, i.e. along world x,y,z + @param + d Vector with x,y,z values representing the translation. + @param + relativeTo The space which this transform is relative to. + */ + virtual void translate(const Vector3& d, TransformSpace relativeTo = TS_PARENT); + /** Moves the node along the cartesian axes. + @par + This method moves the node by the supplied vector along the + world cartesian axes, i.e. along world x,y,z + @param + x + @param + y + @param + z Real x, y and z values representing the translation. + @param + relativeTo The space which this transform is relative to. + */ + virtual void translate(Real x, Real y, Real z, TransformSpace relativeTo = TS_PARENT); + /** Moves the node along arbitrary axes. + @remarks + This method translates the node by a vector which is relative to + a custom set of axes. + @param + axes A 3x3 Matrix containg 3 column vectors each representing the + axes X, Y and Z respectively. In this format the standard cartesian + axes would be expressed as: +
+                1 0 0
+                0 1 0
+                0 0 1
+                
+ i.e. the identity matrix. + @param + move Vector relative to the axes above. + @param + relativeTo The space which this transform is relative to. + */ + virtual void translate(const Matrix3& axes, const Vector3& move, TransformSpace relativeTo = TS_PARENT); + /** Moves the node along arbitrary axes. + @remarks + This method translates the node by a vector which is relative to + a custom set of axes. + @param + axes A 3x3 Matrix containg 3 column vectors each representing the + axes X, Y and Z respectively. In this format the standard cartesian + axes would be expressed as +
+                1 0 0
+                0 1 0
+                0 0 1
+                
+ i.e. the identity matrix. + @param + x,y,z Translation components relative to the axes above. + @param + relativeTo The space which this transform is relative to. + */ + virtual void translate(const Matrix3& axes, Real x, Real y, Real z, TransformSpace relativeTo = TS_PARENT); + + /** Rotate the node around the Z-axis. + */ + virtual void roll(const Radian& angle, TransformSpace relativeTo = TS_LOCAL); +#ifndef OGRE_FORCE_ANGLE_TYPES + inline void roll(Real degrees, TransformSpace relativeTo = TS_LOCAL) { + roll ( Angle(degrees), relativeTo ); + } +#endif//OGRE_FORCE_ANGLE_TYPES + + /** Rotate the node around the X-axis. + */ + virtual void pitch(const Radian& angle, TransformSpace relativeTo = TS_LOCAL); +#ifndef OGRE_FORCE_ANGLE_TYPES + inline void pitch(Real degrees, TransformSpace relativeTo = TS_LOCAL) { + pitch ( Angle(degrees), relativeTo ); + } +#endif//OGRE_FORCE_ANGLE_TYPES + + /** Rotate the node around the Y-axis. + */ + virtual void yaw(const Radian& angle, TransformSpace relativeTo = TS_LOCAL); +#ifndef OGRE_FORCE_ANGLE_TYPES + inline void yaw(Real degrees, TransformSpace relativeTo = TS_LOCAL) { + yaw ( Angle(degrees), relativeTo ); + } +#endif//OGRE_FORCE_ANGLE_TYPES + + /** Rotate the node around an arbitrary axis. + */ + virtual void rotate(const Vector3& axis, const Radian& angle, TransformSpace relativeTo = TS_LOCAL); +#ifndef OGRE_FORCE_ANGLE_TYPES + inline void rotate(const Vector3& axis, Real degrees, TransformSpace relativeTo = TS_LOCAL) { + rotate ( axis, Angle(degrees), relativeTo ); + } +#endif//OGRE_FORCE_ANGLE_TYPES + + /** Rotate the node around an aritrary axis using a Quarternion. + */ + virtual void rotate(const Quaternion& q, TransformSpace relativeTo = TS_LOCAL); + + /** Gets a matrix whose columns are the local axes based on + the nodes orientation relative to it's parent. */ + virtual Matrix3 getLocalAxes(void) const; + + /** Creates an unnamed new Node as a child of this node. + @param + translate Initial translation offset of child relative to parent + @param + rotate Initial rotation relative to parent + */ + virtual Node* createChild( + const Vector3& translate = Vector3::ZERO, + const Quaternion& rotate = Quaternion::IDENTITY ); + + /** Creates a new named Node as a child of this node. + @remarks + This creates a child node with a given name, which allows you to look the node up from + the parent which holds this collection of nodes. + @param + translate Initial translation offset of child relative to parent + @param + rotate Initial rotation relative to parent + */ + virtual Node* createChild(const String& name, const Vector3& translate = Vector3::ZERO, const Quaternion& rotate = Quaternion::IDENTITY); + + /** Adds a (precreated) child scene node to this node. If it is attached to another node, + it must be detached first. + @param child The Node which is to become a child node of this one + */ + virtual void addChild(Node* child); + + /** Reports the number of child nodes under this one. + */ + virtual unsigned short numChildren(void) const; + + /** Gets a pointer to a child node. + @remarks + There is an alternate getChild method which returns a named child. + */ + virtual Node* getChild(unsigned short index) const; + + /** Gets a pointer to a named child node. + */ + virtual Node* getChild(const String& name) const; + + /** Retrieves an iterator for efficiently looping through all children of this node. + @remarks + Using this is faster than repeatedly calling getChild if you want to go through + all (or most of) the children of this node. + Note that the returned iterator is only valid whilst no children are added or + removed from this node. Thus you should not store this returned iterator for + later use, nor should you add / remove children whilst iterating through it; + store up changes for later. Note that calling methods on returned items in + the iterator IS allowed and does not invalidate the iterator. + */ + virtual ChildNodeIterator getChildIterator(void); + + /** Retrieves an iterator for efficiently looping through all children of this node. + @remarks + Using this is faster than repeatedly calling getChild if you want to go through + all (or most of) the children of this node. + Note that the returned iterator is only valid whilst no children are added or + removed from this node. Thus you should not store this returned iterator for + later use, nor should you add / remove children whilst iterating through it; + store up changes for later. Note that calling methods on returned items in + the iterator IS allowed and does not invalidate the iterator. + */ + virtual ConstChildNodeIterator getChildIterator(void) const; + + /** Drops the specified child from this node. + @remarks + Does not delete the node, just detaches it from + this parent, potentially to be reattached elsewhere. + There is also an alternate version which drops a named + child from this node. + */ + virtual Node* removeChild(unsigned short index); + /** Drops the specified child from this node. + @remarks + Does not delete the node, just detaches it from + this parent, potentially to be reattached elsewhere. + There is also an alternate version which drops a named + child from this node. + */ + virtual Node* removeChild(Node* child); + + /** Drops the named child from this node. + @remarks + Does not delete the node, just detaches it from + this parent, potentially to be reattached elsewhere. + */ + virtual Node* removeChild(const String& name); + /** Removes all child Nodes attached to this node. Does not delete the nodes, just detaches them from + this parent, potentially to be reattached elsewhere. + */ + virtual void removeAllChildren(void); + + /** Gets the orientation of the node as derived from all parents. + */ + virtual const Quaternion & _getDerivedOrientation(void) const; + + /** Gets the position of the node as derived from all parents. + */ + virtual const Vector3 & _getDerivedPosition(void) const; + + /** Gets the scaling factor of the node as derived from all parents. + */ + virtual const Vector3 & _getDerivedScale(void) const; + + /** Gets the full transformation matrix for this node. + @remarks + This method returns the full transformation matrix + for this node, including the effect of any parent node + transformations, provided they have been updated using the Node::_update method. + This should only be called by a SceneManager which knows the + derived transforms have been updated before calling this method. + Applications using Ogre should just use the relative transforms. + */ + virtual const Matrix4& _getFullTransform(void) const; + + /** Internal method to update the Node. + @note + Updates this node and any relevant children to incorporate transforms etc. + Don't call this yourself unless you are writing a SceneManager implementation. + @param + updateChildren If true, the update cascades down to all children. Specify false if you wish to + update children separately, e.g. because of a more selective SceneManager implementation. + @param + parentHasChanged This flag indicates that the parent xform has changed, + so the child should retrieve the parent's xform and combine it with its own + even if it hasn't changed itself. + */ + virtual void _update(bool updateChildren, bool parentHasChanged); + + /** Sets a listener for this Node. + @remarks + Note for size and performance reasons only one listener per node is + allowed. + */ + virtual void setListener(Listener* listener) { mListener = listener; } + + /** Gets the current listener for this Node. + */ + virtual Listener* getListener(void) const { return mListener; } + + /** Overridden from Renderable. + @remarks + This is only used if the SceneManager chooses to render the node. This option can be set + for SceneNodes at SceneManager::setDisplaySceneNodes, and for entities based on skeletal + models using Entity::setDisplayBones() + */ + const MaterialPtr& getMaterial(void) const; + /** Overridden from Renderable. + @remarks + This is only used if the SceneManager chooses to render the node. This option can be set + for SceneNodes at SceneManager::setDisplaySceneNodes, and for entities based on skeletal + models using Entity::setDisplaySkeleton() + */ + void getRenderOperation(RenderOperation& op); + /** Overridden from Renderable. + @remarks + This is only used if the SceneManager chooses to render the node. This option can be set + for SceneNodes at SceneManager::setDisplaySceneNodes, and for entities based on skeletal + models using Entity::setDisplaySkeleton() + */ + void getWorldTransforms(Matrix4* xform) const; + /** @copydoc Renderable::getWorldOrientation */ + const Quaternion& getWorldOrientation(void) const; + /** @copydoc Renderable::getWorldPosition */ + const Vector3& getWorldPosition(void) const; + + /** Sets the current transform of this node to be the 'initial state' ie that + position / orientation / scale to be used as a basis for delta values used + in keyframe animation. + @remarks + You never need to call this method unless you plan to animate this node. If you do + plan to animate it, call this method once you've loaded the node with it's base state, + ie the state on which all keyframes are based. + @par + If you never call this method, the initial state is the identity transform, ie do nothing. + */ + virtual void setInitialState(void); + + /** Resets the position / orientation / scale of this node to it's initial state, see setInitialState for more info. */ + virtual void resetToInitialState(void); + + /** Gets the initial position of this node, see setInitialState for more info. + @remarks + Also resets the cumulative animation weight used for blending. + */ + virtual const Vector3& getInitialPosition(void) const; + + /** Gets the initial orientation of this node, see setInitialState for more info. */ + virtual const Quaternion& getInitialOrientation(void) const; + + /** Gets the initial position of this node, see setInitialState for more info. */ + virtual const Vector3& getInitialScale(void) const; + + /** Overridden, see Renderable */ + Real getSquaredViewDepth(const Camera* cam) const; + + /** To be called in the event of transform changes to this node that require it's recalculation. + @remarks + This not only tags the node state as being 'dirty', it also requests it's parent to + know about it's dirtiness so it will get an update next time. + @param forceParentUpdate Even if the node thinks it has already told it's + parent, tell it anyway + */ + virtual void needUpdate(bool forceParentUpdate = false); + /** Called by children to notify their parent that they need an update. + @param forceParentUpdate Even if the node thinks it has already told it's + parent, tell it anyway + */ + virtual void requestUpdate(Node* child, bool forceParentUpdate = false); + /** Called by children to notify their parent that they no longer need an update. */ + virtual void cancelUpdate(Node* child); + + /** Queue a 'needUpdate' call to a node safely. + @ramarks + You can't call needUpdate() during the scene graph update, e.g. in + response to a Node::Listener hook, because the graph is already being + updated, and update flag changes cannot be made reliably in that context. + Call this method if you need to queue a needUpdate call in this case. + */ + static void queueNeedUpdate(Node* n); + /** Process queued 'needUpdate' calls. */ + static void processQueuedUpdates(void); + + /** @copydoc Renderable::getLights */ + const LightList& getLights(void) const; + + + + }; + +} //namespace + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreNumerics.h b/school/informatik/verkerhssimulation/src/ogre/OgreNumerics.h new file mode 100644 index 00000000..6a004c02 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreNumerics.h @@ -0,0 +1,55 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#ifndef __NumericSolvers_H__ +#define __NumericSolvers_H__ + +#include "OgrePrerequisites.h" + + +namespace Ogre { + + /** Real type for numeric solvers */ + typedef double PreciseReal; + + + /** Provides numeric solvers for Ogre + @remarks + Handles linear algebra numerics. + */ + class _OgreExport NumericSolver + { + public: + /** Solves a full rank NxN linear system of equations + @remarks + This implements a naive gaussian elimination algorithm. + The algorithm is destructive, so there are side effects in coeff and col. + */ + static bool solveNxNLinearSysDestr(int n, PreciseReal **coeff, PreciseReal *col); + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreOptimisedUtil.h b/school/informatik/verkerhssimulation/src/ogre/OgreOptimisedUtil.h new file mode 100644 index 00000000..b4600bd0 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreOptimisedUtil.h @@ -0,0 +1,221 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __OptimisedUtil_H__ +#define __OptimisedUtil_H__ + +#include "OgrePrerequisites.h" +#include "OgreEdgeListBuilder.h" + +namespace Ogre { + + /** Utility class for provides optimised functions. + @note + This class are supposed used by internal engine only. + */ + class _OgreExport OptimisedUtil + { + private: + /// Privated copy constructor, to prevent misuse + OptimisedUtil(const OptimisedUtil& rhs); /* do nothing, should not use */ + /// Privated operator=, to prevent misuse + OptimisedUtil& operator=(const OptimisedUtil& rhs); /* do not use */ + + protected: + /// Store a pointer to the implementation + static OptimisedUtil* msImplementation; + + /// Detect best implementation based on run-time environment + static OptimisedUtil* _detectImplementation(void); + + public: + // Default constructor + OptimisedUtil(void) {} + // Destructor + virtual ~OptimisedUtil() {} + + /** Gets the implementation of this class. + @note + Don't cache the pointer returned by this function, it'll change due + run-time environment detection to pick up the best implementation. + */ + static OptimisedUtil* getImplementation(void) { return msImplementation; } + + /** Performs software vertex skinning. + @param srcPosPtr Pointer to source position buffer. + @param destPosPtr Pointer to destination position buffer. + @param srcNormPtr Pointer to source normal buffer, if NULL, + means blend position only. + @param destNormPtr Pointer to destination normal buffer, it's + ignored if srcNormPtr is NULL. + @param blendWeightPtr Pointer to blend weight buffer. + @param blendIndexPtr Pointer to blend index buffer. + @param blendMatrices An array of pointer of blend matrix, the matrix + must be aligned to SIMD alignment, but not necessary for the array + itself. + @param srcPosStride The stride of source position in bytes. + @param destPosStride The stride of destination position in bytes. + @param srcNormStride The stride of source normal in bytes, + it's ignored if srcNormPtr is NULL. + @param destNormStride The stride of destination normal in bytes, + it's ignored if srcNormPtr is NULL. + @param blendWeightStride The stride of blend weight buffer in bytes. + @param blendIndexStride The stride of blend index buffer in bytes. + @param numWeightsPerVertex Number of blend weights per-vertex, as well + as for blend indices. + @param numVertices Number of vertices to blend. + */ + virtual void softwareVertexSkinning( + const float *srcPosPtr, float *destPosPtr, + const float *srcNormPtr, float *destNormPtr, + const float *blendWeightPtr, const unsigned char* blendIndexPtr, + const Matrix4* const* blendMatrices, + size_t srcPosStride, size_t destPosStride, + size_t srcNormStride, size_t destNormStride, + size_t blendWeightStride, size_t blendIndexStride, + size_t numWeightsPerVertex, + size_t numVertices) = 0; + + /** Performs a software vertex morph, of the kind used for + morph animation although it can be used for other purposes. + @remarks + This function will linearly interpolate positions between two + source buffers, into a third buffer. + @param t Parametric distance between the start and end positions + @param srcPos1 Pointer to buffer for the start positions + @param srcPos2 Pointer to buffer for the end positions + @param dstPos Pointer to buffer for the destination positions + @param numVertices Number of vertices to morph, which agree with + the number in start, end and destination buffer. Bear in mind + three floating-point values per vertex + */ + virtual void softwareVertexMorph( + Real t, + const float *srcPos1, const float *srcPos2, + float *dstPos, + size_t numVertices) = 0; + + /** Concatenate an affine matrix to an array of affine matrices. + @note + An affine matrix is a 4x4 matrix with row 3 equal to (0, 0, 0, 1), + e.g. no projective coefficients. + @param baseMatrix The matrix used as first operand. + @param srcMatrices An array of matrix used as second operand. + @param dstMatrices An array of matrix to store matrix concatenate results. + @param numMatrices Number of matrices in the array. + */ + virtual void concatenateAffineMatrices( + const Matrix4& baseMatrix, + const Matrix4* srcMatrices, + Matrix4* dstMatrices, + size_t numMatrices) = 0; + + /** Calculate the face normals for the triangles based on position + information. + @param positions Pointer to position information, which packed in + (x, y, z) format, indexing by vertex index in the triangle. No + alignment requests. + @param triangles The triangles need to calculate face normal, the vertex + positions is indexed by vertex index to position information. + @param faceNormals The array of Vector4 used to store triangles face normal, + Must be aligned to SIMD alignment. + @param numTriangles Number of triangles to calculate face normal. + */ + virtual void calculateFaceNormals( + const float *positions, + const EdgeData::Triangle *triangles, + Vector4 *faceNormals, + size_t numTriangles) = 0; + + /** Calculate the light facing state of the triangle's face normals + @remarks + This is normally the first stage of calculating a silhouette, ie + establishing which tris are facing the light and which are facing + away. + @param lightPos 4D position of the light in object space, note that + for directional lights (which have no position), the w component + is 0 and the x/y/z position are the direction. + @param faceNormals An array of face normals for the triangles, the face + normal are unit vector othogonal to the triangles, plus distance + from origin. This array must be aligned to SIMD alignment. + @param lightFacings An array of flags for store light facing state + results, the result flag is true if corresponding face normal facing + the light, false otherwise. This array no alignment requires. + @param numFaces Number of face normals to calculate. + */ + virtual void calculateLightFacing( + const Vector4& lightPos, + const Vector4* faceNormals, + char* lightFacings, + size_t numFaces) = 0; + + /** Extruding vertices by a fixed distance based on light position. + @param lightPos 4D light position, when w=0.0f this represents a + directional light, otherwise, w must be equal to 1.0f, which + represents a point light. + @param extrudeDist The distance to extrude. + @param srcPositions Pointer to source vertex's position buffer, which + the position is a 3D vector packed in xyz format. No SIMD alignment + requirement but loss performance for unaligned data. + @param destPositions Pointer to destination vertex's position buffer, + which the position is a 3D vector packed in xyz format. No SIMD + alignment requirement but loss performance for unaligned data. + @param numVertices Number of vertices need to extruding, which agree + with source and destination buffers. + */ + virtual void extrudeVertices( + const Vector4& lightPos, + Real extrudeDist, + const float* srcPositions, + float* destPositions, + size_t numVertices) = 0; + }; + + /** Returns raw offseted of the given pointer. + @note + The offset are in bytes, no matter what type of the pointer. + */ + template + static FORCEINLINE T* rawOffsetPointer(T* ptr, ptrdiff_t offset) + { + return (T*)((char*)(ptr) + offset); + } + + /** Advance the pointer with raw offset. + @note + The offset are in bytes, no matter what type of the pointer. + */ + template + static FORCEINLINE void advanceRawPointer(T*& ptr, ptrdiff_t offset) + { + ptr = rawOffsetPointer(ptr, offset); + } + +} + +#endif // __OptimisedUtil_H__ diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreOverlay.h b/school/informatik/verkerhssimulation/src/ogre/OgreOverlay.h new file mode 100644 index 00000000..cbbc7beb --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreOverlay.h @@ -0,0 +1,285 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __Overlay_H__ +#define __Overlay_H__ + +#include "OgrePrerequisites.h" +#include "OgreSceneNode.h" +#include "OgreIteratorWrappers.h" +#include "OgreMatrix4.h" + +namespace Ogre { + + + /** Represents a layer which is rendered on top of the 'normal' scene contents. + @remarks + An overlay is a container for visual components (2D and 3D) which will be + rendered after the main scene in order to composite heads-up-displays, menus + or other layers on top of the contents of the scene. + @par + An overlay always takes up the entire size of the viewport, although the + components attached to it do not have to. An overlay has no visual element + in itself, it it merely a container for visual elements. + @par + Overlays are created by calling OverlayManager::create, or by defining them + in special text scripts (.overlay files). As many overlays + as you like can be defined; after creation an overlay is hidden i.e. not + visible until you specifically enable it by calling 'show'. This allows you to have multiple + overlays predefined (menus etc) which you make visible only when you want. + It is possible to have multiple overlays enabled at once; in this case the + relative 'zorder' parameter of the overlays determine which one is displayed + on top. + @par + By default overlays are rendered into all viewports. This is fine when you only + have fullscreen viewports, but if you have picture-in-picture views, you probably + don't want the overlay displayed in the smaller viewports. You turn this off for + a specific viewport by calling the Viewport::setDisplayOverlays method. + */ + class _OgreExport Overlay + { + + public: + typedef std::list OverlayContainerList; + protected: + String mName; + /// Internal root node, used as parent for 3D objects + SceneNode* mRootNode; + // 2D elements + // OverlayContainers, linked list for easy sorting by zorder later + // Not a map because sort can be saved since changes infrequent (unlike render queue) + OverlayContainerList m2DElements; + + // Degrees of rotation around center + Radian mRotate; + // Scroll values, offsets + Real mScrollX, mScrollY; + // Scale values + Real mScaleX, mScaleY; + + mutable Matrix4 mTransform; + mutable bool mTransformOutOfDate; + bool mTransformUpdated; + ulong mZOrder; + bool mVisible; + bool mInitialised; + String mOrigin; + /** Internal lazy update method. */ + void updateTransform(void) const; + /** Internal method for initialising an overlay */ + void initialise(void); + + public: + /// Constructor: do not call direct, use OverlayManager::create + Overlay(const String& name); + virtual ~Overlay(); + + + OverlayContainer* getChild(const String& name); + + /** Gets the name of this overlay. */ + const String& getName(void) const; + /** Alters the ZOrder of this overlay. + @remarks + Values between 0 and 650 are valid here. + */ + void setZOrder(ushort zorder); + /** Gets the ZOrder of this overlay. */ + ushort getZOrder(void) const; + + /** Gets whether the overlay is displayed or not. */ + bool isVisible(void) const; + + /** Gets whether the overlay is initialised or not. */ + bool isInitialised(void) const { return mInitialised; } + + /** Shows the overlay if it was hidden. */ + void show(void); + + /** Hides the overlay if it was visible. */ + void hide(void); + + /** Adds a 2D 'container' to the overlay. + @remarks + Containers are created and managed using the OverlayManager. A container + could be as simple as a square panel, or something more complex like + a grid or tree view. Containers group collections of other elements, + giving them a relative coordinate space and a common z-order. + If you want to attach a gui widget to an overlay, you have to do it via + a container. + @param cont Pointer to a container to add, created using OverlayManager. + */ + void add2D(OverlayContainer* cont); + + + /** Removes a 2D container from the overlay. + @remarks + NOT FAST. Consider OverlayElement::hide. + */ + void remove2D(OverlayContainer* cont); + + /** Adds a node capable of holding 3D objects to the overlay. + @remarks + Although overlays are traditionally associated with 2D elements, there + are reasons why you might want to attach 3D elements to the overlay too. + For example, if you wanted to have a 3D cockpit, which was overlaid with a + HUD, then you would create 2 overlays, one with a 3D object attached for the + cockpit, and one with the HUD elements attached (the zorder of the HUD + overlay would be higher than the cockpit to ensure it was always on top). + @par + A SceneNode can have any number of 3D objects attached to it. SceneNodes + are usually created using SceneManager::createSceneNode, but in this case + you should create a standard SceneNode instance manually; this is + because these scene nodes are not managed by the SceneManager and some custom + SceneManager plugins will rely on specialist behaviour the overlay does not + support. By attaching a SceneNode to an overlay, you indicate that:
    +
  1. You want the contents of this node to only appear when the overlay is active
  2. +
  3. You want the node to inherit a coordinate space relative to the camera, + rather than relative to the root scene node
  4. +
  5. You want these objects to be rendered after the contents of the main scene + to ensure they are rendered on top
  6. +
+ One major consideration when using 3D objects in overlays is the behaviour of + the depth buffer. Overlays should use materials with depth checking off, to ensure + that their contents are always displayed on top of the main scene (to do + otherwise would result in objects 'poking through' the overlay). The problem + with using 3D objects is that if they are concave, or self-overlap, then you + can get artefacts because of the lack of depth buffer checking. So you should + ensure that any 3D objects you us in the overlay are convex, and don't overlap + each other. If they must overlap, split them up and put them in 2 overlays. + Alternatively, use a 2D element underneath them which will clear the depth buffer + values underneath ready for the 3D element to be rendered correctly. + */ + void add3D(SceneNode* node); + + /** Removes a 3D element from the overlay. */ + void remove3D(SceneNode* node); + + /** Clears the overlay of all attached items. */ + void clear(); + + /** Sets the scrolling factor of this overlay. + @remarks + You can use this to set an offset to be used to scroll an + overlay around the screen. + @param x Horizontal scroll value, where 0 = normal, -0.5 = scroll so that only + the right half the screen is visible etc + @param y Vertical scroll value, where 0 = normal, 0.5 = scroll down by half + a screen etc. + */ + void setScroll(Real x, Real y); + + /** Gets the current X scroll value */ + Real getScrollX(void) const; + + /** Gets the current Y scroll value */ + Real getScrollY(void) const; + + /** Scrolls the overlay by the offsets provided. + @remarks + This method moves the overlay by the amounts provided. As with + other methods on this object, a full screen width / height is represented + by the value 1.0. + */ + void scroll(Real xoff, Real yoff); + + /** Sets the rotation applied to this overlay.*/ + void setRotate(const Radian& angle); +#ifndef OGRE_FORCE_ANGLE_TYPES + inline void setRotate(Real degrees) { + setRotate ( Angle(degrees) ); + } +#endif//OGRE_FORCE_ANGLE_TYPES + + /** Gets the rotation applied to this overlay, in degrees.*/ + const Radian &getRotate(void) const { return mRotate; } + + /** Adds the passed in angle to the rotation applied to this overlay. */ + void rotate(const Radian& angle); +#ifndef OGRE_FORCE_ANGLE_TYPES + inline void rotate(Real degrees) { + rotate ( Angle(degrees) ); + } +#endif//OGRE_FORCE_ANGLE_TYPES + + /** Sets the scaling factor of this overlay. + @remarks + You can use this to set an scale factor to be used to zoom an + overlay. + @param x Horizontal scale value, where 1.0 = normal, 0.5 = half size etc + @param y Vertical scale value, where 1.0 = normal, 0.5 = half size etc + */ + void setScale(Real x, Real y); + + /** Gets the current X scale value */ + Real getScaleX(void) const; + + /** Gets the current Y scale value */ + Real getScaleY(void) const; + + /** Used to transform the overlay when scrolling, scaling etc. */ + void _getWorldTransforms(Matrix4* xform) const; + /** @copydoc Renderable::getWorldOrientation */ + const Quaternion& getWorldOrientation(void) const; + /** @copydoc Renderable::getWorldPosition */ + const Vector3& getWorldPosition(void) const; + + /** Internal method to put the overlay contents onto the render queue. */ + void _findVisibleObjects(Camera* cam, RenderQueue* queue); + + /** This returns a OverlayElement at position x,y. */ + virtual OverlayElement* findElementAt(Real x, Real y); + + /** Returns an iterator over all 2D elements in this manager. + @remarks + VectorIterator is actually a too generic name, since it also works for lists. + */ + typedef VectorIterator Overlay2DElementsIterator ; + Overlay2DElementsIterator get2DElementsIterator () + { + return Overlay2DElementsIterator (m2DElements.begin(), m2DElements.end()); + } + /** Get the origin of this overlay, e.g. a script file name. + @remarks + This property will only contain something if the creator of + this overlay chose to populate it. Script loaders are advised + to populate it. + */ + const String& getOrigin(void) const { return mOrigin; } + /// Notify this overlay of it's origin + void _notifyOrigin(const String& origin) { mOrigin = origin; } + + + }; + +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreOverlayContainer.h b/school/informatik/verkerhssimulation/src/ogre/OgreOverlayContainer.h new file mode 100644 index 00000000..7d340c71 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreOverlayContainer.h @@ -0,0 +1,145 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __OverlayContainer_H__ +#define __OverlayContainer_H__ + +#include "OgrePrerequisites.h" +#include "OgreOverlayElement.h" +#include "OgreIteratorWrappers.h" + + +namespace Ogre { + + + /** A 2D element which contains other OverlayElement instances. + @remarks + This is a specialisation of OverlayElement for 2D elements that contain other + elements. These are also the smallest elements that can be attached directly + to an Overlay. + @remarks + OverlayContainers should be managed using OverlayManager. This class is responsible for + instantiating / deleting elements, and also for accepting new types of element + from plugins etc. + */ + class _OgreExport OverlayContainer : public OverlayElement + { + public: + typedef std::map ChildMap; + typedef MapIterator ChildIterator; + typedef std::map ChildContainerMap; + typedef MapIterator ChildContainerIterator; + protected: + // Map of all children + ChildMap mChildren; + // Map of container children (subset of mChildren) + ChildContainerMap mChildContainers; + + bool mChildrenProcessEvents; + + public: + /// Constructor: do not call direct, use OverlayManager::createOverlayElement + OverlayContainer(const String& name); + virtual ~OverlayContainer(); + + /** Adds another OverlayElement to this container. */ + virtual void addChild(OverlayElement* elem); + /** Adds another OverlayElement to this container. */ + virtual void addChildImpl(OverlayElement* elem); + /** Add a nested container to this container. */ + virtual void addChildImpl(OverlayContainer* cont); + /** Removes a named element from this container. */ + virtual void removeChild(const String& name); + /** Gets the named child of this container. */ + virtual OverlayElement* getChild(const String& name); + + /** @copydoc OverlayElement::initialise */ + void initialise(void); + + void _addChild(OverlayElement* elem); + void _removeChild(OverlayElement* elem) { _removeChild(elem->getName()); } + void _removeChild(const String& name); + + /** Gets an object for iterating over all the children of this object. */ + virtual ChildIterator getChildIterator(void); + + /** Gets an iterator for just the container children of this object. + @remarks + Good for cascading updates without having to use RTTI + */ + virtual ChildContainerIterator getChildContainerIterator(void); + + /** Tell the object and its children to recalculate */ + virtual void _positionsOutOfDate(void); + + /** Overridden from OverlayElement. */ + virtual void _update(void); + + /** Overridden from OverlayElement. */ + virtual void _notifyZOrder(ushort newZOrder); + + /** Overridden from OverlayElement. */ + virtual void _notifyViewport(); + + /** Overridden from OverlayElement. */ + virtual void _notifyWorldTransforms(const Matrix4& xform); + + /** Overridden from OverlayElement. */ + virtual void _notifyParent(OverlayContainer* parent, Overlay* overlay); + + /** Overridden from OverlayElement. */ + virtual void _updateRenderQueue(RenderQueue* queue); + + /** Overridden from OverlayElement. */ + inline bool isContainer() const + { return true; } + + /** Should this container pass events to their children */ + virtual inline bool isChildrenProcessEvents() const + { return true; } + + /** Should this container pass events to their children */ + virtual inline void setChildrenProcessEvents(bool val) + { mChildrenProcessEvents = val; } + + /** This returns a OverlayElement at position x,y. */ + virtual OverlayElement* findElementAt(Real x, Real y); // relative to parent + + void copyFromTemplate(OverlayElement* templateOverlay); + virtual OverlayElement* clone(const String& instanceName); + + }; + + + +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreOverlayElement.h b/school/informatik/verkerhssimulation/src/ogre/OgreOverlayElement.h new file mode 100644 index 00000000..1ab87869 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreOverlayElement.h @@ -0,0 +1,490 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __OverlayElement_H__ +#define __OverlayElement_H__ + +#include "OgrePrerequisites.h" +#include "OgreString.h" +#include "OgreRenderable.h" +#include "OgreUTFString.h" +#include "OgreStringInterface.h" +#include "OgreOverlayElementCommands.h" + +#include "OgreColourValue.h" +#include "OgreRectangle.h" + +namespace Ogre { + +#if OGRE_UNICODE_SUPPORT + typedef UTFString DisplayString; +# define OGRE_DEREF_DISPLAYSTRING_ITERATOR(it) it.getCharacter() +#else + typedef String DisplayString; +# define OGRE_DEREF_DISPLAYSTRING_ITERATOR(it) *it +#endif + /** Enum describing how the position / size of an element is to be recorded. + */ + enum GuiMetricsMode + { + /// 'left', 'top', 'height' and 'width' are parametrics from 0.0 to 1.0 + GMM_RELATIVE, + /// Positions & sizes are in absolute pixels + GMM_PIXELS, + /// Positions & sizes are in virtual pixels + GMM_RELATIVE_ASPECT_ADJUSTED + }; + + /** Enum describing where '0' is in relation to the parent in the horizontal dimension. + @remarks Affects how 'left' is interpreted. + */ + enum GuiHorizontalAlignment + { + GHA_LEFT, + GHA_CENTER, + GHA_RIGHT + }; + /** Enum describing where '0' is in relation to the parent in the vertical dimension. + @remarks Affects how 'top' is interpreted. + */ + enum GuiVerticalAlignment + { + GVA_TOP, + GVA_CENTER, + GVA_BOTTOM + }; + + /** Abstract definition of a 2D element to be displayed in an Overlay. + @remarks + This class abstracts all the details of a 2D element which will appear in + an overlay. In fact, not all OverlayElement instances can be directly added to an + Overlay, only those which are OverlayContainer instances (a subclass of this class). + OverlayContainer objects can contain any OverlayElement however. This is just to + enforce some level of grouping on widgets. + @par + OverlayElements should be managed using OverlayManager. This class is responsible for + instantiating / deleting elements, and also for accepting new types of element + from plugins etc. + @par + Note that positions / dimensions of 2D screen elements are expressed as parametric + values (0.0 - 1.0) because this makes them resolution-independent. However, most + screen resolutions have an aspect ratio of 1.3333:1 (width : height) so note that + in physical pixels 0.5 is wider than it is tall, so a 0.5x0.5 panel will not be + square on the screen (but it will take up exactly half the screen in both dimensions). + @par + Because this class is designed to be extensible, it subclasses from StringInterface + so its parameters can be set in a generic way. + */ + class _OgreExport OverlayElement : public StringInterface, public Renderable + { + public: + + protected: + // Command object for setting / getting parameters + static OverlayElementCommands::CmdLeft msLeftCmd; + static OverlayElementCommands::CmdTop msTopCmd; + static OverlayElementCommands::CmdWidth msWidthCmd; + static OverlayElementCommands::CmdHeight msHeightCmd; + static OverlayElementCommands::CmdMaterial msMaterialCmd; + static OverlayElementCommands::CmdCaption msCaptionCmd; + static OverlayElementCommands::CmdMetricsMode msMetricsModeCmd; + static OverlayElementCommands::CmdHorizontalAlign msHorizontalAlignCmd; + static OverlayElementCommands::CmdVerticalAlign msVerticalAlignCmd; + static OverlayElementCommands::CmdVisible msVisibleCmd; + + + String mName; + bool mVisible; + bool mCloneable; + Real mLeft; + Real mTop; + Real mWidth; + Real mHeight; + String mMaterialName; + MaterialPtr mpMaterial; + DisplayString mCaption; + ColourValue mColour; + Rectangle mClippingRegion; + + GuiMetricsMode mMetricsMode; + GuiHorizontalAlignment mHorzAlign; + GuiVerticalAlignment mVertAlign; + + // metric-mode positions, used in GMM_PIXELS & GMM_RELATIVE_ASPECT_ADJUSTED mode. + Real mPixelTop; + Real mPixelLeft; + Real mPixelWidth; + Real mPixelHeight; + Real mPixelScaleX; + Real mPixelScaleY; + + // Parent pointer + OverlayContainer* mParent; + // Overlay attached to + Overlay* mOverlay; + + // Derived positions from parent + Real mDerivedLeft; + Real mDerivedTop; + bool mDerivedOutOfDate; + + /// Flag indicating if the vertex positons need recalculating + bool mGeomPositionsOutOfDate; + /// Flag indicating if the vertex uvs need recalculating + bool mGeomUVsOutOfDate; + + // Zorder for when sending to render queue + // Derived from parent + ushort mZOrder; + + // world transforms + Matrix4 mXForm; + + // is element enabled + bool mEnabled; + + // is element initialised + bool mInitialised; + + // Used to see if this element is created from a Template + OverlayElement* mSourceTemplate ; + + /** Internal method which is triggered when the positions of the element get updated, + meaning the element should be rebuilding it's mesh positions. Abstract since + subclasses must implement this. + */ + virtual void updatePositionGeometry(void) = 0; + /** Internal method which is triggered when the UVs of the element get updated, + meaning the element should be rebuilding it's mesh UVs. Abstract since + subclasses must implement this. + */ + virtual void updateTextureGeometry(void) = 0; + + /** Internal method for setting up the basic parameter definitions for a subclass. + @remarks + Because StringInterface holds a dictionary of parameters per class, subclasses need to + call this to ask the base class to add it's parameters to their dictionary as well. + Can't do this in the constructor because that runs in a non-virtual context. + @par + The subclass must have called it's own createParamDictionary before calling this method. + */ + virtual void addBaseParameters(void); + + public: + /// Constructor: do not call direct, use OverlayManager::createElement + OverlayElement(const String& name); + virtual ~OverlayElement(); + + /** Initialise gui element */ + virtual void initialise(void) = 0; + + /** Gets the name of this overlay. */ + const String& getName(void) const; + + + /** Shows this element if it was hidden. */ + virtual void show(void); + + /** Hides this element if it was visible. */ + virtual void hide(void); + + /** Returns whether or not the element is visible. */ + bool isVisible(void) const; + + bool isEnabled() const; + virtual void setEnabled(bool b); + + + /** Sets the dimensions of this element in relation to the screen (1.0 = screen width/height). */ + void setDimensions(Real width, Real height); + + /** Sets the position of the top-left corner of the element, relative to the screen size + (1.0 = screen width / height) */ + void setPosition(Real left, Real top); + + /** Sets the width of this element in relation to the screen (where 1.0 = screen width) */ + void setWidth(Real width); + /** Gets the width of this element in relation to the screen (where 1.0 = screen width) */ + Real getWidth(void) const; + + /** Sets the height of this element in relation to the screen (where 1.0 = screen height) */ + void setHeight(Real height); + /** Gets the height of this element in relation to the screen (where 1.0 = screen height) */ + Real getHeight(void) const; + + /** Sets the left of this element in relation to the screen (where 0 = far left, 1.0 = far right) */ + void setLeft(Real left); + /** Gets the left of this element in relation to the screen (where 0 = far left, 1.0 = far right) */ + Real getLeft(void) const; + + /** Sets the top of this element in relation to the screen (where 0 = top, 1.0 = bottom) */ + void setTop(Real Top); + /** Gets the top of this element in relation to the screen (where 0 = top, 1.0 = bottom) */ + Real getTop(void) const; + + /** Gets the left of this element in relation to the screen (where 0 = far left, 1.0 = far right) */ + Real _getLeft(void) const { return mLeft; } + /** Gets the top of this element in relation to the screen (where 0 = far left, 1.0 = far right) */ + Real _getTop(void) const { return mTop; } + /** Gets the width of this element in relation to the screen (where 1.0 = screen width) */ + Real _getWidth(void) const { return mWidth; } + /** Gets the height of this element in relation to the screen (where 1.0 = screen height) */ + Real _getHeight(void) const { return mHeight; } + /** Sets the left of this element in relation to the screen (where 1.0 = screen width) */ + void _setLeft(Real left); + /** Sets the top of this element in relation to the screen (where 1.0 = screen width) */ + void _setTop(Real top); + /** Sets the width of this element in relation to the screen (where 1.0 = screen width) */ + void _setWidth(Real width); + /** Sets the height of this element in relation to the screen (where 1.0 = screen width) */ + void _setHeight(Real height); + /** Sets the left and top of this element in relation to the screen (where 1.0 = screen width) */ + void _setPosition(Real left, Real top); + /** Sets the width and height of this element in relation to the screen (where 1.0 = screen width) */ + void _setDimensions(Real width, Real height); + + /** Gets the name of the material this element uses. */ + virtual const String& getMaterialName(void) const; + + /** Sets the name of the material this element will use. + @remarks + Different elements will use different materials. One constant about them + all though is that a Material used for a OverlayElement must have it's depth + checking set to 'off', which means it always gets rendered on top. OGRE + will set this flag for you if necessary. What it does mean though is that + you should not use the same Material for rendering OverlayElements as standard + scene objects. It's fine to use the same textures, just not the same + Material. + */ + virtual void setMaterialName(const String& matName); + + + // --- Renderable Overrides --- + /** See Renderable */ + const MaterialPtr& getMaterial(void) const; + + // NB getRenderOperation not implemented, still abstract here + + /** See Renderable */ + void getWorldTransforms(Matrix4* xform) const; + /** @copydoc Renderable::getWorldOrientation */ + const Quaternion& getWorldOrientation(void) const; + /** @copydoc Renderable::getWorldPosition */ + const Vector3& getWorldPosition(void) const; + + /** Tell the object to recalculate */ + virtual void _positionsOutOfDate(void); + + /** Internal method to update the element based on transforms applied. */ + virtual void _update(void); + + /** Updates this elements transform based on it's parent. */ + virtual void _updateFromParent(void); + + /** Internal method for notifying the gui element of it's parent and ultimate overlay. */ + virtual void _notifyParent(OverlayContainer* parent, Overlay* overlay); + + /** Gets the 'left' position as derived from own left and that of parents. */ + virtual Real _getDerivedLeft(void); + + /** Gets the 'top' position as derived from own left and that of parents. */ + virtual Real _getDerivedTop(void); + + /** Gets the 'width' as derived from own width and metrics mode. */ + virtual Real _getRelativeWidth(void); + /** Gets the 'height' as derived from own height and metrics mode. */ + virtual Real _getRelativeHeight(void); + + + /** Gets the clipping region of the element */ + virtual void _getClippingRegion(Rectangle &clippingRegion); + + /** Internal method to notify the element when Zorder of parent overlay + has changed. + @remarks + Overlays have explicit Z orders. OverlayElements do not, they inherit the + ZOrder of the overlay, and the Zorder is incremented for every container + nested within this to ensure that containers are displayed behind contained + items. This method is used internally to notify the element of a change in + final zorder which is used to render the element. + */ + virtual void _notifyZOrder(ushort newZOrder); + + /** Internal method to notify the element when it's world transform + of parent overlay has changed. + */ + virtual void _notifyWorldTransforms(const Matrix4& xform); + + /** Internal method to notify the element when the viewport + of parent overlay has changed. + */ + virtual void _notifyViewport(); + + /** Internal method to put the contents onto the render queue. */ + virtual void _updateRenderQueue(RenderQueue* queue); + + /** Gets the type name of the element. All concrete subclasses must implement this. */ + virtual const String& getTypeName(void) const = 0; + + /** Sets the caption on elements that support it. + @remarks + This property doesn't do something on all elements, just those that support it. + However, being a common requirement it is in the top-level interface to avoid + having to set it via the StringInterface all the time. + */ + virtual void setCaption(const DisplayString& text); + /** Gets the caption for this element. */ + virtual const DisplayString& getCaption(void) const; + /** Sets the colour on elements that support it. + @remarks + This property doesn't do something on all elements, just those that support it. + However, being a common requirement it is in the top-level interface to avoid + having to set it via the StringInterface all the time. + */ + virtual void setColour(const ColourValue& col); + + /** Gets the colour for this element. */ + virtual const ColourValue& getColour(void) const; + + /** Tells this element how to interpret the position and dimension values it is given. + @remarks + By default, OverlayElements are positioned and sized according to relative dimensions + of the screen. This is to ensure portability between different resolutions when you + want things to be positioned and sized the same way across all resolutions. However, + sometimes you want things to be sized according to fixed pixels. In order to do this, + you can call this method with the parameter GMM_PIXELS. Note that if you then want + to place your element relative to the center, right or bottom of it's parent, you will + need to use the setHorizontalAlignment and setVerticalAlignment methods. + */ + virtual void setMetricsMode(GuiMetricsMode gmm); + /** Retrieves the current settings of how the element metrics are interpreted. */ + virtual GuiMetricsMode getMetricsMode(void) const; + /** Sets the horizontal origin for this element. + @remarks + By default, the horizontal origin for a OverlayElement is the left edge of the parent container + (or the screen if this is a root element). You can alter this by calling this method, which is + especially useful when you want to use pixel-based metrics (see setMetricsMode) since in this + mode you can't use relative positioning. + @par + For example, if you were using GMM_PIXELS metrics mode, and you wanted to place a 30x30 pixel + crosshair in the center of the screen, you would use GHA_CENTER with a 'left' property of -15. + @par + Note that neither GHA_CENTER or GHA_RIGHT alter the position of the element based + on it's width, you have to alter the 'left' to a negative number to do that; all this + does is establish the origin. This is because this way you can align multiple things + in the center and right with different 'left' offsets for maximum flexibility. + */ + virtual void setHorizontalAlignment(GuiHorizontalAlignment gha); + /** Gets the horizontal alignment for this element. */ + virtual GuiHorizontalAlignment getHorizontalAlignment(void) const; + /** Sets the vertical origin for this element. + @remarks + By default, the vertical origin for a OverlayElement is the top edge of the parent container + (or the screen if this is a root element). You can alter this by calling this method, which is + especially useful when you want to use pixel-based metrics (see setMetricsMode) since in this + mode you can't use relative positioning. + @par + For example, if you were using GMM_PIXELS metrics mode, and you wanted to place a 30x30 pixel + crosshair in the center of the screen, you would use GHA_CENTER with a 'top' property of -15. + @par + Note that neither GVA_CENTER or GVA_BOTTOM alter the position of the element based + on it's height, you have to alter the 'top' to a negative number to do that; all this + does is establish the origin. This is because this way you can align multiple things + in the center and bottom with different 'top' offsets for maximum flexibility. + */ + virtual void setVerticalAlignment(GuiVerticalAlignment gva); + /** Gets the vertical alignment for this element. */ + virtual GuiVerticalAlignment getVerticalAlignment(void) const; + + + + + /** Returns true if xy is within the constraints of the component */ + virtual bool contains(Real x, Real y) const; + + /** Returns true if xy is within the constraints of the component */ + virtual OverlayElement* findElementAt(Real x, Real y); // relative to parent + + /** + * returns false as this class is not a container type + */ + inline virtual bool isContainer() const + { return false; } + + inline virtual bool isKeyEnabled() const + { return false; } + + inline virtual bool isCloneable() const + { return mCloneable; } + + inline virtual void setCloneable(bool c) + { mCloneable = c; } + + /** + * Returns the parent container. + */ + OverlayContainer* getParent() ; + void _setParent(OverlayContainer* parent) { mParent = parent; } + + /** + * Returns the zOrder of the element + */ + inline ushort getZOrder() const + { return mZOrder; } + + /** Overridden from Renderable */ + Real getSquaredViewDepth(const Camera* cam) const + { + return 10000 - getZOrder(); + } + + /** @copydoc Renderable::getLights */ + const LightList& getLights(void) const + { + // Overlayelements should not be lit by the scene, this will not get called + static LightList ll; + return ll; + } + + virtual void copyFromTemplate(OverlayElement* templateOverlay); + virtual OverlayElement* clone(const String& instanceName); + + // Returns the SourceTemplate for this element + const OverlayElement* getSourceTemplate () const { + return mSourceTemplate ; + } + }; + + + +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreOverlayElementCommands.h b/school/informatik/verkerhssimulation/src/ogre/OgreOverlayElementCommands.h new file mode 100644 index 00000000..b57184cf --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreOverlayElementCommands.h @@ -0,0 +1,115 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __OverlayElementEmitterCommands_H__ +#define __OverlayElementEmitterCommands_H__ + +#include "OgrePrerequisites.h" +#include "OgreStringInterface.h" + +namespace Ogre { + + + namespace OverlayElementCommands { + /// Command object for OverlayElement - see ParamCommand + class _OgreExport CmdLeft : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for OverlayElement - see ParamCommand + class _OgreExport CmdTop : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for OverlayElement - see ParamCommand + class _OgreExport CmdWidth : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for OverlayElement - see ParamCommand + class _OgreExport CmdHeight : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for OverlayElement - see ParamCommand + class _OgreExport CmdMaterial : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for OverlayElement - see ParamCommand + class _OgreExport CmdCaption : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for OverlayElement - see ParamCommand + class _OgreExport CmdMetricsMode : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for OverlayElement - see ParamCommand + class _OgreExport CmdHorizontalAlign : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for OverlayElement - see ParamCommand + class _OgreExport CmdVerticalAlign : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for OverlayElement - see ParamCommand + class _OgreExport CmdVisible : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + } +} + +#endif + + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreOverlayElementFactory.h b/school/informatik/verkerhssimulation/src/ogre/OgreOverlayElementFactory.h new file mode 100644 index 00000000..ef4f08e0 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreOverlayElementFactory.h @@ -0,0 +1,121 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __OverlayElementFactory_H__ +#define __OverlayElementFactory_H__ + +#include "OgrePrerequisites.h" +#include "OgreOverlayElement.h" +#include "OgrePanelOverlayElement.h" +#include "OgreBorderPanelOverlayElement.h" +#include "OgreTextAreaOverlayElement.h" + +namespace Ogre { + + /** Defines the interface which all components wishing to + supply OverlayElement subclasses must implement. + @remarks + To allow the OverlayElement types available for inclusion on + overlays to be extended, OGRE allows external apps or plugins + to register their ability to create custom OverlayElements with + the OverlayManager, using the addOverlayElementFactory method. Classes + wanting to do this must implement this interface. + @par + Each OverlayElementFactory creates a single type of OverlayElement, + identified by a 'type name' which must be unique. + */ + class _OgreExport OverlayElementFactory + { + public: + /** Destroy the overlay element factory */ + virtual ~OverlayElementFactory () {} + /** Creates a new OverlayElement instance with the name supplied. */ + virtual OverlayElement* createOverlayElement(const String& instanceName) = 0; + /** Destroys a OverlayElement which this factory created previously. */ + virtual void destroyOverlayElement(OverlayElement* pElement) { delete pElement; }; + /** Gets the string uniquely identifying the type of element this factory creates. */ + virtual const String& getTypeName(void) const = 0; + }; + + + /** Factory for creating PanelOverlayElement instances. */ + class _OgreExport PanelOverlayElementFactory: public OverlayElementFactory + { + public: + /** See OverlayElementFactory */ + OverlayElement* createOverlayElement(const String& instanceName) + { + return new PanelOverlayElement(instanceName); + } + /** See OverlayElementFactory */ + const String& getTypeName(void) const + { + static String name = "Panel"; + return name; + } + }; + + /** Factory for creating BorderPanelOverlayElement instances. */ + class _OgreExport BorderPanelOverlayElementFactory: public OverlayElementFactory + { + public: + /** See OverlayElementFactory */ + OverlayElement* createOverlayElement(const String& instanceName) + { + return new BorderPanelOverlayElement(instanceName); + } + /** See OverlayElementFactory */ + const String& getTypeName(void) const + { + static String name = "BorderPanel"; + return name; + } + }; + + /** Factory for creating TextAreaOverlayElement instances. */ + class _OgreExport TextAreaOverlayElementFactory: public OverlayElementFactory + { + public: + /** See OverlayElementFactory */ + OverlayElement* createOverlayElement(const String& instanceName) + { + return new TextAreaOverlayElement(instanceName); + } + /** See OverlayElementFactory */ + const String& getTypeName(void) const + { + static String name = "TextArea"; + return name; + } + }; + +} + + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreOverlayManager.h b/school/informatik/verkerhssimulation/src/ogre/OgreOverlayManager.h new file mode 100644 index 00000000..952671bb --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreOverlayManager.h @@ -0,0 +1,235 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __OverlayManager_H__ +#define __OverlayManager_H__ + +#include "OgrePrerequisites.h" +#include "OgreSingleton.h" +#include "OgreStringVector.h" +#include "OgreOverlay.h" +#include "OgreScriptLoader.h" + +namespace Ogre { + + /** Manages Overlay objects, parsing them from .overlay files and + storing a lookup library of them. Alo manages the creation of + OverlayContainers and OverlayElements, used for non-interactive 2D + elements such as HUDs. + */ + class _OgreExport OverlayManager : public Singleton, public ScriptLoader + { + public: + typedef std::map OverlayMap; + typedef std::map ElementMap; + protected: + OverlayMap mOverlayMap; + StringVector mScriptPatterns; + + void parseNewElement( DataStreamPtr& chunk, String& elemType, String& elemName, + bool isContainer, Overlay* pOverlay, bool isTemplate, String templateName = String(""), OverlayContainer* container = 0); + void parseAttrib( const String& line, Overlay* pOverlay); + void parseElementAttrib( const String& line, Overlay* pOverlay, OverlayElement* pElement ); + void skipToNextCloseBrace(DataStreamPtr& chunk); + void skipToNextOpenBrace(DataStreamPtr& chunk); + + int mLastViewportWidth, mLastViewportHeight; + bool mViewportDimensionsChanged; + + bool parseChildren( DataStreamPtr& chunk, const String& line, + Overlay* pOverlay, bool isTemplate, OverlayContainer* parent = NULL); + + typedef std::map FactoryMap; + FactoryMap mFactories; + + ElementMap mInstances; + ElementMap mTemplates; + + typedef std::set LoadedScripts; + LoadedScripts mLoadedScripts; + + + + + ElementMap& getElementMap(bool isTemplate); + + OverlayElement* createOverlayElementImpl(const String& typeName, const String& instanceName, ElementMap& elementMap); + + OverlayElement* getOverlayElementImpl(const String& name, ElementMap& elementMap); + + void destroyOverlayElementImpl(const String& instanceName, ElementMap& elementMap); + + void destroyOverlayElementImpl(OverlayElement* pInstance, ElementMap& elementMap); + + void destroyAllOverlayElementsImpl(ElementMap& elementMap); + + public: + OverlayManager(); + virtual ~OverlayManager(); + + /// @copydoc ScriptLoader::getScriptPatterns + const StringVector& getScriptPatterns(void) const; + /// @copydoc ScriptLoader::parseScript + void parseScript(DataStreamPtr& stream, const String& groupName); + /// @copydoc ScriptLoader::getLoadingOrder + Real getLoadingOrder(void) const; + + /** Create a new Overlay. */ + Overlay* create(const String& name); + /** Retrieve an Overlay by name + @returns A pointer to the Overlay, or 0 if not found + */ + Overlay* getByName(const String& name); + /** Destroys an existing overlay by name */ + void destroy(const String& name); + /** Destroys an existing overlay */ + void destroy(Overlay* overlay); + /** Destroys all existing overlays */ + void destroyAll(void); + typedef MapIterator OverlayMapIterator; + OverlayMapIterator getOverlayIterator(void); + + /** Internal method for queueing the visible overlays for rendering. */ + void _queueOverlaysForRendering(Camera* cam, RenderQueue* pQueue, Viewport *vp); + + /** Method for determining if the viewport has changed dimensions. + @remarks This is used by pixel-based OverlayElements to work out if they need to + reclaculate their sizes. + */ + bool hasViewportChanged(void) const; + + /** Gets the height of the destination viewport in pixels. */ + int getViewportHeight(void) const; + + /** Gets the width of the destination viewport in pixels. */ + int getViewportWidth(void) const; + Real getViewportAspectRatio(void) const; + + + /** Creates a new OverlayElement of the type requested. + @remarks + The type of element to create is passed in as a string because this + allows plugins to register new types of component. + @param typeName The type of element to create. + @param instanceName The name to give the new instance. + */ + OverlayElement* createOverlayElement(const String& typeName, const String& instanceName, bool isTemplate = false); + + /** Gets a reference to an existing element. */ + OverlayElement* getOverlayElement(const String& name, bool isTemplate = false); + + /** Destroys a OverlayElement. + @remarks + Make sure you're not still using this in an Overlay. If in + doubt, let OGRE destroy elements on shutdown. + */ + void destroyOverlayElement(const String& instanceName, bool isTemplate = false); + + /** Destroys a OverlayElement. + @remarks + Make sure you're not still using this in an Overlay. If in + doubt, let OGRE destroy elements on shutdown. + */ + void destroyOverlayElement(OverlayElement* pInstance, bool isTemplate = false); + + /** Destroys all the OverlayElement created so far. + @remarks + Best to leave this to the engine to call internally, there + should rarely be a need to call it yourself. + */ + void destroyAllOverlayElements(bool isTemplate = false); + + /** Registers a new OverlayElementFactory with this manager. + @remarks + Should be used by plugins or other apps wishing to provide + a new OverlayElement subclass. + */ + void addOverlayElementFactory(OverlayElementFactory* elemFactory); + + OverlayElement* createOverlayElementFromTemplate(const String& templateName, const String& typeName, const String& instanceName, bool isTemplate = false); + /** + * @remarks + * Creates a new OverlayElement object from the specified template name. The new + * object's name, and all of it's children, will be instanceName/orignalName. + */ + OverlayElement* cloneOverlayElementFromTemplate(const String& templateName, const String& instanceName); + + OverlayElement* createOverlayElementFromFactory(const String& typeName, const String& instanceName); + + typedef MapIterator TemplateIterator; + /** Returns an iterator over all templates in this manager.*/ + TemplateIterator getTemplateIterator () + { + return TemplateIterator (mTemplates.begin (), mTemplates.end ()) ; + } + /* Returns whether the Element with the given name is a Template */ + bool isTemplate (String strName) const { + return (mTemplates.find (strName) != mTemplates.end()) ; + } + + + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static OverlayManager& getSingleton(void); + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static OverlayManager* getSingletonPtr(void); + }; + + + +} + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgrePanelOverlayElement.h b/school/informatik/verkerhssimulation/src/ogre/OgrePanelOverlayElement.h new file mode 100644 index 00000000..05e35abb --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgrePanelOverlayElement.h @@ -0,0 +1,154 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __PanelOverlayElement_H__ +#define __PanelOverlayElement_H__ + +#include "OgreOverlayContainer.h" + +namespace Ogre { + + + /** OverlayElement representing a flat, single-material (or transparent) panel which can contain other elements. + @remarks + This class subclasses OverlayContainer because it can contain other elements. Like other + containers, if hidden it's contents are also hidden, if moved it's contents also move etc. + The panel itself is a 2D rectangle which is either completely transparent, or is rendered + with a single material. The texture(s) on the panel can be tiled depending on your requirements. + @par + This component is suitable for backgrounds and grouping other elements. Note that because + it has a single repeating material it cannot have a discrete border (unless the texture has one and + the texture is tiled only once). For a bordered panel, see it's subclass BorderPanelOverlayElement. + @par + Note that the material can have all the usual effects applied to it like multiple texture + layers, scrolling / animated textures etc. For multiple texture layers, you have to set + the tiling level for each layer. + */ + class _OgreExport PanelOverlayElement : public OverlayContainer + { + public: + /** Constructor. */ + PanelOverlayElement(const String& name); + virtual ~PanelOverlayElement(); + + /** Initialise */ + virtual void initialise(void); + + /** Sets the number of times textures should repeat. + @param x The number of times the texture should repeat horizontally + @param y The number of times the texture should repeat vertically + @param layer The texture layer to specify (only needs to be altered if + you're using a multi-texture layer material) + */ + void setTiling(Real x, Real y, ushort layer = 0); + + Real getTileX(ushort layer = 0) const; + /** Gets the number of times the texture should repeat vertically. + @param layer The texture layer to specify (only needs to be altered if + you're using a multi-texture layer material) + */ + Real getTileY(ushort layer = 0) const; + + /** Sets the texture coordinates for the panel. */ + void setUV(Real u1, Real v1, Real u2, Real v2); + + /** Get the uv coordinates for the panel*/ + void getUV(Real& u1, Real& v1, Real& u2, Real& v2) const; + + /** Sets whether this panel is transparent (used only as a grouping level), or + if it is actually renderred. + */ + void setTransparent(bool isTransparent); + + /** Returns whether this panel is transparent. */ + bool isTransparent(void) const; + + /** See OverlayElement. */ + virtual const String& getTypeName(void) const; + /** See Renderable. */ + void getRenderOperation(RenderOperation& op); + /** Overridden from OverlayElement */ + void setMaterialName(const String& matName); + /** Overridden from OverlayContainer */ + void _updateRenderQueue(RenderQueue* queue); + + + /** Command object for specifying tiling (see ParamCommand).*/ + class _OgrePrivate CmdTiling : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /** Command object for specifying transparency (see ParamCommand).*/ + class _OgrePrivate CmdTransparent : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /** Command object for specifying UV coordinates (see ParamCommand).*/ + class _OgrePrivate CmdUVCoords : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + protected: + // Flag indicating if this panel should be visual or just group things + bool mTransparent; + // Texture tiling + Real mTileX[OGRE_MAX_TEXTURE_LAYERS]; + Real mTileY[OGRE_MAX_TEXTURE_LAYERS]; + size_t mNumTexCoordsInBuffer; + Real mU1, mV1, mU2, mV2; + + RenderOperation mRenderOp; + + /// internal method for setting up geometry, called by OverlayElement::update + virtual void updatePositionGeometry(void); + + /// Called to update the texture coords when layers change + virtual void updateTextureGeometry(void); + + /// Method for setting up base parameters for this class + void addBaseParameters(void); + + static String msTypeName; + + // Command objects + static CmdTiling msCmdTiling; + static CmdTransparent msCmdTransparent; + static CmdUVCoords msCmdUVCoords; + + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreParticle.h b/school/informatik/verkerhssimulation/src/ogre/OgreParticle.h new file mode 100644 index 00000000..42c825f2 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreParticle.h @@ -0,0 +1,147 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Particle_H__ +#define __Particle_H__ + +#include "OgrePrerequisites.h" +#include "OgreBillboard.h" + +namespace Ogre { + + /** Abstract class containing any additional data required to be associated + with a particle to perform the required rendering. + @remarks + Because you can specialise the way that particles are renderered by supplying + custom ParticleSystemRenderer classes, you might well need some additional + data for your custom rendering routine which is not held on the default particle + class. If that's the case, then you should define a subclass of this class, + and construct it when asked in your custom ParticleSystemRenderer class. + */ + class _OgreExport ParticleVisualData + { + public: + ParticleVisualData() {} + virtual ~ParticleVisualData() {} + + }; + + /** Class representing a single particle instance. */ + class _OgreExport Particle + { + protected: + /// Parent ParticleSystem + ParticleSystem* mParentSystem; + /// Additional visual data you might want to associate with the Particle + ParticleVisualData* mVisual; + public: + /// Type of particle + enum ParticleType + { + Visual, + Emitter + }; + + /// Does this particle have it's own dimensions? + bool mOwnDimensions; + /// Personal width if mOwnDimensions == true + Real mWidth; + /// Personal height if mOwnDimensions == true + Real mHeight; + /// Current rotation value + Radian rotation; + // Note the intentional public access to internal variables + // Accessing via get/set would be too costly for 000's of particles + /// World position + Vector3 position; + /// Direction (and speed) + Vector3 direction; + /// Current colour + ColourValue colour; + /// Time to live, number of seconds left of particles natural life + Real timeToLive; + /// Total Time to live, number of seconds of particles natural life + Real totalTimeToLive; + /// Speed of rotation in radians/sec + Radian rotationSpeed; + /// Determines the type of particle. + ParticleType particleType; + + Particle() + : mParentSystem(0), mVisual(0), mOwnDimensions(false), rotation(0), + position(Vector3::ZERO), direction(Vector3::ZERO), + colour(ColourValue::White), timeToLive(10), totalTimeToLive(10), + rotationSpeed(0), particleType(Visual) + { + } + + /** Sets the width and height for this particle. + @remarks + Note that it is most efficient for every particle in a ParticleSystem to have the same dimensions. If you + choose to alter the dimensions of an individual particle the set will be less efficient. Do not call + this method unless you really need to have different particle dimensions within the same set. Otherwise + just call the ParticleSystem::setDefaultDimensions method instead. + */ + void setDimensions(Real width, Real height); + + /** Returns true if this particle deviates from the ParticleSystem's default dimensions (i.e. if the + particle::setDimensions method has been called for this instance). + @see + particle::setDimensions + */ + bool hasOwnDimensions(void) const { return mOwnDimensions; } + + /** Retrieves the particle's personal width, if hasOwnDimensions is true. */ + Real getOwnWidth(void) const { return mWidth; } + + /** Retrieves the particle's personal width, if hasOwnDimensions is true. */ + Real getOwnHeight(void) const { return mHeight; } + + /** Sets the current rotation */ + void setRotation(const Radian& rad); + + const Radian& getRotation(void) const { return rotation; } + + /** Internal method for notifying the particle of it's owner. + */ + void _notifyOwner(ParticleSystem* owner); + + /** Internal method for notifying the particle of it's optional visual data. + */ + void _notifyVisualData(ParticleVisualData* vis) { mVisual = vis; } + + /// Get the optional visual data associated with the class + ParticleVisualData* getVisualData(void) const { return mVisual; } + + /// Utility method to reset this particle + void resetDimensions(void); + }; +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreParticleAffector.h b/school/informatik/verkerhssimulation/src/ogre/OgreParticleAffector.h new file mode 100644 index 00000000..bb551089 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreParticleAffector.h @@ -0,0 +1,116 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ParticleAffector_H__ +#define __ParticleAffector_H__ + +#include "OgrePrerequisites.h" +#include "OgreString.h" +#include "OgreStringInterface.h" + + +namespace Ogre { + + /** Abstract class defining the interface to be implemented by particle affectors. + @remarks + Particle affectors modify particles in a particle system over their lifetime. They can be + grouped into types, e.g. 'vector force' affectors, 'fader' affectors etc; each type will + modify particles in a different way, using different parameters. + @par + Because there are so many types of affectors you could use, OGRE chooses not to dictate + the available types. It comes with some in-built, but allows plugins or applications to extend the affector types available. + This is done by subclassing ParticleAffector to have the appropriate emission behaviour you want, + and also creating a subclass of ParticleAffectorFactory which is responsible for creating instances + of your new affector type. You register this factory with the ParticleSystemManager using + addAffectorFactory, and from then on affectors of this type can be created either from code or through + text particle scripts by naming the type. + @par + This same approach is used for ParticleEmitters (which are the source of particles in a system). + This means that OGRE is particularly flexible when it comes to creating particle system effects, + with literally infinite combinations of affector and affector types, and paramters within those + types. + */ + class _OgreExport ParticleAffector : public StringInterface + { + protected: + /// Name of the type of affector, MUST be initialised by subclasses + String mType; + + /** Internal method for setting up the basic parameter definitions for a subclass. + @remarks + Because StringInterface holds a dictionary of parameters per class, subclasses need to + call this to ask the base class to add it's parameters to their dictionary as well. + Can't do this in the constructor because that runs in a non-virtual context. + @par + The subclass must have called it's own createParamDictionary before calling this method. + */ + void addBaseParameters(void) { /* actually do nothing - for future possible use */ } + + ParticleSystem* mParent; + public: + ParticleAffector(ParticleSystem* parent): mParent(parent) {} + + /** Virtual destructor essential. */ + virtual ~ParticleAffector(); + + /** Method called to allow the affector to initialize all newly created particles in the system. + @remarks + This is where the affector gets the chance to initialize it's effects to the particles of a system. + The affector is expected to initialize some or all of the particles in the system + passed to it, depending on the affector's approach. + @param + pParticle Pointer to a Particle to initialize. + */ + virtual void _initParticle(Particle* pParticle) { /* by default do nothing */ } + + /** Method called to allow the affector to 'do it's stuff' on all active particles in the system. + @remarks + This is where the affector gets the chance to apply it's effects to the particles of a system. + The affector is expected to apply it's effect to some or all of the particles in the system + passed to it, depending on the affector's approach. + @param + pSystem Pointer to a ParticleSystem to affect. + @param + timeElapsed The number of seconds which have elapsed since the last call. + */ + virtual void _affectParticles(ParticleSystem* pSystem, Real timeElapsed) = 0; + + /** Returns the name of the type of affector. + @remarks + This property is useful for determining the type of affector procedurally so another + can be created. + */ + const String &getType(void) const { return mType; } + + }; + +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreParticleAffectorFactory.h b/school/informatik/verkerhssimulation/src/ogre/OgreParticleAffectorFactory.h new file mode 100644 index 00000000..664a512c --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreParticleAffectorFactory.h @@ -0,0 +1,74 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ParticleAffectorFactory_H__ +#define __ParticleAffectorFactory_H__ + + +#include "OgrePrerequisites.h" +#include "OgreParticleAffector.h" + +namespace Ogre { + + /** Abstract class defining the interface to be implemented by creators of ParticleAffector subclasses. + @remarks + Plugins or 3rd party applications can add new types of particle affectors to Ogre by creating + subclasses of the ParticleAffector class. Because multiple instances of these affectors may be + required, a factory class to manage the instances is also required. + @par + ParticleAffectorFactory subclasses must allow the creation and destruction of ParticleAffector + subclasses. They must also be registered with the ParticleSystemManager. All factories have + a name which identifies them, examples might be 'force_vector', 'attractor', or 'fader', and these can be + also be used from particle system scripts. + */ + class _OgreExport ParticleAffectorFactory + { + protected: + std::vector mAffectors; + public: + ParticleAffectorFactory() {}; + virtual ~ParticleAffectorFactory(); + /** Returns the name of the factory, the name which identifies the particle affector type this factory creates. */ + virtual String getName() const = 0; + + /** Creates a new affector instance. + @remarks + The subclass MUST add a pointer to the created instance to mAffectors. + */ + virtual ParticleAffector* createAffector(ParticleSystem* psys) = 0; + + /** Destroys the affector pointed to by the parameter (for early clean up if reauired). */ + virtual void destroyAffector(ParticleAffector* e); + }; + + +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreParticleEmitter.h b/school/informatik/verkerhssimulation/src/ogre/OgreParticleEmitter.h new file mode 100644 index 00000000..463c546b --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreParticleEmitter.h @@ -0,0 +1,506 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ParticleEmitter_H__ +#define __ParticleEmitter_H__ + +#include "OgrePrerequisites.h" +#include "OgreString.h" +#include "OgreVector3.h" +#include "OgreColourValue.h" +#include "OgreStringInterface.h" +#include "OgreParticleEmitterCommands.h" +#include "OgreParticle.h" + + +namespace Ogre { + + + /** Abstract class defining the interface to be implemented by particle emitters. + @remarks + Particle emitters are the sources of particles in a particle system. + This class defines the ParticleEmitter interface, and provides a basic implementation + for tasks which most emitters will do (these are of course overridable). + Particle emitters can be grouped into types, e.g. 'point' emitters, 'box' emitters etc; each type will + create particles with a different starting point, direction and velocity (although + within the types you can configure the ranges of these parameters). + @par + Because there are so many types of emitters you could use, OGRE chooses not to dictate + the available types. It comes with some in-built, but allows plugins or applications to extend the emitter types available. + This is done by subclassing ParticleEmitter to have the appropriate emission behaviour you want, + and also creating a subclass of ParticleEmitterFactory which is responsible for creating instances + of your new emitter type. You register this factory with the ParticleSystemManager using + addEmitterFactory, and from then on emitters of this type can be created either from code or through + text particle scripts by naming the type. + @par + This same approach is used for ParticleAffectors (which modify existing particles per frame). + This means that OGRE is particularly flexible when it comes to creating particle system effects, + with literally infinite combinations of emitter and affector types, and paramters within those + types. + */ + class _OgreExport ParticleEmitter : public StringInterface, public Particle + { + protected: + + // Command object for setting / getting parameters + static EmitterCommands::CmdAngle msAngleCmd; + static EmitterCommands::CmdColour msColourCmd; + static EmitterCommands::CmdColourRangeStart msColourRangeStartCmd; + static EmitterCommands::CmdColourRangeEnd msColourRangeEndCmd; + static EmitterCommands::CmdDirection msDirectionCmd; + static EmitterCommands::CmdEmissionRate msEmissionRateCmd; + static EmitterCommands::CmdMaxTTL msMaxTTLCmd; + static EmitterCommands::CmdMaxVelocity msMaxVelocityCmd; + static EmitterCommands::CmdMinTTL msMinTTLCmd; + static EmitterCommands::CmdMinVelocity msMinVelocityCmd; + static EmitterCommands::CmdPosition msPositionCmd; + static EmitterCommands::CmdTTL msTTLCmd; + static EmitterCommands::CmdVelocity msVelocityCmd; + static EmitterCommands::CmdDuration msDurationCmd; + static EmitterCommands::CmdMinDuration msMinDurationCmd; + static EmitterCommands::CmdMaxDuration msMaxDurationCmd; + static EmitterCommands::CmdRepeatDelay msRepeatDelayCmd; + static EmitterCommands::CmdMinRepeatDelay msMinRepeatDelayCmd; + static EmitterCommands::CmdMaxRepeatDelay msMaxRepeatDelayCmd; + static EmitterCommands::CmdName msNameCmd; + static EmitterCommands::CmdEmittedEmitter msEmittedEmitterCmd; + + + /// Parent particle system + ParticleSystem* mParent; + /// Position relative to the center of the ParticleSystem + Vector3 mPosition; + /// Rate in particles per second at which this emitter wishes to emit particles + Real mEmissionRate; + /// Name of the type of emitter, MUST be initialised by subclasses + String mType; + /// Base direction of the emitter, may not be used by some emitters + Vector3 mDirection; + // Notional up vector, just used to speed up generation of variant directions + Vector3 mUp; + /// Angle around direction which particles may be emitted, internally radians but angleunits for interface + Radian mAngle; + /// Min speed of particles + Real mMinSpeed; + /// Max speed of particles + Real mMaxSpeed; + /// Initial time-to-live of particles (min) + Real mMinTTL; + /// Initial time-to-live of particles (max) + Real mMaxTTL; + /// Initial colour of particles (range start) + ColourValue mColourRangeStart; + /// Initial colour of particles (range end) + ColourValue mColourRangeEnd; + + /// Whether this emitter is currently enabled (defaults to true) + bool mEnabled; + + /// Start time (in seconds from start of first call to ParticleSystem to update) + Real mStartTime; + /// Minimum length of time emitter will run for (0 = forever) + Real mDurationMin; + /// Maximum length of time the emitter will run for (0 = forever) + Real mDurationMax; + /// Current duration remainder + Real mDurationRemain; + + /// Time between each repeat + Real mRepeatDelayMin; + Real mRepeatDelayMax; + /// Repeat delay left + Real mRepeatDelayRemain; + + // Fractions of particles wanted to be emitted last time + Real mRemainder; + + /// The name of the emitter. The name is optional unless it is used as an emitter that is emitted itself. + String mName; + + /// The name of the emitter to be emitted (optional) + String mEmittedEmitter; + + // If 'true', this emitter is emitted by another emitter. + // NB. That doesn´t imply that the emitter itself emits other emitters (that could or could not be the case) + bool mEmitted; + + // NB Method below here are to help out people implementing emitters by providing the + // most commonly used approaches as piecemeal methods + + /** Internal utility method for generating particle exit direction + @param destVector Reference to vector to complete with new direction (normalised) + */ + virtual void genEmissionDirection(Vector3& destVector); + + /** Internal utility method to apply velocity to a particle direction. + @param destVector The vector to scale by a randomly generated scale between min and max speed. + Assumed normalised already, and likely already oriented in the right direction. + */ + virtual void genEmissionVelocity(Vector3& destVector); + + /** Internal utility method for generating a time-to-live for a particle. */ + virtual Real genEmissionTTL(void); + + /** Internal utility method for generating a colour for a particle. */ + virtual void genEmissionColour(ColourValue& destColour); + + /** Internal utility method for generating an emission count based on a constant emission rate. */ + virtual unsigned short genConstantEmissionCount(Real timeElapsed); + + /** Internal method for setting up the basic parameter definitions for a subclass. + @remarks + Because StringInterface holds a dictionary of parameters per class, subclasses need to + call this to ask the base class to add it's parameters to their dictionary as well. + Can't do this in the constructor because that runs in a non-virtual context. + @par + The subclass must have called it's own createParamDictionary before calling this method. + */ + void addBaseParameters(void); + + /** Internal method for initialising the duration & repeat of an emitter. */ + void initDurationRepeat(void); + + + public: + ParticleEmitter(ParticleSystem* psys); + /** Virtual destructor essential. */ + virtual ~ParticleEmitter(); + + /** Sets the position of this emitter relative to the particle system center. */ + virtual void setPosition(const Vector3& pos); + + /** Returns the position of this emitter relative to thte center of the particle system. */ + virtual const Vector3& getPosition(void) const; + + /** Sets the direction of the emitter. + @remarks + Most emitters will have a base direction in which they emit particles (those which + emit in all directions will ignore this parameter). They may not emit exactly along this + vector for every particle, many will introduce a random scatter around this vector using + the angle property. + @param direction + The base direction for particles emitted. + */ + virtual void setDirection(const Vector3& direction); + + /** Returns the base direction of the emitter. */ + virtual const Vector3& getDirection(void) const; + + /** Sets the maximum angle away from the emitter direction which particle will be emitted. + @remarks + Whilst the direction property defines the general direction of emission for particles, + this property defines how far the emission angle can deviate away from this base direction. + This allows you to create a scatter effect - if set to 0, all particles will be emitted + exactly along the emitters direction vector, wheras if you set it to 180 degrees or more, + particles will be emitted in a sphere, i.e. in all directions. + @param degrees + Maximum angle which initial particle direction can deviate from the emitter base direction vector. + */ + virtual void setAngle(const Radian& angle); +#ifndef OGRE_FORCE_ANGLE_TYPES + inline void setAngle(Real angle) { + setAngle ( Angle(angle) ); + } +#endif//OGRE_FORCE_ANGLE_TYPES + + /** Returns the maximum angle which the initial particle direction can deviate from the emitters base direction. */ + virtual const Radian& getAngle(void) const; + + /** Sets the initial velocity of particles emitted. + @remarks + This method sets a constant speed for emitted particles. See the alternate version + of this method which takes 2 parameters if you want a variable speed. + @param + speed The initial speed in world units per second which every particle emitted starts with. + */ + virtual void setParticleVelocity(Real speed); + + + /** Sets the initial velocity range of particles emitted. + @remarks + This method sets the range of starting speeds for emitted particles. + See the alternate version of this method which takes 1 parameter if you want a + constant speed. This emitter will randomly choose a speed between the minimum and + maximum for each particle. + @param max The maximum speed in world units per second for the initial particle speed on emission. + @param min The minimum speed in world units per second for the initial particle speed on emission. + */ + virtual void setParticleVelocity(Real min, Real max); + /** Returns the minimum particle velocity. */ + virtual void setMinParticleVelocity(Real min); + /** Returns the maximum particle velocity. */ + virtual void setMaxParticleVelocity(Real max); + + /** Returns the initial velocity of particles emitted. */ + virtual Real getParticleVelocity(void) const; + + /** Returns the minimum particle velocity. */ + virtual Real getMinParticleVelocity(void) const; + + /** Returns the maximum particle velocity. */ + virtual Real getMaxParticleVelocity(void) const; + + /** Sets the emission rate for this emitter. + @remarks + This method tells the emitter how many particles per second should be emitted. The emitter + subclass does not have to emit these in a continuous burst - this is a relative parameter + and the emitter may choose to emit all of the second's worth of particles every half-second + for example. This is controlled by the emitter's getEmissionCount method. + @par + Also, if the ParticleSystem's particle quota is exceeded, not all the particles requested + may be actually emitted. + @param + particlesPerSecond The number of particles to be emitted every second. + */ + virtual void setEmissionRate(Real particlesPerSecond); + + /** Returns the emission rate set for this emitter. */ + virtual Real getEmissionRate(void) const; + + /** Sets the lifetime of all particles emitted. + @remarks + The emitter initialises particles with a time-to-live (TTL), the number of seconds a particle + will exist before being destroyed. This method sets a constant TTL for all particles emitted. + Note that affectors are able to modify the TTL of particles later. + @par + Also see the alternate version of this method which takes a min and max TTL in order to + have the TTL vary per particle. + @param ttl The number of seconds each particle will live for. + */ + virtual void setTimeToLive(Real ttl); + /** Sets the range of lifetime for particles emitted. + @remarks + The emitter initialises particles with a time-to-live (TTL), the number of seconds a particle + will exist before being destroyed. This method sets a range for the TTL for all particles emitted; + the ttl may be randomised between these 2 extremes or will vary some other way depending on the + emitter. + Note that affectors are able to modify the TTL of particles later. + @par + Also see the alternate version of this method which takes a single TTL in order to + set a constant TTL for all particles. + @param minTtl The minimum number of seconds each particle will live for. + @param maxTtl The maximum number of seconds each particle will live for. + */ + virtual void setTimeToLive(Real minTtl, Real maxTtl); + + /** Sets the minimum time each particle will live for. */ + virtual void setMinTimeToLive(Real min); + /** Sets the maximum time each particle will live for. */ + virtual void setMaxTimeToLive(Real max); + + /** Gets the time each particle will live for. */ + virtual Real getTimeToLive(void) const; + + /** Gets the minimum time each particle will live for. */ + virtual Real getMinTimeToLive(void) const; + /** Gets the maximum time each particle will live for. */ + virtual Real getMaxTimeToLive(void) const; + + /** Sets the initial colour of particles emitted. + @remarks + Particles have an initial colour on emission which the emitter sets. This method sets + this colour. See the alternate version of this method which takes 2 colours in order to establish + a range of colours to be assigned to particles. + @param colour The colour which all particles will be given on emission. + */ + virtual void setColour(const ColourValue& colour); + /** Sets the range of colours for emitted particles. + @remarks + Particles have an initial colour on emission which the emitter sets. This method sets + the range of this colour. See the alternate version of this method which takes a single colour + in order to set a constant colour for all particles. Emitters may choose to randomly assign + a colour in this range, or may use some other method to vary the colour. + @param colourStart The start of the colour range + @param colourEnd The end of the colour range + */ + virtual void setColour(const ColourValue& colourStart, const ColourValue& colourEnd); + /** Sets the minimum colour of particles to be emitted. */ + virtual void setColourRangeStart(const ColourValue& colour); + /** Sets the maximum colour of particles to be emitted. */ + virtual void setColourRangeEnd(const ColourValue& colour); + /** Gets the colour of particles to be emitted. */ + virtual const ColourValue& getColour(void) const; + /** Gets the minimum colour of particles to be emitted. */ + virtual const ColourValue& getColourRangeStart(void) const; + /** Gets the maximum colour of particles to be emitted. */ + virtual const ColourValue& getColourRangeEnd(void) const; + + /** Gets the number of particles which this emitter would like to emit based on the time elapsed. + @remarks + For efficiency the emitter does not actually create new Particle instances (these are reused + by the ParticleSystem as existing particles 'die'). The implementation for this method must + return the number of particles the emitter would like to emit given the number of seconds which + have elapsed (passed in as a parameter). + @par + Based on the return value from this method, the ParticleSystem class will call + _initParticle once for each particle it chooses to allow to be emitted by this emitter. + The emitter should not track these _initParticle calls, it should assume all emissions + requested were made (even if they could not be because of particle quotas). + */ + virtual unsigned short _getEmissionCount(Real timeElapsed) = 0; + + /** Initialises a particle based on the emitter's approach and parameters. + @remarks + See the _getEmissionCount method for details of why there is a separation between + 'requested' emissions and actual initialised particles. + @param + pParticle Pointer to a particle which must be initialised based on how this emitter + starts particles. This is passed as a pointer rather than being created by the emitter so the + ParticleSystem can reuse Particle instances, and can also set defaults itself. + */ + virtual void _initParticle(Particle* pParticle) { + // Initialise size incase it's been altered + pParticle->resetDimensions(); + } + + + /** Returns the name of the type of emitter. + @remarks + This property is useful for determining the type of emitter procedurally so another + can be created. + */ + const String &getType(void) const { return mType; } + + /** Sets whether or not the emitter is enabled. + @remarks + You can turn an emitter off completely by setting this parameter to false. + */ + virtual void setEnabled(bool enabled); + + /** Gets the flag indicating if this emitter is enabled or not. */ + virtual bool getEnabled(void) const; + + /** Sets the 'start time' of this emitter. + @remarks + By default an emitter starts straight away as soon as a ParticleSystem is first created, + or also just after it is re-enabled. This parameter allows you to set a time delay so + that the emitter does not 'kick in' until later. + @param startTime The time in seconds from the creation or enabling of the emitter. + */ + virtual void setStartTime(Real startTime); + /** Gets the start time of the emitter. */ + virtual Real getStartTime(void) const; + + /** Sets the duration of the emitter. + @remarks + By default emitters run indefinitely (unless you manually disable them). By setting this + parameter, you can make an emitter turn off on it's own after a set number of seconds. It + will then remain disabled until either setEnabled(true) is called, or if the 'repeatAfter' parameter + has been set it will also repeat after a number of seconds. + @par + Also see the alternative version of this method which allows you to set a min and max duration for + a random variable duration. + @param duration The duration in seconds. + */ + virtual void setDuration(Real duration); + + /** Gets the duration of the emitter from when it is created or re-enabled. */ + virtual Real getDuration(void) const; + + /** Sets the range of random duration for this emitter. + @remarks + By default emitters run indefinitely (unless you manually disable them). By setting this + parameter, you can make an emitter turn off on it's own after a random number of seconds. It + will then remain disabled until either setEnabled(true) is called, or if the 'repeatAfter' parameter + has been set it will also repeat after a number of seconds. + @par + Also see the alternative version of this method which allows you to set a constant duration. + @param min The minimum duration in seconds. + @param max The minimum duration in seconds. + */ + virtual void setDuration(Real min, Real max); + /** Sets the minimum duration of this emitter in seconds (see setDuration for more details) */ + virtual void setMinDuration(Real min); + /** Sets the maximum duration of this emitter in seconds (see setDuration for more details) */ + virtual void setMaxDuration(Real max); + /** Gets the minimum duration of this emitter in seconds (see setDuration for more details) */ + virtual Real getMinDuration(void) const; + /** Gets the maximum duration of this emitter in seconds (see setDuration for more details) */ + virtual Real getMaxDuration(void) const; + + /** Sets the time between repeats of the emitter. + @remarks + By default emitters run indefinitely (unless you manually disable them). However, if you manually + disable the emitter (by calling setEnabled(false), or it's duration runs out, it will cease to emit + @par + Also see the alternative version of this method which allows you to set a min and max duration for + a random variable duration. + @param duration The duration in seconds. + */ + virtual void setRepeatDelay(Real duration); + + /** Gets the duration of the emitter from when it is created or re-enabled. */ + virtual Real getRepeatDelay(void) const; + + /** Sets the range of random duration for this emitter. + @remarks + By default emitters run indefinitely (unless you manually disable them). By setting this + parameter, you can make an emitter turn off on it's own after a random number of seconds. It + will then remain disabled until either setEnabled(true) is called, or if the 'repeatAfter' parameter + has been set it will also repeat after a number of seconds. + @par + Also see the alternative version of this method which allows you to set a constant duration. + @param min The minimum duration in seconds. + @param max The minimum duration in seconds. + */ + virtual void setRepeatDelay(Real min, Real max); + /** Sets the minimum duration of this emitter in seconds (see setRepeatDelay for more details) */ + virtual void setMinRepeatDelay(Real min); + /** Sets the maximum duration of this emitter in seconds (see setRepeatDelay for more details) */ + virtual void setMaxRepeatDelay(Real max); + /** Gets the minimum duration of this emitter in seconds (see setRepeatDelay for more details) */ + virtual Real getMinRepeatDelay(void) const; + /** Gets the maximum duration of this emitter in seconds (see setRepeatDelay for more details) */ + virtual Real getMaxRepeatDelay(void) const; + + /** Returns the name of the emitter */ + const String &getName(void) const; + + /** Sets the name of the emitter */ + virtual void setName(const String& newName); + + /** Returns the name of the emitter to be emitted */ + const String &getEmittedEmitter(void) const; + + /** Sets the name of the emitter to be emitted*/ + virtual void setEmittedEmitter(const String& emittedEmitter); + + /** Return ´true´ if the emitter is emitted by another emitter */ + virtual bool isEmitted(void) const; + + /** Set the indication (true/false) to indicate that the emitter is emitted by another emitter */ + virtual void setEmitted(bool emitted); + + + }; + +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreParticleEmitterCommands.h b/school/informatik/verkerhssimulation/src/ogre/OgreParticleEmitterCommands.h new file mode 100644 index 00000000..8406a5b2 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreParticleEmitterCommands.h @@ -0,0 +1,200 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ParticleEmitterCommands_H__ +#define __ParticleEmitterCommands_H__ + +#include "OgrePrerequisites.h" +#include "OgreStringInterface.h" + +namespace Ogre { + + + namespace EmitterCommands { + /// Command object for ParticleEmitter - see ParamCommand + class _OgreExport CmdAngle : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdColour : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdColourRangeStart : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdColourRangeEnd : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdDirection : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdEmissionRate : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdVelocity : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdMinVelocity : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdMaxVelocity : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdTTL : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdMinTTL : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdMaxTTL : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdPosition : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdDuration : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdMinDuration : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdMaxDuration : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdRepeatDelay : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdMinRepeatDelay : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdMaxRepeatDelay : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdName : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /// Command object for particle emitter - see ParamCommand + class _OgreExport CmdEmittedEmitter : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + } + +} + + + + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreParticleEmitterFactory.h b/school/informatik/verkerhssimulation/src/ogre/OgreParticleEmitterFactory.h new file mode 100644 index 00000000..233863df --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreParticleEmitterFactory.h @@ -0,0 +1,77 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ParticleEmitterFactory_H__ +#define __ParticleEmitterFactory_H__ + + +#include "OgrePrerequisites.h" +#include "OgreParticleEmitter.h" +#include "OgreString.h" + +namespace Ogre { + + /** Abstract class defining the interface to be implemented by creators of ParticleEmitter subclasses. + @remarks + Plugins or 3rd party applications can add new types of particle emitters to Ogre by creating + subclasses of the ParticleEmitter class. Because multiple instances of these emitters may be + required, a factory class to manage the instances is also required. + @par + ParticleEmitterFactory subclasses must allow the creation and destruction of ParticleEmitter + subclasses. They must also be registered with the ParticleSystemManager. All factories have + a name which identifies them, examples might be 'point', 'cone', or 'box', and these can be + also be used from particle system scripts. + */ + class _OgreExport ParticleEmitterFactory + { + protected: + std::vector mEmitters; + public: + ParticleEmitterFactory() {}; + virtual ~ParticleEmitterFactory(); + + /** Returns the name of the factory, the name which identifies the particle emitter type this factory creates. */ + virtual String getName() const = 0; + + /** Creates a new emitter instance. + @remarks + The subclass MUST add a pointer to the created instance to mEmitters. + */ + virtual ParticleEmitter* createEmitter(ParticleSystem* psys) = 0; + + /** Destroys the emitter pointed to by the parameter (for early clean up if reauired). */ + virtual void destroyEmitter(ParticleEmitter* e); + + }; + + +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreParticleIterator.h b/school/informatik/verkerhssimulation/src/ogre/OgreParticleIterator.h new file mode 100644 index 00000000..c5a60a5f --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreParticleIterator.h @@ -0,0 +1,61 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ParticleIterator_H__ +#define __ParticleIterator_H__ + +#include "OgrePrerequisites.h" + +namespace Ogre { + + + /** Convenience class to make it easy to step through all particles in a ParticleSystem. + */ + class _OgreExport ParticleIterator + { + friend class ParticleSystem; + protected: + std::list::iterator mPos; + std::list::iterator mStart; + std::list::iterator mEnd; + + /// Protected constructor, only available from ParticleSystem::getIterator + ParticleIterator(std::list::iterator start, std::list::iterator end); + + public: + // Returns true when at the end of the particle list + bool end(void); + + /** Returns a pointer to the next particle, and moves the iterator on by 1 element. */ + Particle* getNext(void); + }; +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreParticleSystem.h b/school/informatik/verkerhssimulation/src/ogre/OgreParticleSystem.h new file mode 100644 index 00000000..ba09398e --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreParticleSystem.h @@ -0,0 +1,878 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ParticleSystem_H__ +#define __ParticleSystem_H__ + +#include "OgrePrerequisites.h" + +#include "OgreVector3.h" +#include "OgreString.h" +#include "OgreParticleIterator.h" +#include "OgreStringInterface.h" +#include "OgreMovableObject.h" +#include "OgreRadixSort.h" +#include "OgreController.h" + + +namespace Ogre { + + /** Class defining particle system based special effects. + @remarks + Particle systems are special effects generators which are based on a + number of moving points to create the impression of things like like + sparkles, smoke, blood spurts, dust etc. + @par + This class simply manages a single collection of particles in world space + with a shared local origin for emission. The visual aspect of the + particles is handled by a ParticleSystemRenderer instance. + @par + Particle systems are created using the SceneManager, never directly. + In addition, like all subclasses of MovableObject, the ParticleSystem + will only be considered for rendering once it has been attached to a + SceneNode. + */ + class _OgreExport ParticleSystem : public StringInterface, public MovableObject + { + public: + + /** Command object for quota (see ParamCommand).*/ + class _OgrePrivate CmdQuota : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /** Command object for emittedEmitterQuota (see ParamCommand).*/ + class _OgrePrivate CmdEmittedEmitterQuota : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /** Command object for material (see ParamCommand).*/ + class _OgrePrivate CmdMaterial : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /** Command object for cull_each (see ParamCommand).*/ + class _OgrePrivate CmdCull : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /** Command object for particle_width (see ParamCommand).*/ + class _OgrePrivate CmdWidth : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /** Command object for particle_height (see ParamCommand).*/ + class _OgrePrivate CmdHeight : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /** Command object for renderer (see ParamCommand).*/ + class _OgrePrivate CmdRenderer : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /** Command object for sorting (see ParamCommand).*/ + class CmdSorted : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /** Command object for local space (see ParamCommand).*/ + class CmdLocalSpace : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /** Command object for iteration interval(see ParamCommand).*/ + class CmdIterationInterval : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /** Command object for nonvisible timeout (see ParamCommand).*/ + class CmdNonvisibleTimeout : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /// Default constructor required for STL creation in manager + ParticleSystem(); + /** Creates a particle system with no emitters or affectors. + @remarks + You should use the ParticleSystemManager to create particle systems rather than creating + them directly. + */ + ParticleSystem(const String& name, const String& resourceGroupName); + + virtual ~ParticleSystem(); + + /** Sets the ParticleRenderer to be used to render this particle system. + @remarks + The main ParticleSystem just manages the creation and movement of + particles; they are rendered using functions in ParticleRenderer + and the ParticleVisual instances they create. + @param typeName String identifying the type of renderer to use; a new + instance of this type will be created; a factory must have been registered + with ParticleSystemManager. + */ + void setRenderer(const String& typeName); + + /** Gets the ParticleRenderer to be used to render this particle system. */ + ParticleSystemRenderer* getRenderer(void) const; + /** Gets the name of the ParticleRenderer to be used to render this particle system. */ + const String& getRendererName(void) const; + + /** Adds an emitter to this particle system. + @remarks + Particles are created in a particle system by emitters - see the ParticleEmitter + class for more details. + @param + emitterType String identifying the emitter type to create. Emitter types are defined + by registering new factories with the manager - see ParticleEmitterFactory for more details. + Emitter types can be extended by OGRE, plugin authors or application developers. + */ + ParticleEmitter* addEmitter(const String& emitterType); + + /** Retrieves an emitter by it's index (zero-based). + @remarks + Used to retrieve a pointer to an emitter for a particle system to procedurally change + emission parameters etc. + You should check how many emitters are registered against this system before calling + this method with an arbitrary index using getNumEmitters. + @param + index Zero-based index of the emitter to retrieve. + */ + ParticleEmitter* getEmitter(unsigned short index) const; + + /** Returns the number of emitters for this particle system. */ + unsigned short getNumEmitters(void) const; + + /** Removes an emitter from the system. + @remarks + Drops the emitter with the index specified from this system. + You should check how many emitters are registered against this system before calling + this method with an arbitrary index using getNumEmitters. + @param + index Zero-based index of the emitter to retrieve. + */ + void removeEmitter(unsigned short index); + + /** Removes all the emitters from this system. */ + void removeAllEmitters(void); + + + /** Adds an affector to this particle system. + @remarks + Particles are modified over time in a particle system by affectors - see the ParticleAffector + class for more details. + @param + affectorType String identifying the affector type to create. Affector types are defined + by registering new factories with the manager - see ParticleAffectorFactory for more details. + Affector types can be extended by OGRE, plugin authors or application developers. + */ + ParticleAffector* addAffector(const String& affectorType); + + /** Retrieves an affector by it's index (zero-based). + @remarks + Used to retrieve a pointer to an affector for a particle system to procedurally change + affector parameters etc. + You should check how many affectors are registered against this system before calling + this method with an arbitrary index using getNumAffectors. + @param + index Zero-based index of the affector to retrieve. + */ + ParticleAffector* getAffector(unsigned short index) const; + + /** Returns the number of affectors for this particle system. */ + unsigned short getNumAffectors(void) const; + + /** Removes an affector from the system. + @remarks + Drops the affector with the index specified from this system. + You should check how many affectors are registered against this system before calling + this method with an arbitrary index using getNumAffectors. + @param + index Zero-based index of the affector to retrieve. + */ + void removeAffector(unsigned short index); + + /** Removes all the affectors from this system. */ + void removeAllAffectors(void); + + /** Empties this set of all particles. + */ + void clear(); + + /** Gets the number of individual particles in the system right now. + @remarks + The number of particles active in a system at a point in time depends on + the number of emitters, their emission rates, the time-to-live (TTL) each particle is + given on emission (and whether any affectors modify that TTL) and the maximum + number of particles allowed in this system at once (particle quota). + */ + size_t getNumParticles(void) const; + + /** Manually add a particle to the system. + @remarks + Instead of using an emitter, you can manually add a particle to the system. + You must initialise the returned particle instance immediately with the + 'emission' state. + @note + There is no corresponding 'destroyParticle' method - if you want to dispose of a + particle manually (say, if you've used setSpeedFactor(0) to make particles live forever) + you should use getParticle() and modify it's timeToLive to zero, meaning that it will + get cleaned up in the next update. + */ + Particle* createParticle(void); + + /** Manually add an emitter particle to the system. + @remarks + The purpose of a particle emitter is to emit particles. Besides visual particles, also other other + particle types can be emitted, other emitters for example. The emitted emitters have a double role; + they behave as particles and can be influenced by affectors, but they are still emitters and capable + to emit other particles (or emitters). It is possible to create a chain of emitters - emitters + emitting other emitters, which also emit emitters. + @param emitterName The name of a particle emitter that must be emitted. + */ + Particle* createEmitterParticle(const String& emitterName); + + /** Retrieve a particle from the system for manual tweaking. + @remarks + Normally you use an affector to alter particles in flight, but + for small manually controlled particle systems you might want to use + this method. + */ + Particle* getParticle(size_t index); + + /** Returns the maximum number of particles this system is allowed to have active at once. + @remarks + See ParticleSystem::setParticleQuota for more info. + */ + size_t getParticleQuota(void) const; + + /** Sets the maximum number of particles this system is allowed to have active at once. + @remarks + Particle systems all have a particle quota, i.e. a maximum number of particles they are + allowed to have active at a time. This allows the application to set a keep particle systems + under control should they be affected by complex parameters which alter their emission rates + etc. If a particle system reaches it's particle quota, none of the emitters will be able to + emit any more particles. As existing particles die, the spare capacity will be allocated + equally across all emitters to be as consistent to the origina particle system style as possible. + @param quota The maximum number of particles this system is allowed to have. + */ + void setParticleQuota(size_t quota); + + /** Returns the maximum number of emitted emitters this system is allowed to have active at once. + @remarks + See ParticleSystem::setEmittedEmitterQuota for more info. + */ + size_t getEmittedEmitterQuota(void) const; + + /** Sets the maximum number of emitted emitters this system is allowed to have active at once. + @remarks + Particle systems can have - besides a particle quota - also an emitted emitter quota. + @param quota The maximum number of emitted emitters this system is allowed to have. + */ + void setEmittedEmitterQuota(size_t quota); + + /** Assignment operator for copying. + @remarks + This operator deep copies all particle emitters and effectors, but not particles. The + system's name is also not copied. + */ + ParticleSystem& operator=(const ParticleSystem& rhs); + + /** Updates the particles in the system based on time elapsed. + @remarks + This is called automatically every frame by OGRE. + @param + timeElapsed The amount of time, in seconds, since the last frame. + */ + void _update(Real timeElapsed); + + /** Returns an iterator for stepping through all particles in this system. + @remarks + This method is designed to be used by people providing new ParticleAffector subclasses, + this is the easiest way to step through all the particles in a system and apply the + changes the affector wants to make. + */ + ParticleIterator _getIterator(void); + + /** Sets the name of the material to be used for this billboard set. + @param + name The new name of the material to use for this set. + */ + virtual void setMaterialName(const String& name); + + /** Sets the name of the material to be used for this billboard set. + @returns The name of the material that is used for this set. + */ + virtual const String& getMaterialName(void) const; + + /** Overridden from MovableObject + @see + MovableObject + */ + virtual void _notifyCurrentCamera(Camera* cam); + + /** Overridden from MovableObject + @see + MovableObject + */ + void _notifyAttached(Node* parent, bool isTagPoint = false); + + /** Overridden from MovableObject + @see + MovableObject + */ + virtual const AxisAlignedBox& getBoundingBox(void) const { return mAABB; } + + /** Overridden from MovableObject + @see + MovableObject + */ + virtual Real getBoundingRadius(void) const { return mBoundingRadius; } + + /** Overridden from MovableObject + @see + MovableObject + */ + virtual void _updateRenderQueue(RenderQueue* queue); + + /** Fast-forwards this system by the required number of seconds. + @remarks + This method allows you to fast-forward a system so that it effectively looks like + it has already been running for the time you specify. This is useful to avoid the + 'startup sequence' of a system, when you want the system to be fully populated right + from the start. + @param + time The number of seconds to fast-forward by. + @param + interval The sampling interval used to generate particles, apply affectors etc. The lower this + is the more realistic the fast-forward, but it takes more iterations to do it. + */ + void fastForward(Real time, Real interval = 0.1); + + /** Sets a 'speed factor' on this particle system, which means it scales the elapsed + real time which has passed by this factor before passing it to the emitters, affectors, + and the particle life calculation. + @remarks + An interesting side effect - if you want to create a completely manual particle system + where you control the emission and life of particles yourself, you can set the speed + factor to 0.0f, thus disabling normal particle emission, alteration, and death. + */ + void setSpeedFactor(Real speedFactor) { mSpeedFactor = speedFactor; } + + /** Gets the 'speed factor' on this particle system. + */ + Real getSpeedFactor(void) const { return mSpeedFactor; } + + /** Sets a 'iteration interval' on this particle system. + @remarks + The default Particle system update interval, based on elapsed frame time, + will cause different behavior between low frame-rate and high frame-rate. + By using this option, you can make the particle system update at + a fixed interval, keeping the behavior the same no matter what frame-rate + is. + @par + When iteration interval is set to zero, it means the update occurs based + on an elapsed frame time, otherwise each iteration will take place + at the given interval, repeating until it has used up all the elapsed + frame time. + @param + iterationInterval The iteration interval, default to zero. + */ + void setIterationInterval(Real iterationInterval); + + /** Gets a 'iteration interval' on this particle system. + */ + Real getIterationInterval(void) const { return mIterationInterval; } + + /** Set the default iteration interval for all ParticleSystem instances. + */ + static void setDefaultIterationInterval(Real iterationInterval) { msDefaultIterationInterval = iterationInterval; } + + /** Get the default iteration interval for all ParticleSystem instances. + */ + static Real getDefaultIterationInterval(void) { return msDefaultIterationInterval; } + + /** Sets when the particle system should stop updating after it hasn't been + visible for a while. + @remarks + By default, visible particle systems update all the time, even when + not in view. This means that they are guaranteed to be consistent when + they do enter view. However, this comes at a cost, updating particle + systems can be expensive, especially if they are perpetual. + @par + This option lets you set a 'timeout' on the particle system, so that + if it isn't visible for this amount of time, it will stop updating + until it is next visible. + @param timeout The time after which the particle system will be disabled + if it is no longer visible. 0 to disable the timeout and always update. + */ + void setNonVisibleUpdateTimeout(Real timeout); + /** Gets when the particle system should stop updating after it hasn't been + visible for a while. + */ + Real getNonVisibleUpdateTimeout(void) const { return mNonvisibleTimeout; } + + /** Set the default nonvisible timeout for all ParticleSystem instances. + */ + static void setDefaultNonVisibleUpdateTimeout(Real timeout) + { msDefaultNonvisibleTimeout = timeout; } + + /** Get the default nonvisible timeout for all ParticleSystem instances. + */ + static Real getDefaultNonVisibleUpdateTimeout(void) { return msDefaultNonvisibleTimeout; } + + /** Overridden from MovableObject */ + const String& getMovableType(void) const; + + /** Internal callback used by Particles to notify their parent that they have been resized. + */ + virtual void _notifyParticleResized(void); + + /** Internal callback used by Particles to notify their parent that they have been rotated. + */ + virtual void _notifyParticleRotated(void); + + /** Sets the default dimensions of the particles in this set. + @remarks + All particles in a set are created with these default dimensions. The set will render most efficiently if + all the particles in the set are the default size. It is possible to alter the size of individual + particles at the expense of extra calculation. See the Particle class for more info. + @param width + The new default width for the particles in this set. + @param height + The new default height for the particles in this set. + */ + virtual void setDefaultDimensions(Real width, Real height); + + /** See setDefaultDimensions - this sets 1 component individually. */ + virtual void setDefaultWidth(Real width); + /** See setDefaultDimensions - this gets 1 component individually. */ + virtual Real getDefaultWidth(void) const; + /** See setDefaultDimensions - this sets 1 component individually. */ + virtual void setDefaultHeight(Real height); + /** See setDefaultDimensions - this gets 1 component individually. */ + virtual Real getDefaultHeight(void) const; + /** Returns whether or not particles in this are tested individually for culling. */ + virtual bool getCullIndividually(void) const; + /** Sets whether culling tests particles in this individually as well as in a group. + @remarks + Particle sets are always culled as a whole group, based on a bounding box which + encloses all particles in the set. For fairly localised sets, this is enough. However, you + can optionally tell the set to also cull individual particles in the set, i.e. to test + each individual particle before rendering. The default is not to do this. + @par + This is useful when you have a large, fairly distributed set of particles, like maybe + trees on a landscape. You probably still want to group them into more than one + set (maybe one set per section of landscape), which will be culled coarsely, but you also + want to cull the particles individually because they are spread out. Whilst you could have + lots of single-tree sets which are culled separately, this would be inefficient to render + because each tree would be issued as it's own rendering operation. + @par + By calling this method with a parameter of true, you can have large particle sets which + are spaced out and so get the benefit of batch rendering and coarse culling, but also have + fine-grained culling so unnecessary rendering is avoided. + @param cullIndividual If true, each particle is tested before being sent to the pipeline as well + as the whole set having to pass the coarse group bounding test. + */ + virtual void setCullIndividually(bool cullIndividual); + /// Return the resource group to be used to load dependent resources + virtual const String& getResourceGroupName(void) const { return mResourceGroupName; } + /** Get the origin of this particle system, e.g. a script file name. + @remarks + This property will only contain something if the creator of + this particle system chose to populate it. Script loaders are advised + to populate it. + */ + const String& getOrigin(void) const { return mOrigin; } + /// Notify this particle system of it's origin + void _notifyOrigin(const String& origin) { mOrigin = origin; } + + /** @copydoc MovableObject::setRenderQueueGroup */ + void setRenderQueueGroup(uint8 queueID); + + /** Set whether or not particles are sorted according to the camera. + @remarks + Enabling sorting alters the order particles are sent to the renderer. + When enabled, particles are sent to the renderer in order of + furthest distance from the camera. + */ + void setSortingEnabled(bool enabled) { mSorted = enabled; } + /// Gets whether particles are sorted relative to the camera. + bool getSortingEnabled(void) const { return mSorted; } + + /** Set the (initial) bounds of the particle system manually. + @remarks + If you can, set the bounds of a particle system up-front and + call setBoundsAutoUpdated(false); this is the most efficient way to + organise it. Otherwise, set an initial bounds and let the bounds increase + for a little while (the default is 5 seconds), after which time the + AABB is fixed to save time. + @param aabb Bounds in local space. + */ + void setBounds(const AxisAlignedBox& aabb); + + /** Sets whether the bounds will be automatically updated + for the life of the particle system + @remarks + If you have a stationary particle system, it would be a good idea to + call this method and set the value to 'false', since the maximum + bounds of the particle system will eventually be static. If you do + this, you can either set the bounds manually using the setBounds() + method, or set the second parameter of this method to a positive + number of seconds, so that the bounds are calculated for a few + seconds and then frozen. + @param autoUpdate If true (the default), the particle system will + update it's bounds every frame. If false, the bounds update will + cease after the 'stopIn' number of seconds have passed. + @param stopIn Only applicable if the first parameter is true, this is the + number of seconds after which the automatic update will cease. + */ + void setBoundsAutoUpdated(bool autoUpdate, Real stopIn = 0.0f); + + /** Sets whether particles (and any affector effects) remain relative + to the node the particle system is attached to. + @remarks + By defalt particles are in world space once emitted, so they are not + affected by movement in the parent node of the particle system. This + makes the most sense when dealing with completely independent particles, + but if you want to constrain them to follow local motion too, you + can set this to true. + */ + void setKeepParticlesInLocalSpace(bool keepLocal); + + /** Gets whether particles (and any affector effects) remain relative + to the node the particle system is attached to. + */ + bool getKeepParticlesInLocalSpace(void) const { return mLocalSpace; } + + /** Internal method for updating the bounds of the particle system. + @remarks + This is called automatically for a period of time after the system's + creation (10 seconds by default, settable by setBoundsAutoUpdated) + to increase (and only increase) the bounds of the system according + to the emitted and affected particles. After this period, the + system is assumed to achieved its maximum size, and the bounds are + no longer computed for efficiency. You can tweak the behaviour by + either setting the bounds manually (setBounds, preferred), or + changing the time over which the bounds are updated (performance cost). + You can also call this method manually if you need to update the + bounds on an ad-hoc basis. + */ + void _updateBounds(void); + + /// Override to return specific type flag + uint32 getTypeFlags(void) const; + protected: + + /// Command objects + static CmdCull msCullCmd; + static CmdHeight msHeightCmd; + static CmdMaterial msMaterialCmd; + static CmdQuota msQuotaCmd; + static CmdEmittedEmitterQuota msEmittedEmitterQuotaCmd; + static CmdWidth msWidthCmd; + static CmdRenderer msRendererCmd; + static CmdSorted msSortedCmd; + static CmdLocalSpace msLocalSpaceCmd; + static CmdIterationInterval msIterationIntervalCmd; + static CmdNonvisibleTimeout msNonvisibleTimeoutCmd; + + + AxisAlignedBox mAABB; + Real mBoundingRadius; + bool mBoundsAutoUpdate; + Real mBoundsUpdateTime; + Real mUpdateRemainTime; + + /// World AABB, only used to compare world-space positions to calc bounds + AxisAlignedBox mWorldAABB; + + /// Name of the resource group to use to load materials + String mResourceGroupName; + /// Name of the material to use + String mMaterialName; + /// Have we set the material etc on the renderer? + bool mIsRendererConfigured; + /// Pointer to the material to use + MaterialPtr mpMaterial; + /// Default width of each particle + Real mDefaultWidth; + /// Default height of each particle + Real mDefaultHeight; + /// Speed factor + Real mSpeedFactor; + /// Iteration interval + Real mIterationInterval; + /// Iteration interval set? Otherwise track default + bool mIterationIntervalSet; + /// Particles sorted according to camera? + bool mSorted; + /// Particles in local space? + bool mLocalSpace; + /// Update timeout when nonvisible (0 for no timeout) + Real mNonvisibleTimeout; + /// Update timeout when nonvisible set? Otherwise track default + bool mNonvisibleTimeoutSet; + /// Amount of time non-visible so far + Real mTimeSinceLastVisible; + /// Last frame in which known to be visible + unsigned long mLastVisibleFrame; + /// Controller for time update + Controller* mTimeController; + /// Indication whether the emitted emitter pool (= pool with particle emitters that are emitted) is initialised + bool mEmittedEmitterPoolInitialised; + + typedef std::list ActiveParticleList; + typedef std::list FreeParticleList; + typedef std::vector ParticlePool; + + /** Sort by direction functor */ + struct SortByDirectionFunctor + { + /// Direction to sort in + Vector3 sortDir; + + SortByDirectionFunctor(const Vector3& dir); + float operator()(Particle* p) const; + }; + + /** Sort by distance functor */ + struct SortByDistanceFunctor + { + /// Position to sort in + Vector3 sortPos; + + SortByDistanceFunctor(const Vector3& pos); + float operator()(Particle* p) const; + }; + + static RadixSort mRadixSorter; + + /** Active particle list. + @remarks + This is a linked list of pointers to particles in the particle pool. + @par + This allows very fast instertions and deletions from anywhere in + the list to activate / deactivate particles as well as resuse of + Particle instances in the pool without construction & destruction + which avoids memory thrashing. + */ + ActiveParticleList mActiveParticles; + + /** Free particle queue. + @remarks + This contains a list of the particles free for use as new instances + as required by the set. Particle instances are preconstructed up + to the estimated size in the mParticlePool vector and are + referenced on this deque at startup. As they get used this list + reduces, as they get released back to to the set they get added + back to the list. + */ + FreeParticleList mFreeParticles; + + /** Pool of particle instances for use and reuse in the active particle list. + @remarks + This vector will be preallocated with the estimated size of the set,and will extend as required. + */ + ParticlePool mParticlePool; + + typedef std::list FreeEmittedEmitterList; + typedef std::list ActiveEmittedEmitterList; + typedef std::vector EmittedEmitterList; + typedef std::map FreeEmittedEmitterMap; + typedef std::map EmittedEmitterPool; + + /** Pool of emitted emitters for use and reuse in the active emitted emitter list. + @remarks + The emitters in this pool act as particles and as emitters. The pool is a map containing lists + of emitters, identified by their name. + @par + The emitters in this pool are cloned using emitters that are kept in the main emitter list + of the ParticleSystem. + */ + EmittedEmitterPool mEmittedEmitterPool; + + /** Free emitted emitter list. + @remarks + This contains a list of the emitters free for use as new instances as required by the set. + */ + FreeEmittedEmitterMap mFreeEmittedEmitters; + + /** Active emitted emitter list. + @remarks + This is a linked list of pointers to emitters in the emitted emitter pool. + Emitters that are used are stored (their pointers) in both the list with active particles and in + the list with active emitted emitters. */ + ActiveEmittedEmitterList mActiveEmittedEmitters; + + typedef std::vector ParticleEmitterList; + typedef std::vector ParticleAffectorList; + + /// List of particle emitters, ie sources of particles + ParticleEmitterList mEmitters; + /// List of particle affectors, ie modifiers of particles + ParticleAffectorList mAffectors; + + /// The renderer used to render this particle system + ParticleSystemRenderer* mRenderer; + + /// Do we cull each particle individually? + bool mCullIndividual; + + /// The name of the type of renderer used to render this system + String mRendererType; + + /// The number of particles in the pool. + size_t mPoolSize; + + /// The number of emitted emitters in the pool. + size_t mEmittedEmitterPoolSize; + + /// Optional origin of this particle system (eg script name) + String mOrigin; + + /// Default iteration interval + static Real msDefaultIterationInterval; + /// Default nonvisible update timeout + static Real msDefaultNonvisibleTimeout; + + /** Internal method used to expire dead particles. */ + void _expire(Real timeElapsed); + + /** Spawn new particles based on free quota and emitter requirements. */ + void _triggerEmitters(Real timeElapsed); + + /** Helper function that actually performs the emission of particles + */ + void _executeTriggerEmitters(ParticleEmitter* emitter, unsigned requested, Real timeElapsed); + + /** Updates existing particle based on their momentum. */ + void _applyMotion(Real timeElapsed); + + /** Applies the effects of affectors. */ + void _triggerAffectors(Real timeElapsed); + + /** Sort the particles in the system **/ + void _sortParticles(Camera* cam); + + /** Resize the internal pool of particles. */ + void increasePool(size_t size); + + /** Resize the internal pool of emitted emitters. + @remarks + The pool consists of multiple vectors containing pointers to particle emitters. Increasing the + pool with ´size´ implies that the vectors are equally increased. The quota of emitted emitters is + defined on a particle system level and not on a particle emitter level. This is to prevent that + the number of created emitters becomes too high; the quota is shared amongst the emitted emitters. + */ + void increaseEmittedEmitterPool(size_t size); + + /** Internal method for initialising string interface. */ + void initParameters(void); + + /** Internal method to configure the renderer. */ + void configureRenderer(void); + + /// Internal method for creating ParticleVisualData instances for the pool + void createVisualParticles(size_t poolstart, size_t poolend); + /// Internal method for destroying ParticleVisualData instances for the pool + void destroyVisualParticles(size_t poolstart, size_t poolend); + + /** Create a pool of emitted emitters and assign them to the free emitter list. + @remarks + The emitters in the pool are grouped by name. This name is the name of the base emitter in the + main list with particle emitters, which forms the template of the created emitted emitters. + */ + void initialiseEmittedEmitters(void); + + /** Determine which emitters in the Particle Systems main emitter become a template for creating an + pool of emitters that can be emitted. + */ + void initialiseEmittedEmitterPool(void); + + /** Add emitters from the pool to the free emitted emitter queue. */ + void addFreeEmittedEmitters(void); + + /** Removes all emitted emitters from this system. */ + void removeAllEmittedEmitters(void); + + /** Find the list with free emitted emitters. + @param name The name that identifies the list with free emitted emitters. + */ + FreeEmittedEmitterList* findFreeEmittedEmitter (const String& name); + + /** Removes an emitter from the active emitted emitter list. + @remarks + The emitter will not be destroyed! + @param emitter Pointer to a particle emitter. + */ + void removeFromActiveEmittedEmitters (ParticleEmitter* emitter); + + /** Moves all emitted emitters from the active list to the free list + @remarks + The active emitted emitter list will not be cleared and still keeps references to the emitters! + */ + void addActiveEmittedEmittersToFreeList (void); + + /** This function clears all data structures that are used in combination with emitted emitters and + sets the flag to indicate that the emitted emitter pool must be initialised again. + @remarks + This function should be called if new emitters are added to a ParticleSystem or deleted from a + ParticleSystem. The emitted emitter data structures become out of sync and need to be build up + again. The data structures are not reorganised in this function, but by setting a ´flag´, + they are rebuild in the regular process flow. + */ + void _notifyReorganiseEmittedEmitterData (void); + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreParticleSystemManager.h b/school/informatik/verkerhssimulation/src/ogre/OgreParticleSystemManager.h new file mode 100644 index 00000000..57276fbd --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreParticleSystemManager.h @@ -0,0 +1,389 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ParticleSystemManager_H__ +#define __ParticleSystemManager_H__ + + +#include "OgrePrerequisites.h" +#include "OgreParticleSystem.h" +#include "OgreFrameListener.h" +#include "OgreSingleton.h" +#include "OgreIteratorWrappers.h" +#include "OgreScriptLoader.h" +#include "OgreResourceGroupManager.h" + +namespace Ogre { + + // Forward decl + class ParticleSystemFactory; + + /** Manages particle systems, particle system scripts (templates) and the + available emitter & affector factories. + @remarks + This singleton class is responsible for creating and managing particle + systems. All particle systems must be created and destroyed using this + object, although the user interface to creating them is via + SceneManager. Remember that like all other MovableObject + subclasses, ParticleSystems do not get rendered until they are + attached to a SceneNode object. + @par + This class also manages factories for ParticleEmitter and + ParticleAffector classes. To enable easy extensions to the types of + emitters (particle sources) and affectors (particle modifiers), the + ParticleSystemManager lets plugins or applications register factory + classes which submit new subclasses to ParticleEmitter and + ParticleAffector. Ogre comes with a number of them already provided, + such as cone, sphere and box-shaped emitters, and simple affectors such + as constant directional force and colour faders. However using this + registration process, a plugin can create any behaviour required. + @par + This class also manages the loading and parsing of particle system + scripts, which are text files describing named particle system + templates. Instances of particle systems using these templates can + then be created easily through the createParticleSystem method. + */ + class _OgreExport ParticleSystemManager: + public Singleton, public ScriptLoader + { + friend class ParticleSystemFactory; + public: + typedef std::map ParticleTemplateMap; + typedef std::map ParticleAffectorFactoryMap; + typedef std::map ParticleEmitterFactoryMap; + typedef std::map ParticleSystemRendererFactoryMap; + protected: + OGRE_AUTO_MUTEX + /// Templates based on scripts + ParticleTemplateMap mSystemTemplates; + + /// Factories for named emitter types (can be extended using plugins) + ParticleEmitterFactoryMap mEmitterFactories; + + /// Factories for named affector types (can be extended using plugins) + ParticleAffectorFactoryMap mAffectorFactories; + + /// Map of renderer types to factories + ParticleSystemRendererFactoryMap mRendererFactories; + + StringVector mScriptPatterns; + + // Factory instance + ParticleSystemFactory* mFactory; + + /** Internal script parsing method. */ + void parseNewEmitter(const String& type, DataStreamPtr& chunk, ParticleSystem* sys); + /** Internal script parsing method. */ + void parseNewAffector(const String& type, DataStreamPtr& chunk, ParticleSystem* sys); + /** Internal script parsing method. */ + void parseAttrib(const String& line, ParticleSystem* sys); + /** Internal script parsing method. */ + void parseEmitterAttrib(const String& line, ParticleEmitter* sys); + /** Internal script parsing method. */ + void parseAffectorAttrib(const String& line, ParticleAffector* sys); + /** Internal script parsing method. */ + void skipToNextCloseBrace(DataStreamPtr& chunk); + /** Internal script parsing method. */ + void skipToNextOpenBrace(DataStreamPtr& chunk); + + /// Internal implementation of createSystem + ParticleSystem* createSystemImpl(const String& name, size_t quota, + const String& resourceGroup); + /// Internal implementation of createSystem + ParticleSystem* createSystemImpl(const String& name, const String& templateName); + /// Internal implementation of destroySystem + void destroySystemImpl(ParticleSystem* sys); + + + public: + + ParticleSystemManager(); + virtual ~ParticleSystemManager(); + + /** Adds a new 'factory' object for emitters to the list of available emitter types. + @remarks + This method allows plugins etc to add new particle emitter types to Ogre. Particle emitters + are sources of particles, and generate new particles with their start positions, colours and + momentums appropriately. Plugins would create new subclasses of ParticleEmitter which + emit particles a certain way, and register a subclass of ParticleEmitterFactory to create them (since multiple + emitters can be created for different particle systems). + @par + All particle emitter factories have an assigned name which is used to identify the emitter + type. This must be unique. + @par + Note that the object passed to this function will not be destroyed by the ParticleSystemManager, + since it may have been allocted on a different heap in the case of plugins. The caller must + destroy the object later on, probably on plugin shutdown. + @param + factory Pointer to a ParticleEmitterFactory subclass created by the plugin or application code. + */ + void addEmitterFactory(ParticleEmitterFactory* factory); + + /** Adds a new 'factory' object for affectors to the list of available affector types. + @remarks + This method allows plugins etc to add new particle affector types to Ogre. Particle + affectors modify the particles in a system a certain way such as affecting their direction + or changing their colour, lifespan etc. Plugins would + create new subclasses of ParticleAffector which affect particles a certain way, and register + a subclass of ParticleAffectorFactory to create them. + @par + All particle affector factories have an assigned name which is used to identify the affector + type. This must be unique. + @par + Note that the object passed to this function will not be destroyed by the ParticleSystemManager, + since it may have been allocted on a different heap in the case of plugins. The caller must + destroy the object later on, probably on plugin shutdown. + @param + factory Pointer to a ParticleAffectorFactory subclass created by the plugin or application code. + */ + void addAffectorFactory(ParticleAffectorFactory* factory); + + /** Registers a factory class for creating ParticleSystemRenderer instances. + @par + Note that the object passed to this function will not be destroyed by the ParticleSystemManager, + since it may have been allocted on a different heap in the case of plugins. The caller must + destroy the object later on, probably on plugin shutdown. + @param + factory Pointer to a ParticleSystemRendererFactory subclass created by the plugin or application code. + */ + void addRendererFactory(ParticleSystemRendererFactory* factory); + + /** Adds a new particle system template to the list of available templates. + @remarks + Instances of particle systems in a scene are not normally unique - often you want to place the + same effect in many places. This method allows you to register a ParticleSystem as a named template, + which can subsequently be used to create instances using the createSystem method. + @par + Note that particle system templates can either be created programmatically by an application + and registered using this method, or they can be defined in a script file (*.particle) which is + loaded by the engine at startup, very much like Material scripts. + @param + name The name of the template. Must be unique across all templates. + @param + sysTemplate A pointer to a particle system to be used as a template. The manager + will take over ownership of this pointer. + + */ + void addTemplate(const String& name, ParticleSystem* sysTemplate); + + /** Removes a specified template from the ParticleSystemManager. + @remarks + This method removes a given template from the particle system manager, optionally deleting + the template if the deleteTemplate method is called. Throws an exception if the template + could not be found. + @param + name The name of the template to remove. + @param + deleteTemplate Whether or not to delete the template before removing it. + */ + void removeTemplate(const String& name, bool deleteTemplate = true); + + /** Removes a specified template from the ParticleSystemManager. + @remarks + This method removes all templates from the ParticleSystemManager. + @param + deleteTemplate Whether or not to delete the templates before removing them. + */ + void removeAllTemplates(bool deleteTemplate = true); + + /** Create a new particle system template. + @remarks + This method is similar to the addTemplate method, except this just creates a new template + and returns a pointer to it to be populated. Use this when you don't already have a system + to add as a template and just want to create a new template which you will build up in-place. + @param + name The name of the template. Must be unique across all templates. + @param + resourceGroup The name of the resource group which will be used to + load any dependent resources. + + */ + ParticleSystem* createTemplate(const String& name, const String& resourceGroup); + + /** Retrieves a particle system template for possible modification. + @remarks + Modifying a template does not affect the settings on any ParticleSystems already created + from this template. + */ + ParticleSystem* getTemplate(const String& name); + + /** Internal method for creating a new emitter from a factory. + @remarks + Used internally by the engine to create new ParticleEmitter instances from named + factories. Applications should use the ParticleSystem::addEmitter method instead, + which calls this method to create an instance. + @param + emitterType String name of the emitter type to be created. A factory of this type must have been registered. + @param + psys The particle system this is being created for + */ + ParticleEmitter* _createEmitter(const String& emitterType, ParticleSystem* psys); + + /** Internal method for destroying an emitter. + @remarks + Because emitters are created by factories which may allocate memory from separate heaps, + the memory allocated must be freed from the same place. This method is used to ask the factory + to destroy the instance passed in as a pointer. + @param + emitter Pointer to emitter to be destroyed. On return this pointer will point to invalid (freed) memory. + */ + void _destroyEmitter(ParticleEmitter* emitter); + + /** Internal method for creating a new affector from a factory. + @remarks + Used internally by the engine to create new ParticleAffector instances from named + factories. Applications should use the ParticleSystem::addAffector method instead, + which calls this method to create an instance. + @param + effectorType String name of the affector type to be created. A factory of this type must have been registered. + @param + psys The particle system it is being created for + */ + ParticleAffector* _createAffector(const String& affectorType, ParticleSystem* psys); + + /** Internal method for destroying an affector. + @remarks + Because affectors are created by factories which may allocate memory from separate heaps, + the memory allocated must be freed from the same place. This method is used to ask the factory + to destroy the instance passed in as a pointer. + @param + affector Pointer to affector to be destroyed. On return this pointer will point to invalid (freed) memory. + */ + void _destroyAffector(ParticleAffector* affector); + + /** Internal method for creating a new renderer from a factory. + @remarks + Used internally by the engine to create new ParticleSystemRenderer instances from named + factories. Applications should use the ParticleSystem::setRenderer method instead, + which calls this method to create an instance. + @param + rendererType String name of the renderer type to be created. A factory of this type must have been registered. + */ + ParticleSystemRenderer* _createRenderer(const String& rendererType); + + /** Internal method for destroying a renderer. + @remarks + Because renderer are created by factories which may allocate memory from separate heaps, + the memory allocated must be freed from the same place. This method is used to ask the factory + to destroy the instance passed in as a pointer. + @param + renderer Pointer to renderer to be destroyed. On return this pointer will point to invalid (freed) memory. + */ + void _destroyRenderer(ParticleSystemRenderer* renderer); + + /** Init method to be called by OGRE system. + @remarks + Due to dependencies between various objects certain initialisation tasks cannot be done + on construction. OGRE will call this method when the rendering subsystem is initialised. + */ + void _initialise(void); + + /// @copydoc ScriptLoader::getScriptPatterns + const StringVector& getScriptPatterns(void) const; + /// @copydoc ScriptLoader::parseScript + void parseScript(DataStreamPtr& stream, const String& groupName); + /// @copydoc ScriptLoader::getLoadingOrder + Real getLoadingOrder(void) const; + + typedef MapIterator ParticleAffectorFactoryIterator; + typedef MapIterator ParticleEmitterFactoryIterator; + typedef MapIterator ParticleRendererFactoryIterator; + /** Return an iterator over the affector factories currently registered */ + ParticleAffectorFactoryIterator getAffectorFactoryIterator(void); + /** Return an iterator over the emitter factories currently registered */ + ParticleEmitterFactoryIterator getEmitterFactoryIterator(void); + /** Return an iterator over the renderer factories currently registered */ + ParticleRendererFactoryIterator getRendererFactoryIterator(void); + + + typedef MapIterator ParticleSystemTemplateIterator; + /** Gets an iterator over the list of particle system templates. */ + ParticleSystemTemplateIterator getTemplateIterator(void) + { + return ParticleSystemTemplateIterator( + mSystemTemplates.begin(), mSystemTemplates.end()); + } + + /** Get an instance of ParticleSystemFactory (internal use). */ + ParticleSystemFactory* _getFactory(void) { return mFactory; } + + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static ParticleSystemManager& getSingleton(void); + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static ParticleSystemManager* getSingletonPtr(void); + + }; + + /** Factory object for creating ParticleSystem instances */ + class _OgreExport ParticleSystemFactory : public MovableObjectFactory + { + protected: + MovableObject* createInstanceImpl(const String& name, const NameValuePairList* params); + public: + ParticleSystemFactory() {} + ~ParticleSystemFactory() {} + + static String FACTORY_TYPE_NAME; + + const String& getType(void) const; + void destroyInstance( MovableObject* obj); + + }; + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreParticleSystemRenderer.h b/school/informatik/verkerhssimulation/src/ogre/OgreParticleSystemRenderer.h new file mode 100644 index 00000000..5b923394 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreParticleSystemRenderer.h @@ -0,0 +1,124 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ParticleSystemRenderer_H__ +#define __ParticleSystemRenderer_H__ + +#include "OgrePrerequisites.h" +#include "OgreStringInterface.h" +#include "OgreFactoryObj.h" +#include "OgreRenderQueue.h" +#include "OgreCommon.h" + +namespace Ogre { + + /** Abstract class defining the interface required to be implemented + by classes which provide rendering capability to ParticleSystem instances. + */ + class _OgreExport ParticleSystemRenderer : public StringInterface + { + public: + /// Constructor + ParticleSystemRenderer() {} + /// Destructor + virtual ~ParticleSystemRenderer() {} + + /** Gets the type of this renderer - must be implemented by subclasses */ + virtual const String& getType(void) const = 0; + + /** Delegated to by ParticleSystem::_updateRenderQueue + @remarks + The subclass must update the render queue using whichever Renderable + instance(s) it wishes. + */ + virtual void _updateRenderQueue(RenderQueue* queue, + std::list& currentParticles, bool cullIndividually) = 0; + + /** Sets the material this renderer must use; called by ParticleSystem. */ + virtual void _setMaterial(MaterialPtr& mat) = 0; + /** Delegated to by ParticleSystem::_notifyCurrentCamera */ + virtual void _notifyCurrentCamera(Camera* cam) = 0; + /** Delegated to by ParticleSystem::_notifyAttached */ + virtual void _notifyAttached(Node* parent, bool isTagPoint = false) = 0; + /** Optional callback notified when particles are rotated */ + virtual void _notifyParticleRotated(void) {} + /** Optional callback notified when particles are resized individually */ + virtual void _notifyParticleResized(void) {} + /** Tells the renderer that the particle quota has changed */ + virtual void _notifyParticleQuota(size_t quota) = 0; + /** Tells the renderer that the particle default size has changed */ + virtual void _notifyDefaultDimensions(Real width, Real height) = 0; + /** Optional callback notified when particle emitted */ + virtual void _notifyParticleEmitted(Particle* particle) {} + /** Optional callback notified when particle expired */ + virtual void _notifyParticleExpired(Particle* particle) {} + /** Optional callback notified when particles moved */ + virtual void _notifyParticleMoved(std::list& currentParticles) {} + /** Optional callback notified when particles cleared */ + virtual void _notifyParticleCleared(std::list& currentParticles) {} + /** Create a new ParticleVisualData instance for attachment to a particle. + @remarks + If this renderer needs additional data in each particle, then this should + be held in an instance of a subclass of ParticleVisualData, and this method + should be overridden to return a new instance of it. The default + behaviour is to return null. + */ + virtual ParticleVisualData* _createVisualData(void) { return 0; } + /** Destroy a ParticleVisualData instance. + @remarks + If this renderer needs additional data in each particle, then this should + be held in an instance of a subclass of ParticleVisualData, and this method + should be overridden to destroy an instance of it. The default + behaviour is to do nothing. + */ + virtual void _destroyVisualData(ParticleVisualData* vis) { assert (vis == 0); } + + /** Sets which render queue group this renderer should target with it's + output. + */ + virtual void setRenderQueueGroup(uint8 queueID) = 0; + + /** Setting carried over from ParticleSystem. + */ + virtual void setKeepParticlesInLocalSpace(bool keepLocal) = 0; + + /** Gets the desired particles sort mode of this renderer */ + virtual SortMode _getSortMode(void) const = 0; + + }; + + /** Abstract class definition of a factory object for ParticleSystemRenderer. */ + class _OgreExport ParticleSystemRendererFactory : public FactoryObj + { + public: + // No methods, must just override all methods inherited from FactoryObj + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgrePass.h b/school/informatik/verkerhssimulation/src/ogre/OgrePass.h new file mode 100644 index 00000000..a82956c6 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgrePass.h @@ -0,0 +1,1321 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Pass_H__ +#define __Pass_H__ + +#include "OgrePrerequisites.h" +#include "OgreGpuProgram.h" +#include "OgreColourValue.h" +#include "OgreBlendMode.h" +#include "OgreCommon.h" +#include "OgreLight.h" +#include "OgreTextureUnitState.h" + +namespace Ogre { + /** Class defining a single pass of a Technique (of a Material), ie + a single rendering call. + @remarks + Rendering can be repeated with many passes for more complex effects. + Each pass is either a fixed-function pass (meaning it does not use + a vertex or fragment program) or a programmable pass (meaning it does + use either a vertex and fragment program, or both). + @par + Programmable passes are complex to define, because they require custom + programs and you have to set all constant inputs to the programs (like + the position of lights, any base material colours you wish to use etc), but + they do give you much total flexibility over the algorithms used to render your + pass, and you can create some effects which are impossible with a fixed-function pass. + On the other hand, you can define a fixed-function pass in very little time, and + you can use a range of fixed-function effects like environment mapping very + easily, plus your pass will be more likely to be compatible with older hardware. + There are pros and cons to both, just remember that if you use a programmable + pass to create some great effects, allow more time for definition and testing. + */ + class _OgreExport Pass + { + public: + /** Definition of a functor for calculating the hashcode of a Pass. + @remarks + The hashcode of a Pass is used to sort Passes for rendering, in order + to reduce the number of render state changes. Each Pass represents a + single unique set of states, but by ordering them, state changes can + be minimised between passes. An implementation of this functor should + order passes so that the elements that you want to keep constant are + sorted next to each other. + @see Pass::setHashFunc + */ + struct HashFunc + { + virtual uint32 operator()(const Pass* p) const = 0; + /// Need virtual destructor in case subclasses use it + virtual ~HashFunc() {} + }; + protected: + Technique* mParent; + unsigned short mIndex; // pass index + String mName; // optional name for the pass + uint32 mHash; // pass hash + //------------------------------------------------------------------------- + // Colour properties, only applicable in fixed-function passes + ColourValue mAmbient; + ColourValue mDiffuse; + ColourValue mSpecular; + ColourValue mEmissive; + Real mShininess; + TrackVertexColourType mTracking; + //------------------------------------------------------------------------- + + //------------------------------------------------------------------------- + // Blending factors + SceneBlendFactor mSourceBlendFactor; + SceneBlendFactor mDestBlendFactor; + //------------------------------------------------------------------------- + + //------------------------------------------------------------------------- + // Depth buffer settings + bool mDepthCheck; + bool mDepthWrite; + CompareFunction mDepthFunc; + float mDepthBiasConstant; + float mDepthBiasSlopeScale; + + // Colour buffer settings + bool mColourWrite; + + // Alpha reject settings + CompareFunction mAlphaRejectFunc; + unsigned char mAlphaRejectVal; + //------------------------------------------------------------------------- + + //------------------------------------------------------------------------- + // Culling mode + CullingMode mCullMode; + ManualCullingMode mManualCullMode; + //------------------------------------------------------------------------- + + /// Lighting enabled? + bool mLightingEnabled; + /// Max simultaneous lights + unsigned short mMaxSimultaneousLights; + /// Starting light index + unsigned short mStartLight; + /// Run this pass once per light? + bool mIteratePerLight; + /// Iterate per how many lights? + unsigned short mLightsPerIteration; + // Should it only be run for a certain light type? + bool mRunOnlyForOneLightType; + Light::LightTypes mOnlyLightType; + + /// Shading options + ShadeOptions mShadeOptions; + /// Polygon mode + PolygonMode mPolygonMode; + + //------------------------------------------------------------------------- + // Fog + bool mFogOverride; + FogMode mFogMode; + ColourValue mFogColour; + Real mFogStart; + Real mFogEnd; + Real mFogDensity; + //------------------------------------------------------------------------- + + /// Storage of texture unit states + typedef std::vector TextureUnitStates; + TextureUnitStates mTextureUnitStates; + + // Vertex program details + GpuProgramUsage *mVertexProgramUsage; + // Vertex program details + GpuProgramUsage *mShadowCasterVertexProgramUsage; + // Vertex program details + GpuProgramUsage *mShadowReceiverVertexProgramUsage; + // Fragment program details + GpuProgramUsage *mFragmentProgramUsage; + // Fragment program details + GpuProgramUsage *mShadowReceiverFragmentProgramUsage; + // Is this pass queued for deletion? + bool mQueuedForDeletion; + // number of pass iterations to perform + size_t mPassIterationCount; + // point size, applies when not using per-vertex point size + Real mPointSize; + Real mPointMinSize; + Real mPointMaxSize; + bool mPointSpritesEnabled; + bool mPointAttenuationEnabled; + // constant, linear, quadratic coeffs + Real mPointAttenuationCoeffs[3]; + // TU Content type lookups + typedef std::vector ContentTypeLookup; + mutable ContentTypeLookup mShadowContentTypeLookup; + mutable bool mContentTypeLookupBuilt; + + public: + typedef std::set PassSet; + protected: + /// List of Passes whose hashes need recalculating + static PassSet msDirtyHashList; + /// The place where passes go to die + static PassSet msPassGraveyard; + /// The Pass hash functor + static HashFunc* msHashFunc; + public: + OGRE_STATIC_MUTEX(msDirtyHashListMutex); + OGRE_STATIC_MUTEX(msPassGraveyardMutex); + /// Default constructor + Pass(Technique* parent, unsigned short index); + /// Copy constructor + Pass(Technique* parent, unsigned short index, const Pass& oth ); + /// Operator = overload + Pass& operator=(const Pass& oth); + ~Pass(); + + /// Returns true if this pass is programmable ie includes either a vertex or fragment program. + bool isProgrammable(void) const { return mVertexProgramUsage || mFragmentProgramUsage; } + /// Returns true if this pass uses a programmable vertex pipeline + bool hasVertexProgram(void) const { return mVertexProgramUsage != NULL; } + /// Returns true if this pass uses a programmable fragment pipeline + bool hasFragmentProgram(void) const { return mFragmentProgramUsage != NULL; } + /// Returns true if this pass uses a shadow caster vertex program + bool hasShadowCasterVertexProgram(void) const { return mShadowCasterVertexProgramUsage != NULL; } + /// Returns true if this pass uses a shadow receiver vertex program + bool hasShadowReceiverVertexProgram(void) const { return mShadowReceiverVertexProgramUsage != NULL; } + /// Returns true if this pass uses a shadow receiver fragment program + bool hasShadowReceiverFragmentProgram(void) const { return mShadowReceiverFragmentProgramUsage != NULL; } + + + /// Gets the index of this Pass in the parent Technique + unsigned short getIndex(void) const { return mIndex; } + /* Set the name of the pass + @remarks + The name of the pass is optional. Its usefull in material scripts where a material could inherit + from another material and only want to modify a particalar pass. + */ + void setName(const String& name); + /// get the name of the pass + const String& getName(void) const { return mName; } + + /** Sets the ambient colour reflectance properties of this pass. + @remarks + The base colour of a pass is determined by how much red, green and blue light is reflects + (provided texture layer #0 has a blend mode other than LBO_REPLACE). This property determines how + much ambient light (directionless global light) is reflected. The default is full white, meaning + objects are completely globally illuminated. Reduce this if you want to see diffuse or specular light + effects, or change the blend of colours to make the object have a base colour other than white. + @note + This setting has no effect if dynamic lighting is disabled (see Pass::setLightingEnabled), + or if this is a programmable pass. + */ + void setAmbient(Real red, Real green, Real blue); + + /** Sets the ambient colour reflectance properties of this pass. + @remarks + The base colour of a pass is determined by how much red, green and blue light is reflects + (provided texture layer #0 has a blend mode other than LBO_REPLACE). This property determines how + much ambient light (directionless global light) is reflected. The default is full white, meaning + objects are completely globally illuminated. Reduce this if you want to see diffuse or specular light + effects, or change the blend of colours to make the object have a base colour other than white. + @note + This setting has no effect if dynamic lighting is disabled (see Pass::setLightingEnabled), + or if this is a programmable pass. + */ + + void setAmbient(const ColourValue& ambient); + + /** Sets the diffuse colour reflectance properties of this pass. + @remarks + The base colour of a pass is determined by how much red, green and blue light is reflects + (provided texture layer #0 has a blend mode other than LBO_REPLACE). This property determines how + much diffuse light (light from instances of the Light class in the scene) is reflected. The default + is full white, meaning objects reflect the maximum white light they can from Light objects. + @note + This setting has no effect if dynamic lighting is disabled (see Pass::setLightingEnabled), + or if this is a programmable pass. + */ + void setDiffuse(Real red, Real green, Real blue, Real alpha); + + /** Sets the diffuse colour reflectance properties of this pass. + @remarks + The base colour of a pass is determined by how much red, green and blue light is reflects + (provided texture layer #0 has a blend mode other than LBO_REPLACE). This property determines how + much diffuse light (light from instances of the Light class in the scene) is reflected. The default + is full white, meaning objects reflect the maximum white light they can from Light objects. + @note + This setting has no effect if dynamic lighting is disabled (see Pass::setLightingEnabled), + or if this is a programmable pass. + */ + void setDiffuse(const ColourValue& diffuse); + + /** Sets the specular colour reflectance properties of this pass. + @remarks + The base colour of a pass is determined by how much red, green and blue light is reflects + (provided texture layer #0 has a blend mode other than LBO_REPLACE). This property determines how + much specular light (highlights from instances of the Light class in the scene) is reflected. + The default is to reflect no specular light. + @note + The size of the specular highlights is determined by the separate 'shininess' property. + @note + This setting has no effect if dynamic lighting is disabled (see Pass::setLightingEnabled), + or if this is a programmable pass. + */ + void setSpecular(Real red, Real green, Real blue, Real alpha); + + /** Sets the specular colour reflectance properties of this pass. + @remarks + The base colour of a pass is determined by how much red, green and blue light is reflects + (provided texture layer #0 has a blend mode other than LBO_REPLACE). This property determines how + much specular light (highlights from instances of the Light class in the scene) is reflected. + The default is to reflect no specular light. + @note + The size of the specular highlights is determined by the separate 'shininess' property. + @note + This setting has no effect if dynamic lighting is disabled (see Pass::setLightingEnabled), + or if this is a programmable pass. + */ + void setSpecular(const ColourValue& specular); + + /** Sets the shininess of the pass, affecting the size of specular highlights. + @note + This setting has no effect if dynamic lighting is disabled (see Pass::setLightingEnabled), + or if this is a programmable pass. + */ + void setShininess(Real val); + + /** Sets the amount of self-illumination an object has. + @remarks + If an object is self-illuminating, it does not need external sources to light it, ambient or + otherwise. It's like the object has it's own personal ambient light. This property is rarely useful since + you can already specify per-pass ambient light, but is here for completeness. + @note + This setting has no effect if dynamic lighting is disabled (see Pass::setLightingEnabled), + or if this is a programmable pass. + */ + void setSelfIllumination(Real red, Real green, Real blue); + + /** Sets the amount of self-illumination an object has. + @remarks + If an object is self-illuminating, it does not need external sources to light it, ambient or + otherwise. It's like the object has it's own personal ambient light. This property is rarely useful since + you can already specify per-pass ambient light, but is here for completeness. + @note + This setting has no effect if dynamic lighting is disabled (see Pass::setLightingEnabled), + or if this is a programmable pass. + */ + void setSelfIllumination(const ColourValue& selfIllum); + + /** Sets which material properties follow the vertex colour + */ + void setVertexColourTracking(TrackVertexColourType tracking); + + /** Gets the point size of the pass. + @remarks + This property determines what point size is used to render a point + list. + */ + Real getPointSize(void) const; + + /** Sets the point size of this pass. + @remarks + This setting allows you to change the size of points when rendering + a point list, or a list of point sprites. The interpretation of this + command depends on the Pass::setPointSizeAttenuation option - if it + is off (the default), the point size is in screen pixels, if it is on, + it expressed as normalised screen coordinates (1.0 is the height of + the screen) when the point is at the origin. + @note + Some drivers have an upper limit on the size of points they support + - this can even vary between APIs on the same card! Don't rely on + point sizes that cause the point sprites to get very large on screen, + since they may get clamped on some cards. Upper sizes can range from + 64 to 256 pixels. + */ + void setPointSize(Real ps); + + /** Sets whether or not rendering points using OT_POINT_LIST will + render point sprites (textured quads) or plain points (dots). + @param enabled True enables point sprites, false returns to normal + point rendering. + */ + void setPointSpritesEnabled(bool enabled); + + /** Returns whether point sprites are enabled when rendering a + point list. + */ + bool getPointSpritesEnabled(void) const; + + /** Sets how points are attenuated with distance. + @remarks + When performing point rendering or point sprite rendering, + point size can be attenuated with distance. The equation for + doing this is attenuation = 1 / (constant + linear * dist + quadratic * d^2). + @par + For example, to disable distance attenuation (constant screensize) + you would set constant to 1, and linear and quadratic to 0. A + standard perspective attenuation would be 0, 1, 0 respectively. + @note + The resulting size is clamped to the minimum and maximum point + size. + @param enabled Whether point attenuation is enabled + @param constant, linear, quadratic Parameters to the attentuation + function defined above + */ + void setPointAttenuation(bool enabled, + Real constant = 0.0f, Real linear = 1.0f, Real quadratic = 0.0f); + + /** Returns whether points are attenuated with distance. */ + bool isPointAttenuationEnabled(void) const; + + /** Returns the constant coefficient of point attenuation. */ + Real getPointAttenuationConstant(void) const; + /** Returns the linear coefficient of point attenuation. */ + Real getPointAttenuationLinear(void) const; + /** Returns the quadratic coefficient of point attenuation. */ + Real getPointAttenuationQuadratic(void) const; + + /** Set the minimum point size, when point attenuation is in use. */ + void setPointMinSize(Real min); + /** Get the minimum point size, when point attenuation is in use. */ + Real getPointMinSize(void) const; + /** Set the maximum point size, when point attenuation is in use. + @remarks Setting this to 0 indicates the max size supported by the card. + */ + void setPointMaxSize(Real max); + /** Get the maximum point size, when point attenuation is in use. + @remarks 0 indicates the max size supported by the card. + */ + Real getPointMaxSize(void) const; + + /** Gets the ambient colour reflectance of the pass. + */ + const ColourValue& getAmbient(void) const; + + /** Gets the diffuse colour reflectance of the pass. + */ + const ColourValue& getDiffuse(void) const; + + /** Gets the specular colour reflectance of the pass. + */ + const ColourValue& getSpecular(void) const; + + /** Gets the self illumination colour of the pass. + */ + const ColourValue& getSelfIllumination(void) const; + + /** Gets the 'shininess' property of the pass (affects specular highlights). + */ + Real getShininess(void) const; + + /** Gets which material properties follow the vertex colour + */ + TrackVertexColourType getVertexColourTracking(void) const; + + /** Inserts a new TextureUnitState object into the Pass. + @remarks + This unit is is added on top of all previous units. + */ + TextureUnitState* createTextureUnitState(void); + /** Inserts a new TextureUnitState object into the Pass. + @remarks + This unit is is added on top of all previous units. + @param + name The basic name of the texture e.g. brickwall.jpg, stonefloor.png + @param + texCoordSet The index of the texture coordinate set to use. + @note + Applies to both fixed-function and programmable passes. + */ + TextureUnitState* createTextureUnitState( const String& textureName, unsigned short texCoordSet = 0); + /** Adds the passed in TextureUnitState, to the existing Pass. + @param + state The Texture Unit State to be attached to this pass. It must not be attached to another pass. + @note + Throws an exception if the TextureUnitState is attached to another Pass.*/ + void addTextureUnitState(TextureUnitState* state); + /** Retrieves a pointer to a texture unit state so it may be modified. + */ + TextureUnitState* getTextureUnitState(unsigned short index); + /** Retrieves the Texture Unit State matching name. + Returns 0 if name match is not found. + */ + TextureUnitState* getTextureUnitState(const String& name); + /** Retrieves a const pointer to a texture unit state. + */ + const TextureUnitState* getTextureUnitState(unsigned short index) const; + /** Retrieves the Texture Unit State matching name. + Returns 0 if name match is not found. + */ + const TextureUnitState* getTextureUnitState(const String& name) const; + + /** Retrieve the index of the Texture Unit State in the pass. + @param + state The Texture Unit State this is attached to this pass. + @note + Throws an exception if the state is not attached to the pass. + */ + unsigned short getTextureUnitStateIndex(const TextureUnitState* state) const; + + typedef VectorIterator TextureUnitStateIterator; + /** Get an iterator over the TextureUnitStates contained in this Pass. */ + TextureUnitStateIterator getTextureUnitStateIterator(void); + + typedef ConstVectorIterator ConstTextureUnitStateIterator; + /** Get an iterator over the TextureUnitStates contained in this Pass. */ + ConstTextureUnitStateIterator getTextureUnitStateIterator(void) const; + + /** Removes the indexed texture unit state from this pass. + @remarks + Note that removing a texture which is not the topmost will have a larger performance impact. + */ + void removeTextureUnitState(unsigned short index); + + /** Removes all texture unit settings. + */ + void removeAllTextureUnitStates(void); + + /** Returns the number of texture unit settings. + */ + unsigned short getNumTextureUnitStates(void) const + { + return static_cast(mTextureUnitStates.size()); + } + + /** Sets the kind of blending this pass has with the existing contents of the scene. + @remarks + Wheras the texture blending operations seen in the TextureUnitState class are concerned with + blending between texture layers, this blending is about combining the output of the Pass + as a whole with the existing contents of the rendering target. This blending therefore allows + object transparency and other special effects. If all passes in a technique have a scene + blend, then the whole technique is considered to be transparent. + @par + This method allows you to select one of a number of predefined blending types. If you require more + control than this, use the alternative version of this method which allows you to specify source and + destination blend factors. + @note + This method is applicable for both the fixed-function and programmable pipelines. + @param + sbt One of the predefined SceneBlendType blending types + */ + void setSceneBlending( const SceneBlendType sbt ); + + /** Allows very fine control of blending this Pass with the existing contents of the scene. + @remarks + Wheras the texture blending operations seen in the TextureUnitState class are concerned with + blending between texture layers, this blending is about combining the output of the material + as a whole with the existing contents of the rendering target. This blending therefore allows + object transparency and other special effects. + @par + This version of the method allows complete control over the blending operation, by specifying the + source and destination blending factors. The result of the blending operation is: + + final = (texture * sourceFactor) + (pixel * destFactor) + + @par + Each of the factors is specified as one of a number of options, as specified in the SceneBlendFactor + enumerated type. + @param + sourceFactor The source factor in the above calculation, i.e. multiplied by the texture colour components. + @param + destFactor The destination factor in the above calculation, i.e. multiplied by the pixel colour components. + @note + This method is applicable for both the fixed-function and programmable pipelines. + */ + void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor); + + /** Retrieves the source blending factor for the material (as set using Materiall::setSceneBlending). + */ + SceneBlendFactor getSourceBlendFactor() const; + + /** Retrieves the destination blending factor for the material (as set using Materiall::setSceneBlending). + */ + SceneBlendFactor getDestBlendFactor() const; + + /** Returns true if this pass has some element of transparency. */ + bool isTransparent(void) const; + + /** Sets whether or not this pass renders with depth-buffer checking on or not. + @remarks + If depth-buffer checking is on, whenever a pixel is about to be written to the frame buffer + the depth buffer is checked to see if the pixel is in front of all other pixels written at that + point. If not, the pixel is not written. + @par + If depth checking is off, pixels are written no matter what has been rendered before. + Also see setDepthFunction for more advanced depth check configuration. + @see + setDepthFunction + */ + void setDepthCheckEnabled(bool enabled); + + /** Returns whether or not this pass renders with depth-buffer checking on or not. + @see + setDepthCheckEnabled + */ + bool getDepthCheckEnabled(void) const; + + /** Sets whether or not this pass renders with depth-buffer writing on or not. + @remarks + If depth-buffer writing is on, whenever a pixel is written to the frame buffer + the depth buffer is updated with the depth value of that new pixel, thus affecting future + rendering operations if future pixels are behind this one. + @par + If depth writing is off, pixels are written without updating the depth buffer Depth writing should + normally be on but can be turned off when rendering static backgrounds or when rendering a collection + of transparent objects at the end of a scene so that they overlap each other correctly. + */ + void setDepthWriteEnabled(bool enabled); + + /** Returns whether or not this pass renders with depth-buffer writing on or not. + @see + setDepthWriteEnabled + */ + bool getDepthWriteEnabled(void) const; + + /** Sets the function used to compare depth values when depth checking is on. + @remarks + If depth checking is enabled (see setDepthCheckEnabled) a comparison occurs between the depth + value of the pixel to be written and the current contents of the buffer. This comparison is + normally CMPF_LESS_EQUAL, i.e. the pixel is written if it is closer (or at the same distance) + than the current contents. If you wish you can change this comparison using this method. + */ + void setDepthFunction( CompareFunction func ); + /** Returns the function used to compare depth values when depth checking is on. + @see + setDepthFunction + */ + CompareFunction getDepthFunction(void) const; + + /** Sets whether or not colour buffer writing is enabled for this Pass. + @remarks + For some effects, you might wish to turn off the colour write operation + when rendering geometry; this means that only the depth buffer will be + updated (provided you have depth buffer writing enabled, which you + probably will do, although you may wish to only update the stencil + buffer for example - stencil buffer state is managed at the RenderSystem + level only, not the Material since you are likely to want to manage it + at a higher level). + */ + void setColourWriteEnabled(bool enabled); + /** Determines if colour buffer writing is enabled for this pass. */ + bool getColourWriteEnabled(void) const; + + /** Sets the culling mode for this pass based on the 'vertex winding'. + @remarks + A typical way for the rendering engine to cull triangles is based on the 'vertex winding' of + triangles. Vertex winding refers to the direction in which the vertices are passed or indexed + to in the rendering operation as viewed from the camera, and will wither be clockwise or + anticlockwise (that's 'counterclockwise' for you Americans out there ;) The default is + CULL_CLOCKWISE i.e. that only triangles whose vertices are passed/indexed in anticlockwise order + are rendered - this is a common approach and is used in 3D studio models for example. You can + alter this culling mode if you wish but it is not advised unless you know what you are doing. + @par + You may wish to use the CULL_NONE option for mesh data that you cull yourself where the vertex + winding is uncertain. + */ + void setCullingMode( CullingMode mode ); + + /** Returns the culling mode for geometry rendered with this pass. See setCullingMode for more information. + */ + CullingMode getCullingMode(void) const; + + /** Sets the manual culling mode, performed by CPU rather than hardware. + @pemarks + In some situations you want to use manual culling of triangles rather than sending the + triangles to the hardware and letting it cull them. This setting only takes effect on SceneManager's + that use it (since it is best used on large groups of planar world geometry rather than on movable + geometry since this would be expensive), but if used can cull geometry before it is sent to the + hardware. + @note + The default for this setting is MANUAL_CULL_BACK. + @param + mode The mode to use - see enum ManualCullingMode for details + + */ + void setManualCullingMode( ManualCullingMode mode ); + + /** Retrieves the manual culling mode for this pass + @see + setManualCullingMode + */ + ManualCullingMode getManualCullingMode(void) const; + + /** Sets whether or not dynamic lighting is enabled. + @param + enabled + If true, dynamic lighting is performed on geometry with normals supplied, geometry without + normals will not be displayed. + @par + If false, no lighting is applied and all geometry will be full brightness. + */ + void setLightingEnabled(bool enabled); + + /** Returns whether or not dynamic lighting is enabled. + */ + bool getLightingEnabled(void) const; + + /** Sets the maximum number of lights to be used by this pass. + @remarks + During rendering, if lighting is enabled (or if the pass uses an automatic + program parameter based on a light) the engine will request the nearest lights + to the object being rendered in order to work out which ones to use. This + parameter sets the limit on the number of lights which should apply to objects + rendered with this pass. + */ + void setMaxSimultaneousLights(unsigned short maxLights); + /** Gets the maximum number of lights to be used by this pass. */ + unsigned short getMaxSimultaneousLights(void) const; + + /** Sets the light index that this pass will start at in the light list. + @remarks + Normally the lights passed to a pass will start from the beginning + of the light list for this object. This option allows you to make this + pass start from a higher light index, for example if one of your earlier + passes could deal with lights 0-3, and this pass dealt with lights 4+. + This option also has an interaction with pass iteration, in that + if you choose to iterate this pass per light too, the iteration will + only begin from light 4. + */ + void setStartLight(unsigned short startLight); + /** Gets the light index that this pass will start at in the light list. */ + unsigned short getStartLight(void) const; + + /** Sets the type of light shading required + @note + The default shading method is Gouraud shading. + */ + void setShadingMode( ShadeOptions mode ); + + /** Returns the type of light shading to be used. + */ + ShadeOptions getShadingMode(void) const; + + /** Sets the type of polygon rendering required + @note + The default shading method is Solid + */ + void setPolygonMode( PolygonMode mode ); + + /** Returns the type of light shading to be used. + */ + PolygonMode getPolygonMode(void) const; + + /** Sets the fogging mode applied to this pass. + @remarks + Fogging is an effect that is applied as polys are rendered. Sometimes, you want + fog to be applied to an entire scene. Other times, you want it to be applied to a few + polygons only. This pass-level specification of fog parameters lets you easily manage + both. + @par + The SceneManager class also has a setFog method which applies scene-level fog. This method + lets you change the fog behaviour for this pass compared to the standard scene-level fog. + @param + overrideScene If true, you authorise this pass to override the scene's fog params with it's own settings. + If you specify false, so other parameters are necessary, and this is the default behaviour for passs. + @param + mode Only applicable if overrideScene is true. You can disable fog which is turned on for the + rest of the scene by specifying FOG_NONE. Otherwise, set a pass-specific fog mode as + defined in the enum FogMode. + @param + colour The colour of the fog. Either set this to the same as your viewport background colour, + or to blend in with a skydome or skybox. + @param + expDensity The density of the fog in FOG_EXP or FOG_EXP2 mode, as a value between 0 and 1. + The default is 0.001. + @param + linearStart Distance in world units at which linear fog starts to encroach. + Only applicable if mode is FOG_LINEAR. + @param + linearEnd Distance in world units at which linear fog becomes completely opaque. + Only applicable if mode is FOG_LINEAR. + */ + void setFog( + bool overrideScene, + FogMode mode = FOG_NONE, + const ColourValue& colour = ColourValue::White, + Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 ); + + /** Returns true if this pass is to override the scene fog settings. + */ + bool getFogOverride(void) const; + + /** Returns the fog mode for this pass. + @note + Only valid if getFogOverride is true. + */ + FogMode getFogMode(void) const; + + /** Returns the fog colour for the scene. + */ + const ColourValue& getFogColour(void) const; + + /** Returns the fog start distance for this pass. + @note + Only valid if getFogOverride is true. + */ + Real getFogStart(void) const; + + /** Returns the fog end distance for this pass. + @note + Only valid if getFogOverride is true. + */ + Real getFogEnd(void) const; + + /** Returns the fog density for this pass. + @note + Only valid if getFogOverride is true. + */ + Real getFogDensity(void) const; + + /** Sets the depth bias to be used for this material. + @remarks + When polygons are coplanar, you can get problems with 'depth fighting' where + the pixels from the two polys compete for the same screen pixel. This is particularly + a problem for decals (polys attached to another surface to represent details such as + bulletholes etc.). + @par + A way to combat this problem is to use a depth bias to adjust the depth buffer value + used for the decal such that it is slightly higher than the true value, ensuring that + the decal appears on top. There are two aspects to the biasing, a constant + bias value and a slope-relative biasing value, which varies according to the + maximum depth slope relative to the camera, ie: +
finalBias = maxSlope * slopeScaleBias + constantBias
+ Note that slope scale bias, whilst more accurate, may be ignored by old hardware. + @param constantBias The constant bias value, expressed as a factor of the + minimum observable depth + @param slopeScaleBias The slope-relative bias value, expressed as a factor + of the depth slope + */ + void setDepthBias(float constantBias, float slopeScaleBias = 0.0f); + + /** Retrieves the const depth bias value as set by setDepthBias. */ + float getDepthBiasConstant(void) const; + /** Retrieves the slope-scale depth bias value as set by setDepthBias. */ + float getDepthBiasSlopeScale(void) const; + + /** Sets the way the pass will have use alpha to totally reject pixels from the pipeline. + @remarks + The default is CMPF_ALWAYS_PASS i.e. alpha is not used to reject pixels. + @param func The comparison which must pass for the pixel to be written. + @param value 1 byte value against which alpha values will be tested(0-255) + @note + This option applies in both the fixed function and the programmable pipeline. + */ + void setAlphaRejectSettings(CompareFunction func, unsigned char value); + + /** Sets the alpha reject function. See setAlphaRejectSettings for more information. + */ + void setAlphaRejectFunction(CompareFunction func); + + /** Gets the alpha reject value. See setAlphaRejectSettings for more information. + */ + void setAlphaRejectValue(unsigned char val); + + /** Gets the alpha reject function. See setAlphaRejectSettings for more information. + */ + CompareFunction getAlphaRejectFunction(void) const { return mAlphaRejectFunc; } + + /** Gets the alpha reject value. See setAlphaRejectSettings for more information. + */ + unsigned char getAlphaRejectValue(void) const { return mAlphaRejectVal; } + /** Sets whether or not this pass should iterate per light or number of + lights which can affect the object being rendered. + @remarks + The default behaviour for a pass (when this option is 'false'), is + for a pass to be rendered only once (or the number of times set in + setPassIterationCount), with all the lights which could + affect this object set at the same time (up to the maximum lights + allowed in the render system, which is typically 8). + @par + Setting this option to 'true' changes this behaviour, such that + instead of trying to issue render this pass once per object, it + is run per light, or for a group of 'n' lights each time + which can affect this object, the number of + times set in setPassIterationCount (default is once). In + this case, only light index 0 is ever used, and is a different light + every time the pass is issued, up to the total number of lights + which is affecting this object. This has 2 advantages: +
  • There is no limit on the number of lights which can be + supported
  • +
  • It's easier to write vertex / fragment programs for this because + a single program can be used for any number of lights
  • +
+ However, this technique is more expensive, and typically you + will want an additional ambient pass, because if no lights are + affecting the object it will not be rendered at all, which will look + odd even if ambient light is zero (imagine if there are lit objects + behind it - the objects silhouette would not show up). Therefore, + use this option with care, and you would be well advised to provide + a less expensive fallback technique for use in the distance. + @note + The number of times this pass runs is still limited by the maximum + number of lights allowed as set in setMaxSimultaneousLights, so + you will never get more passes than this. Also, the iteration is + started from the 'start light' as set in Pass::setStartLight, and + the number of passes is the number of lights to iterate over divided + by the number of lights per iteration (default 1, set by + setLightCountPerIteration). + @param enabled Whether this feature is enabled + @param onlyForOneLightType If true, the pass will only be run for a single type + of light, other light types will be ignored. + @param lightType The single light type which will be considered for this pass + */ + void setIteratePerLight(bool enabled, + bool onlyForOneLightType = true, Light::LightTypes lightType = Light::LT_POINT); + + /** Does this pass run once for every light in range? */ + bool getIteratePerLight(void) const { return mIteratePerLight; } + /** Does this pass run only for a single light type (if getIteratePerLight is true). */ + bool getRunOnlyForOneLightType(void) const { return mRunOnlyForOneLightType; } + /** Gets the single light type this pass runs for if getIteratePerLight and + getRunOnlyForOneLightType are both true. */ + Light::LightTypes getOnlyLightType() const { return mOnlyLightType; } + + /** If light iteration is enabled, determine the number of lights per + iteration. + @remarks + The default for this setting is 1, so if you enable light iteration + (Pass::setIteratePerLight), the pass is rendered once per light. If + you set this value higher, the passes will occur once per 'n' lights. + The start of the iteration is set by Pass::setStartLight and the end + by Pass::setMaxSimultaneousLights. + */ + void setLightCountPerIteration(unsigned short c); + /** If light iteration is enabled, determine the number of lights per + iteration. + */ + unsigned short getLightCountPerIteration(void) const; + + /// Gets the parent Technique + Technique* getParent(void) const { return mParent; } + + /// Gets the resource group of the ultimate parent Material + const String& getResourceGroup(void) const; + + /** Sets the details of the vertex program to use. + @remarks + Only applicable to programmable passes, this sets the details of + the vertex program to use in this pass. The program will not be + loaded until the parent Material is loaded. + @param name The name of the program - this must have been + created using GpuProgramManager by the time that this Pass + is loaded. If this parameter is blank, any vertex program in this pass is disabled. + @param resetParams + If true, this will create a fresh set of parameters from the + new program being linked, so if you had previously set parameters + you will have to set them again. If you set this to false, you must + be absolutely sure that the parameters match perfectly, and in the + case of named parameters refers to the indexes underlying them, + not just the names. + */ + void setVertexProgram(const String& name, bool resetParams = true); + /** Sets the vertex program parameters. + @remarks + Only applicable to programmable passes, and this particular call is + designed for low-level programs; use the named parameter methods + for setting high-level program parameters. + */ + void setVertexProgramParameters(GpuProgramParametersSharedPtr params); + /** Gets the name of the vertex program used by this pass. */ + const String& getVertexProgramName(void) const; + /** Gets the vertex program parameters used by this pass. */ + GpuProgramParametersSharedPtr getVertexProgramParameters(void) const; + /** Gets the vertex program used by this pass, only available after _load(). */ + const GpuProgramPtr& getVertexProgram(void) const; + + + /** Sets the details of the vertex program to use when rendering as a + shadow caster. + @remarks + Texture-based shadows require that the caster is rendered to a texture + in a solid colour (the shadow colour in the case of modulative texture + shadows). Whilst Ogre can arrange this for the fixed function + pipeline, passes which use vertex programs might need the vertex + programs still to run in order to preserve any deformation etc + that it does. However, lighting calculations must be a lot simpler, + with only the ambient colour being used (which the engine will ensure + is bound to the shadow colour). + @par + Therefore, it is up to implemetors of vertex programs to provide an + alternative vertex program which can be used to render the object + to a shadow texture. Do all the same vertex transforms, but set the + colour of the vertex to the ambient colour, as bound using the + standard auto parameter binding mechanism. + @note + Some vertex programs will work without doing this, because Ogre ensures + that all lights except for ambient are set black. However, the chances + are that your vertex program is doing a lot of unnecessary work in this + case, since the other lights are having no effect, and it is good practice + to supply an alternative. + @note + This is only applicable to programmable passes. + @par + The default behaviour is for Ogre to switch to fixed-function + rendering if an explict vertex program alternative is not set. + */ + void setShadowCasterVertexProgram(const String& name); + /** Sets the vertex program parameters for rendering as a shadow caster. + @remarks + Only applicable to programmable passes, and this particular call is + designed for low-level programs; use the named parameter methods + for setting high-level program parameters. + */ + void setShadowCasterVertexProgramParameters(GpuProgramParametersSharedPtr params); + /** Gets the name of the vertex program used by this pass when rendering shadow casters. */ + const String& getShadowCasterVertexProgramName(void) const; + /** Gets the vertex program parameters used by this pass when rendering shadow casters. */ + GpuProgramParametersSharedPtr getShadowCasterVertexProgramParameters(void) const; + /** Gets the vertex program used by this pass when rendering shadow casters, + only available after _load(). */ + const GpuProgramPtr& getShadowCasterVertexProgram(void) const; + + /** Sets the details of the vertex program to use when rendering as a + shadow receiver. + @remarks + Texture-based shadows require that the shadow receiver is rendered using + a projective texture. Whilst Ogre can arrange this for the fixed function + pipeline, passes which use vertex programs might need the vertex + programs still to run in order to preserve any deformation etc + that it does. So in this case, we need a vertex program which does the + appropriate vertex transformation, but generates projective texture + coordinates. + @par + Therefore, it is up to implemetors of vertex programs to provide an + alternative vertex program which can be used to render the object + as a shadow receiver. Do all the same vertex transforms, but generate + 2 sets of texture coordinates using the auto parameter + ACT_TEXTURE_VIEWPROJ_MATRIX, which Ogre will bind to the parameter name / + index you supply as the second parameter to this method. 2 texture + sets are needed because Ogre needs to use 2 texture units for some + shadow effects. + @note + This is only applicable to programmable passes. + @par + The default behaviour is for Ogre to switch to fixed-function + rendering if an explict vertex program alternative is not set. + */ + void setShadowReceiverVertexProgram(const String& name); + /** Sets the vertex program parameters for rendering as a shadow receiver. + @remarks + Only applicable to programmable passes, and this particular call is + designed for low-level programs; use the named parameter methods + for setting high-level program parameters. + */ + void setShadowReceiverVertexProgramParameters(GpuProgramParametersSharedPtr params); + + /** This method allows you to specify a fragment program for use when + rendering a texture shadow receiver. + @remarks + Texture shadows are applied by rendering the receiver. Modulative texture + shadows are performed as a post-render darkening pass, and as such + fragment programs are generally not required per-object. Additive + texture shadows, however, are applied by accumulating light masked + out using a texture shadow (black & white by default, unless you + customise this using SceneManager::setCustomShadowCasterMaterial). + OGRE can do this for you for most materials, but if you use a custom + lighting program (e.g. per pixel lighting) then you'll need to provide + a custom version for receiving shadows. You don't need to provide + this for shadow casters if you don't use self-shadowing since they + will never be shadow receivers too. + @par + The shadow texture is always bound to texture unit 0 when rendering + texture shadow passes. Therefore your custom shadow receiver program + may well just need to shift it's texture unit usage up by one unit, + and take the shadow texture into account in its calculations. + */ + void setShadowReceiverFragmentProgram(const String& name); + /** Sets the fragment program parameters for rendering as a shadow receiver. + @remarks + Only applicable to programmable passes, and this particular call is + designed for low-level programs; use the named parameter methods + for setting high-level program parameters. + */ + void setShadowReceiverFragmentProgramParameters(GpuProgramParametersSharedPtr params); + + /** Gets the name of the vertex program used by this pass when rendering shadow receivers. */ + const String& getShadowReceiverVertexProgramName(void) const; + /** Gets the vertex program parameters used by this pass when rendering shadow receivers. */ + GpuProgramParametersSharedPtr getShadowReceiverVertexProgramParameters(void) const; + /** Gets the vertex program used by this pass when rendering shadow receivers, + only available after _load(). */ + const GpuProgramPtr& getShadowReceiverVertexProgram(void) const; + + /** Gets the name of the fragment program used by this pass when rendering shadow receivers. */ + const String& getShadowReceiverFragmentProgramName(void) const; + /** Gets the fragment program parameters used by this pass when rendering shadow receivers. */ + GpuProgramParametersSharedPtr getShadowReceiverFragmentProgramParameters(void) const; + /** Gets the fragment program used by this pass when rendering shadow receivers, + only available after _load(). */ + const GpuProgramPtr& getShadowReceiverFragmentProgram(void) const; + + /** Sets the details of the fragment program to use. + @remarks + Only applicable to programmable passes, this sets the details of + the fragment program to use in this pass. The program will not be + loaded until the parent Material is loaded. + @param name The name of the program - this must have been + created using GpuProgramManager by the time that this Pass + is loaded. If this parameter is blank, any fragment program in this pass is disabled. + @param resetParams + If true, this will create a fresh set of parameters from the + new program being linked, so if you had previously set parameters + you will have to set them again. If you set this to false, you must + be absolutely sure that the parameters match perfectly, and in the + case of named parameters refers to the indexes underlying them, + not just the names. + */ + void setFragmentProgram(const String& name, bool resetParams = true); + /** Sets the fragment program parameters. + @remarks + Only applicable to programmable passes. + */ + void setFragmentProgramParameters(GpuProgramParametersSharedPtr params); + /** Gets the name of the fragment program used by this pass. */ + const String& getFragmentProgramName(void) const; + /** Gets the fragment program parameters used by this pass. */ + GpuProgramParametersSharedPtr getFragmentProgramParameters(void) const; + /** Gets the fragment program used by this pass, only available after _load(). */ + const GpuProgramPtr& getFragmentProgram(void) const; + + /** Splits this Pass to one which can be handled in the number of + texture units specified. + @remarks + Only works on non-programmable passes, programmable passes cannot be + split, it's up to the author to ensure that there is a fallback Technique + for less capable cards. + @param numUnits The target number of texture units + @returns A new Pass which contains the remaining units, and a scene_blend + setting appropriate to approximate the multitexture. This Pass will be + attached to the parent Technique of this Pass. + */ + Pass* _split(unsigned short numUnits); + + /** Internal method to adjust pass index. */ + void _notifyIndex(unsigned short index); + + /** Internal method for loading this pass. */ + void _load(void); + /** Internal method for unloading this pass. */ + void _unload(void); + // Is this loaded? + bool isLoaded(void) const; + + /** Gets the 'hash' of this pass, ie a precomputed number to use for sorting + @remarks + This hash is used to sort passes, and for this reason the pass is hashed + using firstly its index (so that all passes are rendered in order), then + by the textures which it's TextureUnitState instances are using. + */ + uint32 getHash(void) const { return mHash; } + /// Mark the hash as dirty + void _dirtyHash(void); + /** Internal method for recalculating the hash. + @remarks + Do not call this unless you are sure the old hash is not still being + used by anything. If in doubt, call _dirtyHash if you want to force + recalculation of the has next time. + */ + void _recalculateHash(void); + /** Tells the pass that it needs recompilation. */ + void _notifyNeedsRecompile(void); + + /** Update any automatic parameters (except lights) on this pass */ + void _updateAutoParamsNoLights(const AutoParamDataSource& source) const; + /** Update any automatic light parameters on this pass */ + void _updateAutoParamsLightsOnly(const AutoParamDataSource& source) const; + + /** Gets the 'nth' texture which references the given content type. + @remarks + If the 'nth' texture unit which references the content type doesn't + exist, then this method returns an arbitrary high-value outside the + valid range to index texture units. + */ + unsigned short _getTextureUnitWithContentTypeIndex( + TextureUnitState::ContentType contentType, unsigned short index) const; + + /** Set texture filtering for every texture unit + @note + This property actually exists on the TextureUnitState class + For simplicity, this method allows you to set these properties for + every current TeextureUnitState, If you need more precision, retrieve the + TextureUnitState instance and set the property there. + @see TextureUnitState::setTextureFiltering + */ + void setTextureFiltering(TextureFilterOptions filterType); + /** Sets the anisotropy level to be used for all textures. + @note + This property has been moved to the TextureUnitState class, which is accessible via the + Technique and Pass. For simplicity, this method allows you to set these properties for + every current TeextureUnitState, If you need more precision, retrieve the Technique, + Pass and TextureUnitState instances and set the property there. + @see TextureUnitState::setTextureAnisotropy + */ + void setTextureAnisotropy(unsigned int maxAniso); + /** Static method to retrieve all the Passes which need their + hash values recalculated. + */ + static const PassSet& getDirtyHashList(void) + { return msDirtyHashList; } + /** Static method to retrieve all the Passes which are pending deletion. + */ + static const PassSet& getPassGraveyard(void) + { return msPassGraveyard; } + /** Static method to reset the list of passes which need their hash + values recalculated. + @remarks + For performance, the dirty list is not updated progressively as + the hashes are recalculated, instead we expect the processor of the + dirty hash list to clear the list when they are done. + */ + static void clearDirtyHashList(void); + + /** Process all dirty and pending deletion passes. */ + static void processPendingPassUpdates(void); + + /** Queue this pass for deletion when appropriate. */ + void queueForDeletion(void); + + /** Returns whether this pass is ambient only. + */ + bool isAmbientOnly(void) const; + + /** set the number of iterations that this pass + should perform when doing fast multi pass operation. + @remarks + Only applicable for programmable passes. + @param count number of iterations to perform fast multi pass operations. + A value greater than 1 will cause the pass to be executed count number of + times without changing the render state. This is very usefull for passes + that use programmable shaders that have to iterate more than once but don't + need a render state change. Using multi pass can dramatically speed up rendering + for materials that do things like fur, blur. + A value of 1 turns off multi pass operation and the pass does + the normal pass operation. + */ + void setPassIterationCount(const size_t count) { mPassIterationCount = count; } + + /** Gets the pass iteration count value. + */ + size_t getPassIterationCount(void) const { return mPassIterationCount; } + + /** Applies texture names to Texture Unit State with matching texture name aliases. + All Texture Unit States within the pass are checked. + If matching texture aliases are found then true is returned. + + @param + aliasList is a map container of texture alias, texture name pairs + @param + apply set true to apply the texture aliases else just test to see if texture alias matches are found. + @return + True if matching texture aliases were found in the pass. + */ + bool applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply = true) const; + + + /** There are some default hash functions used to order passes so that + render state changes are minimised, this enumerates them. + */ + enum BuiltinHashFunction + { + /** Try to minimise the number of texture changes. */ + MIN_TEXTURE_CHANGE, + /** Try to minimise the number of GPU program changes. + @note Only really useful if you use GPU programs for all of your + materials. + */ + MIN_GPU_PROGRAM_CHANGE + }; + /** Sets one of the default hash functions to be used. + @remarks + You absolutely must not change the hash function whilst any Pass instances + exist in the render queue. The only time you can do this is either + before you render anything, or directly after you manuall call + RenderQueue::clear(true) to completely destroy the queue structures. + The default is MIN_TEXTURE_CHANGE. + @note + You can also implement your own hash function, see the alternate version + of this method. + @see HashFunc + */ + static void setHashFunction(BuiltinHashFunction builtin); + + /** Set the hash function used for all passes. + @remarks + You absolutely must not change the hash function whilst any Pass instances + exist in the render queue. The only time you can do this is either + before you render anything, or directly after you manuall call + RenderQueue::clear(true) to completely destroy the queue structures. + @note + You can also use one of the built-in hash functions, see the alternate version + of this method. The default is MIN_TEXTURE_CHANGE. + @see HashFunc + */ + static void setHashFunction(HashFunc* hashFunc) { msHashFunc = hashFunc; } + + /** Get the hash function used for all passes. + */ + static HashFunc* getHashFunction(void) { return msHashFunc; } + + }; + + enum IlluminationStage + { + /// Part of the rendering which occurs without any kind of direct lighting + IS_AMBIENT, + /// Part of the rendering which occurs per light + IS_PER_LIGHT, + /// Post-lighting rendering + IS_DECAL + }; + /** Struct recording a pass which can be used for a specific illumination stage. + @remarks + This structure is used to record categorised passes which fit into a + number of distinct illumination phases - ambient, diffuse / specular + (per-light) and decal (post-lighting texturing). + An original pass may fit into one of these categories already, or it + may require splitting into its component parts in order to be categorised + properly. + */ + struct IlluminationPass + { + IlluminationStage stage; + /// The pass to use in this stage + Pass* pass; + /// Whether this pass is one which should be deleted itself + bool destroyOnShutdown; + /// The original pass which spawned this one + Pass* originalPass; + }; + + typedef std::vector IlluminationPassList; + + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgrePatchMesh.h b/school/informatik/verkerhssimulation/src/ogre/OgrePatchMesh.h new file mode 100644 index 00000000..dd331c19 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgrePatchMesh.h @@ -0,0 +1,152 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __PatchMesh_H__ +#define __PatchMesh_H__ + +#include "OgrePrerequisites.h" +#include "OgreMesh.h" +#include "OgrePatchSurface.h" + +namespace Ogre { + + /** Patch specialisation of Mesh. + @remarks + Instances of this class should be created by calling MeshManager::createBezierPatch. + */ + class _OgreExport PatchMesh : public Mesh + { + protected: + /// Internal surface definition + PatchSurface mSurface; + /// Vertex declaration, cloned from the input + VertexDeclaration* mDeclaration; + public: + /// Constructor + PatchMesh(ResourceManager* creator, const String& name, ResourceHandle handle, + const String& group); + + /// Define the patch, as defined in MeshManager::createBezierPatch + void define(void* controlPointBuffer, + VertexDeclaration *declaration, size_t width, size_t height, + size_t uMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL, + size_t vMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL, + PatchSurface::VisibleSide visibleSide = PatchSurface::VS_FRONT, + HardwareBuffer::Usage vbUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, + HardwareBuffer::Usage ibUsage = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, + bool vbUseShadow = false, bool ibUseShadow = false); + + /* Sets the current subdivision level as a proportion of full detail. + @param factor Subdivision factor as a value from 0 (control points only) to 1 (maximum + subdivision). */ + void setSubdivision(Real factor); + protected: + /// Overridden from Resource + void loadImpl(void); + + }; + /** Specialisation of SharedPtr to allow SharedPtr to be assigned to PatchMeshPtr + @note Has to be a subclass since we need operator=. + We could templatise this instead of repeating per Resource subclass, + except to do so requires a form VC6 does not support i.e. + ResourceSubclassPtr : public SharedPtr + */ + class _OgreExport PatchMeshPtr : public SharedPtr + { + public: + PatchMeshPtr() : SharedPtr() {} + explicit PatchMeshPtr(PatchMesh* rep) : SharedPtr(rep) {} + PatchMeshPtr(const PatchMeshPtr& r) : SharedPtr(r) {} + PatchMeshPtr(const ResourcePtr& r) : SharedPtr() + { + // lock & copy other mutex pointer + OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME) + { + OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME) + OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME) + pRep = static_cast(r.getPointer()); + pUseCount = r.useCountPointer(); + if (pUseCount) + { + ++(*pUseCount); + } + } + } + + /// Operator used to convert a ResourcePtr to a PatchMeshPtr + PatchMeshPtr& operator=(const ResourcePtr& r) + { + if (pRep == static_cast(r.getPointer())) + return *this; + release(); + + OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME) + { + // lock & copy other mutex pointer + OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME) + OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME) + pRep = static_cast(r.getPointer()); + pUseCount = r.useCountPointer(); + if (pUseCount) + { + ++(*pUseCount); + } + } + else + { + // RHS must be a null pointer + assert(r.isNull() && "RHS must be null if it has no mutex!"); + setNull(); + } + return *this; + } + /// Operator used to convert a MeshPtr to a PatchMeshPtr + PatchMeshPtr& operator=(const MeshPtr& r) + { + if (pRep == static_cast(r.getPointer())) + return *this; + release(); + // lock & copy other mutex pointer + OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME) + { + OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME) + OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME) + pRep = static_cast(r.getPointer()); + pUseCount = r.useCountPointer(); + if (pUseCount) + { + ++(*pUseCount); + } + } + return *this; + } + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgrePatchSurface.h b/school/informatik/verkerhssimulation/src/ogre/OgrePatchSurface.h new file mode 100644 index 00000000..cb5aa5b2 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgrePatchSurface.h @@ -0,0 +1,233 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __PatchSurface_H__ +#define __PatchSurface_H__ + +#include "OgrePrerequisites.h" + +#include "OgreVector3.h" +#include "OgreString.h" +#include "OgreRenderOperation.h" +#include "OgreAxisAlignedBox.h" + +namespace Ogre { + + /** A surface which is defined by curves of some kind to form a patch, e.g. a Bezier patch. + @remarks + This object will take a list of control points with various assorted data, and will + subdivide it into a patch mesh. Currently only Bezier curves are supported for defining + the surface, but other techniques such as NURBS would follow the same basic approach. + */ + class _OgreExport PatchSurface + { + public: + PatchSurface(); + ~PatchSurface(); + + enum PatchSurfaceType + { + /// A patch defined by a set of bezier curves + PST_BEZIER + }; + + /// Constant for indicating automatic determination of subdivision level for patches + enum + { + AUTO_LEVEL = -1 + }; + + enum VisibleSide { + /// The side from which u goes right and v goes up (as in texture coords) + VS_FRONT, + /// The side from which u goes right and v goes down (reverse of texture coords) + VS_BACK, + /// Both sides are visible - warning this creates 2x the number of triangles and adds extra overhead for calculating normals + VS_BOTH + }; + /** Sets up the surface by defining it's control points, type and initial subdivision level. + @remarks + This method initialises the surface by passing it a set of control points. The type of curves to be used + are also defined here, although the only supported option currently is a bezier patch. You can also + specify a global subdivision level here if you like, although it is recommended that the parameter + is left as AUTO_LEVEL, which means the system decides how much subdivision is required (based on the + curvature of the surface) + @param + controlPointBuffer A pointer to a buffer containing the vertex data which defines control points + of the curves rather than actual vertices. Note that you are expected to provide not + just position information, but potentially normals and texture coordinates too. The + format of the buffer is defined in the VertexDeclaration parameter + @param + decaration VertexDeclaration describing the contents of the buffer. + Note this declaration must _only_ draw on buffer source 0! + @param + width Specifies the width of the patch in control points. + @param + height Specifies the height of the patch in control points. + @param + pType The type of surface - currently only PST_BEZIER is supported + @param + uMaxSubdivisionLevel,vMaxSubdivisionLevel If you want to manually set the top level of subdivision, + do it here, otherwise let the system decide. + @param + visibleSide Determines which side of the patch (or both) triangles are generated for. + */ + void defineSurface(void* controlPointBuffer, + VertexDeclaration *declaration, size_t width, size_t height, + PatchSurfaceType pType = PST_BEZIER, + size_t uMaxSubdivisionLevel = AUTO_LEVEL, size_t vMaxSubdivisionLevel = AUTO_LEVEL, + VisibleSide visibleSide = VS_FRONT); + + /** Based on a previous call to defineSurface, establishes the number of vertices required + to hold this patch at the maximum detail level. + @remarks This is useful when you wish to build the patch into external vertex / index buffers. + + */ + size_t getRequiredVertexCount(void) const; + /** Based on a previous call to defineSurface, establishes the number of indexes required + to hold this patch at the maximum detail level. + @remarks This is useful when you wish to build the patch into external vertex / index buffers. + + */ + size_t getRequiredIndexCount(void) const; + + /** Gets the current index count based on the current subdivision level. */ + size_t getCurrentIndexCount(void) const; + /// Returns the index offset used by this buffer to write data into the buffer + size_t getIndexOffset(void) const { return mIndexOffset; } + /// Returns the vertex offset used by this buffer to write data into the buffer + size_t getVertexOffset(void) const { return mVertexOffset; } + + + /** Gets the bounds of this patch, only valid after calling defineSurface. */ + const AxisAlignedBox& getBounds(void) const; + /** Gets the radius of the bounding sphere for this patch, only valid after defineSurface + has been called. */ + Real getBoundingSphereRadius(void) const; + /** Tells the system to build the mesh relating to the surface into externally created + buffers. + @remarks + The VertexDeclaration of the vertex buffer must be identical to the one passed into + defineSurface. In addition, there must be enough space in the buffer to + accommodate the patch at full detail level; you should call getRequiredVertexCount + and getRequiredIndexCount to determine this. This method does not create an internal + mesh for this patch and so getMesh will return null if you call it after building the + patch this way. + @param destVertexBuffer The destination vertex buffer in which to build the patch. + @param vertexStart The offset at which to start writing vertices for this patch + @param destIndexBuffer The destination index buffer in which to build the patch. + @param vertexStart The offset at which to start writing indexes for this patch + + */ + void build(HardwareVertexBufferSharedPtr destVertexBuffer, size_t vertexStart, + HardwareIndexBufferSharedPtr destIndexBuffer, size_t indexStart); + + /** Alters the level of subdivision for this surface. + @remarks + This method changes the proportionate detail level of the patch; since + the U and V directions can have different subdivision levels, this method + takes a single Real value where 0 is the minimum detail (the control points) + and 1 is the maximum detail level as supplied to the original call to + defineSurface. + */ + void setSubdivisionFactor(Real factor); + + /** Gets the current level of subdivision. */ + Real getSubdivisionFactor(void) const; + + void* getControlPointBuffer(void) const + { + return mControlPointBuffer; + } + /** Convenience method for telling the patch that the control points have been + deleted, since once the patch has been built they are not required. */ + void notifyControlPointBufferDeallocated(void) { + mControlPointBuffer = 0; + } + protected: + /// Vertex declaration describing the control point buffer + VertexDeclaration* mDeclaration; + /// Buffer containing the system-memory control points + void* mControlPointBuffer; + /// Type of surface + PatchSurfaceType mType; + /// Width in control points + size_t mCtlWidth; + /// Height in control points + size_t mCtlHeight; + /// TotalNumber of control points + size_t mCtlCount; + /// U-direction subdivision level + size_t mULevel; + /// V-direction subdivision level + size_t mVLevel; + /// Max subdivision level + size_t mMaxULevel; + size_t mMaxVLevel; + /// Width of the subdivided mesh (big enough for max level) + size_t mMeshWidth; + /// Height of the subdivided mesh (big enough for max level) + size_t mMeshHeight; + /// Which side is visible + VisibleSide mVSide; + + Real mSubdivisionFactor; + + std::vector mVecCtlPoints; + + /** Internal method for finding the subdivision level given 3 control points. + */ + size_t findLevel( Vector3& a, Vector3& b, Vector3& c); + + void distributeControlPoints(void* lockedBuffer); + void subdivideCurve(void* lockedBuffer, size_t startIdx, size_t stepSize, size_t numSteps, size_t iterations); + void interpolateVertexData(void* lockedBuffer, size_t leftIndex, size_t rightIndex, size_t destIndex); + void makeTriangles(void); + + size_t getAutoULevel(bool forMax = false); + size_t getAutoVLevel(bool forMax = false); + + HardwareVertexBufferSharedPtr mVertexBuffer; + HardwareIndexBufferSharedPtr mIndexBuffer; + size_t mVertexOffset; + size_t mIndexOffset; + size_t mRequiredVertexCount; + size_t mRequiredIndexCount; + size_t mCurrIndexCount; + + AxisAlignedBox mAABB; + Real mBoundingSphere; + + + + }; + + +} // namespace + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgrePixelFormat.h b/school/informatik/verkerhssimulation/src/ogre/OgrePixelFormat.h new file mode 100644 index 00000000..c8b5c437 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgrePixelFormat.h @@ -0,0 +1,473 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _PixelFormat_H__ +#define _PixelFormat_H__ + +#include "OgrePrerequisites.h" +#include "OgreCommon.h" + +namespace Ogre { + /** The pixel format used for images, textures, and render surfaces */ + enum PixelFormat + { + /// Unknown pixel format. + PF_UNKNOWN = 0, + /// 8-bit pixel format, all bits luminace. + PF_L8 = 1, + PF_BYTE_L = PF_L8, + /// 16-bit pixel format, all bits luminace. + PF_L16 = 2, + PF_SHORT_L = PF_L16, + /// 8-bit pixel format, all bits alpha. + PF_A8 = 3, + PF_BYTE_A = PF_A8, + /// 8-bit pixel format, 4 bits alpha, 4 bits luminace. + PF_A4L4 = 4, + /// 2 byte pixel format, 1 byte luminance, 1 byte alpha + PF_BYTE_LA = 5, + /// 16-bit pixel format, 5 bits red, 6 bits green, 5 bits blue. + PF_R5G6B5 = 6, + /// 16-bit pixel format, 5 bits red, 6 bits green, 5 bits blue. + PF_B5G6R5 = 7, + /// 8-bit pixel format, 2 bits blue, 3 bits green, 3 bits red. + PF_R3G3B2 = 31, + /// 16-bit pixel format, 4 bits for alpha, red, green and blue. + PF_A4R4G4B4 = 8, + /// 16-bit pixel format, 5 bits for blue, green, red and 1 for alpha. + PF_A1R5G5B5 = 9, + /// 24-bit pixel format, 8 bits for red, green and blue. + PF_R8G8B8 = 10, + /// 24-bit pixel format, 8 bits for blue, green and red. + PF_B8G8R8 = 11, + /// 32-bit pixel format, 8 bits for alpha, red, green and blue. + PF_A8R8G8B8 = 12, + /// 32-bit pixel format, 8 bits for blue, green, red and alpha. + PF_A8B8G8R8 = 13, + /// 32-bit pixel format, 8 bits for blue, green, red and alpha. + PF_B8G8R8A8 = 14, + /// 32-bit pixel format, 8 bits for red, green, blue and alpha. + PF_R8G8B8A8 = 28, + /// 32-bit pixel format, 8 bits for red, 8 bits for green, 8 bits for blue + /// like PF_A8R8G8B8, but alpha will get discarded + PF_X8R8G8B8 = 26, + /// 32-bit pixel format, 8 bits for blue, 8 bits for green, 8 bits for red + /// like PF_A8B8G8R8, but alpha will get discarded + PF_X8B8G8R8 = 27, +#if OGRE_ENDIAN == OGRE_ENDIAN_BIG + /// 3 byte pixel format, 1 byte for red, 1 byte for green, 1 byte for blue + PF_BYTE_RGB = PF_R8G8B8, + /// 3 byte pixel format, 1 byte for blue, 1 byte for green, 1 byte for red + PF_BYTE_BGR = PF_B8G8R8, + /// 4 byte pixel format, 1 byte for blue, 1 byte for green, 1 byte for red and one byte for alpha + PF_BYTE_BGRA = PF_B8G8R8A8, + /// 4 byte pixel format, 1 byte for red, 1 byte for green, 1 byte for blue, and one byte for alpha + PF_BYTE_RGBA = PF_R8G8B8A8, +#else + /// 3 byte pixel format, 1 byte for red, 1 byte for green, 1 byte for blue + PF_BYTE_RGB = PF_B8G8R8, + /// 3 byte pixel format, 1 byte for blue, 1 byte for green, 1 byte for red + PF_BYTE_BGR = PF_R8G8B8, + /// 4 byte pixel format, 1 byte for blue, 1 byte for green, 1 byte for red and one byte for alpha + PF_BYTE_BGRA = PF_A8R8G8B8, + /// 4 byte pixel format, 1 byte for red, 1 byte for green, 1 byte for blue, and one byte for alpha + PF_BYTE_RGBA = PF_A8B8G8R8, +#endif + /// 32-bit pixel format, 2 bits for alpha, 10 bits for red, green and blue. + PF_A2R10G10B10 = 15, + /// 32-bit pixel format, 10 bits for blue, green and red, 2 bits for alpha. + PF_A2B10G10R10 = 16, + /// DDS (DirectDraw Surface) DXT1 format + PF_DXT1 = 17, + /// DDS (DirectDraw Surface) DXT2 format + PF_DXT2 = 18, + /// DDS (DirectDraw Surface) DXT3 format + PF_DXT3 = 19, + /// DDS (DirectDraw Surface) DXT4 format + PF_DXT4 = 20, + /// DDS (DirectDraw Surface) DXT5 format + PF_DXT5 = 21, + // 16-bit pixel format, 16 bits (float) for red + PF_FLOAT16_R = 32, + // 48-bit pixel format, 16 bits (float) for red, 16 bits (float) for green, 16 bits (float) for blue + PF_FLOAT16_RGB = 22, + // 64-bit pixel format, 16 bits (float) for red, 16 bits (float) for green, 16 bits (float) for blue, 16 bits (float) for alpha + PF_FLOAT16_RGBA = 23, + // 16-bit pixel format, 16 bits (float) for red + PF_FLOAT32_R = 33, + // 96-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue + PF_FLOAT32_RGB = 24, + // 128-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue, 32 bits (float) for alpha + PF_FLOAT32_RGBA = 25, + // 32-bit, 2-channel s10e5 floating point pixel format, 16-bit green, 16-bit red + PF_FLOAT16_GR = 35, + // 64-bit, 2-channel floating point pixel format, 32-bit green, 32-bit red + PF_FLOAT32_GR = 36, + // Depth texture format + PF_DEPTH = 29, + // 64-bit pixel format, 16 bits for red, green, blue and alpha + PF_SHORT_RGBA = 30, + // 32-bit pixel format, 16-bit green, 16-bit red + PF_SHORT_GR = 34, + // 48-bit pixel format, 16 bits for red, green and blue + PF_SHORT_RGB = 37, + // Number of pixel formats currently defined + PF_COUNT = 38 + }; + + /** + * Flags defining some on/off properties of pixel formats + */ + enum PixelFormatFlags { + // This format has an alpha channel + PFF_HASALPHA = 0x00000001, + // This format is compressed. This invalidates the values in elemBytes, + // elemBits and the bit counts as these might not be fixed in a compressed format. + PFF_COMPRESSED = 0x00000002, + // This is a floating point format + PFF_FLOAT = 0x00000004, + // This is a depth format (for depth textures) + PFF_DEPTH = 0x00000008, + // Format is in native endian. Generally true for the 16, 24 and 32 bits + // formats which can be represented as machine integers. + PFF_NATIVEENDIAN = 0x00000010, + // This is an intensity format instead of a RGB one. The luminance + // replaces R,G and B. (but not A) + PFF_LUMINANCE = 0x00000020 + }; + + /** Pixel component format */ + enum PixelComponentType + { + PCT_BYTE = 0, /// Byte per component (8 bit fixed 0.0..1.0) + PCT_SHORT = 1, /// Short per component (16 bit fixed 0.0..1.0)) + PCT_FLOAT16 = 2, /// 16 bit float per component + PCT_FLOAT32 = 3, /// 32 bit float per component + PCT_COUNT = 4 /// Number of pixel types + }; + + /** A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory. + In case of a rectangle, depth must be 1. + Pixels are stored as a succession of "depth" slices, each containing "height" rows of + "width" pixels. + */ + class _OgreExport PixelBox: public Box { + public: + /// Parameter constructor for setting the members manually + PixelBox() {} + /** Constructor providing extents in the form of a Box object. This constructor + assumes the pixel data is laid out consecutively in memory. (this + means row after row, slice after slice, with no space in between) + @param extents Extents of the region defined by data + @param pixelFormat Format of this buffer + @param pixelData Pointer to the actual data + */ + PixelBox(const Box &extents, PixelFormat pixelFormat, void *pixelData=0): + Box(extents), data(pixelData), format(pixelFormat) + { + setConsecutive(); + } + /** Constructor providing width, height and depth. This constructor + assumes the pixel data is laid out consecutively in memory. (this + means row after row, slice after slice, with no space in between) + @param width Width of the region + @param height Height of the region + @param depth Depth of the region + @param pixelFormat Format of this buffer + @param pixelData Pointer to the actual data + */ + PixelBox(size_t width, size_t height, size_t depth, PixelFormat pixelFormat, void *pixelData=0): + Box(0, 0, 0, width, height, depth), + data(pixelData), format(pixelFormat) + { + setConsecutive(); + } + + /// The data pointer + void *data; + /// The pixel format + PixelFormat format; + /** Number of elements between the leftmost pixel of one row and the left + pixel of the next. This value must always be equal to getWidth() (consecutive) + for compressed formats. + */ + size_t rowPitch; + /** Number of elements between the top left pixel of one (depth) slice and + the top left pixel of the next. This can be a negative value. Must be a multiple of + rowPitch. This value must always be equal to getWidth()*getHeight() (consecutive) + for compressed formats. + */ + size_t slicePitch; + + /** Set the rowPitch and slicePitch so that the buffer is laid out consecutive + in memory. + */ + void setConsecutive() + { + rowPitch = getWidth(); + slicePitch = getWidth()*getHeight(); + } + /** Get the number of elements between one past the rightmost pixel of + one row and the leftmost pixel of the next row. (IE this is zero if rows + are consecutive). + */ + size_t getRowSkip() const { return rowPitch - getWidth(); } + /** Get the number of elements between one past the right bottom pixel of + one slice and the left top pixel of the next slice. (IE this is zero if slices + are consecutive). + */ + size_t getSliceSkip() const { return slicePitch - (getHeight() * rowPitch); } + + /** Return whether this buffer is laid out consecutive in memory (ie the pitches + are equal to the dimensions) + */ + bool isConsecutive() const + { + return rowPitch == getWidth() && slicePitch == getWidth()*getHeight(); + } + /** Return the size (in bytes) this image would take if it was + laid out consecutive in memory + */ + size_t getConsecutiveSize() const; + /** Return a subvolume of this PixelBox. + @param def Defines the bounds of the subregion to return + @returns A pixel box describing the region and the data in it + @remarks This function does not copy any data, it just returns + a PixelBox object with a data pointer pointing somewhere inside + the data of object. + @throws Exception(ERR_INVALIDPARAMS) if def is not fully contained + */ + PixelBox getSubVolume(const Box &def) const; + }; + + + /** + * Some utility functions for packing and unpacking pixel data + */ + class _OgreExport PixelUtil { + public: + /** Returns the size in bytes of an element of the given pixel format. + @returns + The size in bytes of an element. See Remarks. + @remarks + Passing PF_UNKNOWN will result in returning a size of 0 bytes. + */ + static size_t getNumElemBytes( PixelFormat format ); + + /** Returns the size in bits of an element of the given pixel format. + @returns + The size in bits of an element. See Remarks. + @remarks + Passing PF_UNKNOWN will result in returning a size of 0 bits. + */ + static size_t getNumElemBits( PixelFormat format ); + + /** Returns the size in memory of a region with the given extents and pixel + format with consecutive memory layout. + @param width + The width of the area + @param height + The height of the area + @param depth + The depth of the area + @param format + The format of the area + @returns + The size in bytes + @remarks + In case that the format is non-compressed, this simply returns + width*height*depth*PixelUtil::getNumElemBytes(format). In the compressed + case, this does serious magic. + */ + static size_t getMemorySize(size_t width, size_t height, size_t depth, PixelFormat format); + + /** Returns the property flags for this pixel format + @returns + A bitfield combination of PFF_HASALPHA, PFF_ISCOMPRESSED, + PFF_FLOAT, PFF_DEPTH, PFF_NATIVEENDIAN, PFF_LUMINANCE + @remarks + This replaces the seperate functions for formatHasAlpha, formatIsFloat, ... + */ + static unsigned int getFlags( PixelFormat format ); + + /** Shortcut method to determine if the format has an alpha component */ + static bool hasAlpha(PixelFormat format); + /** Shortcut method to determine if the format is floating point */ + static bool isFloatingPoint(PixelFormat format); + /** Shortcut method to determine if the format is compressed */ + static bool isCompressed(PixelFormat format); + /** Shortcut method to determine if the format is a depth format. */ + static bool isDepth(PixelFormat format); + /** Shortcut method to determine if the format is in native endian format. */ + static bool isNativeEndian(PixelFormat format); + /** Shortcut method to determine if the format is a luminance format. */ + static bool isLuminance(PixelFormat format); + + /** Return wether a certain image extent is valid for this image format. + @param width + The width of the area + @param height + The height of the area + @param depth + The depth of the area + @param format + The format of the area + @remarks For non-compressed formats, this is always true. For DXT formats, + only sizes with a width and height multiple of 4 and depth 1 are allowed. + */ + static bool isValidExtent(size_t width, size_t height, size_t depth, PixelFormat format); + + /** Gives the number of bits (RGBA) for a format. See remarks. + @remarks For non-colour formats (dxt, depth) this returns [0,0,0,0]. + */ + static void getBitDepths(PixelFormat format, int rgba[4]); + + /** Gives the masks for the R, G, B and A component + @note Only valid for native endian formats + */ + static void getBitMasks(PixelFormat format, uint32 rgba[4]); + + /** Gets the name of an image format + */ + static String getFormatName(PixelFormat srcformat); + + /** Returns wether the format can be packed or unpacked with the packColour() + and unpackColour() functions. This is generally not true for compressed and + depth formats as they are special. It can only be true for formats with a + fixed element size. + @returns + true if yes, otherwise false + */ + static bool isAccessible(PixelFormat srcformat); + + /** Returns the component type for a certain pixel format. Returns PCT_BYTE + in case there is no clear component type like with compressed formats. + This is one of PCT_BYTE, PCT_SHORT, PCT_FLOAT16, PCT_FLOAT32. + */ + static PixelComponentType getComponentType(PixelFormat fmt); + + /** Returns the component count for a certain pixel format. Returns 3(no alpha) or + 4 (has alpha) in case there is no clear component type like with compressed formats. + */ + static size_t getComponentCount(PixelFormat fmt); + + /** Gets the format from given name. + @param name The string of format name + @param accessibleOnly If true, non-accessible format will treat as invalid format, + otherwise, all supported format are valid. + @param caseSensitive Should be set true if string match should use case sensitivity. + @returns The format match the format name, or PF_UNKNOWN if is invalid name. + */ + static PixelFormat getFormatFromName(const String& name, bool accessibleOnly = false, bool caseSensitive = false); + + /** Gets the BNF expression of the pixel-formats. + @note The string returned by this function is intented to use as a BNF expression + to work with Compiler2Pass. + @param accessibleOnly If true, only accessible pixel format will take into account, otherwise all + pixel formats list in PixelFormat enumeration will being returned. + @returns A string contains the BNF expression. + */ + static String getBNFExpressionOfPixelFormats(bool accessibleOnly = false); + + /** Returns the similar format but acoording with given bit depths. + @param fmt The original foamt. + @param integerBits Preferred bit depth (pixel bits) for integer pixel format. + Available values: 0, 16 and 32, where 0 (the default) means as it is. + @param floatBits Preferred bit depth (channel bits) for float pixel format. + Available values: 0, 16 and 32, where 0 (the default) means as it is. + @returns The format that similar original format with bit depth according + with preferred bit depth, or original format if no convertion occuring. + */ + static PixelFormat getFormatForBitDepths(PixelFormat fmt, ushort integerBits, ushort floatBits); + + /** Pack a colour value to memory + @param colour The colour + @param pf Pixelformat in which to write the colour + @param dest Destination memory location + */ + static void packColour(const ColourValue &colour, const PixelFormat pf, void* dest); + /** Pack a colour value to memory + @param r,g,b,a The four colour components, range 0x00 to 0xFF + @param pf Pixelformat in which to write the colour + @param dest Destination memory location + */ + static void packColour(const uint8 r, const uint8 g, const uint8 b, const uint8 a, const PixelFormat pf, void* dest); + /** Pack a colour value to memory + @param r,g,b,a The four colour components, range 0.0f to 1.0f + (an exception to this case exists for floating point pixel + formats, which don't clamp to 0.0f..1.0f) + @param pf Pixelformat in which to write the colour + @param dest Destination memory location + */ + static void packColour(const float r, const float g, const float b, const float a, const PixelFormat pf, void* dest); + + /** Unpack a colour value from memory + @param colour The colour is returned here + @param pf Pixelformat in which to read the colour + @param src Source memory location + */ + static void unpackColour(ColourValue *colour, PixelFormat pf, const void* src); + /** Unpack a colour value from memory + @param r,g,b,a The colour is returned here (as byte) + @param pf Pixelformat in which to read the colour + @param src Source memory location + @remarks This function returns the colour components in 8 bit precision, + this will lose precision when coming from PF_A2R10G10B10 or floating + point formats. + */ + static void unpackColour(uint8 *r, uint8 *g, uint8 *b, uint8 *a, PixelFormat pf, const void* src); + /** Unpack a colour value from memory + @param r,g,b,a The colour is returned here (as float) + @param pf Pixelformat in which to read the colour + @param src Source memory location + */ + static void unpackColour(float *r, float *g, float *b, float *a, PixelFormat pf, const void* src); + + /** Convert consecutive pixels from one format to another. No dithering or filtering is being done. + Converting from RGB to luminance takes the R channel. In case the source and destination format match, + just a copy is done. + @param src Pointer to source region + @param srcFormat Pixel format of source region + @param dst Pointer to destination region + @param dstFormat Pixel format of destination region + */ + static void bulkPixelConversion(void *src, PixelFormat srcFormat, void *dest, PixelFormat dstFormat, unsigned int count); + + /** Convert pixels from one format to another. No dithering or filtering is being done. Converting + from RGB to luminance takes the R channel. + @param src PixelBox containing the source pixels, pitches and format + @param dst PixelBox containing the destination pixels, pitches and format + @remarks The source and destination boxes must have the same + dimensions. In case the source and destination format match, a plain copy is done. + */ + static void bulkPixelConversion(const PixelBox &src, const PixelBox &dst); + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgrePlane.h b/school/informatik/verkerhssimulation/src/ogre/OgrePlane.h new file mode 100644 index 00000000..88cd5ca4 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgrePlane.h @@ -0,0 +1,154 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +// Original free version by: +// Magic Software, Inc. +// http://www.geometrictools.com/ +// Copyright (c) 2000, All Rights Reserved + +#ifndef __Plane_H__ +#define __Plane_H__ + +#include "OgrePrerequisites.h" + +#include "OgreVector3.h" + +namespace Ogre { + + /** Defines a plane in 3D space. + @remarks + A plane is defined in 3D space by the equation + Ax + By + Cz + D = 0 + @par + This equates to a vector (the normal of the plane, whose x, y + and z components equate to the coefficients A, B and C + respectively), and a constant (D) which is the distance along + the normal you have to go to move the plane back to the origin. + */ + class _OgreExport Plane + { + public: + /** Default constructor - sets everything to 0. + */ + Plane (); + Plane (const Plane& rhs); + /** Construct a plane through a normal, and a distance to move the plane along the normal.*/ + Plane (const Vector3& rkNormal, Real fConstant); + Plane (const Vector3& rkNormal, const Vector3& rkPoint); + Plane (const Vector3& rkPoint0, const Vector3& rkPoint1, + const Vector3& rkPoint2); + + /** The "positive side" of the plane is the half space to which the + plane normal points. The "negative side" is the other half + space. The flag "no side" indicates the plane itself. + */ + enum Side + { + NO_SIDE, + POSITIVE_SIDE, + NEGATIVE_SIDE, + BOTH_SIDE + }; + + Side getSide (const Vector3& rkPoint) const; + + /** + returns the side where the aligneBox is. the flag BOTH_SIDE indicates an intersecting box. + one corner ON the plane is sufficient to consider the box and the plane intersecting. + */ + Side getSide (const AxisAlignedBox& rkBox) const; + + /** Returns which side of the plane that the given box lies on. + The box is defined as centre/half-size pairs for effectively. + @param centre The centre of the box. + @param halfSize The half-size of the box. + @returns + POSITIVE_SIDE if the box complete lies on the "positive side" of the plane, + NEGATIVE_SIDE if the box complete lies on the "negative side" of the plane, + and BOTH_SIDE if the box intersects the plane. + */ + Side getSide (const Vector3& centre, const Vector3& halfSize) const; + + /** This is a pseudodistance. The sign of the return value is + positive if the point is on the positive side of the plane, + negative if the point is on the negative side, and zero if the + point is on the plane. + @par + The absolute value of the return value is the true distance only + when the plane normal is a unit length vector. + */ + Real getDistance (const Vector3& rkPoint) const; + + /** Redefine this plane based on 3 points. */ + void redefine(const Vector3& rkPoint0, const Vector3& rkPoint1, + const Vector3& rkPoint2); + + /** Redefine this plane based on a normal and a point. */ + void redefine(const Vector3& rkNormal, const Vector3& rkPoint); + + /** Project a vector onto the plane. + @remarks This gives you the element of the input vector that is perpendicular + to the normal of the plane. You can get the element which is parallel + to the normal of the plane by subtracting the result of this method + from the original vector, since parallel + perpendicular = original. + @param v The input vector + */ + Vector3 projectVector(const Vector3& v) const; + + /** Normalises the plane. + @remarks + This method normalises the plane's normal and the length scale of d + is as well. + @note + This function will not crash for zero-sized vectors, but there + will be no changes made to their components. + @returns The previous length of the plane's normal. + */ + Real normalise(void); + + Vector3 normal; + Real d; + + /// Comparison operator + bool operator==(const Plane& rhs) const + { + return (rhs.d == d && rhs.normal == normal); + } + bool operator!=(const Plane& rhs) const + { + return (rhs.d != d && rhs.normal != normal); + } + + _OgreExport friend std::ostream& operator<< (std::ostream& o, const Plane& p); + }; + + typedef std::vector PlaneList; + +} // namespace Ogre + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgrePlaneBoundedVolume.h b/school/informatik/verkerhssimulation/src/ogre/OgrePlaneBoundedVolume.h new file mode 100644 index 00000000..17fe40ef --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgrePlaneBoundedVolume.h @@ -0,0 +1,128 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __PlaneBoundedVolume_H_ +#define __PlaneBoundedVolume_H_ + +// Precompiler options +#include "OgrePrerequisites.h" +#include "OgreAxisAlignedBox.h" +#include "OgreSphere.h" +#include "OgreMath.h" +#include "OgrePlane.h" + +namespace Ogre { + + /** Represents a convex volume bounded by planes. + */ + class _OgreExport PlaneBoundedVolume + { + public: + typedef std::vector PlaneList; + /// Publicly accessible plane list, you can modify this direct + PlaneList planes; + Plane::Side outside; + + PlaneBoundedVolume() :outside(Plane::NEGATIVE_SIDE) {} + /** Constructor, determines which side is deemed to be 'outside' */ + PlaneBoundedVolume(Plane::Side theOutside) + : outside(theOutside) {} + + /** Intersection test with AABB + @remarks May return false positives but will never miss an intersection. + */ + inline bool intersects(const AxisAlignedBox& box) const + { + if (box.isNull()) return false; + if (box.isInfinite()) return true; + + // Get centre of the box + Vector3 centre = box.getCenter(); + // Get the half-size of the box + Vector3 halfSize = box.getHalfSize(); + + PlaneList::const_iterator i, iend; + iend = planes.end(); + for (i = planes.begin(); i != iend; ++i) + { + const Plane& plane = *i; + + Plane::Side side = plane.getSide(centre, halfSize); + if (side == outside) + { + // Found a splitting plane therefore return not intersecting + return false; + } + } + + // couldn't find a splitting plane, assume intersecting + return true; + + } + /** Intersection test with Sphere + @remarks May return false positives but will never miss an intersection. + */ + inline bool intersects(const Sphere& sphere) const + { + PlaneList::const_iterator i, iend; + iend = planes.end(); + for (i = planes.begin(); i != iend; ++i) + { + const Plane& plane = *i; + + // Test which side of the plane the sphere is + Real d = plane.getDistance(sphere.getCenter()); + // Negate d if planes point inwards + if (outside == Plane::NEGATIVE_SIDE) d = -d; + + if ( (d - sphere.getRadius()) > 0) + return false; + } + + return true; + + } + + /** Intersection test with a Ray + @returns std::pair of hit (bool) and distance + @remarks May return false positives but will never miss an intersection. + */ + inline std::pair intersects(const Ray& ray) + { + return Math::intersects(ray, planes, outside == Plane::POSITIVE_SIDE); + } + + }; + + typedef std::vector PlaneBoundedVolumeList; + + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgrePlatform.h b/school/informatik/verkerhssimulation/src/ogre/OgrePlatform.h new file mode 100644 index 00000000..b1e0ba03 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgrePlatform.h @@ -0,0 +1,219 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Platform_H_ +#define __Platform_H_ + +#include "OgreConfig.h" + +namespace Ogre { +/* Initial platform/compiler-related stuff to set. +*/ +#define OGRE_PLATFORM_WIN32 1 +#define OGRE_PLATFORM_LINUX 2 +#define OGRE_PLATFORM_APPLE 3 + +#define OGRE_COMPILER_MSVC 1 +#define OGRE_COMPILER_GNUC 2 +#define OGRE_COMPILER_BORL 3 + +#define OGRE_ENDIAN_LITTLE 1 +#define OGRE_ENDIAN_BIG 2 + +#define OGRE_ARCHITECTURE_32 1 +#define OGRE_ARCHITECTURE_64 2 + +/* Finds the compiler type and version. +*/ +#if defined( _MSC_VER ) +# define OGRE_COMPILER OGRE_COMPILER_MSVC +# define OGRE_COMP_VER _MSC_VER + +#elif defined( __GNUC__ ) +# define OGRE_COMPILER OGRE_COMPILER_GNUC +# define OGRE_COMP_VER (((__GNUC__)*100) + \ + (__GNUC_MINOR__*10) + \ + __GNUC_PATCHLEVEL__) + +#elif defined( __BORLANDC__ ) +# define OGRE_COMPILER OGRE_COMPILER_BORL +# define OGRE_COMP_VER __BCPLUSPLUS__ + +#else +# pragma error "No known compiler. Abort! Abort!" + +#endif + +/* See if we can use __forceinline or if we need to use __inline instead */ +#if OGRE_COMPILER == OGRE_COMPILER_MSVC +# if OGRE_COMP_VER >= 1200 +# define FORCEINLINE __forceinline +# endif +#elif defined(__MINGW32__) +# if !defined(FORCEINLINE) +# define FORCEINLINE __inline +# endif +#else +# define FORCEINLINE __inline +#endif + +/* Finds the current platform */ + +#if defined( __WIN32__ ) || defined( _WIN32 ) +# define OGRE_PLATFORM OGRE_PLATFORM_WIN32 + +#elif defined( __APPLE_CC__) +# define OGRE_PLATFORM OGRE_PLATFORM_APPLE + +#else +# define OGRE_PLATFORM OGRE_PLATFORM_LINUX +#endif + + /* Find the arch type */ +#if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__) +# define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_64 +#else +# define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_32 +#endif + +// For generating compiler warnings - should work on any compiler +// As a side note, if you start your message with 'Warning: ', the MSVC +// IDE actually does catch a warning :) +#define OGRE_QUOTE_INPLACE(x) # x +#define OGRE_QUOTE(x) OGRE_QUOTE_INPLACE(x) +#define OGRE_WARN( x ) message( __FILE__ "(" QUOTE( __LINE__ ) ") : " x "\n" ) + +//---------------------------------------------------------------------------- +// Windows Settings +#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 + +// If we're not including this from a client build, specify that the stuff +// should get exported. Otherwise, import it. +# if defined( OGRE_STATIC_LIB ) + // Linux compilers don't have symbol import/export directives. +# define _OgreExport +# define _OgrePrivate +# else +# if defined( OGRE_NONCLIENT_BUILD ) +# define _OgreExport __declspec( dllexport ) +# else +# if defined( __MINGW32__ ) +# define _OgreExport +# else +# define _OgreExport __declspec( dllimport ) +# endif +# endif +# define _OgrePrivate +# endif +// Win32 compilers use _DEBUG for specifying debug builds. +# ifdef _DEBUG +# define OGRE_DEBUG_MODE 1 +# else +# define OGRE_DEBUG_MODE 0 +# endif + +// Disable unicode support on MingW at the moment, poorly supported in stdlibc++ +// STLPORT fixes this though so allow if found +// MinGW C++ Toolkit supports unicode and sets the define __MINGW32_TOOLKIT_UNICODE__ in _mingw.h +#if defined( __MINGW32__ ) && !defined(_STLPORT_VERSION) +# include<_mingw.h> +# if defined(__MINGW32_TOOLBOX_UNICODE__) +# define OGRE_UNICODE_SUPPORT 1 +# else +# define OGRE_UNICODE_SUPPORT 0 +# endif +#else +# define OGRE_UNICODE_SUPPORT 1 +#endif + +#endif +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +// Linux/Apple Settings +#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX || OGRE_PLATFORM == OGRE_PLATFORM_APPLE + +// Enable GCC symbol visibility +# if defined( OGRE_GCC_VISIBILITY ) +# define _OgreExport __attribute__ ((visibility("default"))) +# define _OgrePrivate __attribute__ ((visibility("hidden"))) +# else +# define _OgreExport +# define _OgrePrivate +# endif + +// A quick define to overcome different names for the same function +# define stricmp strcasecmp + +// Unlike the Win32 compilers, Linux compilers seem to use DEBUG for when +// specifying a debug build. +// (??? this is wrong, on Linux debug builds aren't marked in any way unless +// you mark it yourself any way you like it -- zap ???) +# ifdef DEBUG +# define OGRE_DEBUG_MODE 1 +# else +# define OGRE_DEBUG_MODE 0 +# endif + +#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE + #define OGRE_PLATFORM_LIB "OgrePlatform.bundle" +#else + //OGRE_PLATFORM_LINUX + #define OGRE_PLATFORM_LIB "libOgrePlatform.so" +#endif + +// Always enable unicode support for the moment +// Perhaps disable in old versions of gcc if necessary +#define OGRE_UNICODE_SUPPORT 1 + +#endif + +//For apple, we always have a custom config.h file +#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE +# include "config.h" +#endif + +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +// Endian Settings +// check for BIG_ENDIAN config flag, set OGRE_ENDIAN correctly +#ifdef OGRE_CONFIG_BIG_ENDIAN +# define OGRE_ENDIAN OGRE_ENDIAN_BIG +#else +# define OGRE_ENDIAN OGRE_ENDIAN_LITTLE +#endif + +// Integer formats of fixed bit width +typedef unsigned int uint32; +typedef unsigned short uint16; +typedef unsigned char uint8; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgrePlatformInformation.h b/school/informatik/verkerhssimulation/src/ogre/OgrePlatformInformation.h new file mode 100644 index 00000000..5fd2969a --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgrePlatformInformation.h @@ -0,0 +1,168 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __PlatformInformation_H__ +#define __PlatformInformation_H__ + +#include "OgrePrerequisites.h" + +namespace Ogre { +// +// TODO: Puts following macros into OgrePlatform.h? +// + +/* Initial CPU stuff to set. +*/ +#define OGRE_CPU_UNKNOWN 0 +#define OGRE_CPU_X86 1 +#define OGRE_CPU_PPC 2 + +/* Find CPU type +*/ +#if (defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))) || \ + (defined(__GNUC__) && (defined(__i386__) /*|| defined(__x86_64__)*/)) +# define OGRE_CPU OGRE_CPU_X86 + +#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE && defined(__BIG_ENDIAN__) +# define OGRE_CPU OGRE_CPU_PPC +#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE +# define OGRE_CPU OGRE_CPU_X86 + +#else +# define OGRE_CPU OGRE_CPU_UNKNOWN +#endif + +/* Find how to declare aligned variable. +*/ +#if OGRE_COMPILER == OGRE_COMPILER_MSVC +# define OGRE_ALIGNED_DECL(type, var, alignment) __declspec(align(alignment)) type var + +#elif OGRE_COMPILER == OGRE_COMPILER_GNUC +# define OGRE_ALIGNED_DECL(type, var, alignment) type var __attribute__((__aligned__(alignment))) + +#else +# define OGRE_ALIGNED_DECL(type, var, alignment) type var +#endif + +/** Find perfect alignment (should supports SIMD alignment if SIMD available) +*/ +#if OGRE_CPU == OGRE_CPU_X86 +# define OGRE_SIMD_ALIGNMENT 16 + +#else +# define OGRE_SIMD_ALIGNMENT 16 +#endif + +/* Declare variable aligned to SIMD alignment. +*/ +#define OGRE_SIMD_ALIGNED_DECL(type, var) OGRE_ALIGNED_DECL(type, var, OGRE_SIMD_ALIGNMENT) + +/* Define whether or not Ogre compiled with SSE supports. +*/ +#if OGRE_DOUBLE_PRECISION == 0 && OGRE_CPU == OGRE_CPU_X86 && OGRE_COMPILER == OGRE_COMPILER_MSVC +# define __OGRE_HAVE_SSE 1 +#elif OGRE_DOUBLE_PRECISION == 0 && OGRE_CPU == OGRE_CPU_X86 && OGRE_COMPILER == OGRE_COMPILER_GNUC +# define __OGRE_HAVE_SSE 1 +#endif + + +#ifndef __OGRE_HAVE_SSE +# define __OGRE_HAVE_SSE 0 +#endif + + + + + /** Class which provides the run-time platform information Ogre runs on. + @remarks + Ogre is designed to be platform-independent, but there some platform + and run-time environment specific optimised functions are built-in + for maximise performance, and those special optimised routines are + need to determine run-time environment for select variant executing + path. + @par + This class manages that provides a couple of functions to determine + platform information of the run-time environment. + @note + This class is supposed to use by advanced user only. + */ + class _OgreExport PlatformInformation + { + public: + + /// Enum describing the different CPU features we want to check for, platform-dependent + enum CpuFeatures + { +#if OGRE_CPU == OGRE_CPU_X86 + CPU_FEATURE_SSE = 1 << 0, + CPU_FEATURE_SSE2 = 1 << 1, + CPU_FEATURE_SSE3 = 1 << 2, + CPU_FEATURE_MMX = 1 << 3, + CPU_FEATURE_MMXEXT = 1 << 4, + CPU_FEATURE_3DNOW = 1 << 5, + CPU_FEATURE_3DNOWEXT = 1 << 6, + CPU_FEATURE_CMOV = 1 << 7, + CPU_FEATURE_TSC = 1 << 8, + CPU_FEATURE_FPU = 1 << 9, + CPU_FEATURE_PRO = 1 << 10, + CPU_FEATURE_HTT = 1 << 11, +#endif + + CPU_FEATURE_NONE = 0 + }; + + /** Gets a string of the CPU identifier. + @note + Actual detecting are performs in the first time call to this function, + and then all future calls with return internal cached value. + */ + static const String& getCpuIdentifier(void); + + /** Gets a or-masked of enum CpuFeatures that are supported by the CPU. + @note + Actual detecting are performs in the first time call to this function, + and then all future calls with return internal cached value. + */ + static uint getCpuFeatures(void); + + /** Gets whether a specific feature is supported by the CPU. + @note + Actual detecting are performs in the first time call to this function, + and then all future calls with return internal cached value. + */ + static bool hasCpuFeature(CpuFeatures feature); + + + /** Write the CPU information to the passed in Log */ + static void log(Log* pLog); + + }; + +} + +#endif // __PlatformInformation_H__ diff --git a/school/informatik/verkerhssimulation/src/ogre/OgrePlugin.h b/school/informatik/verkerhssimulation/src/ogre/OgrePlugin.h new file mode 100644 index 00000000..7bb06b7c --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgrePlugin.h @@ -0,0 +1,132 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __OGREPLUGIN_H__ +#define __OGREPLUGIN_H__ + +#include "OgrePrerequisites.h" + +namespace Ogre +{ + /** Class defining a generic OGRE plugin. + @remarks + OGRE is very plugin-oriented and you can customise much of its behaviour + by registering new plugins, dynamically if you are using dynamic linking. + This class abstracts the generic interface that all plugins must support. + Within the implementations of this interface, the plugin must call other + OGRE classes in order to register the detailed customisations it is + providing, e.g. registering a new SceneManagerFactory, a new + MovableObjectFactory, or a new RenderSystem. + @par + Plugins can be linked statically or dynamically. If they are linked + dynamically (ie the plugin is in a DLL or Shared Object file), then you + load the plugin by calling the Root::loadPlugin method (or some other + mechanism which leads to that call, e.g. plugins.cfg), passing the name of + the DLL. OGRE will then call a global init function on that DLL, and it + will be expected to register one or more Plugin implementations using + Root::installPlugin. The procedure is very similar if you use a static + linked plugin, except that you simply instantiate the Plugin implementation + yourself and pass it to Root::installPlugin. + @note + Lifecycle of a Plugin instance is very important. The Plugin instance must + remain valid until the Plugin is uninstalled. Here are the things you + must bear in mind: +
  • If your plugin is in a DLL: +
    • Create the Plugin instance and call Root::installPlugin in dllStartPlugin
    • +
    • Call Root::uninstallPlugin, then delete it in dllStopPlugin
    +
  • If your plugin is statically linked in your app: +
    • Create the Plugin anytime you like
    • +
    • Call Root::installPlugin any time whilst Root is valid
    • +
    • Call Root::uninstallPlugin if you like so long as Root is valid. However, + it will be done for you when Root is destroyed, so the Plugin instance must + still be valid at that point if you haven't manually uninstalled it.
    +
+ The install and unninstall methods will be called when the plugin is + installed or uninstalled. The initialise and shutdown will be called when + there is a system initialisation or shutdown, e.g. when Root::initialise + or Root::shutdown are called. + */ + class _OgreExport Plugin + { + public: + Plugin() {} + virtual ~Plugin() {} + + /** Get the name of the plugin. + @remarks An implementation must be supplied for this method to uniquely + identify the plugin. + */ + virtual const String& getName() const = 0; + + /** Perform the plugin initial installation sequence. + @remarks An implementation must be supplied for this method. It must perform + the startup tasks necessary to install any rendersystem customisations + or anything else that is not dependent on system initialisation, ie + only dependent on the core of Ogre. It must not perform any + operations that would create rendersystem-specific objects at this stage, + that should be done in initialise(). + */ + virtual void install() = 0; + + /** Perform any tasks the plugin needs to perform on full system + initialisation. + @remarks An implementation must be supplied for this method. It is called + just after the system is fully initialised (either after Root::initialise + if a window is created then, or after the frist window is created) + and therefore all rendersystem functionality is available at this + time. You can use this hook to create any resources which are + dependent on a rendersystem or have rendersystem-specific implementations. + */ + virtual void initialise() = 0; + + /** Perform any tasks the plugin needs to perform when the system is shut down. + @remarks An implementation must be supplied for this method. + This method is called just before key parts of the system are unloaded, + such as rendersystems being shut down. You should use this hook to free up + resources and decouple custom objects from the OGRE system, whilst all the + instances of other plugins (e.g. rendersystems) still exist. + */ + virtual void shutdown() = 0; + + /** Perform the final plugin uninstallation sequence. + @remarks An implementation must be supplied for this method. It must perform + the cleanup tasks which haven't already been performed in shutdown() + (e.g. final deletion of custom instances, if you kept them around incase + the system was reinitialised). At this stage you cannot be sure what other + plugins are still loaded or active. It must therefore not perform any + operations that would reference any rendersystem-specific objects - those + should have been sorted out in the 'shutdown' method. + */ + virtual void uninstall() = 0; + }; + +} + +#endif + + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgrePolygon.h b/school/informatik/verkerhssimulation/src/ogre/OgrePolygon.h new file mode 100644 index 00000000..38e46a41 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgrePolygon.h @@ -0,0 +1,130 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Copyright (c) 2006 Matthias Fink, netAllied GmbH +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Polygon_H__ +#define __Polygon_H__ + +#include "OgrePrerequisites.h" +#include "OgreVector3.h" + + +namespace Ogre +{ + + + /** The class represents a polygon in 3D space. + @remarks + It is made up of 3 or more vertices in a single plane, listed in + counter-clockwise order. + */ + class _OgreExport Polygon + { + + public: + typedef std::vector VertexList; + + typedef std::multimap EdgeMap; + typedef std::pair< Vector3, Vector3> Edge; + + protected: + VertexList mVertexList; + Vector3 mNormal; + bool mIsNormalSet; + /** Updates the normal. + */ + void updateNormal(void); + + + public: + Polygon(); + ~Polygon(); + Polygon( const Polygon& cpy ); + + /** Inserts a vertex at a specific position. + @note Vertices must be coplanar. + */ + void insertVertex(const Vector3& vdata, size_t vertexIndex); + /** Inserts a vertex at the end of the polygon. + @note Vertices must be coplanar. + */ + void insertVertex(const Vector3& vdata); + + /** Returns a vertex. + */ + const Vector3& getVertex(size_t vertex) const; + + /** Sets a specific vertex of a polygon. + @note Vertices must be coplanar. + */ + void setVertex(const Vector3& vdata, size_t vertexIndex); + + /** Removes duplicate vertices from a polygon. + */ + void removeDuplicates(void); + + /** Vertex count. + */ + size_t getVertexCount(void) const; + + /** Returns the polygon normal. + */ + const Vector3& getNormal(void); + + /** Deletes a specific vertex. + */ + void deleteVertex(size_t vertex); + + /** Stores the edges of the polygon in ccw order. + The vertices are copied so the user has to take the + deletion into account. + */ + void storeEdges(EdgeMap *edgeMap) const; + + /** Resets the object. + */ + void reset(void); + + /** Determines if the current object is equal to the compared one. + */ + bool operator == (const Polygon& rhs) const; + + /** Determines if the current object is not equal to the compared one. + */ + bool operator != (const Polygon& rhs) const + { return !( *this == rhs ); } + + /** Prints out the polygon data. + */ + _OgreExport friend std::ostream& operator<< ( std::ostream& strm, const Polygon& poly ); + + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgrePose.h b/school/informatik/verkerhssimulation/src/ogre/OgrePose.h new file mode 100644 index 00000000..0a717d25 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgrePose.h @@ -0,0 +1,111 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2005 The OGRE Team +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __OGRE_POSE_H +#define __OGRE_POSE_H + +#include "OgrePrerequisites.h" +#include "OgreString.h" +#include "OgreHardwareVertexBuffer.h" +#include "OgreVector3.h" +#include "OgreIteratorWrappers.h" + +namespace Ogre { + + /** A pose is a linked set of vertex offsets applying to one set of vertex + data. + @remarks + The target index referred to by the pose has a meaning set by the user + of this class; but for example when used by Mesh it refers to either the + Mesh shared geometry (0) or a SubMesh dedicated geometry (1+). + Pose instances can be referred to by keyframes in VertexAnimationTrack in + order to animate based on blending poses together. + */ + class _OgreExport Pose + { + public: + /** Constructor + @param target The target vertexdata index (0 for shared, 1+ for + dedicated at the submesh index + 1) + @param name Optional name + */ + Pose(ushort target, const String& name = StringUtil::BLANK); + virtual ~Pose(); + /// Return the name of the pose (may be blank) + const String& getName(void) const { return mName; } + /// Return the target geometry index of the pose + ushort getTarget(void) const { return mTarget; } + /// A collection of vertex offsets based on the vertex index + typedef std::map VertexOffsetMap; + /// An iterator over the vertex offsets + typedef MapIterator VertexOffsetIterator; + /// An iterator over the vertex offsets + typedef ConstMapIterator ConstVertexOffsetIterator; + + /** Adds an offset to a vertex for this pose. + @param index The vertex index + @param offset The position offset for this pose + */ + void addVertex(size_t index, const Vector3& offset); + + /** Remove a vertex offset. */ + void removeVertex(size_t index); + + /** Clear all vertex offsets. */ + void clearVertexOffsets(void); + + /** Gets an iterator over all the vertex offsets. */ + ConstVertexOffsetIterator getVertexOffsetIterator(void) const; + /** Gets an iterator over all the vertex offsets. */ + VertexOffsetIterator getVertexOffsetIterator(void); + /** Gets a const reference to the vertex offsets. */ + const VertexOffsetMap& getVertexOffsets(void) const { return mVertexOffsetMap; } + + /** Get a hardware vertex buffer version of the vertex offsets. */ + const HardwareVertexBufferSharedPtr& _getHardwareVertexBuffer(size_t numVertices) const; + + /** Clone this pose and create another one configured exactly the same + way (only really useful for cloning holders of this class). + */ + Pose* clone(void) const; + protected: + /// Target geometry index + ushort mTarget; + /// Optional name + String mName; + /// Primary storage, sparse vertex use + VertexOffsetMap mVertexOffsetMap; + /// Derived hardware buffer, covers all vertices + mutable HardwareVertexBufferSharedPtr mBuffer; + }; + typedef std::vector PoseList; + + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgrePredefinedControllers.h b/school/informatik/verkerhssimulation/src/ogre/OgrePredefinedControllers.h new file mode 100644 index 00000000..aca67b9c --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgrePredefinedControllers.h @@ -0,0 +1,285 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __PredefinedControllers_H__ +#define __PredefinedControllers_H__ + +#include "OgrePrerequisites.h" + +#include "OgreCommon.h" +#include "OgreController.h" +#include "OgreFrameListener.h" +#include "OgreGpuProgram.h" + +namespace Ogre { + + //----------------------------------------------------------------------- + // Controller Values + //----------------------------------------------------------------------- + /** Predefined controller value for getting the latest frame time. + */ + class _OgreExport FrameTimeControllerValue : public ControllerValue, public FrameListener + { + protected: + Real mFrameTime; + Real mTimeFactor; + Real mElapsedTime; + Real mFrameDelay; + + public: + FrameTimeControllerValue(); + bool frameEnded(const FrameEvent &evt); + bool frameStarted(const FrameEvent &evt); + Real getValue(void) const; + void setValue(Real value); + Real getTimeFactor(void) const; + void setTimeFactor(Real tf); + Real getFrameDelay(void) const; + void setFrameDelay(Real fd); + Real getElapsedTime(void) const; + void setElapsedTime(Real elapsedTime); + }; + + //----------------------------------------------------------------------- + /** Predefined controller value for getting / setting the frame number of a texture layer + */ + class _OgreExport TextureFrameControllerValue : public ControllerValue + { + protected: + TextureUnitState* mTextureLayer; + public: + TextureFrameControllerValue(TextureUnitState* t); + + /** Gets the frame number as a parametric value in the range [0,1] + */ + Real getValue(void) const; + /** Sets the frame number as a parametric value in the range [0,1]; the actual frame number is value * (numFrames-1). + */ + void setValue(Real value); + + }; + //----------------------------------------------------------------------- + /** Predefined controller value for getting / setting a texture coordinate modifications (scales and translates). + @remarks + Effects can be applied to the scale or the offset of the u or v coordinates, or both. If separate + modifications are required to u and v then 2 instances are required to control both independently, or 4 + if you ant separate u and v scales as well as separate u and v offsets. + @par + Because of the nature of this value, it can accept values outside the 0..1 parametric range. + */ + class _OgreExport TexCoordModifierControllerValue : public ControllerValue + { + protected: + bool mTransU, mTransV; + bool mScaleU, mScaleV; + bool mRotate; + TextureUnitState* mTextureLayer; + public: + /** Constructor. + @param + t TextureUnitState to apply the modification to. + @param + translateU If true, the u coordinates will be translated by the modification. + @param + translateV If true, the v coordinates will be translated by the modification. + @param + scaleU If true, the u coordinates will be scaled by the modification. + @param + scaleV If true, the v coordinates will be scaled by the modification. + @param + rotate If true, the texture will be rotated by the modification. + */ + TexCoordModifierControllerValue(TextureUnitState* t, bool translateU = false, bool translateV = false, + bool scaleU = false, bool scaleV = false, bool rotate = false ); + + Real getValue(void) const; + void setValue(Real value); + + }; + + //----------------------------------------------------------------------- + /** Predefined controller value for setting a single floating- + point value in a constant paramter of a vertex or fragment program. + @remarks + Any value is accepted, it is propagated into the 'x' + component of the constant register identified by the index. If you + need to use named parameters, retrieve the index from the param + object before setting this controller up. + @note + Retrieving a value from the program parameters is not currently + supported, therefore do not use this controller value as a source, + only as a target. + */ + class _OgreExport FloatGpuParameterControllerValue : public ControllerValue + { + protected: + /// The parameters to access + GpuProgramParameters* mParams; + /// The index of the parameter to e read or set + size_t mParamIndex; + public: + /** Constructor. + @param + params The parameters object to access + @param + index The index of the parameter to be set + */ + FloatGpuParameterControllerValue(GpuProgramParameters* params, + size_t index ); + + ~FloatGpuParameterControllerValue() {} + + Real getValue(void) const; + void setValue(Real value); + + }; + //----------------------------------------------------------------------- + // Controller functions + //----------------------------------------------------------------------- + + /** Predefined controller function which just passes through the original source + directly to dest. + */ + class _OgreExport PassthroughControllerFunction : public ControllerFunction + { + public: + /** Constructor. + @param + sequenceTime The amount of time in seconds it takes to loop through the whole animation sequence. + @param + timeOffset The offset in seconds at which to start (default is start at 0) + */ + PassthroughControllerFunction(bool deltaInput = false); + + /** Overriden function. + */ + Real calculate(Real source); + }; + + /** Predefined controller function for dealing with animation. + */ + class _OgreExport AnimationControllerFunction : public ControllerFunction + { + protected: + Real mSeqTime; + Real mTime; + public: + /** Constructor. + @param + sequenceTime The amount of time in seconds it takes to loop through the whole animation sequence. + @param + timeOffset The offset in seconds at which to start (default is start at 0) + */ + AnimationControllerFunction(Real sequenceTime, Real timeOffset = 0.0f); + + /** Overriden function. + */ + Real calculate(Real source); + + /** Set the time value manually. */ + void setTime(Real timeVal); + /** Set the sequence duration value manually. */ + void setSequenceTime(Real seqVal); + }; + + //----------------------------------------------------------------------- + /** Predefined controller function which simply scales an input to an output value. + */ + class _OgreExport ScaleControllerFunction : public ControllerFunction + { + protected: + Real mScale; + public: + /** Constructor, requires a scale factor. + @param + scalefactor The multipier applied to the input to produce the output. + @param + deltaInput If true, signifies that the input will be a delta value such that the function should + add it to an internal counter before calculating the output. + */ + ScaleControllerFunction(Real scalefactor, bool deltaInput); + + /** Overriden method. + */ + Real calculate(Real source); + + }; + + //----------------------------------------------------------------------- + /** Predefined controller function based on a waveform. + @remarks + A waveform function translates parametric intput to parametric output based on a wave. The factors + affecting the function are: + - wave type - the shape of the wave + - base - the base value of the output from the wave + - frequency - the speed of the wave in cycles per second + - phase - the offset of the start of the wave, e.g. 0.5 to start half-way through the wave + - amplitude - scales the output so that instead of lying within [0,1] it lies within [0,1] * amplitude + - duty cycle - the active width of a PWM signal + @par + Note that for simplicity of integration with the rest of the controller insfrastructure, the output of + the wave is parametric i.e. 0..1, rather than the typical wave output of [-1,1]. To compensate for this, the + traditional output of the wave is scaled by the following function before output: + @par + output = (waveoutput + 1) * 0.5 + @par + Hence a wave output of -1 becomes 0, a wave ouput of 1 becomes 1, and a wave output of 0 becomes 0.5. + */ + class _OgreExport WaveformControllerFunction : public ControllerFunction + { + protected: + WaveformType mWaveType; + Real mBase; + Real mFrequency; + Real mPhase; + Real mAmplitude; + Real mDutyCycle; + + /** Overridden from ControllerFunction. */ + Real getAdjustedInput(Real input); + + public: + /** Default contructor, requires at least a wave type, other parameters can be defaulted unless required. + @param + deltaInput If true, signifies that the input will be a delta value such that the function should + add it to an internal counter before calculating the output. + @param + dutyCycle Used in PWM mode to specify the pulse width. + */ + WaveformControllerFunction(WaveformType wType, Real base = 0, Real frequency = 1, Real phase = 0, Real amplitude = 1, bool deltaInput = true, Real dutyCycle = 0.5); + + /** Overriden function. + */ + Real calculate(Real source); + + }; + //----------------------------------------------------------------------- + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgrePrefabFactory.h b/school/informatik/verkerhssimulation/src/ogre/OgrePrefabFactory.h new file mode 100644 index 00000000..6db90d88 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgrePrefabFactory.h @@ -0,0 +1,66 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __PrefabFactory_H__ +#define __PrefabFactory_H__ + +#include "OgrePrerequisites.h" + +namespace Ogre { + + /** A factory class that can create various mesh prefabs. + @remarks + This class is used by OgreMeshManager to offload the loading of various prefab types + to a central location. + */ + class _OgreExport PrefabFactory + { + public: + /** If the given mesh has a known prefab resource name (e.g "Prefab_Plane") + then this prefab will be created as a submesh of the given mesh. + + @param mesh The mesh that the potential prefab will be created in. + @returns true if a prefab has been created, otherwise false. + */ + static bool createPrefab(Mesh* mesh); + + private: + /// Creates a plane as a submesh of the given mesh + static void createPlane(Mesh* mesh); + + /// Creates a 100x100x100 cube as a submesh of the given mesh + static void createCube(Mesh* mesh); + + /// Creates a sphere with a diameter of 100 units as a submesh of the given mesh + static void createSphere(Mesh* mesh); + }; + +} // namespace Ogre + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgrePrerequisites.h b/school/informatik/verkerhssimulation/src/ogre/OgrePrerequisites.h new file mode 100644 index 00000000..a7d3c3f6 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgrePrerequisites.h @@ -0,0 +1,390 @@ +/*------------------------------------------------------------------------- +This source file is a part of OGRE +(Object-oriented Graphics Rendering Engine) + +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License (LGPL) as +published by the Free Software Foundation; either version 2.1 of the +License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or go to +http://www.gnu.org/copyleft/lesser.txt +-------------------------------------------------------------------------*/ +#ifndef __OgrePrerequisites_H__ +#define __OgrePrerequisites_H__ + +// undefine this to not require new angular units where applicable +#define OGRE_FORCE_ANGLE_TYPES + +// Platform-specific stuff +#include "OgrePlatform.h" + +#if OGRE_COMPILER == OGRE_COMPILER_MSVC +// Turn off warnings generated by long std templates +// This warns about truncation to 255 characters in debug/browse info +# pragma warning (disable : 4786) + +// Turn off warnings generated by long std templates +// This warns about truncation to 255 characters in debug/browse info +# pragma warning (disable : 4503) + +// disable: "conversion from 'double' to 'float', possible loss of data +# pragma warning (disable : 4244) + +// disable: "truncation from 'double' to 'float' +# pragma warning (disable : 4305) + +// disable: " needs to have dll-interface to be used by clients' +// Happens on STL member variables which are not public therefore is ok +# pragma warning (disable : 4251) + +// disable: "non dll-interface class used as base for dll-interface class" +// Happens when deriving from Singleton because bug in compiler ignores +// template export +# pragma warning (disable : 4275) + +// disable: "C++ Exception Specification ignored" +// This is because MSVC 6 did not implement all the C++ exception +// specifications in the ANSI C++ draft. +# pragma warning( disable : 4290 ) + +// disable: "no suitable definition provided for explicit template +// instantiation request" Occurs in VC7 for no justifiable reason on all +// #includes of Singleton +# pragma warning( disable: 4661) + +// disable: deprecation warnings when using CRT calls in VC8 +// These show up on all C runtime lib code in VC8, disable since they clutter +// the warnings with things we may not be able to do anything about (e.g. +// generated code from nvparse etc). I doubt very much that these calls +// will ever be actually removed from VC anyway, it would break too much code. +# pragma warning( disable: 4996) + +// disable: "conditional expression constant", always occurs on +// OGRE_MUTEX_CONDITIONAL when no threading enabled +# pragma warning (disable : 201) + +#endif + +/* Include all the standard header *after* all the configuration + settings have been made. +*/ +//#include "OgreStdHeaders.h" + + +#include "OgreMemoryManager.h" + +namespace Ogre { + // Define ogre version + #define OGRE_VERSION_MAJOR 1 + #define OGRE_VERSION_MINOR 4 + #define OGRE_VERSION_PATCH 4 + #define OGRE_VERSION_SUFFIX "" + #define OGRE_VERSION_NAME "Eihort" + + #define OGRE_VERSION ((OGRE_VERSION_MAJOR << 16) | (OGRE_VERSION_MINOR << 8) | OGRE_VERSION_PATCH) + + // define the real number values to be used + // default to use 'float' unless precompiler option set + #if OGRE_DOUBLE_PRECISION == 1 + /** Software floating point type. + @note Not valid as a pointer to GPU buffers / parameters + */ + typedef double Real; + #else + /** Software floating point type. + @note Not valid as a pointer to GPU buffers / parameters + */ + typedef float Real; + #endif + + #if OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 310 && !defined(STLPORT) + # define HashMap ::__gnu_cxx::hash_map + #else + # if OGRE_COMPILER == OGRE_COMPILER_MSVC + # if OGRE_COMP_VER > 1300 && !defined(_STLP_MSVC) + # define HashMap ::stdext::hash_map + # else + # define HashMap ::std::hash_map + # endif + # else + # define HashMap ::std::hash_map + # endif + #endif + + /** In order to avoid finger-aches :) + */ + typedef unsigned char uchar; + typedef unsigned short ushort; + typedef unsigned int uint; + typedef unsigned long ulong; + + /// Useful macros + #define OGRE_DELETE(p) { if(p) { delete (p); (p)=NULL; } } + #define OGRE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } } + + #if OGRE_WCHAR_T_STRINGS + typedef std::wstring _StringBase; + #else + typedef std::string _StringBase; + #endif + + typedef _StringBase String; + + // Useful threading defines + #define OGRE_AUTO_MUTEX_NAME mutex + #if OGRE_THREAD_SUPPORT + #define OGRE_AUTO_MUTEX mutable boost::recursive_mutex OGRE_AUTO_MUTEX_NAME; + #define OGRE_LOCK_AUTO_MUTEX boost::recursive_mutex::scoped_lock ogreAutoMutexLock(OGRE_AUTO_MUTEX_NAME); + #define OGRE_MUTEX(name) mutable boost::recursive_mutex name; + #define OGRE_STATIC_MUTEX(name) static boost::recursive_mutex name; + #define OGRE_STATIC_MUTEX_INSTANCE(name) boost::recursive_mutex name; + #define OGRE_LOCK_MUTEX(name) boost::recursive_mutex::scoped_lock ogrenameLock(name); + #define OGRE_LOCK_MUTEX_NAMED(mutexName, lockName) boost::recursive_mutex::scoped_lock lockName(mutexName); + // like OGRE_AUTO_MUTEX but mutex held by pointer + #define OGRE_AUTO_SHARED_MUTEX mutable boost::recursive_mutex *OGRE_AUTO_MUTEX_NAME; + #define OGRE_LOCK_AUTO_SHARED_MUTEX assert(OGRE_AUTO_MUTEX_NAME); boost::recursive_mutex::scoped_lock ogreAutoMutexLock(*OGRE_AUTO_MUTEX_NAME); + #define OGRE_NEW_AUTO_SHARED_MUTEX assert(!OGRE_AUTO_MUTEX_NAME); OGRE_AUTO_MUTEX_NAME = new boost::recursive_mutex(); + #define OGRE_DELETE_AUTO_SHARED_MUTEX assert(OGRE_AUTO_MUTEX_NAME); delete OGRE_AUTO_MUTEX_NAME; + #define OGRE_COPY_AUTO_SHARED_MUTEX(from) assert(!OGRE_AUTO_MUTEX_NAME); OGRE_AUTO_MUTEX_NAME = from; + #define OGRE_SET_AUTO_SHARED_MUTEX_NULL OGRE_AUTO_MUTEX_NAME = 0; + #define OGRE_MUTEX_CONDITIONAL(mutex) if (mutex) + #define OGRE_THREAD_SYNCHRONISER(sync) boost::condition sync; + #define OGRE_THREAD_WAIT(sync, lock) sync.wait(lock); + #define OGRE_THREAD_NOTIFY_ONE(sync) sync.notify_one(); + #define OGRE_THREAD_NOTIFY_ALL(sync) sync.notify_all(); + // Thread-local pointer + #define OGRE_THREAD_POINTER(T, var) boost::thread_specific_ptr var + #define OGRE_THREAD_POINTER_SET(var, expr) var.reset(expr) + #define OGRE_THREAD_POINTER_DELETE(var) var.reset(0) + #define OGRE_THREAD_POINTER_GET(var) var.get() + #else + #define OGRE_AUTO_MUTEX + #define OGRE_LOCK_AUTO_MUTEX + #define OGRE_MUTEX(name) + #define OGRE_STATIC_MUTEX(name) + #define OGRE_STATIC_MUTEX_INSTANCE(name) + #define OGRE_LOCK_MUTEX(name) + #define OGRE_LOCK_MUTEX_NAMED(mutexName, lockName) + #define OGRE_AUTO_SHARED_MUTEX + #define OGRE_LOCK_AUTO_SHARED_MUTEX + #define OGRE_NEW_AUTO_SHARED_MUTEX + #define OGRE_DELETE_AUTO_SHARED_MUTEX + #define OGRE_COPY_AUTO_SHARED_MUTEX(from) + #define OGRE_SET_AUTO_SHARED_MUTEX_NULL + #define OGRE_MUTEX_CONDITIONAL(name) if(true) + #define OGRE_THREAD_SYNCHRONISER(sync) + #define OGRE_THREAD_WAIT(sync, lock) + #define OGRE_THREAD_NOTIFY_ONE(sync) + #define OGRE_THREAD_NOTIFY_ALL(sync) + #define OGRE_THREAD_POINTER(T, var) T* var + #define OGRE_THREAD_POINTER_SET(var, expr) var = expr + #define OGRE_THREAD_POINTER_DELETE(var) delete var; var = 0 + #define OGRE_THREAD_POINTER_GET(var) var + #endif + + +// Pre-declare classes +// Allows use of pointers in header files without including individual .h +// so decreases dependencies between files + class Angle; + class Animation; + class AnimationState; + class AnimationStateSet; + class AnimationTrack; + class Archive; + class ArchiveFactory; + class ArchiveManager; + class AutoParamDataSource; + class AxisAlignedBox; + class AxisAlignedBoxSceneQuery; + class Billboard; + class BillboardChain; + class BillboardSet; + class Bone; + class Camera; + class Codec; + class ColourValue; + class ConfigDialog; + template class Controller; + template class ControllerFunction; + class ControllerManager; + template class ControllerValue; + class Degree; + class DynLib; + class DynLibManager; + class EdgeData; + class EdgeListBuilder; + class Entity; + class ErrorDialog; + class ExternalTextureSourceManager; + class Factory; + class Font; + class FontPtr; + class FontManager; + struct FrameEvent; + class FrameListener; + class Frustum; + class GpuProgram; + class GpuProgramPtr; + class GpuProgramManager; + class GpuProgramUsage; + class HardwareIndexBuffer; + class HardwareOcclusionQuery; + class HardwareVertexBuffer; + class HardwarePixelBuffer; + class HardwarePixelBufferSharedPtr; + class HighLevelGpuProgram; + class HighLevelGpuProgramPtr; + class HighLevelGpuProgramManager; + class HighLevelGpuProgramFactory; + class IndexData; + class IntersectionSceneQuery; + class IntersectionSceneQueryListener; + class Image; + class KeyFrame; + class Light; + class Log; + class LogManager; + class ManualResourceLoader; + class ManualObject; + class Material; + class MaterialPtr; + class MaterialManager; + class MaterialScriptCompiler; + class Math; + class Matrix3; + class Matrix4; + class MemoryManager; + class Mesh; + class MeshPtr; + class MeshSerializer; + class MeshSerializerImpl; + class MeshManager; + class MovableObject; + class MovablePlane; + class Node; + class NodeAnimationTrack; + class NodeKeyFrame; + class NumericAnimationTrack; + class NumericKeyFrame; + class Overlay; + class OverlayContainer; + class OverlayElement; + class OverlayElementFactory; + class OverlayManager; + class Particle; + class ParticleAffector; + class ParticleAffectorFactory; + class ParticleEmitter; + class ParticleEmitterFactory; + class ParticleSystem; + class ParticleSystemManager; + class ParticleSystemRenderer; + class ParticleSystemRendererFactory; + class ParticleVisualData; + class Pass; + class PatchMesh; + class PixelBox; + class Plane; + class PlaneBoundedVolume; + class Plugin; + class Pose; + class ProgressiveMesh; + class Profile; + class Profiler; + class Quaternion; + class Radian; + class Ray; + class RaySceneQuery; + class RaySceneQueryListener; + class Renderable; + class RenderPriorityGroup; + class RenderQueue; + class RenderQueueGroup; + class RenderQueueInvocation; + class RenderQueueInvocationSequence; + class RenderQueueListener; + class RenderSystem; + class RenderSystemCapabilities; + class RenderTarget; + class RenderTargetListener; + class RenderTexture; + class MultiRenderTarget; + class RenderWindow; + class RenderOperation; + class Resource; + class ResourceBackgroundQueue; + class ResourceGroupManager; + class ResourceManager; + class RibbonTrail; + class Root; + class SceneManager; + class SceneManagerEnumerator; + class SceneNode; + class SceneQuery; + class SceneQueryListener; + class ScriptLoader; + class Serializer; + class ShadowCaster; + class ShadowRenderable; + class ShadowTextureManager; + class SimpleRenderable; + class SimpleSpline; + class Skeleton; + class SkeletonPtr; + class SkeletonInstance; + class SkeletonManager; + class Sphere; + class SphereSceneQuery; + class StaticGeometry; + class StringConverter; + class StringInterface; + class SubEntity; + class SubMesh; + class TagPoint; + class Technique; + class TempBlendedBufferInfo; + class ExternalTextureSource; + class TextureUnitState; + class Texture; + class TexturePtr; + class TextureFont; + class TextureManager; + class TransformKeyFrame; + class Timer; + class UserDefinedObject; + class Vector2; + class Vector3; + class Vector4; + class Viewport; + class VertexAnimationTrack; + class VertexBufferBinding; + class VertexData; + class VertexDeclaration; + class VertexMorphKeyFrame; + class WireBoundingBox; + class Compositor; + class CompositorManager; + class CompositorChain; + class CompositorInstance; + class CompositionTechnique; + class CompositionPass; + class CompositionTargetPass; +} + +#endif // __OgrePrerequisites_H__ + + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreProfiler.h b/school/informatik/verkerhssimulation/src/ogre/OgreProfiler.h new file mode 100644 index 00000000..0c862324 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreProfiler.h @@ -0,0 +1,415 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +/* + + Although the code is original, many of the ideas for the profiler were borrowed from +"Real-Time In-Game Profiling" by Steve Rabin which can be found in Game Programming +Gems 1. + + This code can easily be adapted to your own non-Ogre project. The only code that is +Ogre-dependent is in the visualization/logging routines and the use of the Timer class. + + Enjoy! + +*/ + +#ifndef __Profiler_H__ +#define __Profiler_H__ + +#include "OgrePrerequisites.h" +#include "OgreSingleton.h" +#include "OgreString.h" +#include "OgreOverlay.h" + +#if OGRE_PROFILING == 1 +# if OGRE_COMPILER != OGRE_COMPILER_BORL +# define OgreProfile( a ) Ogre::Profile _OgreProfileInstance( (a) ) +# define OgreProfileBegin( a ) Ogre::Profiler::getSingleton().beginProfile( (a) ) +# define OgreProfileEnd( a ) Ogre::Profiler::getSingleton().endProfile( (a) ) +# else +# define OgreProfile( a ) Ogre::Profile _OgreProfileInstance( __FUNC__ ) +# define OgreProfileBegin( a ) Ogre::Profiler::getSingleton().beginProfile( __FUNC__ ) +# define OgreProfileEnd( a ) Ogre::Profiler::getSingleton().endProfile( __FUNC__ ) +# endif +#else +# define OgreProfile( a ) +# define OgreProfileBegin( a ) +# define OgreProfileEnd( a ) +#endif + +namespace Ogre { + + /** An individual profile that will be processed by the Profiler + @remarks + Use the macro OgreProfile(name) instead of instantiating this profile directly + @remarks + We use this Profile to allow scoping rules to signify the beginning and end of + the profile. Use the Profiler singleton (through the macro OgreProfileBegin(name) + and OgreProfileEnd(name)) directly if you want a profile to last + outside of a scope (ie the main game loop). + @author Amit Mathew (amitmathew (at) yahoo (dot) com) + */ + class _OgreExport Profile { + + public: + Profile(const String& profileName); + ~Profile(); + + protected: + + /// The name of this profile + String mName; + + + }; + + /** The profiler allows you to measure the performance of your code + @remarks + Do not create profiles directly from this unless you want a profile to last + outside of its scope (ie the main game loop). For most cases, use the macro + OgreProfile(name) and braces to limit the scope. You must enable the Profile + before you can used it with setEnabled(true). If you want to disable profiling + in Ogre, simply set the macro OGRE_PROFILING to 0. + @author Amit Mathew (amitmathew (at) yahoo (dot) com) + @todo resolve artificial cap on number of profiles displayed + @todo fix display ordering of profiles not called every frame + */ + class _OgreExport Profiler : public Singleton { + + public: + Profiler(); + ~Profiler(); + + /** Sets the timer for the profiler */ + void setTimer(Timer* t); + + /** Retrieves the timer for the profiler */ + Timer* getTimer(); + + /** Begins a profile + @remarks + Use the macro OgreProfileBegin(name) instead of calling this directly + so that profiling can be ignored in the release version of your app. + @remarks + You only use the macro (or this) if you want a profile to last outside + of its scope (ie the main game loop). If you use this function, make sure you + use a corresponding OgreProfileEnd(name). Usually you would use the macro + OgreProfile(name). This function will be ignored for a profile that has been + disabled or if the profiler is disabled. + @param profileName Must be unique and must not be an empty string + */ + void beginProfile(const String& profileName); + + /** Ends a profile + @remarks + Use the macro OgreProfileEnd(name) instead of calling this directly so that + profiling can be ignored in the release version of your app. + @remarks + This function is usually not called directly unless you want a profile to + last outside of its scope. In most cases, using the macro OgreProfile(name) + which will call this function automatically when it goes out of scope. Make + sure the name of this profile matches its corresponding beginProfile name. + This function will be ignored for a profile that has been disabled or if the + profiler is disabled. + */ + void endProfile(const String& profileName); + + /** Sets whether this profiler is enabled. Only takes effect after the + the frame has ended. + @remarks When this is called the first time with the parameter true, + it initializes the GUI for the Profiler + */ + void setEnabled(bool enabled); + + /** Gets whether this profiler is enabled */ + bool getEnabled() const; + + /** Enables a previously disabled profile + @remarks Only enables the profile if this function is not + called during the profile it is trying to enable. + */ + void enableProfile(const String& profileName); + + /** Disables a profile + @remarks Only disables the profile if this function is not called during + the profile it is trying to disable. + */ + void disableProfile(const String& profileName); + + /** Returns true if the specified profile reaches a new frame time maximum + @remarks If this is called during a frame, it will be reading the results + from the previous frame. Therefore, it is best to use this after the frame + has ended. + */ + bool watchForMax(const String& profileName); + + /** Returns true if the specified profile reaches a new frame time minimum + @remarks If this is called during a frame, it will be reading the results + from the previous frame. Therefore, it is best to use this after the frame + has ended. + */ + bool watchForMin(const String& profileName); + + /** Returns true if the specified profile goes over or under the given limit + frame time + @remarks If this is called during a frame, it will be reading the results + from the previous frame. Therefore, it is best to use this after the frame + has ended. + @param limit A number between 0 and 1 representing the percentage of frame time + @param greaterThan If true, this will return whether the limit is exceeded. Otherwise, + it will return if the frame time has gone under this limit. + */ + bool watchForLimit(const String& profileName, Real limit, bool greaterThan = true); + + /** Outputs current profile statistics to the log */ + void logResults(); + + /** Clears the profiler statistics */ + void reset(); + + /** Sets the Profiler so the display of results are updated ever n frames*/ + void setUpdateDisplayFrequency(uint freq); + + /** Gets the frequency that the Profiler display is updated */ + uint getUpdateDisplayFrequency() const; + + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static Profiler& getSingleton(void); + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static Profiler* getSingletonPtr(void); + + protected: + + /** Initializes the profiler's gui elements */ + void initialize(); + + /** Prints the profiling results of each frame */ + void displayResults(); + + /** Processes the profiler data after each frame */ + void processFrameStats(); + + /** Handles a change of the profiler's enabled state*/ + void changeEnableState(); + + /** An internal function to create the container which will hold our display elements*/ + OverlayContainer* createContainer(); + + /** An internal function to create a text area */ + OverlayElement* createTextArea(const String& name, Real width, Real height, Real top, Real left, + uint fontSize, const String& caption, bool show = true); + + /** An internal function to create a panel */ + OverlayElement* createPanel(const String& name, Real width, Real height, Real top, Real left, + const String& materialName, bool show = true); + + /// Represents an individual profile call + struct ProfileInstance { + + /// The name of the profile + String name; + + /// The name of the parent, empty string if root + String parent; + + /// The time this profile was started + ulong currTime; + + /// Represents the total time of all child profiles to subtract + /// from this profile + ulong accum; + + /// The hierarchical level of this profile, 0 being the root profile + uint hierarchicalLvl; + }; + + /// Represents the total timing information of a profile + /// since profiles can be called more than once each frame + struct ProfileFrame { + + /// The name of the profile + String name; + + /// The total time this profile has taken this frame + ulong frameTime; + + /// The number of times this profile was called this frame + uint calls; + + /// The hierarchical level of this profile, 0 being the main loop + uint hierarchicalLvl; + + }; + + /// Represents a history of each profile during the duration of the app + struct ProfileHistory { + + /// The name of the profile + String name; + + /// The current percentage of frame time this profile has taken + Real currentTime; // % + + /// The maximum percentage of frame time this profile has taken + Real maxTime; // % + + /// The minimum percentage of frame time this profile has taken + Real minTime; // % + + /// The number of times this profile has been called each frame + uint numCallsThisFrame; + + /// The total percentage of frame time this profile has taken + /// (used to calculate average) + Real totalTime; // % + + /// The total number of times this profile was called + /// (used to calculate average) + ulong totalCalls; // % + + /// The hierarchical level of this profile, 0 being the root profile + uint hierarchicalLvl; + + }; + + + typedef std::list ProfileStack; + typedef std::list ProfileFrameList; + typedef std::list ProfileHistoryList; + typedef std::map ProfileHistoryMap; + typedef std::map DisabledProfileMap; + + typedef std::list ProfileBarList; + + /// A stack for each individual profile per frame + ProfileStack mProfiles; + + /// Accumulates the results of each profile per frame (since a profile can be called + /// more than once a frame) + ProfileFrameList mProfileFrame; + + /// Keeps track of the statistics of each profile + ProfileHistoryList mProfileHistory; + + /// We use this for quick look-ups of profiles in the history list + ProfileHistoryMap mProfileHistoryMap; + + /// Holds the names of disabled profiles + DisabledProfileMap mDisabledProfiles; + + /// Holds the display bars for each profile results + ProfileBarList mProfileBars; + + /// Whether the GUI elements have been initialized + bool mInitialized; + + /// The max number of profiles we can display + uint maxProfiles; + + /// The overlay which contains our profiler results display + Overlay* mOverlay; + + /// The window that displays the profiler results + OverlayContainer* mProfileGui; + + /// The height of each bar + Real mBarHeight; + + /// The height of the stats window + Real mGuiHeight; + + /// The width of the stats window + Real mGuiWidth; + + /// The size of the indent for each profile display bar + Real mBarIndent; + + /// The width of the border between the profile window and each bar + Real mGuiBorderWidth; + + /// The width of the min, avg, and max lines in a profile display + Real mBarLineWidth; + + /// The number of frames that must elapse before the current + /// frame display is updated + uint mUpdateDisplayFrequency; + + /// The number of elasped frame, used with mUpdateDisplayFrequency + uint mCurrentFrame; + + /// The timer used for profiling + Timer* mTimer; + + /// The total time each frame takes + ulong mTotalFrameTime; + + /// Whether this profiler is enabled + bool mEnabled; + + /// Keeps track of whether this profiler has + /// received a request to be enabled/disabled + bool mEnableStateChangePending; + + /// Keeps track of the new enabled/disabled state that the user has requested + /// which will be applied after the frame ends + bool mNewEnableState; + + }; // end class + +} // end namespace + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreProgressiveMesh.h b/school/informatik/verkerhssimulation/src/ogre/OgreProgressiveMesh.h new file mode 100644 index 00000000..19b898fe --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreProgressiveMesh.h @@ -0,0 +1,248 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +// The underlying algorithms in this class are based heavily on: +/* + * Progressive Mesh type Polygon Reduction Algorithm + * by Stan Melax (c) 1998 + */ + +#ifndef __ProgressiveMesh_H_ +#define __ProgressiveMesh_H_ + +#include "OgrePrerequisites.h" +#include "OgreVector3.h" +#include "OgreHardwareVertexBuffer.h" +#include "OgreHardwareIndexBuffer.h" +#include "OgreRenderOperation.h" + +namespace Ogre { + + /** This class reduces the complexity of the geometry it is given. + This class is dedicated to reducing the number of triangles in a given mesh + taking into account seams in both geometry and texture co-ordinates and meshes + which have multiple frames. + @par + The primary use for this is generating LOD versions of Mesh objects, but it can be + used by any geometry provider. The only limitation at the moment is that the + provider uses a common vertex buffer for all LODs and one index buffer per LOD. + Therefore at the moment this class can only handle indexed geometry. + @par + NB the interface of this class will certainly change when compiled vertex buffers are + supported. + */ + class _OgreExport ProgressiveMesh + { + public: + + /** The way to derive the quota of vertices which are reduced at each LOD. */ + enum VertexReductionQuota + { + /// A set number of vertices are removed at each reduction + VRQ_CONSTANT, + /// A proportion of the remaining number of vertices are removed at each reduction + VRQ_PROPORTIONAL + }; + + typedef std::vector LODFaceList; + + /** Constructor, takes the geometry data and index buffer. + @remarks + DO NOT pass write-only, unshadowed buffers to this method! They will not + work. Pass only shadowed buffers, or better yet perform mesh reduction as + an offline process using DefaultHardwareBufferManager to manage vertex + buffers in system memory. + */ + ProgressiveMesh(const VertexData* vertexData, const IndexData* indexData); + virtual ~ProgressiveMesh(); + + /** Adds an extra vertex position buffer. + @remarks + As well as the main vertex buffer, the client of this class may add extra versions + of the vertex buffer which will also be taken into account when the cost of + simplifying the mesh is taken into account. This is because the cost of + simplifying an animated mesh cannot be calculated from just the reference position, + multiple positions needs to be assessed in order to find the best simplification option. + @par + DO NOT pass write-only, unshadowed buffers to this method! They will not + work. Pass only shadowed buffers, or better yet perform mesh reduction as + an offline process using DefaultHardwareBufferManager to manage vertex + buffers in system memory. + @param buffer Pointer to x/y/z buffer with vertex positions. The number of vertices + must be the same as in the original GeometryData passed to the constructor. + */ + virtual void addExtraVertexPositionBuffer(const VertexData* vertexData); + + /** Builds the progressive mesh with the specified number of levels. + @param numLevels The number of levels to include in the output excluding the full detail version. + @param outList Pointer to a list of LOD geometry data which will be completed by the application. + Each entry is a reduced form of the mesh, in decreasing order of detail. + @param quota The way to derive the number of vertices removed at each LOD + @param reductionValue Either the proportion of vertices to remove at each level, or a fixed + number of vertices to remove at each level, depending on the value of quota + */ + virtual void build(ushort numLevels, LODFaceList* outList, + VertexReductionQuota quota = VRQ_PROPORTIONAL, Real reductionValue = 0.5f ); + + protected: + const VertexData *mpVertexData; + const IndexData *mpIndexData; + + size_t mCurrNumIndexes; + size_t mNumCommonVertices; + + // Internal classes + class PMTriangle; + class PMVertex; + + public: // VC6 hack + + /** A vertex as used by a face. This records the index of the actual vertex which is used + by the face, and a pointer to the common vertex used for surface evaluation. */ + class _OgrePrivate PMFaceVertex { + public: + size_t realIndex; + PMVertex* commonVertex; + }; + + protected: + + /** A triangle in the progressive mesh, holds extra info like face normal. */ + class _OgrePrivate PMTriangle { + public: + PMTriangle(); + void setDetails(size_t index, PMFaceVertex *v0, PMFaceVertex *v1, PMFaceVertex *v2); + void computeNormal(void); + void replaceVertex(PMFaceVertex *vold, PMFaceVertex *vnew); + bool hasCommonVertex(PMVertex *v) const; + bool hasFaceVertex(PMFaceVertex *v) const; + PMFaceVertex* getFaceVertexFromCommon(PMVertex* commonVert); + void notifyRemoved(void); + + PMFaceVertex* vertex[3]; // the 3 points that make this tri + Vector3 normal; // unit vector othogonal to this face + bool removed; // true if this tri is now removed + size_t index; + }; + + /** A vertex in the progressive mesh, holds info like collapse cost etc. + This vertex can actually represent several vertices in the final model, because + vertices along texture seams etc will have been duplicated. In order to properly + evaluate the surface properties, a single common vertex is used for these duplicates, + and the faces hold the detail of the duplicated vertices. + */ + class _OgrePrivate PMVertex { + public: + PMVertex(); + void setDetails(const Vector3& v, size_t index); + void removeIfNonNeighbor(PMVertex *n); + bool isBorder(void);/// true if this vertex is on the edge of an open geometry patch + bool isManifoldEdgeWith(PMVertex* v); // is edge this->src a manifold edge? + void notifyRemoved(void); + + Vector3 position; // location of point in euclidean space + size_t index; // place of vertex in original list + typedef std::set NeighborList; + typedef std::set DuplicateList; + NeighborList neighbor; // adjacent vertices + typedef std::set FaceList; + FaceList face; // adjacent triangles + + Real collapseCost; // cached cost of collapsing edge + PMVertex * collapseTo; // candidate vertex for collapse + bool removed; // true if this vert is now removed + bool toBeRemoved; // denug + + bool seam; /// true if this vertex is on a model seam where vertices are duplicated + + }; + + typedef std::vector TriangleList; + typedef std::vector FaceVertexList; + typedef std::vector CommonVertexList; + typedef std::vector WorstCostList; + + /// Data used to calculate the collapse costs + struct PMWorkingData + { + TriangleList mTriList; /// List of faces + FaceVertexList mFaceVertList; // The vertex details referenced by the triangles + CommonVertexList mVertList; // The master list of common vertices + }; + + typedef std::vector WorkingDataList; + /// Multiple copies, 1 per vertex buffer + WorkingDataList mWorkingData; + + /// The worst collapse cost from all vertex buffers for each vertex + WorstCostList mWorstCosts; + + /// Internal method for building PMWorkingData from geometry data + void addWorkingData(const VertexData* vertexData, const IndexData* indexData); + + /// Internal method for initialising the edge collapse costs + void initialiseEdgeCollapseCosts(void); + /// Internal calculation method for deriving a collapse cost from u to v + Real computeEdgeCollapseCost(PMVertex *src, PMVertex *dest); + /// Internal method evaluates all collapse costs from this vertex and picks the lowest for a single buffer + Real computeEdgeCostAtVertexForBuffer(WorkingDataList::iterator idata, size_t vertIndex); + /// Internal method evaluates all collapse costs from this vertex for every buffer and returns the worst + void computeEdgeCostAtVertex(size_t vertIndex); + /// Internal method to compute edge collapse costs for all buffers / + void computeAllCosts(void); + /// Internal method for getting the index of next best vertex to collapse + size_t getNextCollapser(void); + /// Internal method builds an new LOD based on the current state + void bakeNewLOD(IndexData* pData); + + /** Internal method, collapses vertex onto it's saved collapse target. + @remarks + This updates the working triangle list to drop a triangle and recalculates + the edge collapse costs around the collapse target. + This also updates all the working vertex lists for the relevant buffer. + */ + void collapse(PMVertex *collapser); + + /** Internal debugging method */ + void dumpContents(const String& log); + + + + + + + + + + }; + + + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreQuaternion.h b/school/informatik/verkerhssimulation/src/ogre/OgreQuaternion.h new file mode 100644 index 00000000..872d1ff0 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreQuaternion.h @@ -0,0 +1,277 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +// NOTE THAT THIS FILE IS BASED ON MATERIAL FROM: + +// Magic Software, Inc. +// http://www.geometrictools.com/ +// Copyright (c) 2000, All Rights Reserved +// +// Source code from Magic Software is supplied under the terms of a license +// agreement and may not be copied or disclosed except in accordance with the +// terms of that agreement. The various license agreements may be found at +// the Magic Software web site. This file is subject to the license +// +// FREE SOURCE CODE +// http://www.geometrictools.com/License/WildMagic3License.pdf + +#ifndef __Quaternion_H__ +#define __Quaternion_H__ + +#include "OgrePrerequisites.h" +#include "OgreMath.h" + +namespace Ogre { + + /** Implementation of a Quaternion, i.e. a rotation around an axis. + */ + class _OgreExport Quaternion + { + public: + inline Quaternion ( + Real fW = 1.0, + Real fX = 0.0, Real fY = 0.0, Real fZ = 0.0) + { + w = fW; + x = fX; + y = fY; + z = fZ; + } + inline Quaternion (const Quaternion& rkQ) + { + w = rkQ.w; + x = rkQ.x; + y = rkQ.y; + z = rkQ.z; + } + /// Construct a quaternion from a rotation matrix + inline Quaternion(const Matrix3& rot) + { + this->FromRotationMatrix(rot); + } + /// Construct a quaternion from an angle/axis + inline Quaternion(const Radian& rfAngle, const Vector3& rkAxis) + { + this->FromAngleAxis(rfAngle, rkAxis); + } +#ifndef OGRE_FORCE_ANGLE_TYPES + inline Quaternion(const Real& rfAngle, const Vector3& rkAxis) + { + this->FromAngleAxis(rfAngle, rkAxis); + } +#endif//OGRE_FORCE_ANGLE_TYPES + /// Construct a quaternion from 3 orthonormal local axes + inline Quaternion(const Vector3& xaxis, const Vector3& yaxis, const Vector3& zaxis) + { + this->FromAxes(xaxis, yaxis, zaxis); + } + /// Construct a quaternion from 3 orthonormal local axes + inline Quaternion(const Vector3* akAxis) + { + this->FromAxes(akAxis); + } + /// Construct a quaternion from 4 manual w/x/y/z values + inline Quaternion(Real* valptr) + { + memcpy(&w, valptr, sizeof(Real)*4); + } + + /// Array accessor operator + inline Real operator [] ( const size_t i ) const + { + assert( i < 4 ); + + return *(&w+i); + } + + /// Array accessor operator + inline Real& operator [] ( const size_t i ) + { + assert( i < 4 ); + + return *(&w+i); + } + + /// Pointer accessor for direct copying + inline Real* ptr() + { + return &w; + } + + /// Pointer accessor for direct copying + inline const Real* ptr() const + { + return &w; + } + + void FromRotationMatrix (const Matrix3& kRot); + void ToRotationMatrix (Matrix3& kRot) const; + void FromAngleAxis (const Radian& rfAngle, const Vector3& rkAxis); + void ToAngleAxis (Radian& rfAngle, Vector3& rkAxis) const; + inline void ToAngleAxis (Degree& dAngle, Vector3& rkAxis) const { + Radian rAngle; + ToAngleAxis ( rAngle, rkAxis ); + dAngle = rAngle; + } +#ifndef OGRE_FORCE_ANGLE_TYPES + inline void FromAngleAxis (const Real& rfAngle, const Vector3& rkAxis) { + FromAngleAxis ( Angle(rfAngle), rkAxis ); + } + inline void ToAngleAxis (Real& rfAngle, Vector3& rkAxis) const { + Radian r; + ToAngleAxis ( r, rkAxis ); + rfAngle = r.valueAngleUnits(); + } +#endif//OGRE_FORCE_ANGLE_TYPES + void FromAxes (const Vector3* akAxis); + void FromAxes (const Vector3& xAxis, const Vector3& yAxis, const Vector3& zAxis); + void ToAxes (Vector3* akAxis) const; + void ToAxes (Vector3& xAxis, Vector3& yAxis, Vector3& zAxis) const; + /// Get the local x-axis + Vector3 xAxis(void) const; + /// Get the local y-axis + Vector3 yAxis(void) const; + /// Get the local z-axis + Vector3 zAxis(void) const; + + inline Quaternion& operator= (const Quaternion& rkQ) + { + w = rkQ.w; + x = rkQ.x; + y = rkQ.y; + z = rkQ.z; + return *this; + } + Quaternion operator+ (const Quaternion& rkQ) const; + Quaternion operator- (const Quaternion& rkQ) const; + Quaternion operator* (const Quaternion& rkQ) const; + Quaternion operator* (Real fScalar) const; + _OgreExport friend Quaternion operator* (Real fScalar, + const Quaternion& rkQ); + Quaternion operator- () const; + inline bool operator== (const Quaternion& rhs) const + { + return (rhs.x == x) && (rhs.y == y) && + (rhs.z == z) && (rhs.w == w); + } + inline bool operator!= (const Quaternion& rhs) const + { + return !operator==(rhs); + } + // functions of a quaternion + Real Dot (const Quaternion& rkQ) const; // dot product + Real Norm () const; // squared-length + /// Normalises this quaternion, and returns the previous length + Real normalise(void); + Quaternion Inverse () const; // apply to non-zero quaternion + Quaternion UnitInverse () const; // apply to unit-length quaternion + Quaternion Exp () const; + Quaternion Log () const; + + // rotation of a vector by a quaternion + Vector3 operator* (const Vector3& rkVector) const; + + /** Calculate the local roll element of this quaternion. + @param reprojectAxis By default the method returns the 'intuitive' result + that is, if you projected the local Y of the quaterion onto the X and + Y axes, the angle between them is returned. If set to false though, the + result is the actual yaw that will be used to implement the quaternion, + which is the shortest possible path to get to the same orientation and + may involve less axial rotation. + */ + Radian getRoll(bool reprojectAxis = true) const; + /** Calculate the local pitch element of this quaternion + @param reprojectAxis By default the method returns the 'intuitive' result + that is, if you projected the local Z of the quaterion onto the X and + Y axes, the angle between them is returned. If set to true though, the + result is the actual yaw that will be used to implement the quaternion, + which is the shortest possible path to get to the same orientation and + may involve less axial rotation. + */ + Radian getPitch(bool reprojectAxis = true) const; + /** Calculate the local yaw element of this quaternion + @param reprojectAxis By default the method returns the 'intuitive' result + that is, if you projected the local Z of the quaterion onto the X and + Z axes, the angle between them is returned. If set to true though, the + result is the actual yaw that will be used to implement the quaternion, + which is the shortest possible path to get to the same orientation and + may involve less axial rotation. + */ + Radian getYaw(bool reprojectAxis = true) const; + /// Equality with tolerance (tolerance is max angle difference) + bool equals(const Quaternion& rhs, const Radian& tolerance) const; + + // spherical linear interpolation + static Quaternion Slerp (Real fT, const Quaternion& rkP, + const Quaternion& rkQ, bool shortestPath = false); + + static Quaternion SlerpExtraSpins (Real fT, + const Quaternion& rkP, const Quaternion& rkQ, + int iExtraSpins); + + // setup for spherical quadratic interpolation + static void Intermediate (const Quaternion& rkQ0, + const Quaternion& rkQ1, const Quaternion& rkQ2, + Quaternion& rka, Quaternion& rkB); + + // spherical quadratic interpolation + static Quaternion Squad (Real fT, const Quaternion& rkP, + const Quaternion& rkA, const Quaternion& rkB, + const Quaternion& rkQ, bool shortestPath = false); + + // normalised linear interpolation - faster but less accurate (non-constant rotation velocity) + static Quaternion nlerp(Real fT, const Quaternion& rkP, + const Quaternion& rkQ, bool shortestPath = false); + + // cutoff for sine near zero + static const Real ms_fEpsilon; + + // special values + static const Quaternion ZERO; + static const Quaternion IDENTITY; + + Real w, x, y, z; + + /** Function for writing to a stream. Outputs "Quaternion(w, x, y, z)" with w,x,y,z + being the member values of the quaternion. + */ + inline _OgreExport friend std::ostream& operator << + ( std::ostream& o, const Quaternion& q ) + { + o << "Quaternion(" << q.w << ", " << q.x << ", " << q.y << ", " << q.z << ")"; + return o; + } + + }; + +} + + + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreRadixSort.h b/school/informatik/verkerhssimulation/src/ogre/OgreRadixSort.h new file mode 100644 index 00000000..f9da2dff --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreRadixSort.h @@ -0,0 +1,322 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __RadixSort_H__ +#define __RadixSort_H__ + +#include "OgrePrerequisites.h" + +namespace Ogre { + + /** Class for performing a radix sort (fast comparison-less sort based on + byte value) on various standard STL containers. + @remarks + A radix sort is a very fast sort algorithm. It doesn't use comparisons + and thus is able to break the theoretical minimum O(N*logN) complexity. + Radix sort is complexity O(k*N), where k is a constant. Note that radix + sorting is not in-place, it requires additional storage, so it trades + memory for speed. The overhead of copying means that it is only faster + for fairly large datasets, so you are advised to only use it for collections + of at least a few hundred items. + @par + This is a template class to allow it to deal with a variety of containers, + and a variety of value types to sort on. In addition to providing the + container and value type on construction, you also need to supply a + functor object which will retrieve the value to compare on for each item + in the list. For example, if you had an std::vector of by-value instances + of an object of class 'Bibble', and you wanted to sort on + Bibble::getDoobrie(), you'd have to firstly create a functor + like this: + @code + struct BibbleSortFunctor + { + float operator()(const Bibble& val) const + { + return val.getDoobrie(); + } + } + @endcode + Then, you need to declare a RadixSort class which names the container type, + the value type in the container, and the type of the value you want to + sort by. You can then call the sort function. E.g. + @code + RadixSort radixSorter; + BibbleSortFunctor functor; + + radixSorter.sort(myBibbleList, functor); + @endcode + You should try to reuse RadixSort instances, since repeated allocation of the + internal storage is then avoided. + @note + Radix sorting is often associated with just unsigned integer values. Our + implementation can handle both unsigned and signed integers, as well as + floats (which are often not supported by other radix sorters). doubles + are not supported; you will need to implement your functor object to convert + to float if you wish to use this sort routine. + */ + template + class RadixSort + { + public: + typedef typename TContainer::iterator ContainerIter; + protected: + /// Alpha-pass counters of values (histogram) + /// 4 of them so we can radix sort a maximum of a 32bit value + int mCounters[4][256]; + /// Beta-pass offsets + int mOffsets[256]; + /// Sort area size + int mSortSize; + /// Number of passes for this type + int mNumPasses; + + struct SortEntry + { + TCompValueType key; + ContainerIter iter; + SortEntry() {} + SortEntry(TCompValueType k, ContainerIter it) + : key(k), iter(it) {} + + }; + /// Temp sort storage + std::vector mSortArea1; + std::vector mSortArea2; + std::vector* mSrc; + std::vector* mDest; + TContainer mTmpContainer; // initial copy + + + void sortPass(int byteIndex) + { + // Calculate offsets + // Basically this just leaves gaps for duplicate entries to fill + mOffsets[0] = 0; + for (int i = 1; i < 256; ++i) + { + mOffsets[i] = mOffsets[i-1] + mCounters[byteIndex][i-1]; + } + + // Sort pass + for (int i = 0; i < mSortSize; ++i) + { + unsigned char byteVal = getByte(byteIndex, (*mSrc)[i].key); + (*mDest)[mOffsets[byteVal]++] = (*mSrc)[i]; + } + + } + template + void finalPass(int byteIndex, T val) + { + // default is to do normal pass + sortPass(byteIndex); + } + + // special case signed int + void finalPass(int byteIndex, int val) + { + int numNeg = 0; + // all negative values are in entries 128+ in most significant byte + for (int i = 128; i < 256; ++i) + { + numNeg += mCounters[byteIndex][i]; + } + // Calculate offsets - positive ones start at the number of negatives + // do positive numbers + mOffsets[0] = numNeg; + for (int i = 1; i < 128; ++i) + { + mOffsets[i] = mOffsets[i-1] + mCounters[byteIndex][i-1]; + } + // Do negative numbers (must start at zero) + // No need to invert ordering, already correct (-1 is highest number) + mOffsets[128] = 0; + for (int i = 129; i < 256; ++i) + { + mOffsets[i] = mOffsets[i-1] + mCounters[byteIndex][i-1]; + } + + // Sort pass + for (int i = 0; i < mSortSize; ++i) + { + unsigned char byteVal = getByte(byteIndex, (*mSrc)[i].key); + (*mDest)[mOffsets[byteVal]++] = (*mSrc)[i]; + } + } + + + // special case float + void finalPass(int byteIndex, float val) + { + // floats need to be special cased since negative numbers will come + // after positives (high bit = sign) and will be in reverse order + // (no ones-complement of the +ve value) + int numNeg = 0; + // all negative values are in entries 128+ in most significant byte + for (int i = 128; i < 256; ++i) + { + numNeg += mCounters[byteIndex][i]; + } + // Calculate offsets - positive ones start at the number of negatives + // do positive numbers normally + mOffsets[0] = numNeg; + for (int i = 1; i < 128; ++i) + { + mOffsets[i] = mOffsets[i-1] + mCounters[byteIndex][i-1]; + } + // Do negative numbers (must start at zero) + // Also need to invert ordering + // In order to preserve the stability of the sort (essential since + // we rely on previous bytes already being sorted) we have to count + // backwards in our offsets from + mOffsets[255] = mCounters[byteIndex][255]; + for (int i = 254; i > 127; --i) + { + mOffsets[i] = mOffsets[i+1] + mCounters[byteIndex][i]; + } + + // Sort pass + for (int i = 0; i < mSortSize; ++i) + { + unsigned char byteVal = getByte(byteIndex, (*mSrc)[i].key); + if (byteVal > 127) + { + // -ve; pre-decrement since offsets set to count + (*mDest)[--mOffsets[byteVal]] = (*mSrc)[i]; + } + else + { + // +ve + (*mDest)[mOffsets[byteVal]++] = (*mSrc)[i]; + } + } + } + + inline unsigned char getByte(int byteIndex, TCompValueType val) + { +#if OGRE_ENDIAN == OGRE_ENDIAN_LITTLE + return ((unsigned char*)(&val))[byteIndex]; +#else + return ((unsigned char*)(&val))[mNumPasses - byteIndex - 1]; +#endif + } + + public: + + RadixSort() {} + ~RadixSort() {} + + /** Main sort function + @param container A container of the type you declared when declaring + @param func A functor which returns the value for comparison when given + a container value + */ + template + void sort(TContainer& container, TFunction func) + { + if (container.empty()) + return; + + // Set up the sort areas + mSortSize = static_cast(container.size()); + mSortArea1.resize(container.size()); + mSortArea2.resize(container.size()); + + // Copy data now (we need constant iterators for sorting) + mTmpContainer = container; + + mNumPasses = sizeof(TCompValueType); + + // Counter pass + // Initialise the counts + int p; + for (p = 0; p < mNumPasses; ++p) + memset(mCounters[p], 0, sizeof(int) * 256); + + // Perform alpha pass to count + ContainerIter i = mTmpContainer.begin(); + TCompValueType prevValue = func.operator()(*i); + bool needsSorting = false; + for (int u = 0; i != mTmpContainer.end(); ++i, ++u) + { + // get sort value + TCompValueType val = func.operator()(*i); + // cheap check to see if needs sorting (temporal coherence) + if (!needsSorting && val < prevValue) + needsSorting = true; + + // Create a sort entry + mSortArea1[u].key = val; + mSortArea1[u].iter = i; + + // increase counters + for (p = 0; p < mNumPasses; ++p) + { + unsigned char byteVal = getByte(p, val); + mCounters[p][byteVal]++; + } + + prevValue = val; + + } + + // early exit if already sorted + if (!needsSorting) + return; + + + // Sort passes + mSrc = &mSortArea1; + mDest = &mSortArea2; + + for (p = 0; p < mNumPasses - 1; ++p) + { + sortPass(p); + // flip src/dst + std::vector* tmp = mSrc; + mSrc = mDest; + mDest = tmp; + } + // Final pass may differ, make polymorphic + finalPass(p, prevValue); + + // Copy everything back + int c = 0; + for (i = container.begin(); + i != container.end(); ++i, ++c) + { + *i = *((*mDest)[c].iter); + } + } + + }; + + +} +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreRay.h b/school/informatik/verkerhssimulation/src/ogre/OgreRay.h new file mode 100644 index 00000000..2dcc7f77 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreRay.h @@ -0,0 +1,115 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Ray_H_ +#define __Ray_H_ + +// Precompiler options +#include "OgrePrerequisites.h" + +#include "OgreVector3.h" +#include "OgrePlaneBoundedVolume.h" + +namespace Ogre { + + /** Representation of a ray in space, ie a line with an origin and direction. */ + class _OgreExport Ray + { + protected: + Vector3 mOrigin; + Vector3 mDirection; + public: + Ray():mOrigin(Vector3::ZERO), mDirection(Vector3::UNIT_Z) {} + Ray(const Vector3& origin, const Vector3& direction) + :mOrigin(origin), mDirection(direction) {} + + /** Sets the origin of the ray. */ + void setOrigin(const Vector3& origin) {mOrigin = origin;} + /** Gets the origin of the ray. */ + const Vector3& getOrigin(void) const {return mOrigin;} + + /** Sets the direction of the ray. */ + void setDirection(const Vector3& dir) {mDirection = dir;} + /** Gets the direction of the ray. */ + const Vector3& getDirection(void) const {return mDirection;} + + /** Gets the position of a point t units along the ray. */ + Vector3 getPoint(Real t) const { + return Vector3(mOrigin + (mDirection * t)); + } + + /** Gets the position of a point t units along the ray. */ + Vector3 operator*(Real t) const { + return getPoint(t); + }; + + /** Tests whether this ray intersects the given plane. + @returns A pair structure where the first element indicates whether + an intersection occurs, and if true, the second element will + indicate the distance along the ray at which it intersects. + This can be converted to a point in space by calling getPoint(). + */ + std::pair intersects(const Plane& p) const + { + return Math::intersects(*this, p); + } + /** Tests whether this ray intersects the given plane bounded volume. + @returns A pair structure where the first element indicates whether + an intersection occurs, and if true, the second element will + indicate the distance along the ray at which it intersects. + This can be converted to a point in space by calling getPoint(). + */ + std::pair intersects(const PlaneBoundedVolume& p) const + { + return Math::intersects(*this, p.planes, p.outside == Plane::POSITIVE_SIDE); + } + /** Tests whether this ray intersects the given sphere. + @returns A pair structure where the first element indicates whether + an intersection occurs, and if true, the second element will + indicate the distance along the ray at which it intersects. + This can be converted to a point in space by calling getPoint(). + */ + std::pair intersects(const Sphere& s) const + { + return Math::intersects(*this, s); + } + /** Tests whether this ray intersects the given box. + @returns A pair structure where the first element indicates whether + an intersection occurs, and if true, the second element will + indicate the distance along the ray at which it intersects. + This can be converted to a point in space by calling getPoint(). + */ + std::pair intersects(const AxisAlignedBox& box) const + { + return Math::intersects(*this, box); + } + + }; + +} +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreRectangle.h b/school/informatik/verkerhssimulation/src/ogre/OgreRectangle.h new file mode 100644 index 00000000..25907948 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreRectangle.h @@ -0,0 +1,69 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _Rectangle_H__ +#define _Rectangle_H__ + +#include "OgrePrerequisites.h" + +namespace Ogre { + + struct _OgreExport Rectangle + { + Real left; + Real top; + Real right; + Real bottom; + + inline bool inside(Real x, Real y) const { return x >= left && x <= right && y >= top && y <= bottom; } + }; + + /** Geometric intersection of two rectanglar regions. + * + * @remarks Calculates the geometric intersection of two rectangular + * regions. Rectangle coordinates must be ([0-N], [0-N]), such that + * (0,0) is in the upper left hand corner. + * + * If the two input rectangles do not intersect, then the result will be + * a degenerate rectangle, i.e. left >= right or top >= bottom, or both. + */ + inline Rectangle intersect(const Rectangle& lhs, const Rectangle& rhs) + { + Rectangle r; + + r.left = lhs.left > rhs.left ? lhs.left : rhs.left; + r.top = lhs.top > rhs.top ? lhs.top : rhs.top; + r.right = lhs.right < rhs.right ? lhs.right : rhs.right; + r.bottom = lhs.bottom < rhs.bottom ? lhs.bottom : rhs.bottom; + + return r; + } + +} + +#endif // _Rectangle_H__ diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreRectangle2D.h b/school/informatik/verkerhssimulation/src/ogre/OgreRectangle2D.h new file mode 100644 index 00000000..f61021bf --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreRectangle2D.h @@ -0,0 +1,79 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _Rectangle2D_H__ +#define _Rectangle2D_H__ + +#include "OgrePrerequisites.h" + +#include "OgreSimpleRenderable.h" + +namespace Ogre { + + /** Allows the rendering of a simple 2D rectangle + This class renders a simple 2D rectangle; this rectangle has no depth and + therefore is best used with specific render queue and depth settings, + like RENDER_QUEUE_BACKGROUND and 'depth_write off' for backdrops, and + RENDER_QUEUE_OVERLAY and 'depth_check off' for fullscreen quads. + */ + class _OgreExport Rectangle2D : public SimpleRenderable + { + protected: + /** Override this method to prevent parent transforms (rotation,translation,scale) + */ + void getWorldTransforms( Matrix4* xform ) const; + /** @copydoc Renderable::getWorldOrientation */ + const Quaternion& getWorldOrientation(void) const; + /** @copydoc Renderable::getWorldPosition */ + const Vector3& getWorldPosition(void) const; + + public: + + Rectangle2D(bool includeTextureCoordinates = false); + ~Rectangle2D(); + + /** Sets the corners of the rectangle, in relative coordinates. + @param + left Left position in screen relative coordinates, -1 = left edge, 1.0 = right edge + top Top position in screen relative coordinates, 1 = top edge, -1 = bottom edge + right Right position in screen relative coordinates + bottom Bottom position in screen relative coordinates + */ + void setCorners(Real left, Real top, Real right, Real bottom); + + Real getSquaredViewDepth(const Camera* cam) const { return 0; } + + Real getBoundingRadius(void) const { return 0; } + + }; + +}// namespace + +#endif + + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreRenderOperation.h b/school/informatik/verkerhssimulation/src/ogre/OgreRenderOperation.h new file mode 100644 index 00000000..832ad7b1 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreRenderOperation.h @@ -0,0 +1,84 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _RenderOperation_H__ +#define _RenderOperation_H__ + +#include "OgrePrerequisites.h" +#include "OgreVertexIndexData.h" + +namespace Ogre { + + + /** 'New' rendering operation using vertex buffers. */ + class _OgrePrivate RenderOperation { + public: + /// The rendering operation type to perform + enum OperationType { + /// A list of points, 1 vertex per point + OT_POINT_LIST = 1, + /// A list of lines, 2 vertices per line + OT_LINE_LIST = 2, + /// A strip of connected lines, 1 vertex per line plus 1 start vertex + OT_LINE_STRIP = 3, + /// A list of triangles, 3 vertices per triangle + OT_TRIANGLE_LIST = 4, + /// A strip of triangles, 3 vertices for the first triangle, and 1 per triangle after that + OT_TRIANGLE_STRIP = 5, + /// A fan of triangles, 3 vertices for the first triangle, and 1 per triangle after that + OT_TRIANGLE_FAN = 6 + }; + + /// Vertex source data + VertexData *vertexData; + + /// The type of operation to perform + OperationType operationType; + + /** Specifies whether to use indexes to determine the vertices to use as input. If false, the vertices are + simply read in sequence to define the primitives. If true, indexes are used instead to identify vertices + anywhere in the buffer, and allowing vertices to be used more than once. + If true, then the indexBuffer, indexStart and numIndexes properties must be valid. */ + bool useIndexes; + + /// Index data - only valid if useIndexes is true + IndexData *indexData; + /// Debug pointer back to renderable which created this + const Renderable* srcRenderable; + + + RenderOperation() : + vertexData(0), operationType(OT_TRIANGLE_LIST), useIndexes(true), + indexData(0) {} + + }; +} + + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreRenderQueue.h b/school/informatik/verkerhssimulation/src/ogre/OgreRenderQueue.h new file mode 100644 index 00000000..8ee7c199 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreRenderQueue.h @@ -0,0 +1,258 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __RenderQueue_H__ +#define __RenderQueue_H__ + +#include "OgrePrerequisites.h" +#include "OgreIteratorWrappers.h" + +namespace Ogre { + + /** Enumeration of queue groups, by which the application may group queued renderables + so that they are rendered together with events in between + @remarks + When passed into methods these are actually passed as a uint8 to allow you + to use values in between if you want to. + */ + enum RenderQueueGroupID + { + /// Use this queue for objects which must be rendered first e.g. backgrounds + RENDER_QUEUE_BACKGROUND = 0, + /// First queue (after backgrounds), used for skyboxes if rendered first + RENDER_QUEUE_SKIES_EARLY = 5, + RENDER_QUEUE_1 = 10, + RENDER_QUEUE_2 = 20, + RENDER_QUEUE_WORLD_GEOMETRY_1 = 25, + RENDER_QUEUE_3 = 30, + RENDER_QUEUE_4 = 40, + /// The default render queue + RENDER_QUEUE_MAIN = 50, + RENDER_QUEUE_6 = 60, + RENDER_QUEUE_7 = 70, + RENDER_QUEUE_WORLD_GEOMETRY_2 = 75, + RENDER_QUEUE_8 = 80, + RENDER_QUEUE_9 = 90, + /// Penultimate queue(before overlays), used for skyboxes if rendered last + RENDER_QUEUE_SKIES_LATE = 95, + /// Use this queue for objects which must be rendered last e.g. overlays + RENDER_QUEUE_OVERLAY = 100, + /// Final possible render queue, don't exceed this + RENDER_QUEUE_MAX = 105 + }; + + #define OGRE_RENDERABLE_DEFAULT_PRIORITY 100 + + /** Class to manage the scene object rendering queue. + @remarks + Objects are grouped by material to minimise rendering state changes. The map from + material to renderable object is wrapped in a class for ease of use. + @par + This class now includes the concept of 'queue groups' which allows the application + adding the renderable to specifically schedule it so that it is included in + a discrete group. Good for separating renderables into the main scene, + backgrounds and overlays, and also could be used in the future for more + complex multipass routines like stenciling. + */ + class _OgreExport RenderQueue + { + public: + typedef std::map< uint8, RenderQueueGroup* > RenderQueueGroupMap; + /// Iterator over queue groups + typedef MapIterator QueueGroupIterator; + /** Class to listen in on items being added to the render queue. + @remarks + Use RenderQueue::setRenderableListener to get callbacks when an item + is added to the render queue. + */ + class _OgreExport RenderableListener + { + public: + RenderableListener() {} + virtual ~RenderableListener() {} + + /** Method called when a Renderable is added to the queue. + @remarks + You can use this event hook to alter the Technique used to + render a Renderable as the item is added to the queue. This is + a low-level way to override the material settings for a given + Renderable on the fly. + @param rend The Renderable being added to the queue + @param groupID The render queue group this Renderable is being added to + @param priority The priority the Renderable has been given + @param ppTech A pointer to the pointer to the Technique that is + intended to be used; you can alter this to an alternate Technique + if you so wish (the Technique doesn't have to be from the same + Material either). + @returns true to allow the Renderable to be added to the queue, + false if you want to prevent it being added + */ + virtual bool renderableQueued(Renderable* rend, uint8 groupID, + ushort priority, Technique** ppTech) = 0; + }; + protected: + RenderQueueGroupMap mGroups; + /// The current default queue group + uint8 mDefaultQueueGroup; + /// The default priority + ushort mDefaultRenderablePriority; + + bool mSplitPassesByLightingType; + bool mSplitNoShadowPasses; + bool mShadowCastersCannotBeReceivers; + + RenderableListener* mRenderableListener; + public: + RenderQueue(); + virtual ~RenderQueue(); + + /** Empty the queue - should only be called by SceneManagers. + @param destroyPassMaps Set to true to destroy all pass maps so that + the queue is completely clean (useful when switching scene managers) + */ + void clear(bool destroyPassMaps = false); + + /** Get a render queue group. + @remarks + OGRE registers new queue groups as they are requested, + therefore this method will always return a valid group. + */ + RenderQueueGroup* getQueueGroup(uint8 qid); + + /** Add a renderable object to the queue. + @remarks + This methods adds a Renderable to the queue, which will be rendered later by + the SceneManager. This is the advanced version of the call which allows the renderable + to be added to any queue. + @note + Called by implementation of MovableObject::_updateRenderQueue. + @param + pRend Pointer to the Renderable to be added to the queue + @param + groupID The group the renderable is to be added to. This + can be used to schedule renderable objects in separate groups such that the SceneManager + respects the divisions between the groupings and does not reorder them outside these + boundaries. This can be handy for overlays where no matter what you want the overlay to + be rendered last. + @param + priority Controls the priority of the renderable within the queue group. If this number + is raised, the renderable will be rendered later in the group compared to it's peers. + Don't use this unless you really need to, manually ordering renderables prevents OGRE + from sorting them for best efficiency. However this could be useful for ordering 2D + elements manually for example. + */ + void addRenderable(Renderable* pRend, uint8 groupID, ushort priority); + + /** Add a renderable object to the queue. + @remarks + This methods adds a Renderable to the queue, which will be rendered later by + the SceneManager. This is the simplified version of the call which does not + require a priority to be specified. The queue priority is take from the + current default (see setDefaultRenderablePriority). + @note + Called by implementation of MovableObject::_updateRenderQueue. + @param + pRend Pointer to the Renderable to be added to the queue + @param + groupID The group the renderable is to be added to. This + can be used to schedule renderable objects in separate groups such that the SceneManager + respects the divisions between the groupings and does not reorder them outside these + boundaries. This can be handy for overlays where no matter what you want the overlay to + be rendered last. + */ + void addRenderable(Renderable* pRend, uint8 groupId); + + /** Add a renderable object to the queue. + @remarks + This methods adds a Renderable to the queue, which will be rendered later by + the SceneManager. This is the simplified version of the call which does not + require a queue or priority to be specified. The queue group is taken from the + current default (see setDefaultQueueGroup). The queue priority is take from the + current default (see setDefaultRenderablePriority). + @note + Called by implementation of MovableObject::_updateRenderQueue. + @param + pRend Pointer to the Renderable to be added to the queue + */ + void addRenderable(Renderable* pRend); + + /** Gets the current default queue group, which will be used for all renderable which do not + specify which group they wish to be on. + */ + uint8 getDefaultQueueGroup(void) const; + + /** Sets the current default renderable priority, + which will be used for all renderables which do not + specify which priority they wish to use. + */ + void setDefaultRenderablePriority(ushort priority); + + /** Gets the current default renderable priority, which will be used for all renderables which do not + specify which priority they wish to use. + */ + ushort getDefaultRenderablePriority(void) const; + + /** Sets the current default queue group, which will be used for all renderable which do not + specify which group they wish to be on. + */ + void setDefaultQueueGroup(uint8 grp); + + /** Internal method, returns an iterator for the queue groups. */ + QueueGroupIterator _getQueueGroupIterator(void); + /** Sets whether or not the queue will split passes by their lighting type, + ie ambient, per-light and decal. + */ + void setSplitPassesByLightingType(bool split); + /** Sets whether or not the queue will split passes which have shadow receive + turned off (in their parent material), which is needed when certain shadow + techniques are used. + */ + void setSplitNoShadowPasses(bool split); + /** Sets whether or not objects which cast shadows should be treated as + never receiving shadows. + */ + void setShadowCastersCannotBeReceivers(bool ind); + + /** Set a renderable listener on the queue. + @remarks + There can only be a single renderable listener on the queue, since + that listener has complete control over the techniques in use. + */ + void setRenderableListener(RenderableListener* listener) + { mRenderableListener = listener; } + + RenderableListener* getRenderableListener(void) const + { return mRenderableListener; } + + }; + + +} + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreRenderQueueInvocation.h b/school/informatik/verkerhssimulation/src/ogre/OgreRenderQueueInvocation.h new file mode 100644 index 00000000..490b53ff --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreRenderQueueInvocation.h @@ -0,0 +1,218 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2005 The OGRE Team +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __RenderQueueInvocation_H__ +#define __RenderQueueInvocation_H__ + +#include "OgrePrerequisites.h" +#include "OgreRenderQueueSortingGrouping.h" +#include "OgreIteratorWrappers.h" + +namespace Ogre { + + /** Class representing the invocation of queue groups in a RenderQueue. + @remarks + The default behaviour for OGRE's render queue is to render each queue + group in turn, dealing with shadows automatically, and rendering solids + in grouped passes, followed by transparent objects in descending order. + This class, together with RenderQueueInvocationSequence and the ability + to associate one with a Viewport, allows you to change that behaviour + and render queue groups in arbitrary sequence, repeatedly, and to skip + shadows, change the ordering of solids, or even prevent OGRE controlling + the render state during a particular invocation for special effects. + @par + Note that whilst you can change the ordering of rendering solids, you + can't change the ordering on transparent objects, since to do this would + cause them to render incorrectly. + @par + As well as using this class directly and using the options it provides you + with, you can also provide subclasses of it to a + RenderQueueInvocationSequence instance if you want to gain ultimate control. + @note + Invocations will be skipped if there are scene-level options preventing + them being rendered - for example special-case render queues and + render queue listeners that dictate this. + */ + class _OgreExport RenderQueueInvocation + { + protected: + /// Target queue group + uint8 mRenderQueueGroupID; + /// Invocation identifier - used in listeners + String mInvocationName; + /// Solids ordering mode + QueuedRenderableCollection::OrganisationMode mSolidsOrganisation; + /// Suppress shadows processing in this invocation? + bool mSuppressShadows; + /// Suppress OGRE's render state management? + bool mSuppressRenderStateChanges; + public: + /** Constructor + @param renderQueueGroupID ID of the queue this will target + @param invocationName Optional name to uniquely identify this + invocation from others in a RenderQueueListener + */ + RenderQueueInvocation(uint8 renderQueueGroupID, + const String& invocationName = StringUtil::BLANK); + virtual ~RenderQueueInvocation(); + + /// Get the render queue group id + virtual uint8 getRenderQueueGroupID(void) const { return mRenderQueueGroupID; } + + /// Get the invocation name (may be blank if not set by creator) + virtual const String& getInvocationName(void) const { return mInvocationName; } + + /** Set the organisation mode being used for solids in this queue group + invocation. + */ + virtual void setSolidsOrganisation( + QueuedRenderableCollection::OrganisationMode org) + { mSolidsOrganisation = org; } + + /** Get the organisation mode being used for solids in this queue group + invocation. + */ + virtual QueuedRenderableCollection::OrganisationMode + getSolidsOrganisation(void) const { return mSolidsOrganisation; } + + /** Sets whether shadows are suppressed when invoking this queue. + @remarks + When doing effects you often will want to suppress shadow processing + if shadows will already have been done by a previous render. + */ + virtual void setSuppressShadows(bool suppress) + { mSuppressShadows = suppress; } + + /** Gets whether shadows are suppressed when invoking this queue. + */ + virtual bool getSuppressShadows(void) const { return mSuppressShadows; } + + /** Sets whether render state changes are suppressed when invoking this queue. + @remarks + When doing special effects you may want to set up render state yourself + and have it apply for the entire rendering of a queue. In that case, + you should call this method with a parameter of 'true', and use a + RenderQueueListener to set the render state directly on RenderSystem + yourself before the invocation. + @par + Suppressing render state changes is only intended for advanced use, + don't use it if you're unsure of the effect. The only RenderSystem + calls made are to set the world matrix for each object (note - + view an projection matrices are NOT SET - they are under your control) + and to render the object; it is up to the caller to do everything else, + including enabling any vertex / fragment programs and updating their + parameter state, and binding parameters to the RenderSystem. + We advise you use a RenderQueueListener in order to get a notification + when this invocation is going to happen (use an invocation name to + identify it if you like), at which point you can set the state you + need to apply before the objects are rendered. + */ + virtual void setSuppressRenderStateChanges(bool suppress) + { mSuppressRenderStateChanges = suppress; } + + /** Gets whether shadows are suppressed when invoking this queue. + */ + virtual bool getSuppressRenderStateChanges(void) const { return mSuppressRenderStateChanges; } + + /** Invoke this class on a concrete queue group. + @remarks + Implementation will send the queue group to the target scene manager + after doing what it needs to do. + */ + virtual void invoke(RenderQueueGroup* group, SceneManager* targetSceneManager); + + /// Invocation identifier for shadows + static String RENDER_QUEUE_INVOCATION_SHADOWS; + }; + + + /// List of RenderQueueInvocations + typedef std::vector RenderQueueInvocationList; + typedef VectorIterator RenderQueueInvocationIterator; + + /** Class to hold a linear sequence of RenderQueueInvocation objects. + @remarks + This is just a simple data holder class which contains a list of + RenderQueueInvocation objects representing the sequence of invocations + made for a viewport. It's only real purpose is to ensure that + RenderQueueInvocation instances are deleted on shudown, since you can + provide your own subclass instances on RenderQueueInvocation. Remember + that any invocation instances you give to this class will be deleted + by it when it is cleared / destroyed. + */ + class _OgreExport RenderQueueInvocationSequence + { + protected: + String mName; + RenderQueueInvocationList mInvocations; + public: + RenderQueueInvocationSequence(const String& name); + virtual ~RenderQueueInvocationSequence(); + + /** Get the name of this sequence. */ + const String& getName(void) const { return mName; } + + /** Add a standard invocation to the sequence. + @param renderQueueGroupID The ID of the render queue group + @param invocationName Optional name to identify the invocation, useful + for listeners if a single queue group is invoked more than once + @returns A new RenderQueueInvocatin instance which you may customise + */ + RenderQueueInvocation* add(uint8 renderQueueGroupID, + const String& invocationName); + + /** Add a custom invocation to the sequence. + @remarks + Use this to add your own custom subclasses of RenderQueueInvocation + to the sequence; just remember that this class takes ownership of + deleting this pointer when it is cleared / destroyed. + */ + void add(RenderQueueInvocation* i); + + /** Get the number of invocations in this sequence. */ + size_t size(void) const { return mInvocations.size(); } + + /** Clear and delete all invocations in this sequence. */ + void clear(void); + + /** Gets the details of an invocation at a given index. */ + RenderQueueInvocation* get(size_t index); + + /** Removes (and deletes) an invocation by index. */ + void remove(size_t index); + + /** Get an iterator over the invocations. */ + RenderQueueInvocationIterator iterator(void); + + + }; + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreRenderQueueListener.h b/school/informatik/verkerhssimulation/src/ogre/OgreRenderQueueListener.h new file mode 100644 index 00000000..972db082 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreRenderQueueListener.h @@ -0,0 +1,89 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __RenderQueueListener_H__ +#define __RenderQueueListener_H__ + +#include "OgrePrerequisites.h" +#include "OgreRenderQueue.h" + +namespace Ogre { + + /** Abstract interface which classes must implement if they wish to receive + events from the render queue. + @remarks + The OGRE render queue is divided into several queue groups, as defined by + uint8. A class may implement this interface, and register itself + as a listener by calling SceneManager::addRenderQueueListener. After doing so, + the class will receive an event before and after each queue group is sent to + the rendering system. + @par + The event listeners have an option to make a queue either be skipped, or to repeat. + Note that if multiple listeners are registered, the one registered last has the final + say, although options set by previous listeners will not be changed if the latest + does not express a preference. + */ + class _OgreExport RenderQueueListener + { + public: + virtual ~RenderQueueListener() {} + /** Event raised before a queue group is rendered. + @remarks + This method is called by the SceneManager before each queue group is + rendered. + @param queueGroupId The id of the queue group which is about to be rendered + @param invocation Name of the invocation which is causing this to be + called (@see RenderQueueInvocation) + @param skipThisInvocation A boolean passed by reference which is by default set to + false. If the event sets this to true, the queue will be skipped and not + rendered. Note that in this case the renderQueueEnded event will not be raised + for this queue group. + */ + virtual void renderQueueStarted(uint8 queueGroupId, const String& invocation, + bool& skipThisInvocation) = 0; + + /** Event raised after a queue group is rendered. + @remarks + This method is called by the SceneManager after each queue group is + rendered. + @param queueGroupId The id of the queue group which has just been rendered + @param invocation Name of the invocation which is causing this to be + called (@see RenderQueueInvocation) + @param repeatThisInvocation A boolean passed by reference which is by default set to + false. If the event sets this to true, the queue which has just been + rendered will be repeated, and the renderQueueStarted and renderQueueEnded + events will also be fired for it again. + */ + virtual void renderQueueEnded(uint8 queueGroupId, const String& invocation, + bool& repeatThisInvocation) = 0; + }; + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreRenderQueueSortingGrouping.h b/school/informatik/verkerhssimulation/src/ogre/OgreRenderQueueSortingGrouping.h new file mode 100644 index 00000000..68d67715 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreRenderQueueSortingGrouping.h @@ -0,0 +1,653 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __RenderQueueSortingGrouping_H__ +#define __RenderQueueSortingGrouping_H__ + +// Precompiler options +#include "OgrePrerequisites.h" +#include "OgreIteratorWrappers.h" +#include "OgreMaterial.h" +#include "OgreTechnique.h" +#include "OgrePass.h" +#include "OgreRadixSort.h" + +namespace Ogre { + + /** Struct associating a single Pass with a single Renderable. + This is used to for objects sorted by depth and thus not + grouped by pass. + */ + struct RenderablePass + { + /// Pointer to the Renderable details + Renderable* renderable; + /// Pointer to the Pass + Pass* pass; + + RenderablePass(Renderable* rend, Pass* p) :renderable(rend), pass(p) {} + }; + + + /** Visitor interface for items in a QueuedRenderableCollection. + @remarks + Those wishing to iterate over the items in a + QueuedRenderableCollection should implement this visitor pattern, + since internal organisation of the collection depends on the + sorting method in use. + */ + class _OgreExport QueuedRenderableVisitor + { + public: + QueuedRenderableVisitor() {} + virtual ~QueuedRenderableVisitor() {} + + /** Called when visiting a RenderablePass, ie items in a + sorted collection where items are not grouped by pass. + @remarks + If this is called, neither of the other 2 visit methods + will be called. + */ + virtual void visit(const RenderablePass* rp) = 0; + + /* When visiting a collection grouped by pass, this is + called when the grouping pass changes. + @remarks + If this method is called, the RenderablePass visit + method will not be called for this collection. The + Renderable visit method will be called for each item + underneath the pass grouping level. + @returns True to continue, false to skip the Renderables underneath + */ + virtual bool visit(const Pass* p) = 0; + /** Visit method called once per Renderable on a grouped + collection. + @remarks + If this method is called, the RenderablePass visit + method will not be called for this collection. + */ + virtual void visit(const Renderable* r) = 0; + + + }; + + /** Lowest level collection of renderables. + @remarks + To iterate over items in this collection, you must call + the accept method and supply a QueuedRenderableVisitor. + The order of the iteration, and whether that iteration is + over a RenderablePass list or a 2-level grouped list which + causes a visit call at the Pass level, and a call for each + Renderable underneath. + */ + class _OgreExport QueuedRenderableCollection + { + public: + /** Organisation modes required for this collection. + @remarks + This affects the internal placement of the items added to this collection; + if only one type of sorting / grouping is to be required, then renderables + can be stored only once, whilst if multiple types are going to be needed + then internally there will be multiple organisations. Changing the organisation + needs to be done when the collection is empty. + */ + enum OrganisationMode + { + /// Group by pass + OM_PASS_GROUP = 1, + /// Sort descending camera distance + OM_SORT_DESCENDING = 2, + /** Sort ascending camera distance + Note value overlaps with descending since both use same sort + */ + OM_SORT_ASCENDING = 6 + }; + + protected: + /// Comparator to order pass groups + struct PassGroupLess + { + bool _OgreExport operator()(const Pass* a, const Pass* b) const + { + // Sort by passHash, which is pass, then texture unit changes + uint32 hasha = a->getHash(); + uint32 hashb = b->getHash(); + if (hasha == hashb) + { + // Must differentTransparentQueueItemLessiate by pointer incase 2 passes end up with the same hash + return a < b; + } + else + { + return hasha < hashb; + } + } + }; + /// Comparator to order objects by descending camera distance + struct DepthSortDescendingLess + { + const Camera* camera; + + DepthSortDescendingLess(const Camera* cam) + : camera(cam) + { + } + + bool _OgreExport operator()(const RenderablePass& a, const RenderablePass& b) const + { + if (a.renderable == b.renderable) + { + // Same renderable, sort by pass hash + return a.pass->getHash() < b.pass->getHash(); + } + else + { + // Different renderables, sort by depth + Real adepth = a.renderable->getSquaredViewDepth(camera); + Real bdepth = b.renderable->getSquaredViewDepth(camera); + if (adepth == bdepth) + { + // Must return deterministic result, doesn't matter what + return a.pass < b.pass; + } + else + { + // Sort DESCENDING by depth (ie far objects first) + return (adepth > bdepth); + } + } + + } + }; + + /** Vector of RenderablePass objects, this is built on the assumption that + vectors only ever increase in size, so even if we do clear() the memory stays + allocated, ie fast */ + typedef std::vector RenderablePassList; + typedef std::vector RenderableList; + /** Map of pass to renderable lists, this is a grouping by pass. */ + typedef std::map PassGroupRenderableMap; + + /// Functor for accessing sort value 1 for radix sort (Pass) + struct RadixSortFunctorPass + { + uint32 operator()(const RenderablePass& p) const + { + return p.pass->getHash(); + } + }; + + /// Radix sorter for accessing sort value 1 (Pass) + static RadixSort msRadixSorter1; + + /// Functor for descending sort value 2 for radix sort (distance) + struct RadixSortFunctorDistance + { + const Camera* camera; + + RadixSortFunctorDistance(const Camera* cam) + : camera(cam) + { + } + + float operator()(const RenderablePass& p) const + { + // Sort DESCENDING by depth (ie far objects first), use negative distance + // here because radix sorter always dealing with accessing sort + return static_cast(- p.renderable->getSquaredViewDepth(camera)); + } + }; + + /// Radix sorter for sort value 2 (distance) + static RadixSort msRadixSorter2; + + /// Bitmask of the organisation modes requested + uint8 mOrganisationMode; + + /// Grouped + PassGroupRenderableMap mGrouped; + /// Sorted descending (can iterate backwards to get ascending) + RenderablePassList mSortedDescending; + + /// Internal visitor implementation + void acceptVisitorGrouped(QueuedRenderableVisitor* visitor) const; + /// Internal visitor implementation + void acceptVisitorDescending(QueuedRenderableVisitor* visitor) const; + /// Internal visitor implementation + void acceptVisitorAscending(QueuedRenderableVisitor* visitor) const; + + public: + QueuedRenderableCollection(); + ~QueuedRenderableCollection(); + + /// Empty the collection + void clear(void); + + /** Remove the group entry (if any) for a given Pass. + @remarks + To be used when a pass is destroyed, such that any + grouping level for it becomes useless. + */ + void removePassGroup(Pass* p); + + /** Reset the organisation modes required for this collection. + @remarks + You can only do this when the collection is empty. + @see OrganisationMode + */ + void resetOrganisationModes(void) + { + mOrganisationMode = 0; + } + + /** Add a required sorting / grouping mode to this collection when next used. + @remarks + You can only do this when the collection is empty. + @see OrganisationMode + */ + void addOrganisationMode(OrganisationMode om) + { + mOrganisationMode |= om; + } + + /// Add a renderable to the collection using a given pass + void addRenderable(Pass* pass, Renderable* rend); + + /** Perform any sorting that is required on this collection. + @param cam The camera + */ + void sort(const Camera* cam); + + /** Accept a visitor over the collection contents. + @param visitor Visitor class which should be called back + @param om The organisation mode which you want to iterate over. + Note that this must have been included in an addOrganisationMode + call before any renderables were added. + */ + void acceptVisitor(QueuedRenderableVisitor* visitor, OrganisationMode om) const; + + }; + + /** Collection of renderables by priority. + @remarks + This class simply groups renderables for rendering. All the + renderables contained in this class are destined for the same + RenderQueueGroup (coarse groupings like those between the main + scene and overlays) and have the same priority (fine groupings + for detailed overlap control). + @par + This class can order solid renderables by a number of criteria; + it can optimise them into groups based on pass to reduce render + state changes, or can sort them by ascending or descending view + depth. Transparent objects are always ordered by descending depth. + @par + To iterate over items in the collections held by this object + you should retrieve the collection in use (e.g. solids, solids with + no shadows, transparents) and use the accept() method, providing + a class implementing QueuedRenderableVisitor. + + */ + class _OgreExport RenderPriorityGroup + { + protected: + + /// Parent queue group + RenderQueueGroup* mParent; + bool mSplitPassesByLightingType; + bool mSplitNoShadowPasses; + bool mShadowCastersNotReceivers; + /// Solid pass list, used when no shadows, modulative shadows, or ambient passes for additive + QueuedRenderableCollection mSolidsBasic; + /// Solid per-light pass list, used with additive shadows + QueuedRenderableCollection mSolidsDiffuseSpecular; + /// Solid decal (texture) pass list, used with additive shadows + QueuedRenderableCollection mSolidsDecal; + /// Solid pass list, used when shadows are enabled but shadow receive is turned off for these passes + QueuedRenderableCollection mSolidsNoShadowReceive; + /// Transparent list + QueuedRenderableCollection mTransparents; + + /// remove a pass entry from all collections + void removePassEntry(Pass* p); + + /// Internal method for adding a solid renderable + void addSolidRenderable(Technique* pTech, Renderable* rend, bool toNoShadowMap); + /// Internal method for adding a solid renderable + void addSolidRenderableSplitByLightType(Technique* pTech, Renderable* rend); + /// Internal method for adding a transparent renderable + void addTransparentRenderable(Technique* pTech, Renderable* rend); + + public: + RenderPriorityGroup(RenderQueueGroup* parent, + bool splitPassesByLightingType, + bool splitNoShadowPasses, + bool shadowCastersNotReceivers); + + ~RenderPriorityGroup() { } + + /** Get the collection of basic solids currently queued, this includes + all solids when there are no shadows, or all solids which have shadow + receiving enabled when using modulative shadows, or all ambient passes + of solids which have shadow receive enabled for additive shadows. */ + const QueuedRenderableCollection& getSolidsBasic(void) const + { return mSolidsBasic; } + /** Get the collection of solids currently queued per light (only applicable in + additive shadow modes). */ + const QueuedRenderableCollection& getSolidsDiffuseSpecular(void) const + { return mSolidsDiffuseSpecular; } + /** Get the collection of solids currently queued for decal passes (only + applicable in additive shadow modes). */ + const QueuedRenderableCollection& getSolidsDecal(void) const + { return mSolidsDecal; } + /** Get the collection of solids for which shadow receipt is disabled (only + applicable when shadows are enabled). */ + const QueuedRenderableCollection& getSolidsNoShadowReceive(void) const + { return mSolidsNoShadowReceive; } + /** Get the collection of transparent objects currently queued */ + const QueuedRenderableCollection& getTransparents(void) const + { return mTransparents; } + + + /** Reset the organisation modes required for the solids in this group. + @remarks + You can only do this when the group is empty, ie after clearing the + queue. + @see QueuedRenderableCollection::OrganisationMode + */ + void resetOrganisationModes(void); + + /** Add a required sorting / grouping mode for the solids in this group. + @remarks + You can only do this when the group is empty, ie after clearing the + queue. + @see QueuedRenderableCollection::OrganisationMode + */ + void addOrganisationMode(QueuedRenderableCollection::OrganisationMode om); + + /** Set the sorting / grouping mode for the solids in this group to the default. + @remarks + You can only do this when the group is empty, ie after clearing the + queue. + @see QueuedRenderableCollection::OrganisationMode + */ + void defaultOrganisationMode(void); + + /** Add a renderable to this group. */ + void addRenderable(Renderable* pRend, Technique* pTech); + + /** Sorts the objects which have been added to the queue; transparent objects by their + depth in relation to the passed in Camera. */ + void sort(const Camera* cam); + + /** Clears this group of renderables. + */ + void clear(void); + + /** Sets whether or not the queue will split passes by their lighting type, + ie ambient, per-light and decal. + */ + void setSplitPassesByLightingType(bool split) + { + mSplitPassesByLightingType = split; + } + + /** Sets whether or not passes which have shadow receive disabled should + be separated. + */ + void setSplitNoShadowPasses(bool split) + { + mSplitNoShadowPasses = split; + } + + /** Sets whether or not objects which cast shadows should be treated as + never receiving shadows. + */ + void setShadowCastersCannotBeReceivers(bool ind) + { + mShadowCastersNotReceivers = ind; + } + + + + }; + + + /** A grouping level underneath RenderQueue which groups renderables + to be issued at coarsely the same time to the renderer. + @remarks + Each instance of this class itself hold RenderPriorityGroup instances, + which are the groupings of renderables by priority for fine control + of ordering (not required for most instances). + */ + class _OgreExport RenderQueueGroup + { + public: + typedef std::map > PriorityMap; + typedef MapIterator PriorityMapIterator; + protected: + RenderQueue* mParent; + bool mSplitPassesByLightingType; + bool mSplitNoShadowPasses; + bool mShadowCastersNotReceivers; + /// Map of RenderPriorityGroup objects + PriorityMap mPriorityGroups; + /// Whether shadows are enabled for this queue + bool mShadowsEnabled; + + + public: + RenderQueueGroup(RenderQueue* parent, + bool splitPassesByLightingType, + bool splitNoShadowPasses, + bool shadowCastersNotReceivers) + : mParent(parent) + , mSplitPassesByLightingType(splitPassesByLightingType) + , mSplitNoShadowPasses(splitNoShadowPasses) + , mShadowCastersNotReceivers(shadowCastersNotReceivers) + , mShadowsEnabled(true) + { + } + + ~RenderQueueGroup() { + // destroy contents now + PriorityMap::iterator i; + for (i = mPriorityGroups.begin(); i != mPriorityGroups.end(); ++i) + { + delete i->second; + } + } + + /** Get an iterator for browsing through child contents. */ + PriorityMapIterator getIterator(void) + { + return PriorityMapIterator(mPriorityGroups.begin(), mPriorityGroups.end()); + } + + /** Add a renderable to this group, with the given priority. */ + void addRenderable(Renderable* pRend, Technique* pTech, ushort priority) + { + // Check if priority group is there + PriorityMap::iterator i = mPriorityGroups.find(priority); + RenderPriorityGroup* pPriorityGrp; + if (i == mPriorityGroups.end()) + { + // Missing, create + pPriorityGrp = new RenderPriorityGroup(this, + mSplitPassesByLightingType, + mSplitNoShadowPasses, + mShadowCastersNotReceivers); + mPriorityGroups.insert(PriorityMap::value_type(priority, pPriorityGrp)); + } + else + { + pPriorityGrp = i->second; + } + + // Add + pPriorityGrp->addRenderable(pRend, pTech); + + } + + /** Clears this group of renderables. + @param destroy + If false, doesn't delete any priority groups, just empties them. Saves on + memory deallocations since the chances are rougly the same kinds of + renderables are going to be sent to the queue again next time. If + true, completely destroys. + */ + void clear(bool destroy = false) + { + PriorityMap::iterator i, iend; + iend = mPriorityGroups.end(); + for (i = mPriorityGroups.begin(); i != iend; ++i) + { + if (destroy) + delete i->second; + else + i->second->clear(); + } + + if (destroy) + mPriorityGroups.clear(); + + } + + /** Indicate whether a given queue group will be doing any + shadow setup. + @remarks + This method allows you to inform the queue about a queue group, and to + indicate whether this group will require shadow processing of any sort. + In order to preserve rendering order, OGRE has to treat queue groups + as very separate elements of the scene, and this can result in it + having to duplicate shadow setup for each group. Therefore, if you + know that a group which you are using will never need shadows, you + should preregister the group using this method in order to improve + the performance. + */ + void setShadowsEnabled(bool enabled) { mShadowsEnabled = enabled; } + + /** Are shadows enabled for this queue? */ + bool getShadowsEnabled(void) const { return mShadowsEnabled; } + + /** Sets whether or not the queue will split passes by their lighting type, + ie ambient, per-light and decal. + */ + void setSplitPassesByLightingType(bool split) + { + mSplitPassesByLightingType = split; + PriorityMap::iterator i, iend; + iend = mPriorityGroups.end(); + for (i = mPriorityGroups.begin(); i != iend; ++i) + { + i->second->setSplitPassesByLightingType(split); + } + } + /** Sets whether or not the queue will split passes which have shadow receive + turned off (in their parent material), which is needed when certain shadow + techniques are used. + */ + void setSplitNoShadowPasses(bool split) + { + mSplitNoShadowPasses = split; + PriorityMap::iterator i, iend; + iend = mPriorityGroups.end(); + for (i = mPriorityGroups.begin(); i != iend; ++i) + { + i->second->setSplitNoShadowPasses(split); + } + } + /** Sets whether or not objects which cast shadows should be treated as + never receiving shadows. + */ + void setShadowCastersCannotBeReceivers(bool ind) + { + mShadowCastersNotReceivers = ind; + PriorityMap::iterator i, iend; + iend = mPriorityGroups.end(); + for (i = mPriorityGroups.begin(); i != iend; ++i) + { + i->second->setShadowCastersCannotBeReceivers(ind); + } + } + /** Reset the organisation modes required for the solids in this group. + @remarks + You can only do this when the group is empty, ie after clearing the + queue. + @see QueuedRenderableCollection::OrganisationMode + */ + void resetOrganisationModes(void) + { + PriorityMap::iterator i, iend; + iend = mPriorityGroups.end(); + for (i = mPriorityGroups.begin(); i != iend; ++i) + { + i->second->resetOrganisationModes(); + } + } + + /** Add a required sorting / grouping mode for the solids in this group. + @remarks + You can only do this when the group is empty, ie after clearing the + queue. + @see QueuedRenderableCollection::OrganisationMode + */ + void addOrganisationMode(QueuedRenderableCollection::OrganisationMode om) + { + PriorityMap::iterator i, iend; + iend = mPriorityGroups.end(); + for (i = mPriorityGroups.begin(); i != iend; ++i) + { + i->second->addOrganisationMode(om); + } + } + + /** Setthe sorting / grouping mode for the solids in this group to the default. + @remarks + You can only do this when the group is empty, ie after clearing the + queue. + @see QueuedRenderableCollection::OrganisationMode + */ + void defaultOrganisationMode(void) + { + PriorityMap::iterator i, iend; + iend = mPriorityGroups.end(); + for (i = mPriorityGroups.begin(); i != iend; ++i) + { + i->second->defaultOrganisationMode(); + } + } + + }; + + + +} + +#endif + + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreRenderSystem.h b/school/informatik/verkerhssimulation/src/ogre/OgreRenderSystem.h new file mode 100644 index 00000000..3bce6931 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreRenderSystem.h @@ -0,0 +1,1231 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __RenderSystem_H_ +#define __RenderSystem_H_ + +// Precompiler options +#include "OgrePrerequisites.h" + +#include "OgreString.h" + +#include "OgreTextureUnitState.h" +#include "OgreCommon.h" + +#include "OgreRenderOperation.h" +#include "OgreRenderSystemCapabilities.h" +#include "OgreRenderTarget.h" +#include "OgreRenderTexture.h" +#include "OgreFrameListener.h" +#include "OgreConfigOptionMap.h" +#include "OgreGpuProgram.h" +#include "OgrePlane.h" +#include "OgreIteratorWrappers.h" + +namespace Ogre +{ + typedef std::map< String, RenderTarget * > RenderTargetMap; + typedef std::multimap RenderTargetPriorityMap; + + class TextureManager; + /// Enum describing the ways to generate texture coordinates + enum TexCoordCalcMethod + { + /// No calculated texture coordinates + TEXCALC_NONE, + /// Environment map based on vertex normals + TEXCALC_ENVIRONMENT_MAP, + /// Environment map based on vertex positions + TEXCALC_ENVIRONMENT_MAP_PLANAR, + TEXCALC_ENVIRONMENT_MAP_REFLECTION, + TEXCALC_ENVIRONMENT_MAP_NORMAL, + /// Projective texture + TEXCALC_PROJECTIVE_TEXTURE + }; + /// Enum describing the various actions which can be taken onthe stencil buffer + enum StencilOperation + { + /// Leave the stencil buffer unchanged + SOP_KEEP, + /// Set the stencil value to zero + SOP_ZERO, + /// Set the stencil value to the reference value + SOP_REPLACE, + /// Increase the stencil value by 1, clamping at the maximum value + SOP_INCREMENT, + /// Decrease the stencil value by 1, clamping at 0 + SOP_DECREMENT, + /// Increase the stencil value by 1, wrapping back to 0 when incrementing the maximum value + SOP_INCREMENT_WRAP, + /// Decrease the stencil value by 1, wrapping when decrementing 0 + SOP_DECREMENT_WRAP, + /// Invert the bits of the stencil buffer + SOP_INVERT + }; + + /** Defines the functionality of a 3D API + @remarks + The RenderSystem class provides a base interface + which abstracts the general functionality of the 3D API + e.g. Direct3D or OpenGL. Whilst a few of the general + methods have implementations, most of this class is + abstract, requiring a subclass based on a specific API + to be constructed to provide the full functionality. + Note there are 2 levels to the interface - one which + will be used often by the caller of the Ogre library, + and one which is at a lower level and will be used by the + other classes provided by Ogre. These lower level + methods are prefixed with '_' to differentiate them. + The advanced user of the library may use these lower + level methods to access the 3D API at a more fundamental + level (dealing direct with render states and rendering + primitives), but still benefitting from Ogre's abstraction + of exactly which 3D API is in use. + @author + Steven Streeting + @version + 1.0 + */ + class _OgreExport RenderSystem + { + public: + /** Default Constructor. + */ + RenderSystem(); + + /** Destructor. + */ + virtual ~RenderSystem(); + + /** Returns the name of the rendering system. + */ + virtual const String& getName(void) const = 0; + + /** Returns the details of this API's configuration options + @remarks + Each render system must be able to inform the world + of what options must/can be specified for it's + operation. + @par + These are passed as strings for portability, but + grouped into a structure (_ConfigOption) which includes + both options and current value. + @par + Note that the settings returned from this call are + affected by the options that have been set so far, + since some options are interdependent. + @par + This routine is called automatically by the default + configuration dialogue produced by Root::showConfigDialog + or may be used by the caller for custom settings dialogs + @returns + A 'map' of options, i.e. a list of options which is also + indexed by option name. + */ + virtual ConfigOptionMap& getConfigOptions(void) = 0; + + /** Sets an option for this API + @remarks + Used to confirm the settings (normally chosen by the user) in + order to make the renderer able to initialise with the settings as required. + This may be video mode, D3D driver, full screen / windowed etc. + Called automatically by the default configuration + dialog, and by the restoration of saved settings. + These settings are stored and only activated when + RenderSystem::initialise or RenderSystem::reinitialise + are called. + @par + If using a custom configuration dialog, it is advised that the + caller calls RenderSystem::getConfigOptions + again, since some options can alter resulting from a selection. + @param + name The name of the option to alter. + @param + value The value to set the option to. + */ + virtual void setConfigOption(const String &name, const String &value) = 0; + + /** Create an object for performing hardware occlusion queries. + */ + virtual HardwareOcclusionQuery* createHardwareOcclusionQuery(void) = 0; + + /** Destroy a hardware occlusion query object. + */ + virtual void destroyHardwareOcclusionQuery(HardwareOcclusionQuery *hq); + + /** Validates the options set for the rendering system, returning a message if there are problems. + @note + If the returned string is empty, there are no problems. + */ + virtual String validateConfigOptions(void) = 0; + + /** Start up the renderer using the settings selected (Or the defaults if none have been selected). + @remarks + Called by Root::setRenderSystem. Shouldn't really be called + directly, although this can be done if the app wants to. + @param + autoCreateWindow If true, creates a render window + automatically, based on settings chosen so far. This saves + an extra call to RenderSystem::createRenderWindow + for the main render window. + @par + If an application has more specific window requirements, + however (e.g. a level design app), it should specify false + for this parameter and do it manually. + @returns + A pointer to the automatically created window, if requested, otherwise null. + */ + virtual RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window"); + + /** Restart the renderer (normally following a change in settings). + */ + virtual void reinitialise(void) = 0; + + /** Shutdown the renderer and cleanup resources. + */ + virtual void shutdown(void); + + + /** Sets the colour & strength of the ambient (global directionless) light in the world. + */ + virtual void setAmbientLight(float r, float g, float b) = 0; + + /** Sets the type of light shading required (default = Gouraud). + */ + virtual void setShadingType(ShadeOptions so) = 0; + + /** Sets whether or not dynamic lighting is enabled. + @param + enabled If true, dynamic lighting is performed on geometry with normals supplied, geometry without + normals will not be displayed. If false, no lighting is applied and all geometry will be full brightness. + */ + virtual void setLightingEnabled(bool enabled) = 0; + + /** Sets whether or not W-buffers are enabled if they are avalible for this renderer. + @param + enabled If true and the renderer supports them W-buffers will be used. If false + W-buffers will not be used even if avalible. W-buffers are enabled by default + for 16bit depth buffers and disabled for all other depths. + */ + void setWBufferEnabled(bool enabled); + + /** Returns true if the renderer will try to use W-buffers when avalible. + */ + bool getWBufferEnabled(void) const; + + /** Creates a new rendering window. + @remarks + This method creates a new rendering window as specified + by the paramteters. The rendering system could be + responible for only a single window (e.g. in the case + of a game), or could be in charge of multiple ones (in the + case of a level editor). The option to create the window + as a child of another is therefore given. + This method will create an appropriate subclass of + RenderWindow depending on the API and platform implementation. + @par + After creation, this window can be retrieved using getRenderTarget(). + @param + name The name of the window. Used in other methods + later like setRenderTarget and getRenderWindow. + @param + width The width of the new window. + @param + height The height of the new window. + @param + fullScreen Specify true to make the window full screen + without borders, title bar or menu bar. + @param + miscParams A NameValuePairList describing the other parameters for the new rendering window. + Options are case sensitive. Unrecognised parameters will be ignored silently. + These values might be platform dependent, but these are present for all platorms unless + indicated otherwise: + ** + Key: "title" + Description: The title of the window that will appear in the title bar + Values: string + Default: RenderTarget name + ** + Key: "colourDepth" + Description: Colour depth of the resulting rendering window; only applies if fullScreen + is set. + Values: 16 or 32 + Default: desktop depth + Notes: [W32 specific] + ** + Key: "left" + Description: screen x coordinate from left + Values: positive integers + Default: 'center window on screen' + Notes: Ignored in case of full screen + ** + Key: "top" + Description: screen y coordinate from top + Values: positive integers + Default: 'center window on screen' + Notes: Ignored in case of full screen + ** + Key: "depthBuffer" [DX9 specific] + Description: Use depth buffer + Values: false or true + Default: true + ** + Key: "externalWindowHandle" [API specific] + Description: External window handle, for embedding the OGRE context + Values: positive integer for W32 (HWND handle) + poslong:posint:poslong (display*:screen:windowHandle) or + poslong:posint:poslong:poslong (display*:screen:windowHandle:XVisualInfo*) for GLX + Default: 0 (None) + ** + Key: "externalGLControl" [Win32 OpenGL specific] + Description: Let the external window control OpenGL i.e. don't select a pixel format for the window, + do not change v-sync and do not swap buffer. When set to true, the calling application + is responsible of OpenGL initialization and buffer swapping. It should also create an + OpenGL context for its own rendering, Ogre will create one for its use. Then the calling + application must also enable Ogre OpenGL context before calling any Ogre function and + restore its OpenGL context after these calls. The Ogre OpenGL context can be retrieved + after Ogre initialisation by calling wglGetCurrentDC() and wglGetCurrentContext(). + It is only used when the externalWindowHandle parameter is used. + Values: true, false + Default: false + ** + Key: "externalGLContext" [Win32 OpenGL specific] + Description: Use an externally created GL context + Values: + Default: 0 (create own context) + ** + Key: "parentWindowHandle" [API specific] + Description: Parent window handle, for embedding the OGRE context + Values: positive integer for W32 (HWND handle) + poslong:posint:poslong for GLX (display*:screen:windowHandle) + Default: 0 (None) + ** + Key: "FSAA" + Description: Full screen antialiasing factor + Values: 0,2,4,6,... + Default: 0 + ** + Key: "displayFrequency" + Description: Display frequency rate, for fullscreen mode + Values: 60...? + Default: Desktop vsync rate + ** + Key: "vsync" + Description: Synchronize buffer swaps to vsync + Values: true, false + Default: 0 + ** + Key: "border" + Description: The type of window border (in windowed mode) + Values: none, fixed, resize + Default: resize + ** + Key: "outerDimensions" + Description: Whether the width/height is expressed as the size of the + outer window, rather than the content area + Values: true, false + Default: false + ** + Key: "useNVPerfHUD" [DX9 specific] + Description: Enable the use of nVidia NVPerfHUD + Values: true, false + Default: false + */ + virtual RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height, + bool fullScreen, const NameValuePairList *miscParams = 0) = 0; + + /** Creates and registers a render texture object. + @param name + The name for the new render texture. Note that names must be unique. + @param width + The requested width for the render texture. See Remarks for more info. + @param height + The requested width for the render texture. See Remarks for more info. + @param texType + The type of texture; defaults to TEX_TYPE_2D + @param internalFormat + The internal format of the texture; defaults to PF_X8R8G8B8 + @param miscParams This parameter is ignored. + @returns + On succes, a pointer to a new platform-dependernt, RenderTexture-derived + class is returned. On failiure, NULL is returned. + @remarks + Because a render texture is basically a wrapper around a texture object, + the width and height parameters of this method just hint the preferred + size for the texture. Depending on the hardware driver or the underlying + API, these values might change when the texture is created. The same applies + to the internalFormat parameter. + @deprecated + This method is deprecated, and exists only for backward compatibility. You can create + arbitrary rendertextures with the TextureManager::createManual call with usage + TU_RENDERTARGET. + */ + RenderTexture * createRenderTexture( const String & name, unsigned int width, unsigned int height, + TextureType texType = TEX_TYPE_2D, PixelFormat internalFormat = PF_X8R8G8B8, + const NameValuePairList *miscParams = 0 ); + + /** Create a MultiRenderTarget, which is a render target that renders to multiple RenderTextures + at once. Surfaces can be bound and unbound at will. + This fails if mCapabilities->numMultiRenderTargets() is smaller than 2. + */ + virtual MultiRenderTarget * createMultiRenderTarget(const String & name) = 0; + + /** Destroys a render window */ + virtual void destroyRenderWindow(const String& name); + /** Destroys a render texture */ + virtual void destroyRenderTexture(const String& name); + /** Destroys a render target of any sort */ + virtual void destroyRenderTarget(const String& name); + + /** Attaches the passed render target to the render system. + */ + virtual void attachRenderTarget( RenderTarget &target ); + /** Returns a pointer to the render target with the passed name, or NULL if that + render target cannot be found. + */ + virtual RenderTarget * getRenderTarget( const String &name ); + /** Detaches the render target with the passed name from the render system and + returns a pointer to it. + @note + If the render target cannot be found, NULL is returned. + */ + virtual RenderTarget * detachRenderTarget( const String &name ); + + /// Iterator over RenderTargets + typedef MapIterator RenderTargetIterator; + + /** Returns a specialised MapIterator over all render targets attached to the RenderSystem. */ + virtual RenderTargetIterator getRenderTargetIterator(void) { + return RenderTargetIterator( mRenderTargets.begin(), mRenderTargets.end() ); + } + /** Returns a description of an error code. + */ + virtual String getErrorDescription(long errorNumber) const = 0; + + /** Defines whether or now fullscreen render windows wait for the vertical blank before flipping buffers. + @remarks + By default, all rendering windows wait for a vertical blank (when the CRT beam turns off briefly to move + from the bottom right of the screen back to the top left) before flipping the screen buffers. This ensures + that the image you see on the screen is steady. However it restricts the frame rate to the refresh rate of + the monitor, and can slow the frame rate down. You can speed this up by not waiting for the blank, but + this has the downside of introducing 'tearing' artefacts where part of the previous frame is still displayed + as the buffers are switched. Speed vs quality, you choose. + @note + Has NO effect on windowed mode render targets. Only affects fullscreen mode. + @param + enabled If true, the system waits for vertical blanks - quality over speed. If false it doesn't - speed over quality. + */ + void setWaitForVerticalBlank(bool enabled); + + /** Returns true if the system is synchronising frames with the monitor vertical blank. + */ + bool getWaitForVerticalBlank(void) const; + + // ------------------------------------------------------------------------ + // Internal Rendering Access + // All methods below here are normally only called by other OGRE classes + // They can be called by library user if required + // ------------------------------------------------------------------------ + + + /** Tells the rendersystem to use the attached set of lights (and no others) + up to the number specified (this allows the same list to be used with different + count limits) */ + virtual void _useLights(const LightList& lights, unsigned short limit) = 0; + /** Sets the world transform matrix. */ + virtual void _setWorldMatrix(const Matrix4 &m) = 0; + /** Sets multiple world matrices (vertex blending). */ + virtual void _setWorldMatrices(const Matrix4* m, unsigned short count); + /** Sets the view transform matrix */ + virtual void _setViewMatrix(const Matrix4 &m) = 0; + /** Sets the projection transform matrix */ + virtual void _setProjectionMatrix(const Matrix4 &m) = 0; + /** Utility function for setting all the properties of a texture unit at once. + This method is also worth using over the individual texture unit settings because it + only sets those settings which are different from the current settings for this + unit, thus minimising render state changes. + */ + virtual void _setTextureUnitSettings(size_t texUnit, TextureUnitState& tl); + /** Turns off a texture unit. */ + virtual void _disableTextureUnit(size_t texUnit); + /** Disables all texture units from the given unit upwards */ + virtual void _disableTextureUnitsFrom(size_t texUnit); + /** Sets the surface properties to be used for future rendering. + + This method sets the the properties of the surfaces of objects + to be rendered after it. In this context these surface properties + are the amount of each type of light the object reflects (determining + it's colour under different types of light), whether it emits light + itself, and how shiny it is. Textures are not dealt with here, + see the _setTetxure method for details. + This method is used by _setMaterial so does not need to be called + direct if that method is being used. + + @param ambient The amount of ambient (sourceless and directionless) + light an object reflects. Affected by the colour/amount of ambient light in the scene. + @param diffuse The amount of light from directed sources that is + reflected (affected by colour/amount of point, directed and spot light sources) + @param specular The amount of specular light reflected. This is also + affected by directed light sources but represents the colour at the + highlights of the object. + @param emissive The colour of light emitted from the object. Note that + this will make an object seem brighter and not dependent on lights in + the scene, but it will not act as a light, so will not illuminate other + objects. Use a light attached to the same SceneNode as the object for this purpose. + @param shininess A value which only has an effect on specular highlights (so + specular must be non-black). The higher this value, the smaller and crisper the + specular highlights will be, imitating a more highly polished surface. + This value is not constrained to 0.0-1.0, in fact it is likely to + be more (10.0 gives a modest sheen to an object). + @param tracking A bit field that describes which of the ambient, diffuse, specular + and emissive colours follow the vertex colour of the primitive. When a bit in this field is set + its ColourValue is ignored. This is a combination of TVC_AMBIENT, TVC_DIFFUSE, TVC_SPECULAR(note that the shininess value is still + taken from shininess) and TVC_EMISSIVE. TVC_NONE means that there will be no material property + tracking the vertex colours. + */ + virtual void _setSurfaceParams(const ColourValue &ambient, + const ColourValue &diffuse, const ColourValue &specular, + const ColourValue &emissive, Real shininess, + TrackVertexColourType tracking = TVC_NONE) = 0; + + /** Sets whether or not rendering points using OT_POINT_LIST will + render point sprites (textured quads) or plain points. + @param enabled True enables point sprites, false returns to normal + point rendering. + */ + virtual void _setPointSpritesEnabled(bool enabled) = 0; + + /** Sets the size of points and how they are attenuated with distance. + @remarks + When performing point rendering or point sprite rendering, + point size can be attenuated with distance. The equation for + doing this is attenuation = 1 / (constant + linear * dist + quadratic * d^2) . + @par + For example, to disable distance attenuation (constant screensize) + you would set constant to 1, and linear and quadratic to 0. A + standard perspective attenuation would be 0, 1, 0 respectively. + */ + virtual void _setPointParameters(Real size, bool attenuationEnabled, + Real constant, Real linear, Real quadratic, Real minSize, Real maxSize) = 0; + + + /** + Sets the texture to bind to a given texture unit. + + User processes would not normally call this direct unless rendering + primitives themselves. + + @param unit The index of the texture unit to modify. Multitexturing + hardware can support multiple units (see + RenderSystemCapabilites::getNumTextureUnits) + @param enabled Boolean to turn the unit on/off + @param texPtr Pointer to the texture to use. + */ + virtual void _setTexture(size_t unit, bool enabled, + const TexturePtr &texPtr) = 0; + /** + Sets the texture to bind to a given texture unit. + + User processes would not normally call this direct unless rendering + primitives themselves. + + @param unit The index of the texture unit to modify. Multitexturing + hardware can support multiple units (see + RenderSystemCapabilites::getNumTextureUnits) + @param enabled Boolean to turn the unit on/off + @param texname The name of the texture to use - this should have + already been loaded with TextureManager::load. + */ + virtual void _setTexture(size_t unit, bool enabled, const String &texname); + + /** Binds a texture to a vertex sampler. + @remarks + Not all rendersystems support separate vertex samplers. For those that + do, you can set a texture for them, separate to the regular texture + samplers, using this method. For those that don't, you should use the + regular texture samplers which are shared between the vertex and + fragment units; calling this method will throw an exception. + @see RenderSystemCapabilites::getVertexTextureUnitsShared + */ + virtual void _setVertexTexture(size_t unit, const TexturePtr& tex); + + /** + Sets the texture coordinate set to use for a texture unit. + + Meant for use internally - not generally used directly by apps - the Material and TextureUnitState + classes let you manage textures far more easily. + + @param unit Texture unit as above + @param index The index of the texture coordinate set to use. + */ + virtual void _setTextureCoordSet(size_t unit, size_t index) = 0; + + /** + Sets a method for automatically calculating texture coordinates for a stage. + Should not be used by apps - for use by Ogre only. + @param unit Texture unit as above + @param m Calculation method to use + @param frustum Optional Frustum param, only used for projective effects + */ + virtual void _setTextureCoordCalculation(size_t unit, TexCoordCalcMethod m, + const Frustum* frustum = 0) = 0; + + /** Sets the texture blend modes from a TextureUnitState record. + Meant for use internally only - apps should use the Material + and TextureUnitState classes. + @param unit Texture unit as above + @param bm Details of the blending mode + */ + virtual void _setTextureBlendMode(size_t unit, const LayerBlendModeEx& bm) = 0; + + /** Sets the filtering options for a given texture unit. + @param unit The texture unit to set the filtering options for + @param minFilter The filter used when a texture is reduced in size + @param magFilter The filter used when a texture is magnified + @param mipFilter The filter used between mipmap levels, FO_NONE disables mipmapping + */ + virtual void _setTextureUnitFiltering(size_t unit, FilterOptions minFilter, + FilterOptions magFilter, FilterOptions mipFilter); + + /** Sets a single filter for a given texture unit. + @param unit The texture unit to set the filtering options for + @param ftype The filter type + @param filter The filter to be used + */ + virtual void _setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter) = 0; + + /** Sets the maximal anisotropy for the specified texture unit.*/ + virtual void _setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy) = 0; + + /** Sets the texture addressing mode for a texture unit.*/ + virtual void _setTextureAddressingMode(size_t unit, const TextureUnitState::UVWAddressingMode& uvw) = 0; + + /** Sets the texture border colour for a texture unit.*/ + virtual void _setTextureBorderColour(size_t unit, const ColourValue& colour) = 0; + + /** Sets the mipmap bias value for a given texture unit. + @remarks + This allows you to adjust the mipmap calculation up or down for a + given texture unit. Negative values force a larger mipmap to be used, + positive values force a smaller mipmap to be used. Units are in numbers + of levels, so +1 forces the mipmaps to one smaller level. + @note Only does something if render system has capability RSC_MIPMAP_LOD_BIAS. + */ + virtual void _setTextureMipmapBias(size_t unit, float bias) = 0; + + /** Sets the texture coordinate transformation matrix for a texture unit. + @param unit Texture unit to affect + @param xform The 4x4 matrix + */ + virtual void _setTextureMatrix(size_t unit, const Matrix4& xform) = 0; + + /** Sets the global blending factors for combining subsequent renders with the existing frame contents. + The result of the blending operation is:

+

final = (texture * sourceFactor) + (pixel * destFactor)

+ Each of the factors is specified as one of a number of options, as specified in the SceneBlendFactor + enumerated type. + @param sourceFactor The source factor in the above calculation, i.e. multiplied by the texture colour components. + @param destFactor The destination factor in the above calculation, i.e. multiplied by the pixel colour components. + */ + virtual void _setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor) = 0; + + /** Sets the global alpha rejection approach for future renders. + By default images are rendered regardless of texture alpha. This method lets you change that. + @param func The comparison function which must pass for a pixel to be written. + @param val The value to compare each pixels alpha value to (0-255) + */ + virtual void _setAlphaRejectSettings(CompareFunction func, unsigned char value) = 0; + /** + * Signifies the beginning of a frame, ie the start of rendering on a single viewport. Will occur + * several times per complete frame if multiple viewports exist. + */ + virtual void _beginFrame(void) = 0; + + + /** + * Ends rendering of a frame to the current viewport. + */ + virtual void _endFrame(void) = 0; + /** + Sets the provided viewport as the active one for future + rendering operations. This viewport is aware of it's own + camera and render target. Must be implemented by subclass. + + @param target Pointer to the appropriate viewport. + */ + virtual void _setViewport(Viewport *vp) = 0; + /** Get the current active viewport for rendering. */ + virtual Viewport* _getViewport(void); + + /** Sets the culling mode for the render system based on the 'vertex winding'. + A typical way for the rendering engine to cull triangles is based on the + 'vertex winding' of triangles. Vertex winding refers to the direction in + which the vertices are passed or indexed to in the rendering operation as viewed + from the camera, and will wither be clockwise or anticlockwise (that's 'counterclockwise' for + you Americans out there ;) The default is CULL_CLOCKWISE i.e. that only triangles whose vertices + are passed/indexed in anticlockwise order are rendered - this is a common approach and is used in 3D studio models + for example. You can alter this culling mode if you wish but it is not advised unless you know what you are doing. + You may wish to use the CULL_NONE option for mesh data that you cull yourself where the vertex + winding is uncertain. + */ + virtual void _setCullingMode(CullingMode mode) = 0; + + virtual CullingMode _getCullingMode(void) const; + + /** Sets the mode of operation for depth buffer tests from this point onwards. + Sometimes you may wish to alter the behaviour of the depth buffer to achieve + special effects. Because it's unlikely that you'll set these options for an entire frame, + but rather use them to tweak settings between rendering objects, this is an internal + method (indicated by the '_' prefix) which will be used by a SceneManager implementation + rather than directly from the client application. + If this method is never called the settings are automatically the same as the default parameters. + @param depthTest If true, the depth buffer is tested for each pixel and the frame buffer is only updated + if the depth function test succeeds. If false, no test is performed and pixels are always written. + @param depthWrite If true, the depth buffer is updated with the depth of the new pixel if the depth test succeeds. + If false, the depth buffer is left unchanged even if a new pixel is written. + @param depthFunction Sets the function required for the depth test. + */ + virtual void _setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL) = 0; + + /** Sets whether or not the depth buffer check is performed before a pixel write. + @param enabled If true, the depth buffer is tested for each pixel and the frame buffer is only updated + if the depth function test succeeds. If false, no test is performed and pixels are always written. + */ + virtual void _setDepthBufferCheckEnabled(bool enabled = true) = 0; + /** Sets whether or not the depth buffer is updated after a pixel write. + @param enabled If true, the depth buffer is updated with the depth of the new pixel if the depth test succeeds. + If false, the depth buffer is left unchanged even if a new pixel is written. + */ + virtual void _setDepthBufferWriteEnabled(bool enabled = true) = 0; + /** Sets the comparison function for the depth buffer check. + Advanced use only - allows you to choose the function applied to compare the depth values of + new and existing pixels in the depth buffer. Only an issue if the deoth buffer check is enabled + (see _setDepthBufferCheckEnabled) + @param func The comparison between the new depth and the existing depth which must return true + for the new pixel to be written. + */ + virtual void _setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL) = 0; + /** Sets whether or not colour buffer writing is enabled, and for which channels. + @remarks + For some advanced effects, you may wish to turn off the writing of certain colour + channels, or even all of the colour channels so that only the depth buffer is updated + in a rendering pass. However, the chances are that you really want to use this option + through the Material class. + @param red, green, blue, alpha Whether writing is enabled for each of the 4 colour channels. */ + virtual void _setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha) = 0; + /** Sets the depth bias, NB you should use the Material version of this. + @remarks + When polygons are coplanar, you can get problems with 'depth fighting' where + the pixels from the two polys compete for the same screen pixel. This is particularly + a problem for decals (polys attached to another surface to represent details such as + bulletholes etc.). + @par + A way to combat this problem is to use a depth bias to adjust the depth buffer value + used for the decal such that it is slightly higher than the true value, ensuring that + the decal appears on top. + @note + The final bias value is a combination of a constant bias and a bias proportional + to the maximum depth slope of the polygon being rendered. The final bias + is constantBias + slopeScaleBias * maxslope. Slope scale biasing is + generally preferable but is not available on older hardware. + @param constantBias The constant bias value, expressed as a value in + homogenous depth coordinates. + @param slopeScaleBias The bias value which is factored by the maximum slope + of the polygon, see the description above. This is not supported by all + cards. + + */ + virtual void _setDepthBias(float constantBias, float slopeScaleBias = 0.0f) = 0; + /** Sets the fogging mode for future geometry. + @param mode Set up the mode of fog as described in the FogMode enum, or set to FOG_NONE to turn off. + @param colour The colour of the fog. Either set this to the same as your viewport background colour, + or to blend in with a skydome or skybox. + @param expDensity The density of the fog in FOG_EXP or FOG_EXP2 mode, as a value between 0 and 1. The default is 1. i.e. completely opaque, lower values can mean + that fog never completely obscures the scene. + @param linearStart Distance at which linear fog starts to encroach. The distance must be passed + as a parametric value between 0 and 1, with 0 being the near clipping plane, and 1 being the far clipping plane. Only applicable if mode is FOG_LINEAR. + @param linearEnd Distance at which linear fog becomes completely opaque.The distance must be passed + as a parametric value between 0 and 1, with 0 being the near clipping plane, and 1 being the far clipping plane. Only applicable if mode is FOG_LINEAR. + */ + virtual void _setFog(FogMode mode = FOG_NONE, const ColourValue& colour = ColourValue::White, Real expDensity = 1.0, Real linearStart = 0.0, Real linearEnd = 1.0) = 0; + + + /** The RenderSystem will keep a count of tris rendered, this resets the count. */ + virtual void _beginGeometryCount(void); + /** Reports the number of tris rendered since the last _beginGeometryCount call. */ + virtual unsigned int _getFaceCount(void) const; + /** Reports the number of batches rendered since the last _beginGeometryCount call. */ + virtual unsigned int _getBatchCount(void) const; + /** Reports the number of vertices passed to the renderer since the last _beginGeometryCount call. */ + virtual unsigned int _getVertexCount(void) const; + + /** Generates a packed data version of the passed in ColourValue suitable for + use as with this RenderSystem. + @remarks + Since different render systems have different colour data formats (eg + RGBA for GL, ARGB for D3D) this method allows you to use 1 method for all. + @param colour The colour to convert + @param pDest Pointer to location to put the result. + */ + virtual void convertColourValue(const ColourValue& colour, uint32* pDest); + /** Get the native VertexElementType for a compact 32-bit colour value + for this rendersystem. + */ + virtual VertexElementType getColourVertexElementType(void) const = 0; + + /** Converts a uniform projection matrix to suitable for this render system. + @remarks + Because different APIs have different requirements (some incompatible) for the + projection matrix, this method allows each to implement their own correctly and pass + back a generic OGRE matrix for storage in the engine. + */ + virtual void _convertProjectionMatrix(const Matrix4& matrix, + Matrix4& dest, bool forGpuProgram = false) = 0; + + /** Builds a perspective projection matrix suitable for this render system. + @remarks + Because different APIs have different requirements (some incompatible) for the + projection matrix, this method allows each to implement their own correctly and pass + back a generic OGRE matrix for storage in the engine. + */ + virtual void _makeProjectionMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane, + Matrix4& dest, bool forGpuProgram = false) = 0; + + /** Builds a perspective projection matrix for the case when frustum is + not centered around camera. + @remarks + Viewport coordinates are in camera coordinate frame, i.e. camera is + at the origin. + */ + virtual void _makeProjectionMatrix(Real left, Real right, Real bottom, Real top, + Real nearPlane, Real farPlane, Matrix4& dest, bool forGpuProgram = false) = 0; + /** Builds an orthographic projection matrix suitable for this render system. + @remarks + Because different APIs have different requirements (some incompatible) for the + projection matrix, this method allows each to implement their own correctly and pass + back a generic OGRE matrix for storage in the engine. + */ + virtual void _makeOrthoMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane, + Matrix4& dest, bool forGpuProgram = false) = 0; + + /** Update a perspective projection matrix to use 'oblique depth projection'. + @remarks + This method can be used to change the nature of a perspective + transform in order to make the near plane not perpendicular to the + camera view direction, but to be at some different orientation. + This can be useful for performing arbitrary clipping (e.g. to a + reflection plane) which could otherwise only be done using user + clip planes, which are more expensive, and not necessarily supported + on all cards. + @param matrix The existing projection matrix. Note that this must be a + perspective transform (not orthographic), and must not have already + been altered by this method. The matrix will be altered in-place. + @param plane The plane which is to be used as the clipping plane. This + plane must be in CAMERA (view) space. + @param forGpuProgram Is this for use with a Gpu program or fixed-function + */ + virtual void _applyObliqueDepthProjection(Matrix4& matrix, const Plane& plane, + bool forGpuProgram) = 0; + + /** Sets how to rasterise triangles, as points, wireframe or solid polys. */ + virtual void _setPolygonMode(PolygonMode level) = 0; + + /** Turns stencil buffer checking on or off. + @remarks + Stencilling (masking off areas of the rendering target based on the stencil + buffer) canbe turned on or off using this method. By default, stencilling is + disabled. + */ + virtual void setStencilCheckEnabled(bool enabled) = 0; + /** Determines if this system supports hardware accelerated stencil buffer. + @remarks + Note that the lack of this function doesn't mean you can't do stencilling, but + the stencilling operations will be provided in software, which will NOT be + fast. + @par + Generally hardware stencils are only supported in 32-bit colour modes, because + the stencil buffer shares the memory of the z-buffer, and in most cards the + z-buffer has to be the same depth as the colour buffer. This means that in 32-bit + mode, 24 bits of the z-buffer are depth and 8 bits are stencil. In 16-bit mode there + is no room for a stencil (although some cards support a 15:1 depth:stencil option, + this isn't useful for very much) so 8 bits of stencil are provided in software. + This can mean that if you use stencilling, your applications may be faster in + 32-but colour than in 16-bit, which may seem odd to some people. + */ + /*virtual bool hasHardwareStencil(void) = 0;*/ + + /** This method allows you to set all the stencil buffer parameters in one call. + @remarks + The stencil buffer is used to mask out pixels in the render target, allowing + you to do effects like mirrors, cut-outs, stencil shadows and more. Each of + your batches of rendering is likely to ignore the stencil buffer, + update it with new values, or apply it to mask the output of the render. + The stencil test is:
+            (Reference Value & Mask) CompareFunction (Stencil Buffer Value & Mask)
+ The result of this will cause one of 3 actions depending on whether the test fails, + succeeds but with the depth buffer check still failing, or succeeds with the + depth buffer check passing too. + @par + Unlike other render states, stencilling is left for the application to turn + on and off when it requires. This is because you are likely to want to change + parameters between batches of arbitrary objects and control the ordering yourself. + In order to batch things this way, you'll want to use OGRE's separate render queue + groups (see RenderQueue) and register a RenderQueueListener to get notifications + between batches. + @par + There are individual state change methods for each of the parameters set using + this method. + Note that the default values in this method represent the defaults at system + start up too. + @param func The comparison function applied. + @param refValue The reference value used in the comparison + @param mask The bitmask applied to both the stencil value and the reference value + before comparison + @param stencilFailOp The action to perform when the stencil check fails + @param depthFailOp The action to perform when the stencil check passes, but the + depth buffer check still fails + @param passOp The action to take when both the stencil and depth check pass. + @param twoSidedOperation If set to true, then if you render both back and front faces + (you'll have to turn off culling) then these parameters will apply for front faces, + and the inverse of them will happen for back faces (keep remains the same). + */ + virtual void setStencilBufferParams(CompareFunction func = CMPF_ALWAYS_PASS, + uint32 refValue = 0, uint32 mask = 0xFFFFFFFF, + StencilOperation stencilFailOp = SOP_KEEP, + StencilOperation depthFailOp = SOP_KEEP, + StencilOperation passOp = SOP_KEEP, + bool twoSidedOperation = false) = 0; + + + + /** Sets the current vertex declaration, ie the source of vertex data. */ + virtual void setVertexDeclaration(VertexDeclaration* decl) = 0; + /** Sets the current vertex buffer binding state. */ + virtual void setVertexBufferBinding(VertexBufferBinding* binding) = 0; + + /** Sets whether or not normals are to be automatically normalised. + @remarks + This is useful when, for example, you are scaling SceneNodes such that + normals may not be unit-length anymore. Note though that this has an + overhead so should not be turn on unless you really need it. + @par + You should not normally call this direct unless you are rendering + world geometry; set it on the Renderable because otherwise it will be + overridden by material settings. + */ + virtual void setNormaliseNormals(bool normalise) = 0; + + /** + Render something to the active viewport. + + Low-level rendering interface to perform rendering + operations. Unlikely to be used directly by client + applications, since the SceneManager and various support + classes will be responsible for calling this method. + Can only be called between _beginScene and _endScene + + @param op A rendering operation instance, which contains + details of the operation to be performed. + */ + virtual void _render(const RenderOperation& op); + + /** Gets the capabilities of the render system. */ + const RenderSystemCapabilities* getCapabilities(void) const { return mCapabilities; } + + /** Binds a given GpuProgram (but not the parameters). + @remarks Only one GpuProgram of each type can be bound at once, binding another + one will simply replace the exsiting one. + */ + virtual void bindGpuProgram(GpuProgram* prg); + + /** Bind Gpu program parameters. + */ + virtual void bindGpuProgramParameters(GpuProgramType gptype, GpuProgramParametersSharedPtr params) = 0; + /** Only binds Gpu program parameters used for passes that have more than one iteration rendering + */ + virtual void bindGpuProgramPassIterationParameters(GpuProgramType gptype) = 0; + /** Unbinds GpuPrograms of a given GpuProgramType. + @remarks + This returns the pipeline to fixed-function processing for this type. + */ + virtual void unbindGpuProgram(GpuProgramType gptype); + + /** Returns whether or not a Gpu program of the given type is currently bound. */ + virtual bool isGpuProgramBound(GpuProgramType gptype); + + /** sets the clipping region. + */ + virtual void setClipPlanes(const PlaneList& clipPlanes) = 0; + + /** Utility method for initialising all render targets attached to this rendering system. */ + virtual void _initRenderTargets(void); + + /** Utility method to notify all render targets that a camera has been removed, + incase they were referring to it as their viewer. + */ + virtual void _notifyCameraRemoved(const Camera* cam); + + /** Internal method for updating all render targets attached to this rendering system. */ + virtual void _updateAllRenderTargets(void); + + /** Set a clipping plane. */ + virtual void setClipPlane (ushort index, const Plane &p); + /** Set a clipping plane. */ + virtual void setClipPlane (ushort index, Real A, Real B, Real C, Real D) = 0; + /** Enable the clipping plane. */ + virtual void enableClipPlane (ushort index, bool enable) = 0; + + /** Sets whether or not vertex windings set should be inverted; this can be important + for rendering reflections. */ + virtual void setInvertVertexWinding(bool invert); + /** Sets the 'scissor region' ie the region of the target in which rendering can take place. + @remarks + This method allows you to 'mask off' rendering in all but a given rectangular area + as identified by the parameters to this method. + @note + Not all systems support this method. Check the RenderSystemCapabilities for the + RSC_SCISSOR_TEST capability to see if it is supported. + @param enabled True to enable the scissor test, false to disable it. + @param left, top, right, bottom The location of the corners of the rectangle, expressed in + pixels. + */ + virtual void setScissorTest(bool enabled, size_t left = 0, size_t top = 0, + size_t right = 800, size_t bottom = 600) = 0; + + /** Clears one or more frame buffers on the active render target. + @param buffers Combination of one or more elements of FrameBufferType + denoting which buffers are to be cleared + @param colour The colour to clear the colour buffer with, if enabled + @param depth The value to initialise the depth buffer with, if enabled + @param stencil The value to initialise the stencil buffer with, if enabled. + */ + virtual void clearFrameBuffer(unsigned int buffers, + const ColourValue& colour = ColourValue::Black, + Real depth = 1.0f, unsigned short stencil = 0) = 0; + /** Returns the horizontal texel offset value required for mapping + texel origins to pixel origins in this rendersystem. + @remarks + Since rendersystems sometimes disagree on the origin of a texel, + mapping from texels to pixels can sometimes be problematic to + implement generically. This method allows you to retrieve the offset + required to map the origin of a texel to the origin of a pixel in + the horizontal direction. + */ + virtual Real getHorizontalTexelOffset(void) = 0; + /** Returns the vertical texel offset value required for mapping + texel origins to pixel origins in this rendersystem. + @remarks + Since rendersystems sometimes disagree on the origin of a texel, + mapping from texels to pixels can sometimes be problematic to + implement generically. This method allows you to retrieve the offset + required to map the origin of a texel to the origin of a pixel in + the vertical direction. + */ + virtual Real getVerticalTexelOffset(void) = 0; + + /** Gets the minimum (closest) depth value to be used when rendering + using identity transforms. + @remarks + When using identity transforms you can manually set the depth + of a vertex; however the input values required differ per + rendersystem. This method lets you retrieve the correct value. + @see Renderable::getUseIdentityView, Renderable::getUseIdentityProjection + */ + virtual Real getMinimumDepthInputValue(void) = 0; + /** Gets the maximum (farthest) depth value to be used when rendering + using identity transforms. + @remarks + When using identity transforms you can manually set the depth + of a vertex; however the input values required differ per + rendersystem. This method lets you retrieve the correct value. + @see Renderable::getUseIdentityView, Renderable::getUseIdentityProjection + */ + virtual Real getMaximumDepthInputValue(void) = 0; + /** set the current multi pass count value. This must be set prior to + calling _render() if multiple renderings of the same pass state are + required. + @param count Number of times to render the current state. + */ + void setCurrentPassIterationCount(const size_t count) { mCurrentPassIterationCount = count; } + + /** Defines a listener on the custom events that this render system + can raise. + @see RenderSystem::addListener + */ + class _OgreExport Listener + { + public: + Listener() {} + virtual ~Listener() {} + + /** A rendersystem-specific event occurred. + @param eventName The name of the event which has occurred + @param parameters A list of parameters that may belong to this event, + may be null if there are no parameters + */ + virtual void eventOccurred(const String& eventName, + const NameValuePairList* parameters = 0) = 0; + }; + /** Adds a listener to the custom events that this render system can raise. + @remarks + Some render systems have quite specific, internally generated events + that the application may wish to be notified of. Many applications + don't have to worry about these events, and can just trust OGRE to + handle them, but if you want to know, you can add a listener here. + @par + Events are raised very generically by string name. Perhaps the most + common example of a render system specific event is the loss and + restoration of a device in DirectX; which OGRE deals with, but you + may wish to know when it happens. + @see RenderSystem::getRenderSystemEvents + */ + virtual void addListener(Listener* l); + /** Remove a listener to the custom events that this render system can raise. + */ + virtual void removeListener(Listener* l); + + /** Gets a list of the rendersystem specific events that this rendersystem + can raise. + @see RenderSystem::addListener + */ + virtual const StringVector& getRenderSystemEvents(void) const { return mEventNames; } + + /** Tell the rendersystem to perform any prep tasks it needs to directly + before other threads which might access the rendering API are registered. + @remarks + Call this from your main thread before starting your other threads + (which themselves should call registerThread()). Note that if you + start your own threads, there is a specific startup sequence which + must be respected and requires synchronisation between the threads: +
    +
  1. [Main thread]Call preExtraThreadsStarted
  2. +
  3. [Main thread]Start other thread, wait
  4. +
  5. [Other thread]Call registerThread, notify main thread & continue
  6. +
  7. [Main thread]Wake up & call postExtraThreadsStarted
  8. +
+ Once this init sequence is completed the threads are independent but + this startup sequence must be respected. + */ + virtual void preExtraThreadsStarted() = 0; + + /* Tell the rendersystem to perform any tasks it needs to directly + after other threads which might access the rendering API are registered. + @see RenderSystem::preExtraThreadsStarted + */ + virtual void postExtraThreadsStarted() = 0; + + /** Register the an additional thread which may make calls to rendersystem-related + objects. + @remarks + This method should only be called by additional threads during their + initialisation. If they intend to use hardware rendering system resources + they should call this method before doing anything related to the render system. + Some rendering APIs require a per-thread setup and this method will sort that + out. It is also necessary to call unregisterThread before the thread shuts down. + @note + This method takes no parameters - it must be called from the thread being + registered and that context is enough. + */ + virtual void registerThread() = 0; + + /** Unregister an additional thread which may make calls to rendersystem-related objects. + @see RenderSystem::registerThread + */ + virtual void unregisterThread() = 0; + protected: + + + /** The render targets. */ + RenderTargetMap mRenderTargets; + /** The render targets, ordered by priority. */ + RenderTargetPriorityMap mPrioritisedRenderTargets; + /** The Active render target. */ + RenderTarget * mActiveRenderTarget; + /** The Active GPU programs and gpu program parameters*/ + GpuProgramParametersSharedPtr mActiveVertexGpuProgramParameters; + GpuProgramParametersSharedPtr mActiveFragmentGpuProgramParameters; + + // Texture manager + // A concrete class of this will be created and + // made available under the TextureManager singleton, + // managed by the RenderSystem + TextureManager* mTextureManager; + + /// Used to store the capabilities of the graphics card + RenderSystemCapabilities* mCapabilities; + + // Active viewport (dest for future rendering operations) + Viewport* mActiveViewport; + + CullingMode mCullingMode; + + bool mVSync; + bool mWBuffer; + + size_t mBatchCount; + size_t mFaceCount; + size_t mVertexCount; + + /// Saved manual colour blends + ColourValue mManualBlendColours[OGRE_MAX_TEXTURE_LAYERS][2]; + + bool mInvertVertexWinding; + + /// Texture units from this upwards are disabled + size_t mDisabledTexUnitsFrom; + + /// number of times to render the current state + size_t mCurrentPassIterationCount; + + /** updates pass iteration rendering state including bound gpu program parameter + pass iteration auto constant entry + @returns True if more iterations are required + */ + bool updatePassIterationRenderState(void); + + /// List of names of events this rendersystem may raise + StringVector mEventNames; + + /// Internal method for firing a rendersystem event + virtual void fireEvent(const String& name, const NameValuePairList* params = 0); + + typedef std::list ListenerList; + ListenerList mEventListeners; + + typedef std::list HardwareOcclusionQueryList; + HardwareOcclusionQueryList mHwOcclusionQueries; + + bool mVertexProgramBound; + bool mFragmentProgramBound; + + + + }; +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreRenderSystemCapabilities.h b/school/informatik/verkerhssimulation/src/ogre/OgreRenderSystemCapabilities.h new file mode 100644 index 00000000..aae42d36 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreRenderSystemCapabilities.h @@ -0,0 +1,382 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __RenderSystemCapabilities__ +#define __RenderSystemCapabilities__ 1 + +// Precompiler options +#include "OgrePrerequisites.h" +#include "OgreString.h" + +namespace Ogre { + + /// Enum describing the different hardware capabilities we want to check for + enum Capabilities + { + //RSC_MULTITEXTURE = 0x00000001, + /// Supporta generating mipmaps in hardware + RSC_AUTOMIPMAP = 0x00000002, + RSC_BLENDING = 0x00000004, + /// Supports anisotropic texture filtering + RSC_ANISOTROPY = 0x00000008, + /// Supports fixed-function DOT3 texture blend + RSC_DOT3 = 0x00000010, + /// Supports cube mapping + RSC_CUBEMAPPING = 0x00000020, + /// Supports hardware stencil buffer + RSC_HWSTENCIL = 0x00000040, + /// Supports hardware vertex and index buffers + RSC_VBO = 0x00000080, + /// Supports vertex programs (vertex shaders) + RSC_VERTEX_PROGRAM = 0x00000200, + /// Supports fragment programs (pixel shaders) + RSC_FRAGMENT_PROGRAM = 0x00000400, + /// Supports compressed textures + RSC_TEXTURE_COMPRESSION = 0x00000800, + /// Supports compressed textures in the DXT/ST3C formats + RSC_TEXTURE_COMPRESSION_DXT = 0x00001000, + /// Supports compressed textures in the VTC format + RSC_TEXTURE_COMPRESSION_VTC = 0x00002000, + /// Supports performing a scissor test to exclude areas of the screen + RSC_SCISSOR_TEST = 0x00004000, + /// Supports separate stencil updates for both front and back faces + RSC_TWO_SIDED_STENCIL = 0x00008000, + /// Supports wrapping the stencil value at the range extremeties + RSC_STENCIL_WRAP = 0x00010000, + /// Supports hardware occlusion queries + RSC_HWOCCLUSION = 0x00020000, + /// Supports user clipping planes + RSC_USER_CLIP_PLANES = 0x00040000, + /// Supports the VET_UBYTE4 vertex element type + RSC_VERTEX_FORMAT_UBYTE4 = 0x00080000, + /// Supports infinite far plane projection + RSC_INFINITE_FAR_PLANE = 0x00100000, + /// Supports hardware render-to-texture (bigger than framebuffer) + RSC_HWRENDER_TO_TEXTURE = 0x00200000, + /// Supports float textures and render targets + RSC_TEXTURE_FLOAT = 0x00400000, + /// Supports non-power of two textures + RSC_NON_POWER_OF_2_TEXTURES = 0x00800000, + /// Supports 3d (volume) textures + RSC_TEXTURE_3D = 0x01000000, + /// Supports basic point sprite rendering + RSC_POINT_SPRITES = 0x02000000, + /// Supports extra point parameters (minsize, maxsize, attenuation) + RSC_POINT_EXTENDED_PARAMETERS = 0x04000000, + /// Supports vertex texture fetch + RSC_VERTEX_TEXTURE_FETCH = 0x08000000, + /// Supports mipmap LOD biasing + RSC_MIPMAP_LOD_BIAS = 0x10000000 + + }; + + /** singleton class for storing the capabilities of the graphics card. + @remarks + This class stores the capabilities of the graphics card. This + information is set by the individual render systems. + */ + class _OgreExport RenderSystemCapabilities + { + private: + /// The number of world matricies available + ushort mNumWorldMatrices; + /// The number of texture units available + ushort mNumTextureUnits; + /// The stencil buffer bit depth + ushort mStencilBufferBitDepth; + /// The number of matrices available for hardware blending + ushort mNumVertexBlendMatrices; + /// Stores the capabilities flags. + int mCapabilities; + /// The best vertex program that this card / rendersystem supports + String mMaxVertexProgramVersion; + /// The best fragment program that this card / rendersystem supports + String mMaxFragmentProgramVersion; + /// The number of floating-point constants vertex programs support + ushort mVertexProgramConstantFloatCount; + /// The number of integer constants vertex programs support + ushort mVertexProgramConstantIntCount; + /// The number of boolean constants vertex programs support + ushort mVertexProgramConstantBoolCount; + /// The number of floating-point constants fragment programs support + ushort mFragmentProgramConstantFloatCount; + /// The number of integer constants fragment programs support + ushort mFragmentProgramConstantIntCount; + /// The number of boolean constants fragment programs support + ushort mFragmentProgramConstantBoolCount; + /// The number of simultaneous render targets supported + ushort mNumMultiRenderTargets; + /// The maximum point size + Real mMaxPointSize; + /// Are non-POW2 textures feature-limited? + bool mNonPOW2TexturesLimited; + /// The number of vertex texture units supported + ushort mNumVertexTextureUnits; + /// Are vertex texture units shared with fragment processor? + bool mVertexTextureUnitsShared; + + public: + RenderSystemCapabilities (); + ~RenderSystemCapabilities (); + + void setNumWorldMatricies(ushort num) + { + mNumWorldMatrices = num; + } + + void setNumTextureUnits(ushort num) + { + mNumTextureUnits = num; + } + + void setStencilBufferBitDepth(ushort num) + { + mStencilBufferBitDepth = num; + } + + void setNumVertexBlendMatrices(ushort num) + { + mNumVertexBlendMatrices = num; + } + + /// The number of simultaneous render targets supported + void setNumMultiRenderTargets(ushort num) + { + mNumMultiRenderTargets = num; + } + + ushort getNumWorldMatricies(void) const + { + return mNumWorldMatrices; + } + + /** Returns the number of texture units the current output hardware + supports. + + For use in rendering, this determines how many texture units the + are available for multitexturing (i.e. rendering multiple + textures in a single pass). Where a Material has multiple + texture layers, it will try to use multitexturing where + available, and where it is not available, will perform multipass + rendering to achieve the same effect. This property only applies + to the fixed-function pipeline, the number available to the + programmable pipeline depends on the shader model in use. + */ + ushort getNumTextureUnits(void) const + { + return mNumTextureUnits; + } + + /** Determines the bit depth of the hardware accelerated stencil + buffer, if supported. + @remarks + If hardware stencilling is not supported, the software will + provide an 8-bit software stencil. + */ + ushort getStencilBufferBitDepth(void) const + { + return mStencilBufferBitDepth; + } + + /** Returns the number of matrices available to hardware vertex + blending for this rendering system. */ + ushort numVertexBlendMatrices(void) const + { + return mNumVertexBlendMatrices; + } + + /// The number of simultaneous render targets supported + ushort numMultiRenderTargets(void) const + { + return mNumMultiRenderTargets; + } + + /** Adds a capability flag to mCapabilities + */ + void setCapability(const Capabilities c) + { + mCapabilities |= c; + } + + /** Checks for a capability + */ + bool hasCapability(const Capabilities c) const + { + if(mCapabilities & c) + { + return true; + } + else + { + return false; + } + } + /// Gets the best low-level vertex program version supported + const String& getMaxVertexProgramVersion(void) const + { + return mMaxVertexProgramVersion; + } + /// Gets the best fragment program that this card / rendersystem supports + const String& getMaxFragmentProgramVersion(void) const + { + return mMaxFragmentProgramVersion; + } + /// The number of floating-point constants vertex programs support + ushort getVertexProgramConstantFloatCount(void) const + { + return mVertexProgramConstantFloatCount; + } + /// The number of integer constants vertex programs support + ushort getVertexProgramConstantIntCount(void) const + { + return mVertexProgramConstantIntCount; + } + /// The number of boolean constants vertex programs support + ushort getVertexProgramConstantBoolCount(void) const + { + return mVertexProgramConstantBoolCount; + } + /// The number of floating-point constants fragment programs support + ushort getFragmentProgramConstantFloatCount(void) const + { + return mFragmentProgramConstantFloatCount; + } + /// The number of integer constants fragment programs support + ushort getFragmentProgramConstantIntCount(void) const + { + return mFragmentProgramConstantIntCount; + } + /// The number of boolean constants fragment programs support + ushort getFragmentProgramConstantBoolCount(void) const + { + return mFragmentProgramConstantBoolCount; + } + + + + /// sets the best low-level vertex program version supported + void setMaxVertexProgramVersion(const String& ver) + { + mMaxVertexProgramVersion = ver; + } + /// sets the best fragment program that this card / rendersystem supports + void setMaxFragmentProgramVersion(const String& ver) + { + mMaxFragmentProgramVersion = ver; + } + /// The number of floating-point constants vertex programs support + void setVertexProgramConstantFloatCount(ushort c) + { + mVertexProgramConstantFloatCount = c; + } + /// The number of integer constants vertex programs support + void setVertexProgramConstantIntCount(ushort c) + { + mVertexProgramConstantIntCount = c; + } + /// The number of boolean constants vertex programs support + void setVertexProgramConstantBoolCount(ushort c) + { + mVertexProgramConstantBoolCount = c; + } + /// The number of floating-point constants fragment programs support + void setFragmentProgramConstantFloatCount(ushort c) + { + mFragmentProgramConstantFloatCount = c; + } + /// The number of integer constants fragment programs support + void setFragmentProgramConstantIntCount(ushort c) + { + mFragmentProgramConstantIntCount = c; + } + /// The number of boolean constants fragment programs support + void setFragmentProgramConstantBoolCount(ushort c) + { + mFragmentProgramConstantBoolCount = c; + } + /// Maximum point screen size in pixels + void setMaxPointSize(Real s) + { + mMaxPointSize = s; + } + /// Maximum point screen size in pixels + Real getMaxPointSize(void) const + { + return mMaxPointSize; + } + /// Non-POW2 textures limited + void setNonPOW2TexturesLimited(bool l) + { + mNonPOW2TexturesLimited = l; + } + /** Are non-power of two textures limited in features? + @remarks + If the RSC_NON_POWER_OF_2_TEXTURES capability is set, but this + method returns true, you can use non power of 2 textures only if: +
  • You load them explicitly with no mip maps
  • +
  • You don't use DXT texture compression
  • +
  • You use clamp texture addressing
+ */ + bool getNonPOW2TexturesLimited(void) const + { + return mNonPOW2TexturesLimited; + } + + /// Set the number of vertex texture units supported + void setNumVertexTextureUnits(ushort n) + { + mNumVertexTextureUnits = n; + } + /// Get the number of vertex texture units supported + ushort getNumVertexTextureUnits(void) const + { + return mNumVertexTextureUnits; + } + /// Set whether the vertex texture units are shared with the fragment processor + void setVertexTextureUnitsShared(bool shared) + { + mVertexTextureUnitsShared = shared; + } + /// Get whether the vertex texture units are shared with the fragment processor + bool getVertexTextureUnitsShared(void) const + { + return mVertexTextureUnitsShared; + } + + + /** Write the capabilities to the pass in Log */ + void log(Log* pLog); + + + + + }; +} + +#endif // __RenderSystemCapabilities__ + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreRenderTarget.h b/school/informatik/verkerhssimulation/src/ogre/OgreRenderTarget.h new file mode 100644 index 00000000..da6470bd --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreRenderTarget.h @@ -0,0 +1,359 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __RenderTarget_H__ +#define __RenderTarget_H__ + +#include "OgrePrerequisites.h" + +#include "OgreString.h" +#include "OgreTextureManager.h" +#include "OgreViewport.h" +#include "OgreTimer.h" + +/* Define the number of priority groups for the render system's render targets. */ +#ifndef OGRE_NUM_RENDERTARGET_GROUPS + #define OGRE_NUM_RENDERTARGET_GROUPS 10 + #define OGRE_DEFAULT_RT_GROUP 4 + #define OGRE_REND_TO_TEX_RT_GROUP 2 +#endif + +namespace Ogre { + + /** A 'canvas' which can receive the results of a rendering + operation. + @remarks + This abstract class defines a common root to all targets of rendering operations. A + render target could be a window on a screen, or another + offscreen surface like a texture or bump map etc. + @author + Steven Streeting + @version + 1.0 + */ + class _OgreExport RenderTarget + { + public: + enum StatFlags + { + SF_NONE = 0, + SF_FPS = 1, + SF_AVG_FPS = 2, + SF_BEST_FPS = 4, + SF_WORST_FPS = 8, + SF_TRIANGLE_COUNT = 16, + SF_ALL = 0xFFFF + }; + + struct FrameStats + { + float lastFPS; + float avgFPS; + float bestFPS; + float worstFPS; + unsigned long bestFrameTime; + unsigned long worstFrameTime; + size_t triangleCount; + size_t batchCount; + }; + + RenderTarget(); + virtual ~RenderTarget(); + + /// Retrieve target's name. + virtual const String& getName(void) const; + + /// Retrieve information about the render target. + virtual void getMetrics(unsigned int& width, unsigned int& height, unsigned int& colourDepth); + + virtual unsigned int getWidth(void) const; + virtual unsigned int getHeight(void) const; + virtual unsigned int getColourDepth(void) const; + + /** Tells the target to update it's contents. + @remarks + If OGRE is not running in an automatic rendering loop + (started using Root::startRendering), + the user of the library is responsible for asking each render + target to refresh. This is the method used to do this. It automatically + re-renders the contents of the target using whatever cameras have been + pointed at it (using Camera::setRenderTarget). + @par + This allows OGRE to be used in multi-windowed utilities + and for contents to be refreshed only when required, rather than + constantly as with the automatic rendering loop. + */ + virtual void update(void); + + /** Adds a viewport to the rendering target. + @remarks + A viewport is the rectangle into which redering output is sent. This method adds + a viewport to the render target, rendering from the supplied camera. The + rest of the parameters are only required if you wish to add more than one viewport + to a single rendering target. Note that size information passed to this method is + passed as a parametric, i.e. it is relative rather than absolute. This is to allow + viewports to automatically resize along with the target. + @param + cam The camera from which the viewport contents will be rendered (mandatory) + @param + ZOrder The relative order of the viewport with others on the target (allows overlapping + viewports i.e. picture-in-picture). Higher ZOrders are on top of lower ones. The actual number + is irrelevant, only the relative ZOrder matters (you can leave gaps in the numbering) + @param + left The relative position of the left of the viewport on the target, as a value between 0 and 1. + @param + top The relative position of the top of the viewport on the target, as a value between 0 and 1. + @param + width The relative width of the viewport on the target, as a value between 0 and 1. + @param + height The relative height of the viewport on the target, as a value between 0 and 1. + */ + virtual Viewport* addViewport(Camera* cam, int ZOrder = 0, float left = 0.0f, float top = 0.0f , + float width = 1.0f, float height = 1.0f); + + /** Returns the number of viewports attached to this target.*/ + virtual unsigned short getNumViewports(void) const; + + /** Retrieves a pointer to the viewport with the given index. */ + virtual Viewport* getViewport(unsigned short index); + + /** Removes a viewport at a given ZOrder. + */ + virtual void removeViewport(int ZOrder); + + /** Removes all viewports on this target. + */ + virtual void removeAllViewports(void); + + /** Retieves details of current rendering performance. + @remarks + If the user application wishes to do it's own performance + display, or use performance for some other means, this + method allows it to retrieve the statistics. + @param + lastFPS Pointer to a float to receive the number of frames per second (FPS) + based on the last frame rendered. + @param + avgFPS Pointer to a float to receive the FPS rating based on an average of all + the frames rendered since rendering began (the call to + Root::startRendering). + @param + bestFPS Pointer to a float to receive the best FPS rating that has been achieved + since rendering began. + @param + worstFPS Pointer to a float to receive the worst FPS rating seen so far. + */ + virtual void getStatistics(float& lastFPS, float& avgFPS, + float& bestFPS, float& worstFPS) const; // Access to stats + + virtual const FrameStats& getStatistics(void) const; + + /** Individual stats access - gets the number of frames per second (FPS) based on the last frame rendered. + */ + virtual float getLastFPS() const; + + /** Individual stats access - gets the average frames per second (FPS) since call to Root::startRendering. + */ + virtual float getAverageFPS() const; + + /** Individual stats access - gets the best frames per second (FPS) since call to Root::startRendering. + */ + virtual float getBestFPS() const; + + /** Individual stats access - gets the worst frames per second (FPS) since call to Root::startRendering. + */ + virtual float getWorstFPS() const; + + /** Individual stats access - gets the best frame time + */ + virtual float getBestFrameTime() const; + + /** Individual stats access - gets the worst frame time + */ + virtual float getWorstFrameTime() const; + + /** Resets saved frame-rate statistices. + */ + virtual void resetStatistics(void); + + /** Gets a custom (maybe platform-specific) attribute. + @remarks + This is a nasty way of satisfying any API's need to see platform-specific details. + It horrid, but D3D needs this kind of info. At least it's abstracted. + @param + name The name of the attribute. + @param + pData Pointer to memory of the right kind of structure to receive the info. + */ + virtual void getCustomAttribute(const String& name, void* pData); + + /** Add a listener to this RenderTarget which will be called back before & after rendering. + @remarks + If you want notifications before and after a target is updated by the system, use + this method to register your own custom RenderTargetListener class. This is useful + for potentially adding your own manual rendering commands before and after the + 'normal' system rendering. + @par NB this should not be used for frame-based scene updates, use Root::addFrameListener for that. + */ + virtual void addListener(RenderTargetListener* listener); + /** Removes a RenderTargetListener previously registered using addListener. */ + virtual void removeListener(RenderTargetListener* listener); + /** Removes all listeners from this instance. */ + virtual void removeAllListeners(void); + + /** Sets the priority of this render target in relation to the others. + @remarks + This can be used in order to schedule render target updates. Lower + priorities will be rendered first. Note that the priority must be set + at the time the render target is attached to the render system, changes + afterwards will not affect the ordering. + */ + virtual void setPriority( uchar priority ) { mPriority = priority; } + /** Gets the priority of a render target. */ + virtual uchar getPriority() const { return mPriority; } + + /** Used to retrieve or set the active state of the render target. + */ + virtual bool isActive() const; + + /** Used to set the active state of the render target. + */ + virtual void setActive( bool state ); + + /** Sets whether this target should be automatically updated if Ogre's rendering + loop or Root::_updateAllRenderTargets is being used. + @remarks + By default, if you use Ogre's own rendering loop (Root::startRendering) + or call Root::_updateAllRenderTargets, all render targets are updated + automatically. This method allows you to control that behaviour, if + for example you have a render target which you only want to update periodically. + @param autoupdate If true, the render target is updated during the automatic render + loop or when Root::_updateAllRenderTargets is called. If false, the + target is only updated when its update() method is called explicitly. + */ + virtual void setAutoUpdated(bool autoupdate); + /** Gets whether this target is automatically updated if Ogre's rendering + loop or Root::_updateAllRenderTargets is being used. + */ + virtual bool isAutoUpdated(void) const; + + /** Writes the current contents of the render target to the named file. */ + virtual void writeContentsToFile(const String& filename) = 0; + + /** Writes the current contents of the render target to the (PREFIX)(time-stamp)(SUFFIX) file. + @returns the name of the file used.*/ + virtual String writeContentsToTimestampedFile(const String& filenamePrefix, const String& filenameSuffix); + + virtual bool requiresTextureFlipping() const = 0; + + /** Gets the number of triangles rendered in the last update() call. */ + virtual size_t getTriangleCount(void) const; + /** Gets the number of batches rendered in the last update() call. */ + virtual size_t getBatchCount(void) const; + /** Utility method to notify a render target that a camera has been removed, + incase it was referring to it as a viewer. + */ + virtual void _notifyCameraRemoved(const Camera* cam); + + /** Indicates whether this target is the primary window. The + primary window is special in that it is destroyed when + ogre is shut down, and cannot be destroyed directly. + This is the case because it holds the context for vertex, + index buffers and textures. + */ + virtual bool isPrimary(void) const; + + + /** RenderSystem specific interface for a RenderTarget; + this should be subclassed by RenderSystems. + */ + class Impl + { + protected: + /** Declared protected as interface is never used for destruction. + gcc will issue a warning here: `class Impl' has virtual functions + but non-virtual destructor. This is no problem because this interface + is never used to delete an object. + */ + ~Impl() { }; + }; + /** Get rendersystem specific interface for this RenderTarget. + This is used by the RenderSystem to (un)bind this target, + and to get specific information like surfaces + and framebuffer objects. + */ + virtual Impl *_getImpl(); + protected: + /// The name of this target. + String mName; + /// The priority of the render target. + uchar mPriority; + + unsigned int mWidth; + unsigned int mHeight; + unsigned int mColourDepth; + bool mIsDepthBuffered; + + // Stats + FrameStats mStats; + + Timer* mTimer ; + unsigned long mLastSecond; + unsigned long mLastTime; + size_t mFrameCount; + + bool mActive; + bool mAutoUpdate; + + void updateStats(void); + + typedef std::map > ViewportList; + /// List of viewports, map on Z-order + ViewportList mViewportList; + + typedef std::vector RenderTargetListenerList; + RenderTargetListenerList mListeners; + + + /// internal method for firing events + virtual void firePreUpdate(void); + /// internal method for firing events + virtual void firePostUpdate(void); + /// internal method for firing events + virtual void fireViewportPreUpdate(Viewport* vp); + /// internal method for firing events + virtual void fireViewportPostUpdate(Viewport* vp); + /// internal method for firing events + virtual void fireViewportAdded(Viewport* vp); + /// internal method for firing events + virtual void fireViewportRemoved(Viewport* vp); + }; + +} // Namespace + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreRenderTargetListener.h b/school/informatik/verkerhssimulation/src/ogre/OgreRenderTargetListener.h new file mode 100644 index 00000000..8db10421 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreRenderTargetListener.h @@ -0,0 +1,132 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __RenderTargetListener_H__ +#define __RenderTargetListener_H__ + + +#include "OgrePrerequisites.h" + +namespace Ogre { + + /** Struct containing information about a RenderTarget event. + */ + struct RenderTargetEvent + { + /// The source of the event being raised + RenderTarget* source; + }; + + /** Struct containing information about a RenderTarget Viewport-specific event. + */ + struct RenderTargetViewportEvent + { + /// The source of the event being raised + Viewport* source; + }; + + /** A interface class defining a listener which can be used to receive + notifications of RenderTarget events. + @remarks + A 'listener' is an interface designed to be called back when + particular events are called. This class defines the + interface relating to RenderTarget events. In order to receive + notifications of RenderTarget events, you should create a subclass of + RenderTargetListener and override the methods for which you would like + to customise the resulting processing. You should then call + RenderTarget::addListener passing an instance of this class. + There is no limit to the number of RenderTarget listeners you can register, + allowing you to register multiple listeners for different purposes. +

+ RenderTarget events occur before and after the target is updated as a whole, + and before and after each viewport on that target is updated. Each RenderTarget + holds it's own set of listeners, but you can register the same listener on + multiple render targets if you like since the event contains details of the + originating RenderTarget. + */ + class _OgreExport RenderTargetListener + { + /* + Note that this could have been an abstract class, but I made + the explicit choice not to do this, because I wanted to give + people the option of only implementing the methods they wanted, + rather than having to create 'do nothing' implementations for + those they weren't interested in. As such this class follows + the 'Adapter' classes in Java rather than pure interfaces. + */ + public: + virtual ~RenderTargetListener() {} + /** Called just before a RenderTarget is about to be rendered into. + @remarks + This event is raised just before any of the viewports on the target + are rendered to. You can perform manual rendering operations here if + you want, but please note that if the Viewport objects attached to this + target are set up to clear the background, you will lose whatever you + render. If you want some kind of backdrop in this event + you should turn off background clearing off on the viewports, and either + clear the viewports yourself in this event handler before doing your rendering + or just render over the top if you don't need to. + */ + virtual void preRenderTargetUpdate(const RenderTargetEvent& evt) { } + /** Called just after a RenderTarget has been rendered to. + @remarks + This event is called just after all the viewports attached to the target + in question have been rendered to. You can perform your own manual rendering + commands in this event handler if you like, these will be composited with + the contents of the target already there (depending on the material settings + you use etc). + */ + virtual void postRenderTargetUpdate(const RenderTargetEvent& evt) { } + + /* Called just before a Viewport on a RenderTarget is to be updated. + @remarks + This method is called before each viewport on the RenderTarget is + rendered to. You can use this to perform per-viewport settings changes, + such as showing / hiding particular overlays. + */ + virtual void preViewportUpdate(const RenderTargetViewportEvent& evt) { } + + /* Called just after a Viewport on a RenderTarget is to be updated. + @remarks + This method is called after each viewport on the RenderTarget is + rendered to. + */ + virtual void postViewportUpdate(const RenderTargetViewportEvent& evt) { } + + /** Called to notify listener that a Viewport has been added to the + target in question. + */ + virtual void viewportAdded(const RenderTargetViewportEvent& evt) {} + /** Called to notify listener that a Viewport has been removed from the + target in question. + */ + virtual void viewportRemoved(const RenderTargetViewportEvent& evt) {} + }; +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreRenderTexture.h b/school/informatik/verkerhssimulation/src/ogre/OgreRenderTexture.h new file mode 100644 index 00000000..5556408f --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreRenderTexture.h @@ -0,0 +1,100 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __RenderTexture_H__ +#define __RenderTexture_H__ + +#include "OgrePrerequisites.h" + +#include "OgreRenderTarget.h" + +namespace Ogre +{ + /** This class represents a RenderTarget that renders to a Texture. There is no 1 on 1 + relation between Textures and RenderTextures, as there can be multiple + RenderTargets rendering to different mipmaps, faces (for cubemaps) or slices (for 3D textures) + of the same Texture. + */ + class _OgreExport RenderTexture: public RenderTarget + { + public: + RenderTexture(HardwarePixelBuffer *buffer, size_t zoffset); + virtual ~RenderTexture(); + + void writeContentsToFile( const String & filename ); + protected: + HardwarePixelBuffer *mBuffer; + size_t mZOffset; + }; + + /** This class represents a render target that renders to multiple RenderTextures + at once. Surfaces can be bound and unbound at will, as long as the following constraints + are met: + - All bound surfaces have the same size + - All bound surfaces have the same bit depth + - Target 0 is bound + */ + class _OgreExport MultiRenderTarget: public RenderTarget + { + public: + MultiRenderTarget(const String &name); + + /** Bind a surface to a certain attachment point. + + @param attachment 0 .. mCapabilities->numMultiRenderTargets()-1 + + @param target RenderTexture to bind. + + + + It does not bind the surface and fails with an exception (ERR_INVALIDPARAMS) if: + + - Not all bound surfaces have the same size + + - Not all bound surfaces have the same internal format + + */ + + virtual void bindSurface(size_t attachment, RenderTexture *target)=0; + + + + /** Unbind attachment. + + */ + + virtual void unbindSurface(size_t attachment)=0; + + /** Error throwing implementation, it's not possible to write a MultiRenderTarget + to disk. + */ + virtual void writeContentsToFile( const String & filename ); + }; +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreRenderWindow.h b/school/informatik/verkerhssimulation/src/ogre/OgreRenderWindow.h new file mode 100644 index 00000000..fef20350 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreRenderWindow.h @@ -0,0 +1,213 @@ +/*------------------------------------------------------------------------- +This source file is a part of OGRE +(Object-oriented Graphics Rendering Engine) + +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License (LGPL) as +published by the Free Software Foundation; either version 2.1 of the +License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or go to +http://www.gnu.org/copyleft/lesser.txt +-------------------------------------------------------------------------*/ +#ifndef __RenderWindow_H__ +#define __RenderWindow_H__ + +#include "OgrePrerequisites.h" + +#include "OgreRenderTarget.h" + +namespace Ogre +{ + /** Manages the target rendering window. + @remarks + This class handles a window into which the contents + of a scene are rendered. There is a many-to-1 relationship + between instances of this class an instance of RenderSystem + which controls the rendering of the scene. There may be + more than one window in the case of level editor tools etc. + This class is abstract since there may be + different implementations for different windowing systems. + @remarks + Instances are created and communicated with by the render system + although client programs can get a reference to it from + the render system if required for resizing or moving. + Note that you can have multiple viewpoints + in the window for effects like rear-view mirrors and + picture-in-picture views (see Viewport and Camera). + @author + Steven Streeting + @version + 1.0 + */ + class _OgreExport RenderWindow : public RenderTarget + { + + public: + /** Default constructor. + */ + RenderWindow(); + + /** Creates & displays the new window. + @param + width The width of the window in pixels. + @param + height The height of the window in pixels. + @param + colourDepth The colour depth in bits. Ignored if + fullScreen is false since the desktop depth is used. + @param + fullScreen If true, the window fills the screen, + with no title bar or border. + @param + left The x-position of the window. Ignored if + fullScreen = true. + @param + top The y-position of the window. Ignored if + fullScreen = true. + @param + depthBuffer Specify true to include a depth-buffer. + @param + miscParam A variable number of pointers to platform-specific arguments. The + actual requirements must be defined by the implementing subclasses. + */ + virtual void create(const String& name, unsigned int width, unsigned int height, + bool fullScreen, const NameValuePairList *miscParams) = 0; + + /** Alter fullscreen mode options. + @note Nothing will happen unless the settings here are different from the + current settings. + @param fullScreen Whether to use fullscreen mode or not. + @param width The new width to use + @param height The new height to use + */ + virtual void setFullscreen(bool fullScreen, unsigned int width, unsigned int height) {} + + /** Destroys the window. + */ + virtual void destroy(void) = 0; + + /** Alter the size of the window. + */ + virtual void resize(unsigned int width, unsigned int height) = 0; + + /** Notify that the window has been resized + @remarks + You don't need to call this unless you created the window externally. + */ + virtual void windowMovedOrResized() {} + + /** Reposition the window. + */ + virtual void reposition(int left, int top) = 0; + + /** Indicates whether the window is visible (not minimized or obscured) + */ + virtual bool isVisible(void) const { return true; } + + /** Set the visibility state + */ + virtual void setVisible(bool visible) {} + + /** Overridden from RenderTarget, flags invisible windows as inactive + */ + virtual bool isActive(void) const { return mActive && isVisible(); } + + /** Indicates whether the window has been closed by the user. + */ + virtual bool isClosed(void) const = 0; + + /** Indicates wether the window is the primary window. The + primary window is special in that it is destroyed when + ogre is shut down, and cannot be destroyed directly. + This is the case because it holds the context for vertex, + index buffers and textures. + */ + virtual bool isPrimary(void) const; + + /** Swaps the frame buffers to display the next frame. + @remarks + All render windows are double-buffered so that no + 'in-progress' versions of the scene are displayed + during rendering. Once rendering has completed (to + an off-screen version of the window) the buffers + are swapped to display the new frame. + + @param + waitForVSync If true, the system waits for the + next vertical blank period (when the CRT beam turns off + as it travels from bottom-right to top-left at the + end of the pass) before flipping. If false, flipping + occurs no matter what the beam position. Waiting for + a vertical blank can be slower (and limits the + framerate to the monitor refresh rate) but results + in a steadier image with no 'tearing' (a flicker + resulting from flipping buffers when the beam is + in the progress of drawing the last frame). + */ + virtual void swapBuffers(bool waitForVSync = true) = 0; + + /// @copydoc RenderTarget::update + virtual void update(void); + /** Updates the window contents. + @remarks + The window is updated by telling each camera which is supposed + to render into this window to render it's view, and then + the window buffers are swapped via swapBuffers() if requested + @param swapBuffers If set to true, the window will immediately + swap it's buffers after update. Otherwise, the buffers are + not swapped, and you have to call swapBuffers yourself sometime + later. You might want to do this on some rendersystems which + pause for queued rendering commands to complete before accepting + swap buffers calls - so you could do other CPU tasks whilst the + queued commands complete. Or, you might do this if you want custom + control over your windows, such as for externally created windows. + */ + virtual void update(bool swapBuffers); + + /** Returns true if window is running in fullscreen mode. + */ + virtual bool isFullScreen(void) const; + + /** Overloaded version of getMetrics from RenderTarget, including extra details + specific to windowing systems. + */ + virtual void getMetrics(unsigned int& width, unsigned int& height, unsigned int& colourDepth, + int& left, int& top); + + protected: + bool mIsFullScreen; + bool mIsPrimary; + int mLeft; + int mTop; + + /** Indicates that this is the primary window. Only to be called by + Ogre::Root + */ + void _setPrimary() { mIsPrimary = true; } + + friend class Root; + }; + + /** Defines the interface a DLL implemeting a platform-specific version must implement. + @remarks + Any library (.dll, .so) wishing to implement a platform-specific version of this + dialog must export the symbol 'createRenderWindow' with the signature + void createPlatformRenderWindow(RenderWindow** ppDlg) + */ + typedef void (*DLL_CREATERENDERWINDOW)(RenderWindow** ppWindow); + +} // Namespace +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreRenderable.h b/school/informatik/verkerhssimulation/src/ogre/OgreRenderable.h new file mode 100644 index 00000000..d806cfc5 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreRenderable.h @@ -0,0 +1,296 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Renderable_H__ +#define __Renderable_H__ + +#include "OgrePrerequisites.h" +#include "OgreCommon.h" + +#include "OgreRenderOperation.h" +#include "OgreMatrix4.h" +#include "OgreMaterial.h" +#include "OgrePlane.h" +#include "OgreGpuProgram.h" +#include "OgreVector4.h" +#include "OgreException.h" + +namespace Ogre { + + /** Abstract class defining the interface all renderable objects must implement. + @remarks + This interface abstracts renderable discrete objects which will be queued in the render pipeline, + grouped by material. Classes implementing this interface must be based on a single material, a single + world matrix (or a collection of world matrices which are blended by weights), and must be + renderable via a single render operation. + @par + Note that deciding whether to put these objects in the rendering pipeline is done from the more specific + classes e.g. entities. Only once it is decided that the specific class is to be rendered is the abstract version + created (could be more than one per visible object) and pushed onto the rendering queue. + */ + class _OgreExport Renderable + { + public: + Renderable() : mPolygonModeOverrideable(true), mUseIdentityProjection(false), mUseIdentityView(false) {} + /** Virtual destructor needed as class has virtual methods. */ + virtual ~Renderable() { } + /** Retrieves a weak reference to the material this renderable object uses. + @remarks + Note that the Renderable also has the option to override the getTechnique method + to specify a particular Technique to use instead of the best one available. + */ + virtual const MaterialPtr& getMaterial(void) const = 0; + /** Retrieves a pointer to the Material Technique this renderable object uses. + @remarks + This is to allow Renderables to use a chosen Technique if they wish, otherwise + they will use the best Technique available for the Material they are using. + */ + virtual Technique* getTechnique(void) const { return getMaterial()->getBestTechnique(); } + /** Gets the render operation required to send this object to the frame buffer. + */ + virtual void getRenderOperation(RenderOperation& op) = 0; + /** Gets the world transform matrix / matrices for this renderable object. + @remarks + If the object has any derived transforms, these are expected to be up to date as long as + all the SceneNode structures have been updated before this is called. + @par + This method will populate xform with 1 matrix if it does not use vertex blending. If it + does use vertex blending it will fill the passed in pointer with an array of matrices, + the length being the value returned from getNumWorldTransforms. + @note + Internal Ogre never supports non-affine matrix for world transform matrix/matrices, + the behavior is undefined if returns non-affine matrix here. @see Matrix4::isAffine. + */ + virtual void getWorldTransforms(Matrix4* xform) const = 0; + /** Gets the worldspace orientation of this renderable; this is used in order to + more efficiently update parameters to vertex & fragment programs, since inverting Quaterion + and Vector in order to derive object-space positions / directions for cameras and + lights is much more efficient than inverting a complete 4x4 matrix, and also + eliminates problems introduced by scaling. */ + virtual const Quaternion& getWorldOrientation(void) const = 0; + /** Gets the worldspace position of this renderable; this is used in order to + more efficiently update parameters to vertex & fragment programs, since inverting Quaterion + and Vector in order to derive object-space positions / directions for cameras and + lights is much more efficient than inverting a complete 4x4 matrix, and also + eliminates problems introduced by scaling. */ + virtual const Vector3& getWorldPosition(void) const = 0; + + /** Returns the number of world transform matrices this renderable requires. + @remarks + When a renderable uses vertex blending, it uses multiple world matrices instead of a single + one. Each vertex sent to the pipeline can reference one or more matrices in this list + with given weights. + If a renderable does not use vertex blending this method returns 1, which is the default for + simplicity. + */ + virtual unsigned short getNumWorldTransforms(void) const { return 1; } + + /** Sets whether or not to use an 'identity' projection. + @remarks + Usually Renderable objects will use a projection matrix as determined + by the active camera. However, if they want they can cancel this out + and use an identity projection, which effectively projects in 2D using + a {-1, 1} view space. Useful for overlay rendering. Normal renderables + need not change this. The default is false. + @see Renderable::getUseIdentityProjection + */ + void setUseIdentityProjection(bool useIdentityProjection) + { + mUseIdentityProjection = useIdentityProjection; + } + + /** Returns whether or not to use an 'identity' projection. + @remarks + Usually Renderable objects will use a projection matrix as determined + by the active camera. However, if they want they can cancel this out + and use an identity projection, which effectively projects in 2D using + a {-1, 1} view space. Useful for overlay rendering. Normal renderables + need not change this. + @see Renderable::setUseIdentityProjection + */ + bool getUseIdentityProjection(void) const { return mUseIdentityProjection; } + + /** Sets whether or not to use an 'identity' view. + @remarks + Usually Renderable objects will use a view matrix as determined + by the active camera. However, if they want they can cancel this out + and use an identity matrix, which means all geometry is assumed + to be relative to camera space already. Useful for overlay rendering. + Normal renderables need not change this. The default is false. + @see Renderable::getUseIdentityView + */ + void setUseIdentityView(bool useIdentityView) + { + mUseIdentityView = useIdentityView; + } + + /** Returns whether or not to use an 'identity' view. + @remarks + Usually Renderable objects will use a view matrix as determined + by the active camera. However, if they want they can cancel this out + and use an identity matrix, which means all geometry is assumed + to be relative to camera space already. Useful for overlay rendering. + Normal renderables need not change this. + @see Renderable::setUseIdentityView + */ + bool getUseIdentityView(void) const { return mUseIdentityView; } + + /** Returns the camera-relative squared depth of this renderable. + @remarks + Used to sort transparent objects. Squared depth is used rather than + actual depth to avoid having to perform a square root on the result. + */ + virtual Real getSquaredViewDepth(const Camera* cam) const = 0; + + /** Returns whether or not this Renderable wishes the hardware to normalise normals. */ + virtual bool getNormaliseNormals(void) const { return false; } + + /** Gets a list of lights, ordered relative to how close they are to this renderable. + @remarks + Directional lights, which have no position, will always be first on this list. + */ + virtual const LightList& getLights(void) const = 0; + + virtual const PlaneList& getClipPlanes() const { return msDummyPlaneList; }; + + /** Method which reports whether this renderable would normally cast a + shadow. + @remarks + Subclasses should override this if they could have been used to + generate a shadow. + */ + virtual bool getCastsShadows(void) const { return false; } + + /** Sets a custom parameter for this Renderable, which may be used to + drive calculations for this specific Renderable, like GPU program parameters. + @remarks + Calling this method simply associates a numeric index with a 4-dimensional + value for this specific Renderable. This is most useful if the material + which this Renderable uses a vertex or fragment program, and has an + ACT_CUSTOM parameter entry. This parameter entry can refer to the + index you specify as part of this call, thereby mapping a custom + parameter for this renderable to a program parameter. + @param index The index with which to associate the value. Note that this + does not have to start at 0, and can include gaps. It also has no direct + correlation with a GPU program parameter index - the mapping between the + two is performed by the ACT_CUSTOM entry, if that is used. + @param value The value to associate. + */ + void setCustomParameter(size_t index, const Vector4& value) + { + mCustomParameters[index] = value; + } + + /** Gets the custom value associated with this Renderable at the given index. + @param + @see setCustomParaemter for full details. + */ + const Vector4& getCustomParameter(size_t index) const + { + CustomParameterMap::const_iterator i = mCustomParameters.find(index); + if (i != mCustomParameters.end()) + { + return i->second; + } + else + { + OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, + "Parameter at the given index was not found.", + "Renderable::getCustomParameter"); + } + } + + /** Update a custom GpuProgramParameters constant which is derived from + information only this Renderable knows. + @remarks + This method allows a Renderable to map in a custom GPU program parameter + based on it's own data. This is represented by a GPU auto parameter + of ACT_CUSTOM, and to allow there to be more than one of these per + Renderable, the 'data' field on the auto parameter will identify + which parameter is being updated. The implementation of this method + must identify the parameter being updated, and call a 'setConstant' + method on the passed in GpuProgramParameters object, using the details + provided in the incoming auto constant setting to identify the index + at which to set the parameter. + @par + You do not need to override this method if you're using the standard + sets of data associated with the Renderable as provided by setCustomParameter + and getCustomParameter. By default, the implementation will map from the + value indexed by the 'constantEntry.data' parameter to a value previously + set by setCustomParameter. But custom Renderables are free to override + this if they want, in any case. + @param constantEntry The auto constant entry referring to the parameter + being updated + @param params The parameters object which this method should call to + set the updated parameters. + */ + virtual void _updateCustomGpuParameter( + const GpuProgramParameters::AutoConstantEntry& constantEntry, + GpuProgramParameters* params) const + { + CustomParameterMap::const_iterator i = mCustomParameters.find(constantEntry.data); + if (i != mCustomParameters.end()) + { + params->_writeRawConstant(constantEntry.physicalIndex, i->second, + constantEntry.elementCount); + } + } + + /** Sets whether this renderable's chosen detail level can be + overridden (downgraded) by the camera setting. + @param override true means that a lower camera detail will override this + renderables detail level, false means it won't. + */ + virtual void setPolygonModeOverrideable(bool override) + { + mPolygonModeOverrideable = override; + } + + /** Gets whether this renderable's chosen detail level can be + overridden (downgraded) by the camera setting. + */ + virtual bool getPolygonModeOverrideable(void) const + { + return mPolygonModeOverrideable; + } + + + protected: + static const PlaneList msDummyPlaneList; + typedef std::map CustomParameterMap; + CustomParameterMap mCustomParameters; + bool mPolygonModeOverrideable; + bool mUseIdentityProjection; + bool mUseIdentityView; + }; + + + +} + +#endif //__Renderable_H__ diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreResource.h b/school/informatik/verkerhssimulation/src/ogre/OgreResource.h new file mode 100644 index 00000000..4e4c496f --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreResource.h @@ -0,0 +1,415 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _Resource_H__ +#define _Resource_H__ + +#include "OgrePrerequisites.h" +#include "OgreString.h" +#include "OgreSharedPtr.h" +#include "OgreStringInterface.h" + +namespace Ogre { + + typedef unsigned long ResourceHandle; + + + // Forward declaration + class ManualResourceLoader; + + /** Abstract class reprensenting a loadable resource (e.g. textures, sounds etc) + @remarks + Resources are data objects that must be loaded and managed throughout + an application. A resource might be a mesh, a texture, or any other + piece of data - the key thing is that they must be identified by + a name which is unique, must be loaded only once, + must be managed efficiently in terms of retrieval, and they may + also be unloadable to free memory up when they have not been used for + a while and the memory budget is under stress. + @par + All Resource instances must be a member of a resource group; see + ResourceGroupManager for full details. + @par + Subclasses must implement: +
    +
  1. A constructor, overriding the same parameters as the constructor + defined by this class. Subclasses are not allowed to define + constructors with other parameters; other settings must be + settable through accessor methods before loading.
  2. +
  3. The loadImpl() and unloadImpl() methods - mSize must be set + after loadImpl()
  4. +
  5. StringInterface ParamCommand and ParamDictionary setups + in order to allow setting of core parameters (prior to load) + through a generic interface.
  6. +
+ */ + class _OgreExport Resource : public StringInterface + { + public: + OGRE_AUTO_MUTEX // public to allow external locking + class Listener + { + public: + Listener() {} + virtual ~Listener() {} + + /** Callback to indicate that background loading has completed. + @remarks + This callback is only relevant when a Resource has been + marked as background loaded (@see Resource::setBackgroundLoaded) + , and occurs when that loading has completed. The call itself + does not itself occur in the thread which is doing the loading; + when loading is complete a response indicator is placed with the + ResourceGroupManager, which will then be sent back to the + listener as part of the application's primary frame loop thread. + */ + virtual void backgroundLoadingComplete(Resource*) {} + + }; + + /// Enum identifying the loading state of the resource + enum LoadingState + { + /// Not loaded + LOADSTATE_UNLOADED, + /// Loading is in progress + LOADSTATE_LOADING, + /// Fully loaded + LOADSTATE_LOADED, + /// Currently unloading + LOADSTATE_UNLOADING + }; + protected: + /// Creator + ResourceManager* mCreator; + /// Unique name of the resource + String mName; + /// The name of the resource group + String mGroup; + /// Numeric handle for more efficient look up than name + ResourceHandle mHandle; + /// Is the resource currently loaded? + volatile LoadingState mLoadingState; + /// Is this resource going to be background loaded? Only applicable for multithreaded + volatile bool mIsBackgroundLoaded; + /// Mutex to cover the status of loading + OGRE_MUTEX(mLoadingStatusMutex) + /// The size of the resource in bytes + size_t mSize; + /// Is this file manually loaded? + bool mIsManual; + /// Origin of this resource (e.g. script name) - optional + String mOrigin; + /// Optional manual loader; if provided, data is loaded from here instead of a file + ManualResourceLoader* mLoader; + + typedef std::list ListenerList; + ListenerList mListenerList; + + /** Protected unnamed constructor to prevent default construction. + */ + Resource() + : mCreator(0), mHandle(0), mLoadingState(LOADSTATE_UNLOADED), + mIsBackgroundLoaded(false), mSize(0), mIsManual(0), mLoader(0) + { + } + + /** Internal hook to perform actions before the load process, but + after the resource has been marked as 'loading'. + @note Mutex will have already been acquired by the loading thread. + Also, this call will occur even when using a ManualResourceLoader + (when loadImpl is not actually called) + */ + virtual void preLoadImpl(void) {} + /** Internal hook to perform actions after the load process, but + before the resource has been marked as fully loaded. + @note Mutex will have already been acquired by the loading thread. + Also, this call will occur even when using a ManualResourceLoader + (when loadImpl is not actually called) + */ + virtual void postLoadImpl(void) {} + + /** Internal hook to perform actions before the unload process. + @note Mutex will have already been acquired by the unloading thread. + */ + virtual void preUnloadImpl(void) {} + /** Internal hook to perform actions after the unload process, but + before the resource has been marked as fully unloaded. + @note Mutex will have already been acquired by the unloading thread. + */ + virtual void postUnloadImpl(void) {} + + /** Internal implementation of the meat of the 'load' action, only called if this + resource is not being loaded from a ManualResourceLoader. + */ + virtual void loadImpl(void) = 0; + /** Internal implementation of the 'unload' action; called regardless of + whether this resource is being loaded from a ManualResourceLoader. + */ + virtual void unloadImpl(void) = 0; + /** Calculate the size of a resource; this will only be called after 'load' */ + virtual size_t calculateSize(void) const = 0; + + /// Queue the firing of background loading complete event + virtual void queueFireBackgroundLoadingComplete(void); + + public: + /** Standard constructor. + @param creator Pointer to the ResourceManager that is creating this resource + @param name The unique name of the resource + @param group The name of the resource group to which this resource belongs + @param isManual Is this resource manually loaded? If so, you should really + populate the loader parameter in order that the load process + can call the loader back when loading is required. + @param loader Pointer to a ManualResourceLoader implementation which will be called + when the Resource wishes to load (should be supplied if you set + isManual to true). You can in fact leave this parameter null + if you wish, but the Resource will never be able to reload if + anything ever causes it to unload. Therefore provision of a proper + ManualResourceLoader instance is strongly recommended. + */ + Resource(ResourceManager* creator, const String& name, ResourceHandle handle, + const String& group, bool isManual = false, ManualResourceLoader* loader = 0); + + /** Virtual destructor. Shouldn't need to be overloaded, as the resource + deallocation code should reside in unload() + @see + Resource::unload() + */ + virtual ~Resource(); + + /** Loads the resource, if it is not already. + @remarks + If the resource is loaded from a file, loading is automatic. If not, + if for example this resource gained it's data from procedural calls + rather than loading from a file, then this resource will not reload + on it's own. + @param backgroundThread Indicates whether the caller of this method is + the background resource loading thread. + + */ + virtual void load(bool backgroundThread = false); + + /** Reloads the resource, if it is already loaded. + @remarks + Calls unload() and then load() again, if the resource is already + loaded. If it is not loaded already, then nothing happens. + */ + virtual void reload(void); + + /** Returns true if the Resource is reloadable, false otherwise. + */ + bool isReloadable(void) const + { + return !mIsManual || mLoader; + } + + /** Is this resource manually loaded? + */ + bool isManuallyLoaded(void) const + { + return mIsManual; + } + + /** Unloads the resource; this is not permanent, the resource can be + reloaded later if required. + */ + virtual void unload(void); + + /** Retrieves info about the size of the resource. + */ + size_t getSize(void) const + { + return mSize; + } + + /** 'Touches' the resource to indicate it has been used. + */ + virtual void touch(void); + + /** Gets resource name. + */ + const String& getName(void) const + { + return mName; + } + + ResourceHandle getHandle(void) const + { + return mHandle; + } + + /** Returns true if the Resource has been loaded, false otherwise. + */ + bool isLoaded(void) const + { + // No lock required to read this state since no modify + return (mLoadingState == LOADSTATE_LOADED); + } + + /** Returns whether the resource is currently in the process of + background loading. + */ + LoadingState isLoading() const + { + return mLoadingState; + } + + /** Returns the current loading state. + */ + LoadingState getLoadingState() const + { + return mLoadingState; + } + + + + /** Returns whether this Resource has been earmarked for background loading. + @remarks + This option only makes sense when you have built Ogre with + thread support (OGRE_THREAD_SUPPORT). If a resource has been marked + for background loading, then it won't load on demand like normal + when load() is called. Instead, it will ignore request to load() + except if the caller indicates it is the background loader. Any + other users of this resource should check isLoaded(), and if that + returns false, don't use the resource and come back later. + */ + bool isBackgroundLoaded(void) const { return mIsBackgroundLoaded; } + + /** Tells the resource whether it is background loaded or not. + @remarks + @see Resource::isBackgroundLoaded . Note that calling this only + defers the normal on-demand loading behaviour of a resource, it + does not actually set up a thread to make sure the resource gets + loaded in the background. You should use ResourceBackgroundLoadingQueue + to manage the actual loading (which will call this method itself). + */ + void setBackgroundLoaded(bool bl) { mIsBackgroundLoaded = bl; } + + /** Escalates the loading of a background loaded resource. + @remarks + If a resource is set to load in the background, but something needs + it before it's been loaded, there could be a problem. If the user + of this resource really can't wait, they can escalate the loading + which basically pulls the loading into the current thread immediately. + If the resource is already being loaded but just hasn't quite finished + then this method will simply wait until the background load is complete. + */ + void escalateLoading(); + + /** Register a listener on this resource. + @see Resource::Listener + */ + void addListener(Listener* lis); + + /** Remove a listener on this resource. + @see Resource::Listener + */ + void removeListener(Listener* lis); + + /// Gets the group which this resource is a member of + const String& getGroup(void) { return mGroup; } + + /** Change the resource group ownership of a Resource. + @remarks + This method is generally reserved for internal use, although + if you really know what you're doing you can use it to move + this resource from one group to another. + @param newGroup Name of the new group + */ + void changeGroupOwnership(const String& newGroup); + + /// Gets the manager which created this resource + ResourceManager* getCreator(void) { return mCreator; } + /** Get the origin of this resource, e.g. a script file name. + @remarks + This property will only contain something if the creator of + this resource chose to populate it. Script loaders are advised + to populate it. + */ + const String& getOrigin(void) const { return mOrigin; } + /// Notify this resource of it's origin + void _notifyOrigin(const String& origin) { mOrigin = origin; } + + }; + + /** Shared pointer to a Resource. + @remarks + This shared pointer allows many references to a resource to be held, and + when the final reference is removed, the resource will be destroyed. + Note that the ResourceManager which created this Resource will be holding + at least one reference, so this resource will not get destroyed until + someone removes the resource from the manager - this at least gives you + strong control over when resources are freed. But the nature of the + shared pointer means that if anyone refers to the removed resource in the + meantime, the resource will remain valid. + @par + You may well see references to ResourcePtr (i.e. ResourcePtr&) being passed + around internally within Ogre. These are 'weak references' ie they do + not increment the reference count on the Resource. This is done for + efficiency in temporary operations that shouldn't need to incur the + overhead of maintaining the reference count; however we don't recommend + you do it yourself since these references are not guaranteed to remain valid. + */ + typedef SharedPtr ResourcePtr; + + /** Interface describing a manual resource loader. + @remarks + Resources are usually loaded from files; however in some cases you + want to be able to set the data up manually instead. This provides + some problems, such as how to reload a Resource if it becomes + unloaded for some reason, either because of memory constraints, or + because a device fails and some or all of the data is lost. + @par + This interface should be implemented by all classes which wish to + provide manual data to a resource. They provide a pointer to themselves + when defining the resource (via the appropriate ResourceManager), + and will be called when the Resource tries to load. + They should implement the loadResource method such that the Resource + is in the end set up exactly as if it had loaded from a file, + although the implementations will likely differ between subclasses + of Resource, which is why no generic algorithm can be stated here. + @note + The loader must remain valid for the entire life of the resource, + so that if need be it can be called upon to re-load the resource + at any time. + */ + class _OgreExport ManualResourceLoader + { + public: + ManualResourceLoader() {} + virtual ~ManualResourceLoader() {} + + /** Called when a resource wishes to load. + @param resource The resource which wishes to load + */ + virtual void loadResource(Resource* resource) = 0; + }; +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreResourceBackgroundQueue.h b/school/informatik/verkerhssimulation/src/ogre/OgreResourceBackgroundQueue.h new file mode 100644 index 00000000..f9dc0a31 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreResourceBackgroundQueue.h @@ -0,0 +1,456 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ResourceBackgroundQueue_H__ +#define __ResourceBackgroundQueue_H__ + + +#include "OgrePrerequisites.h" +#include "OgreCommon.h" +#include "OgreSingleton.h" +#include "OgreResource.h" + +#if OGRE_THREAD_SUPPORT +# include +# include +#endif + +namespace Ogre { + + /// Identifier of a background process + typedef unsigned long BackgroundProcessTicket; + + /** This class is used to perform Resource operations in a + background thread. + @remarks + If threading is enabled, Ogre will create a single background thread + which can be used to load / unload resources in parallel. Only one + resource will be processed at once in this background thread, but it + will be in parallel with the main thread. + @par + The general approach here is that on requesting a background resource + process, your request is placed on a queue ready for the background + thread to be picked up, and you will get a 'ticket' back, identifying + the request. Your call will then return and your thread can + proceed, knowing that at some point in the background the operation wil + be performed. In it's own thread, the resource operation will be + performed, and once finished the ticket will be marked as complete. + You can check the status of tickets by calling isProcessComplete() + from your queueing thread. It is also possible to get immediate + callbacks on completion, but these callbacks happen in the background + loading thread (not your calling thread), so should only be used if you + really understand multithreading. + @par + By default, when threading is enabled this class will start its own + separate thread to perform the actual loading. However, if you would + prefer to use your own existing thread to perform the background load, + then be sure to call setStartBackgroundThread(false) before initialise() is + called by Root::initialise. Your own thread should call _initThread + immediately on startup, before any resources are loaded at all, and + _doNextQueuedBackgroundProcess to process background requests. + @note + This class will only perform tasks in a background thread if + OGRE_THREAD_SUPPORT is defined to be 1. Otherwise, all methods will + call their exact equivalents in ResourceGroupManager synchronously. + */ + class _OgreExport ResourceBackgroundQueue : public Singleton + { + public: + /** This abstract listener interface lets you get notifications of + completed background processes instead of having to poll ticket + statuses. + @note + For simplicity, these callbacks are not issued direct from the background + loading thread, they are queued themselves to be sent from the main thread + so that you don't have to be concerned about thread safety. + */ + class _OgreExport Listener + { + public: + /** Called when a requested operation completes, queued into main thread. + @note + For simplicity, this callback is not issued direct from the background + loading thread, it is queued to be sent from the main thread + so that you don't have to be concerned about thread safety. + */ + virtual void operationCompleted(BackgroundProcessTicket ticket) = 0; + /** Called when a requested operation completes, immediate in background thread. + @note + This is the advanced version of the background operation notification, + it happens immediately when the background operation is completed, and + your callback is executed in the background thread. Therefore if + you use this version, you have to be aware of thread safety issues + and what you can and cannot do in your callback implementation. + */ + virtual void operationCompletedInThread(BackgroundProcessTicket ticket) {} + /// Need virtual destructor in case subclasses use it + virtual ~Listener() {} + + }; + /// Init notification mutex (must lock before waiting on initCondition) + OGRE_MUTEX(initMutex) + /// Synchroniser token to wait / notify on thread init (public incase external thread) + OGRE_THREAD_SYNCHRONISER(initSync); + + protected: + /** Enumerates the type of requests */ + enum RequestType + { + RT_INITIALISE_GROUP, + RT_INITIALISE_ALL_GROUPS, + RT_LOAD_GROUP, + RT_LOAD_RESOURCE, + RT_UNLOAD_GROUP, + RT_UNLOAD_RESOURCE, + RT_SHUTDOWN + }; + /** Encapsulates a queued request for the background queue */ + struct Request + { + BackgroundProcessTicket ticketID; + RequestType type; + String resourceName; + ResourceHandle resourceHandle; + String resourceType; + String groupName; + bool isManual; + ManualResourceLoader* loader; + const NameValuePairList* loadParams; + Listener* listener; + }; + typedef std::list RequestQueue; + typedef std::map RequestTicketMap; + + /// Queue of requests, used to store and order requests + RequestQueue mRequestQueue; + + /// Request lookup by ticket + RequestTicketMap mRequestTicketMap; + + /// Next ticket ID + unsigned long mNextTicketID; + + /// Struct that holds details of queued notifications + struct QueuedNotification + { + QueuedNotification(Resource::Listener* l, Resource* r) + : resourceListener(l), resource(r), opListener(0), ticket(0) + {} + + QueuedNotification(Listener* l, BackgroundProcessTicket t) + : resourceListener(0), resource(0), opListener(l), ticket(t) + {} + + // Type 1 - Resource::Listener kind + Resource::Listener* resourceListener; + Resource* resource; + // Type 2 - ResourceBackgroundQueue::Listener kind + Listener* opListener; + BackgroundProcessTicket ticket; + }; + typedef std::list NotificationQueue; + /// Queued notifications of background loading being finished + NotificationQueue mNotificationQueue; + /// Mutex to protect the background event queue] + OGRE_MUTEX(mNotificationQueueMutex) + + /// Whether this class should start it's own thread or not + bool mStartThread; + +#if OGRE_THREAD_SUPPORT + /// The single background thread which will process loading requests + boost::thread* mThread; + /// Synchroniser token to wait / notify on queue + boost::condition mCondition; + /// Thread function + static void threadFunc(void); + /// Internal method for adding a request; also assigns a ticketID + BackgroundProcessTicket addRequest(Request& req); + /// Thread shutdown? + bool mShuttingDown; +#else + /// Dummy + void* mThread; +#endif + + /// Private mutex, not allowed to lock from outside + OGRE_AUTO_MUTEX + + /** Queue the firing of the 'background loading complete' event to + a Resource::Listener event. + @remarks + The purpose of this is to allow the background loading thread to + call this method to queue the notification to listeners waiting on + the background loading of a resource. Rather than allow the resource + background loading thread to directly call these listeners, which + would require all the listeners to be thread-safe, this method + implements a thread-safe queue which can be processed in the main + frame loop thread each frame to clear the events in a simpler + manner. + @param listener The listener to be notified + @param ticket The ticket for the operation that has completed + */ + virtual void queueFireBackgroundOperationComplete(Listener* listener, + BackgroundProcessTicket ticket); + + public: + ResourceBackgroundQueue(); + virtual ~ResourceBackgroundQueue(); + + /** Sets whether or not a thread should be created and started to handle + the background loading, or whether a user thread will call the + appropriate hooks. + @remarks + By default, a new thread will be started to handle the background + load requests. However, the application may well have some threads + of its own which is wishes to use to perform the background loading + as well as other tasks (for example on most platforms there will be + a fixed number of hardware threads which the application will wish + to work within). Use this method to turn off the creation of a separate + thread if you wish, and call the _doNextQueuedBackgroundProcess + method from your own thread to process background requests. + @note + You must call this method prior to initialisation. Initialisation + of this class is automatically done when Root::initialise is called. + */ + void setStartBackgroundThread(bool startThread) { mStartThread = startThread; } + + /** Gets whether or not a thread should be created and started to handle + the background loading, or whether a user thread will call the + appropriate hooks. + */ + bool getStartBackgroundThread(void) { return mStartThread; } + /** Initialise the background queue system. + @note Called automatically by Root::initialise. + */ + virtual void initialise(void); + + /** Shut down the background queue system. + @note Called automatically by Root::shutdown. + */ + virtual void shutdown(void); + + /** Initialise a resource group in the background. + @see ResourceGroupManager::initialiseResourceGroup + @param name The name of the resource group to initialise + @param listener Optional callback interface, take note of warnings in + the header and only use if you understand them. + @returns Ticket identifying the request, use isProcessComplete() to + determine if completed if not using listener + */ + virtual BackgroundProcessTicket initialiseResourceGroup( + const String& name, Listener* listener = 0); + + /** Initialise all resource groups which are yet to be initialised in + the background. + @see ResourceGroupManager::intialiseResourceGroup + @param listener Optional callback interface, take note of warnings in + the header and only use if you understand them. + @returns Ticket identifying the request, use isProcessComplete() to + determine if completed if not using listener + */ + virtual BackgroundProcessTicket initialiseAllResourceGroups( + Listener* listener = 0); + /** Loads a resource group in the background. + @see ResourceGroupManager::loadResourceGroup + @param name The name of the resource group to load + @param listener Optional callback interface, take note of warnings in + the header and only use if you understand them. + @returns Ticket identifying the request, use isProcessComplete() to + determine if completed if not using listener + */ + virtual BackgroundProcessTicket loadResourceGroup(const String& name, + Listener* listener = 0); + + + /** Unload a single resource in the background. + @see ResourceManager::unload + @param resType The type of the resource + (from ResourceManager::getResourceType()) + @param name The name of the Resource + */ + virtual BackgroundProcessTicket unload( + const String& resType, const String& name, + Listener* listener = 0); + + /** Unload a single resource in the background. + @see ResourceManager::unload + @param resType The type of the resource + (from ResourceManager::getResourceType()) + @param handle Handle to the resource + */ + virtual BackgroundProcessTicket unload( + const String& resType, ResourceHandle handle, + Listener* listener = 0); + + /** Unloads a resource group in the background. + @see ResourceGroupManager::unloadResourceGroup + @param name The name of the resource group to load + @returns Ticket identifying the request, use isProcessComplete() to + determine if completed if not using listener + */ + virtual BackgroundProcessTicket unloadResourceGroup(const String& name, + Listener* listener = 0); + + + /** Load a single resource in the background. + @see ResourceManager::load + @param resType The type of the resource + (from ResourceManager::getResourceType()) + @param name The name of the Resource + @param group The resource group to which this resource will belong + @param isManual Is the resource to be manually loaded? If so, you should + provide a value for the loader parameter + @param loader The manual loader which is to perform the required actions + when this resource is loaded; only applicable when you specify true + for the previous parameter. NOTE: must be thread safe!! + @param loadParams Optional pointer to a list of name/value pairs + containing loading parameters for this type of resource. Remember + that this must have a lifespan longer than the return of this call! + */ + virtual BackgroundProcessTicket load( + const String& resType, const String& name, + const String& group, bool isManual = false, + ManualResourceLoader* loader = 0, + const NameValuePairList* loadParams = 0, + Listener* listener = 0); + /** Returns whether a previously queued process has completed or not. + @remarks + This method of checking that a background process has completed is + the 'polling' approach. Each queued method takes an optional listener + parameter to allow you to register a callback instead, which is + arguably more efficient. + @param ticket The ticket which was returned when the process was queued + @returns true if process has completed (or if the ticket is + unrecognised), false otherwise + @note Tickets are not stored onced complete so do not accumulate over + time. + This is why a non-existent ticket will return 'true'. + */ + virtual bool isProcessComplete(BackgroundProcessTicket ticket); + + /** Process a single queued background operation. + @remarks + If you are using your own thread to perform background loading, calling + this method from that thread triggers the processing of a single + background loading request from the queue. This method will not + return until the request has been fully processed. It also returns + whether it did in fact process anything - if it returned false, there + was nothing more in the queue. + @note + Do not call this method unless you are using your own thread + to perform the background loading and called setStartBackgroundThread(false). + You must only have one background loading thread. + @returns true if a request was processed, false if the queue was empty. + */ + bool _doNextQueuedBackgroundProcess(); + + /** Initialise processing for a background thread. + @remarks + You must call this method if you use your own thread rather than + letting this class create its own. Moreover, you must call it after + initialise() and after you've started your own thread, but before + any resources have been loaded. There are some + per-thread tasks which have to be performed on some rendering APIs + and it's important that they are done before rendering resources are + created. + @par + You must call this method in your own background thread, not the main + thread. It's important to block the main thread whilst this initialisation + is happening, use an OGRE_THREAD_WAIT on the public initSync token + after locking the initMutex. + */ + void _initThread(); + + /** Queue the firing of the 'background loading complete' event to + a Resource::Listener event. + @remarks + The purpose of this is to allow the background loading thread to + call this method to queue the notification to listeners waiting on + the background loading of a resource. Rather than allow the resource + background loading thread to directly call these listeners, which + would require all the listeners to be thread-safe, this method + implements a thread-safe queue which can be processed in the main + frame loop thread each frame to clear the events in a simpler + manner. + @param listener The listener to be notified + @param res The resource listened on + */ + virtual void _queueFireBackgroundLoadingComplete(Resource::Listener* listener, + Resource* res); + + /** Fires all the queued events for background loaded resources. + @remarks + You should call this from the thread that runs the main frame loop + to avoid having to make the receivers of this event thread-safe. + If you use Ogre's built in frame loop you don't need to call this + yourself. + */ + virtual void _fireBackgroundLoadingComplete(void); + + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static ResourceBackgroundQueue& getSingleton(void); + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static ResourceBackgroundQueue* getSingletonPtr(void); + + + }; + + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreResourceGroupManager.h b/school/informatik/verkerhssimulation/src/ogre/OgreResourceGroupManager.h new file mode 100644 index 00000000..7bf05c8c --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreResourceGroupManager.h @@ -0,0 +1,858 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _ResourceGroupManager_H__ +#define _ResourceGroupManager_H__ + +#include "OgrePrerequisites.h" +#include "OgreSingleton.h" +#include "OgreCommon.h" +#include "OgreDataStream.h" +#include "OgreResource.h" +#include "OgreArchive.h" +#include "OgreIteratorWrappers.h" + +namespace Ogre { + + /** This abstract class defines an interface which is called back during + resource group loading to indicate the progress of the load. + @remarks + Resource group loading is in 2 phases - creating resources from + declarations (which includes parsing scripts), and loading + resources. Note that you don't necessarily have to have both; it + is quite possible to just parse all the scripts for a group (see + ResourceGroupManager::initialiseResourceGroup, but not to + load the resource group. + The sequence of events is (* signifies a repeating item): +
    +
  • resourceGroupScriptingStarted
  • +
  • scriptParseStarted (*)
  • +
  • scriptParseEnded (*)
  • +
  • resourceGroupScriptingEnded
  • +
  • resourceGroupLoadStarted
  • +
  • resourceLoadStarted (*)
  • +
  • resourceLoadEnded (*)
  • +
  • worldGeometryStageStarted (*)
  • +
  • worldGeometryStageEnded (*)
  • +
  • resourceGroupLoadEnded
  • +
+ @note + If OGRE_THREAD_SUPPORT is 1, this class is thread-safe. + + */ + class _OgreExport ResourceGroupListener + { + public: + virtual ~ResourceGroupListener() {} + + /** This event is fired when a resource group begins parsing scripts. + @note + Remember that if you are loading resources through ResourceBackgroundQueue, + these callbacks will occur in the background thread, so you should + not perform any thread-unsafe actions in this callback if that's the + case (check the group name / script name). + @param groupName The name of the group + @param scriptCount The number of scripts which will be parsed + */ + virtual void resourceGroupScriptingStarted(const String& groupName, size_t scriptCount) = 0; + /** This event is fired when a script is about to be parsed. + @param scriptName Name of the to be parsed + */ + virtual void scriptParseStarted(const String& scriptName) = 0; + /** This event is fired when the script has been fully parsed. + */ + virtual void scriptParseEnded(const String& scriptName) = 0; + /** This event is fired when a resource group finished parsing scripts. */ + virtual void resourceGroupScriptingEnded(const String& groupName) = 0; + + /** This event is fired when a resource group begins loading. + @param groupName The name of the group being loaded + @param resourceCount The number of resources which will be loaded, including + a number of stages required to load any linked world geometry + */ + virtual void resourceGroupLoadStarted(const String& groupName, size_t resourceCount) = 0; + /** This event is fired when a declared resource is about to be loaded. + @param resource Weak reference to the resource loaded. + */ + virtual void resourceLoadStarted(const ResourcePtr& resource) = 0; + /** This event is fired when the resource has been loaded. + */ + virtual void resourceLoadEnded(void) = 0; + /** This event is fired when a stage of loading linked world geometry + is about to start. The number of stages required will have been + included in the resourceCount passed in resourceGroupLoadStarted. + @param description Text description of what was just loaded + */ + virtual void worldGeometryStageStarted(const String& description) = 0; + /** This event is fired when a stage of loading linked world geometry + has been completed. The number of stages required will have been + included in the resourceCount passed in resourceGroupLoadStarted. + @param description Text description of what was just loaded + */ + virtual void worldGeometryStageEnded(void) = 0; + + /** This event is fired when a resource group finished loading. */ + virtual void resourceGroupLoadEnded(const String& groupName) = 0; + + }; + /** This singleton class manages the list of resource groups, and notifying + the various resource managers of their obligations to load / unload + resources in a group. It also provides facilities to monitor resource + loading per group (to do progress bars etc), provided the resources + that are required are pre-registered. + @par + Defining new resource groups, and declaring the resources you intend to + use in advance is optional, however it is a very useful feature. In addition, + if a ResourceManager supports the definition of resources through scripts, + then this is the class which drives the locating of the scripts and telling + the ResourceManager to parse them. + @par + There are several states that a resource can be in (the concept, not the + object instance in this case): +
    +
  1. Undefined. Nobody knows about this resource yet. It might be + in the filesystem, but Ogre is oblivious to it at the moment - there + is no Resource instance. This might be because it's never been declared + (either in a script, or using ResourceGroupManager::declareResource), or + it may have previously been a valid Resource instance but has been + removed, either individually through ResourceManager::remove or as a group + through ResourceGroupManager::clearResourceGroup.
  2. +
  3. Declared. Ogre has some forewarning of this resource, either + through calling ResourceGroupManager::declareResource, or by declaring + the resource in a script file which is on one of the resource locations + which has been defined for a group. There is still no instance of Resource, + but Ogre will know to create this resource when + ResourceGroupManager::initialiseResourceGroup is called (which is automatic + if you declare the resource group before Root::initialise).
  4. +
  5. Unloaded. There is now a Resource instance for this resource, + although it is not loaded. This means that code which looks for this + named resource will find it, but the Resource is not using a lot of memory + because it is in an unloaded state. A Resource can get into this state + by having just been created by ResourceGroupManager::initialiseResourceGroup + (either from a script, or from a call to declareResource), by + being created directly from code (ResourceManager::create), or it may + have previously been loaded and has been unloaded, either individually + through Resource::unload, or as a group through ResourceGroupManager::unloadResourceGroup.
  6. +
  7. LoadedThe Resource instance is fully loaded. This may have + happened implicitly because something used it, or it may have been + loaded as part of a group.
  8. +
+ @see ResourceGroupManager::declareResource + @see ResourceGroupManager::initialiseResourceGroup + @see ResourceGroupManager::loadResourceGroup + @see ResourceGroupManager::unloadResourceGroup + @see ResourceGroupManager::clearResourceGroup + */ + class _OgreExport ResourceGroupManager : public Singleton + { + public: + OGRE_AUTO_MUTEX // public to allow external locking + /// Default resource group name + static String DEFAULT_RESOURCE_GROUP_NAME; + /// Internal resource group name (should be used by OGRE internal only) + static String INTERNAL_RESOURCE_GROUP_NAME; + /// Bootstrap resource group name (min OGRE resources) + static String BOOTSTRAP_RESOURCE_GROUP_NAME; + /// Special resource group name which causes resource group to be automatically determined based on searching for the resource in all groups. + static String AUTODETECT_RESOURCE_GROUP_NAME; + /// The number of reference counts held per resource by the resource system + static size_t RESOURCE_SYSTEM_NUM_REFERENCE_COUNTS; + /// Nested struct defining a resource declaration + struct ResourceDeclaration + { + String resourceName; + String resourceType; + ManualResourceLoader* loader; + NameValuePairList parameters; + }; + /// List of resource declarations + typedef std::list ResourceDeclarationList; + typedef std::map ResourceManagerMap; + typedef MapIterator ResourceManagerIterator; + protected: + /// Map of resource types (strings) to ResourceManagers, used to notify them to load / unload group contents + ResourceManagerMap mResourceManagerMap; + + /// Map of loading order (Real) to ScriptLoader, used to order script parsing + typedef std::multimap ScriptLoaderOrderMap; + ScriptLoaderOrderMap mScriptLoaderOrderMap; + + typedef std::vector ResourceGroupListenerList; + ResourceGroupListenerList mResourceGroupListenerList; + + /// Resource index entry, resourcename->location + typedef std::map ResourceLocationIndex; + + /// Resource location entry + struct ResourceLocation + { + /// Pointer to the archive which is the destination + Archive* archive; + /// Whether this location was added recursively + bool recursive; + }; + /// List of possible file locations + typedef std::list LocationList; + /// List of resources which can be loaded / unloaded + typedef std::list LoadUnloadResourceList; + /// Resource group entry + struct ResourceGroup + { + enum Status + { + UNINITIALSED = 0, + INITIALISING = 1, + INITIALISED = 2, + LOADING = 3, + LOADED = 4 + }; + /// General mutex for dealing with group content + OGRE_AUTO_MUTEX + /// Status-specific mutex, separate from content-changing mutex + OGRE_MUTEX(statusMutex) + /// Group name + String name; + /// Group status + bool initialised; + /// List of possible locations to search + LocationList locationList; + /// Index of resource names to locations, built for speedy access (case sensitive archives) + ResourceLocationIndex resourceIndexCaseSensitive; + /// Index of resource names to locations, built for speedy access (case insensitive archives) + ResourceLocationIndex resourceIndexCaseInsensitive; + /// Pre-declared resources, ready to be created + ResourceDeclarationList resourceDeclarations; + /// Created resources which are ready to be loaded / unloaded + // Group by loading order of the type (defined by ResourceManager) + // (e.g. skeletons and materials before meshes) + typedef std::map LoadResourceOrderMap; + LoadResourceOrderMap loadResourceOrderMap; + /// Linked world geometry, as passed to setWorldGeometry + String worldGeometry; + /// Scene manager to use with linked world geometry + SceneManager* worldGeometrySceneManager; + }; + /// Map from resource group names to groups + typedef std::map ResourceGroupMap; + ResourceGroupMap mResourceGroupMap; + + /// Group name for world resources + String mWorldGroupName; + + /** Parses all the available scripts found in the resource locations + for the given group, for all ResourceManagers. + @remarks + Called as part of initialiseResourceGroup + */ + void parseResourceGroupScripts(ResourceGroup* grp); + /** Create all the pre-declared resources. + @remarks + Called as part of initialiseResourceGroup + */ + void createDeclaredResources(ResourceGroup* grp); + /** Adds a created resource to a group. */ + void addCreatedResource(ResourcePtr& res, ResourceGroup& group); + /** Get resource group */ + ResourceGroup* getResourceGroup(const String& name); + /** Drops contents of a group, leave group there, notify ResourceManagers. */ + void dropGroupContents(ResourceGroup* grp); + /** Delete a group for shutdown - don't notify ResourceManagers. */ + void deleteGroup(ResourceGroup* grp); + /// Internal find method for auto groups + ResourceGroup* findGroupContainingResourceImpl(const String& filename); + /// Internal event firing method + void fireResourceGroupScriptingStarted(const String& groupName, size_t scriptCount); + /// Internal event firing method + void fireScriptStarted(const String& scriptName); + /// Internal event firing method + void fireScriptEnded(const String& scriptName); + /// Internal event firing method + void fireResourceGroupScriptingEnded(const String& groupName); + /// Internal event firing method + void fireResourceGroupLoadStarted(const String& groupName, size_t resourceCount); + /// Internal event firing method + void fireResourceStarted(const ResourcePtr& resource); + /// Internal event firing method + void fireResourceEnded(void); + /// Internal event firing method + void fireResourceGroupLoadEnded(const String& groupName); + + + + /// Stored current group - optimisation for when bulk loading a group + ResourceGroup* mCurrentGroup; + public: + ResourceGroupManager(); + virtual ~ResourceGroupManager(); + + /** Create a resource group. + @remarks + A resource group allows you to define a set of resources that can + be loaded / unloaded as a unit. For example, it might be all the + resources used for the level of a game. There is always one predefined + resource group called ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, + which is typically used to hold all resources which do not need to + be unloaded until shutdown. There is another predefined resource + group called ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME too, + which should be used by OGRE internal only, the resources created + in this group aren't supposed to modify, unload or remove by user. + You can create additional ones so that you can control the life of + your resources in whichever way you wish. + There is one other predefined value, + ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME; using this + causes the group name to be derived at load time by searching for + the resource in the resource locations of each group in turn. + @par + Once you have defined a resource group, resources which will be loaded + as part of it are defined in one of 3 ways: +
    +
  1. Manually through declareResource(); this is useful for scripted + declarations since it is entirely generalised, and does not + create Resource instances right away
  2. +
  3. Through the use of scripts; some ResourceManager subtypes have + script formats (e.g. .material, .overlay) which can be used + to declare resources
  4. +
  5. By calling ResourceManager::create to create a resource manually. + This resource will go on the list for it's group and will be loaded + and unloaded with that group
  6. +
+ You must remember to call initialiseResourceGroup if you intend to use + the first 2 types. + @param name The name to give the resource group. + */ + void createResourceGroup(const String& name); + + + /** Initialises a resource group. + @remarks + After creating a resource group, adding some resource locations, and + perhaps pre-declaring some resources using declareResource(), but + before you need to use the resources in the group, you + should call this method to initialise the group. By calling this, + you are triggering the following processes: +
    +
  1. Scripts for all resource types which support scripting are + parsed from the resource locations, and resources within them are + created (but not loaded yet).
  2. +
  3. Creates all the resources which have just pre-declared using + declareResource (again, these are not loaded yet)
  4. +
+ So what this essentially does is create a bunch of unloaded Resource entries + in the respective ResourceManagers based on scripts, and resources + you've pre-declared. That means that code looking for these resources + will find them, but they won't be taking up much memory yet, until + they are either used, or they are loaded in bulk using loadResourceGroup. + Loading the resource group in bulk is entirely optional, but has the + advantage of coming with progress reporting as resources are loaded. + @par + Failure to call this method means that loadResourceGroup will do + nothing, and any resources you define in scripts will not be found. + Similarly, once you have called this method you won't be able to + pick up any new scripts or pre-declared resources, unless you + call clearResourceGroup, set up declared resources, and call this + method again. + @note + When you call Root::initialise, all resource groups that have already been + created are automatically initialised too. Therefore you do not need to + call this method for groups you define and set up before you call + Root::initialise. However, since one of the most useful features of + resource groups is to set them up after the main system initialisation + has occurred (e.g. a group per game level), you must remember to call this + method for the groups you create after this. + + @param name The name of the resource group to initialise + */ + void initialiseResourceGroup(const String& name); + + /** Initialise all resource groups which are yet to be initialised. + @see ResourceGroupManager::intialiseResourceGroup + */ + void initialiseAllResourceGroups(void); + + /** Loads a resource group. + @remarks + Loads any created resources which are part of the named group. + Note that resources must have already been created by calling + ResourceManager::create, or declared using declareResource() or + in a script (such as .material and .overlay). The latter requires + that initialiseResourceGroup has been called. + + When this method is called, this class will callback any ResourceGroupListeners + which have been registered to update them on progress. + @param name The name to of the resource group to load. + @param loadMainResources If true, loads normal resources associated + with the group (you might want to set this to false if you wanted + to just load world geometry in bulk) + @param loadWorldGeom If true, loads any linked world geometry + @see ResourceGroupManager::linkWorldGeometryToResourceGroup + */ + void loadResourceGroup(const String& name, bool loadMainResources = true, + bool loadWorldGeom = true); + + /** Unloads a resource group. + @remarks + This method unloads all the resources that have been declared as + being part of the named resource group. Note that these resources + will still exist in their respective ResourceManager classes, but + will be in an unloaded state. If you want to remove them entirely, + you should use clearResourceGroup or destroyResourceGroup. + @param name The name to of the resource group to unload. + @param reloadableOnly If set to true, only unload the resource that is + reloadable. Because some resources isn't reloadable, they will be + unloaded but can't load them later. Thus, you might not want to them + unloaded. Or, you might unload all of them, and then populate them + manually later. + @see Resource::isReloadable for resource is reloadable. + */ + void unloadResourceGroup(const String& name, bool reloadableOnly = true); + + /** Unload all resources which are not referenced by any other object. + @remarks + This method behaves like unloadResourceGroup, except that it only + unloads resources in the group which are not in use, ie not referenced + by other objects. This allows you to free up some memory selectively + whilst still keeping the group around (and the resources present, + just not using much memory). + @param name The name of the group to check for unreferenced resources + @param reloadableOnly If true (the default), only unloads resources + which can be subsequently automatically reloaded + */ + void unloadUnreferencedResourcesInGroup(const String& name, + bool reloadableOnly = true); + + /** Clears a resource group. + @remarks + This method unloads all resources in the group, but in addition it + removes all those resources from their ResourceManagers, and then + clears all the members from the list. That means after calling this + method, there are no resources declared as part of the named group + any more. Resource locations still persist though. + @param name The name to of the resource group to clear. + */ + void clearResourceGroup(const String& name); + + /** Destroys a resource group, clearing it first, destroying the resources + which are part of it, and then removing it from + the list of resource groups. + @param name The name of the resource group to destroy. + */ + void destroyResourceGroup(const String& name); + + /** Method to add a resource location to for a given resource group. + @remarks + Resource locations are places which are searched to load resource files. + When you choose to load a file, or to search for valid files to load, + the resource locations are used. + @param name The name of the resource location; probably a directory, zip file, URL etc. + @param locType The codename for the resource type, which must correspond to the + Archive factory which is providing the implementation. + @param resGroup The name of the resource group for which this location is + to apply. ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME is the + default group which always exists, and can + be used for resources which are unlikely to be unloaded until application + shutdown. Otherwise it must be the name of a group; if it + has not already been created with createResourceGroup then it is created + automatically. + @param recursive Whether subdirectories will be searched for files when using + a pattern match (such as *.material), and whether subdirectories will be + indexed. This can slow down initial loading of the archive and searches. + When opening a resource you still need to use the fully qualified name, + this allows duplicate names in alternate paths. + */ + void addResourceLocation(const String& name, const String& locType, + const String& resGroup = DEFAULT_RESOURCE_GROUP_NAME, bool recursive = false); + /** Removes a resource location from the search path. */ + void removeResourceLocation(const String& name, + const String& resGroup = DEFAULT_RESOURCE_GROUP_NAME); + + /** Declares a resource to be a part of a resource group, allowing you + to load and unload it as part of the group. + @remarks + By declaring resources before you attempt to use them, you can + more easily control the loading and unloading of those resources + by their group. Declaring them also allows them to be enumerated, + which means events can be raised to indicate the loading progress + (@see ResourceGroupListener). Note that another way of declaring + resources is to use a script specific to the resource type, if + available (e.g. .material). + @par + Declared resources are not created as Resource instances (and thus + are not available through their ResourceManager) until initialiseResourceGroup + is called, at which point all declared resources will become created + (but unloaded) Resource instances, along with any resources declared + in scripts in resource locations associated with the group. + @param name The resource name. + @param resourceType The type of the resource. Ogre comes preconfigured with + a number of resource types: +
    +
  • Font
  • +
  • GpuProgram
  • +
  • HighLevelGpuProgram
  • +
  • Material
  • +
  • Mesh
  • +
  • Skeleton
  • +
  • Texture
  • +
+ .. but more can be added by plugin ResourceManager classes. + @param groupName The name of the group to which it will belong. + @param loadParameters A list of name / value pairs which supply custom + parameters to the resource which will be required before it can + be loaded. These are specific to the resource type. + */ + void declareResource(const String& name, const String& resourceType, + const String& groupName = DEFAULT_RESOURCE_GROUP_NAME, + const NameValuePairList& loadParameters = NameValuePairList()); + /** Declares a resource to be a part of a resource group, allowing you + to load and unload it as part of the group. + @remarks + By declaring resources before you attempt to use them, you can + more easily control the loading and unloading of those resources + by their group. Declaring them also allows them to be enumerated, + which means events can be raised to indicate the loading progress + (@see ResourceGroupListener). Note that another way of declaring + resources is to use a script specific to the resource type, if + available (e.g. .material). + @par + Declared resources are not created as Resource instances (and thus + are not available through their ResourceManager) until initialiseResourceGroup + is called, at which point all declared resources will become created + (but unloaded) Resource instances, along with any resources declared + in scripts in resource locations associated with the group. + @param name The resource name. + @param resourceType The type of the resource. Ogre comes preconfigured with + a number of resource types: +
    +
  • Font
  • +
  • GpuProgram
  • +
  • HighLevelGpuProgram
  • +
  • Material
  • +
  • Mesh
  • +
  • Skeleton
  • +
  • Texture
  • +
+ .. but more can be added by plugin ResourceManager classes. + @param groupName The name of the group to which it will belong. + @param loader Pointer to a ManualResourceLoader implementation which will + be called when the Resource wishes to load. If supplied, the resource + is manually loaded, otherwise it'll loading from file automatic. + @note We don't support declare manually loaded resource without loader + here, since it's meaningless. + @param loadParameters A list of name / value pairs which supply custom + parameters to the resource which will be required before it can + be loaded. These are specific to the resource type. + */ + void declareResource(const String& name, const String& resourceType, + const String& groupName, ManualResourceLoader* loader, + const NameValuePairList& loadParameters = NameValuePairList()); + /** Undeclare a resource. + @remarks + Note that this will not cause it to be unloaded + if it is already loaded, nor will it destroy a resource which has + already been created if initialiseResourceGroup has been called already. + Only unloadResourceGroup / clearResourceGroup / destroyResourceGroup + will do that. + @param name The name of the resource. + @param groupName The name of the group this resource was declared in. + */ + void undeclareResource(const String& name, const String& groupName); + + /** Open a single resource by name and return a DataStream + pointing at the source of the data. + @param resourceName The name of the resource to locate. + Even if resource locations are added recursively, you + must provide a fully qualified name to this method. You + can find out the matching fully qualified names by using the + find() method if you need to. + @param groupName The name of the resource group; this determines which + locations are searched. + @param searchGroupsIfNotFound If true, if the resource is not found in + the group specified, other groups will be searched. If you're + loading a real Resource using this option, you must + also provide the resourceBeingLoaded parameter to enable the + group membership to be changed + @param resourceBeingLoaded Optional pointer to the resource being + loaded, which you should supply if you want + @returns Shared pointer to data stream containing the data, will be + destroyed automatically when no longer referenced + */ + DataStreamPtr openResource(const String& resourceName, + const String& groupName = DEFAULT_RESOURCE_GROUP_NAME, + bool searchGroupsIfNotFound = true, Resource* resourceBeingLoaded = 0); + + /** Open all resources matching a given pattern (which can contain + the character '*' as a wildcard), and return a collection of + DataStream objects on them. + @param pattern The pattern to look for. If resource locations have been + added recursively, subdirectories will be searched too so this + does not need to be fully qualified. + @param groupName The resource group; this determines which locations + are searched. + @returns Shared pointer to a data stream list , will be + destroyed automatically when no longer referenced + */ + DataStreamListPtr openResources(const String& pattern, + const String& groupName = DEFAULT_RESOURCE_GROUP_NAME); + + /** List all file or directory names in a resource group. + @note + This method only returns filenames, you can also retrieve other + information using listFileInfo. + @param groupName The name of the group + @param dirs If true, directory names will be returned instead of file names + @returns A list of filenames matching the criteria, all are fully qualified + */ + StringVectorPtr listResourceNames(const String& groupName, bool dirs = false); + + /** List all files in a resource group with accompanying information. + @param groupName The name of the group + @param dirs If true, directory names will be returned instead of file names + @returns A list of structures detailing quite a lot of information about + all the files in the archive. + */ + FileInfoListPtr listResourceFileInfo(const String& groupName, bool dirs = false); + + /** Find all file or directory names matching a given pattern in a + resource group. + @note + This method only returns filenames, you can also retrieve other + information using findFileInfo. + @param groupName The name of the group + @param pattern The pattern to search for; wildcards (*) are allowed + @param dirs Set to true if you want the directories to be listed + instead of files + @returns A list of filenames matching the criteria, all are fully qualified + */ + StringVectorPtr findResourceNames(const String& groupName, const String& pattern, + bool dirs = false); + + /** Find out if the named file exists in a group. + @param group The name of the resource group + @param filename Fully qualified name of the file to test for + */ + bool resourceExists(const String& group, const String& filename); + + /** Find out if the named file exists in a group. + @param group Pointer to the resource group + @param filename Fully qualified name of the file to test for + */ + bool resourceExists(ResourceGroup* group, const String& filename); + /** Find the group in which a resource exists. + @param filename Fully qualified name of the file the resource should be + found as + @returns Name of the resource group the resource was found in. An + exception is thrown if the group could not be determined. + */ + const String& findGroupContainingResource(const String& filename); + + /** Find all files or directories matching a given pattern in a group + and get some detailed information about them. + @param group The name of the resource group + @param pattern The pattern to search for; wildcards (*) are allowed + @param dirs Set to true if you want the directories to be listed + instead of files + @returns A list of file information structures for all files matching + the criteria. + */ + FileInfoListPtr findResourceFileInfo(const String& group, const String& pattern, + bool dirs = false); + + + /** Adds a ResourceGroupListener which will be called back during + resource loading events. + */ + void addResourceGroupListener(ResourceGroupListener* l); + /** Removes a ResourceGroupListener */ + void removeResourceGroupListener(ResourceGroupListener* l); + + /** Sets the resource group that 'world' resources will use. + @remarks + This is the group which should be used by SceneManagers implementing + world geometry when looking for their resources. Defaults to the + DEFAULT_RESOURCE_GROUP_NAME but this can be altered. + */ + void setWorldResourceGroupName(const String& groupName) {mWorldGroupName = groupName;} + + /// Sets the resource group that 'world' resources will use. + const String& getWorldResourceGroupName(void) const { return mWorldGroupName; } + + /** Associates some world geometry with a resource group, causing it to + be loaded / unloaded with the resource group. + @remarks + You would use this method to essentially defer a call to + SceneManager::setWorldGeometry to the time when the resource group + is loaded. The advantage of this is that compatible scene managers + will include the estimate of the number of loading stages for that + world geometry when the resource group begins loading, allowing you + to include that in a loading progress report. + @param group The name of the resource group + @param worldGeometry The parameter which should be passed to setWorldGeometry + @param sceneManager The SceneManager which should be called + */ + void linkWorldGeometryToResourceGroup(const String& group, + const String& worldGeometry, SceneManager* sceneManager); + + /** Clear any link to world geometry from a resource group. + @remarks + Basically undoes a previous call to linkWorldGeometryToResourceGroup. + */ + void unlinkWorldGeometryFromResourceGroup(const String& group); + + /** Shutdown all ResourceManagers, performed as part of clean-up. */ + void shutdownAll(void); + + + /** Internal method for registering a ResourceManager (which should be + a singleton). Creators of plugins can register new ResourceManagers + this way if they wish. + @remarks + ResourceManagers that wish to parse scripts must also call + _registerScriptLoader. + @param resourceType String identifying the resource type, must be unique. + @param rm Pointer to the ResourceManager instance. + */ + void _registerResourceManager(const String& resourceType, ResourceManager* rm); + + /** Internal method for unregistering a ResourceManager. + @remarks + ResourceManagers that wish to parse scripts must also call + _unregisterScriptLoader. + @param resourceType String identifying the resource type. + */ + void _unregisterResourceManager(const String& resourceType); + + /** Get an iterator over the registered resource managers. + */ + ResourceManagerIterator getResourceManagerIterator() + { return ResourceManagerIterator( + mResourceManagerMap.begin(), mResourceManagerMap.end()); } + + /** Internal method for registering a ScriptLoader. + @remarks ScriptLoaders parse scripts when resource groups are initialised. + @param su Pointer to the ScriptLoader instance. + */ + void _registerScriptLoader(ScriptLoader* su); + + /** Internal method for unregistering a ScriptLoader. + @param su Pointer to the ScriptLoader instance. + */ + void _unregisterScriptLoader(ScriptLoader* su); + + /** Internal method for getting a registered ResourceManager. + @param resourceType String identifying the resource type. + */ + ResourceManager* _getResourceManager(const String& resourceType); + + /** Internal method called by ResourceManager when a resource is created. + @param res Weak reference to resource + */ + void _notifyResourceCreated(ResourcePtr& res); + + /** Internal method called by ResourceManager when a resource is removed. + @param res Weak reference to resource + */ + void _notifyResourceRemoved(ResourcePtr& res); + + /** Internale method to notify the group manager that a resource has + changed group (only applicable for autodetect group) */ + void _notifyResourceGroupChanged(const String& oldGroup, Resource* res); + + /** Internal method called by ResourceManager when all resources + for that manager are removed. + @param manager Pointer to the manager for which all resources are being removed + */ + void _notifyAllResourcesRemoved(ResourceManager* manager); + + /** Notify this manager that one stage of world geometry loading has been + started. + @remarks + Custom SceneManagers which load custom world geometry should call this + method the number of times equal to the value they return from + SceneManager::estimateWorldGeometry while loading their geometry. + */ + void _notifyWorldGeometryStageStarted(const String& description); + /** Notify this manager that one stage of world geometry loading has been + completed. + @remarks + Custom SceneManagers which load custom world geometry should call this + method the number of times equal to the value they return from + SceneManager::estimateWorldGeometry while loading their geometry. + */ + void _notifyWorldGeometryStageEnded(void); + + /** Get a list of the currently defined resource groups. + @note This method intentionally returns a copy rather than a reference in + order to avoid any contention issues in multithreaded applications. + @returns A copy of list of currently defined groups. + */ + StringVector getResourceGroups(void); + /** Get the list of resource declarations for the specified group name. + @note This method intentionally returns a copy rather than a reference in + order to avoid any contention issues in multithreaded applications. + @param groupName The name of the group + @returns A copy of list of currently defined resources. + */ + ResourceDeclarationList getResourceDeclarationList(const String& groupName); + + + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static ResourceGroupManager& getSingleton(void); + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static ResourceGroupManager* getSingletonPtr(void); + + }; +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreResourceManager.h b/school/informatik/verkerhssimulation/src/ogre/OgreResourceManager.h new file mode 100644 index 00000000..f09ae1d1 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreResourceManager.h @@ -0,0 +1,446 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _ResourceManager_H__ +#define _ResourceManager_H__ + +#include "OgrePrerequisites.h" + +#include "OgreResource.h" +#include "OgreResourceGroupManager.h" +#include "OgreIteratorWrappers.h" +#include "OgreCommon.h" +#include "OgreDataStream.h" +#include "OgreStringVector.h" +#include "OgreScriptLoader.h" + +namespace Ogre { + + /** Defines a generic resource handler. + @remarks + A resource manager is responsible for managing a pool of + resources of a particular type. It must index them, look + them up, load and destroy them. It may also need to stay within + a defined memory budget, and temporaily unload some resources + if it needs to to stay within this budget. + @par + Resource managers use a priority system to determine what can + be unloaded, and a Least Recently Used (LRU) policy within + resources of the same priority. + @par + Resources can be loaded using the generalised load interface, + and they can be unloaded and removed. In addition, each + subclass of ResourceManager will likely define custom 'load' methods + which take explicit parameters depending on the kind of resource + being created. + @note + Resources can be loaded and unloaded through the Resource class, + but they can only be removed (and thus eventually destroyed) using + their parent ResourceManager. + @note + If OGRE_THREAD_SUPPORT is 1, this class is thread-safe. + */ + class _OgreExport ResourceManager : public ScriptLoader + { + public: + OGRE_AUTO_MUTEX // public to allow external locking + ResourceManager(); + virtual ~ResourceManager(); + + /** Creates a new blank resource, but does not immediately load it. + @remarks + Resource managers handle disparate types of resources, so if you want + to get at the detailed interface of this resource, you'll have to + cast the result to the subclass you know you're creating. + @param name The unique name of the resource + @param group The name of the resource group to attach this new resource to + @param isManual Is this resource manually loaded? If so, you should really + populate the loader parameter in order that the load process + can call the loader back when loading is required. + @param loader Pointer to a ManualLoader implementation which will be called + when the Resource wishes to load (should be supplied if you set + isManual to true). You can in fact leave this parameter null + if you wish, but the Resource will never be able to reload if + anything ever causes it to unload. Therefore provision of a proper + ManualLoader instance is strongly recommended. + @param createParams If any parameters are required to create an instance, + they should be supplied here as name / value pairs + */ + virtual ResourcePtr create(const String& name, const String& group, + bool isManual = false, ManualResourceLoader* loader = 0, + const NameValuePairList* createParams = 0); + + typedef std::pair ResourceCreateOrRetrieveResult; + /** Create a new resource, or retrieve an existing one with the same + name if it already exists. + @remarks + This method performs the same task as calling getByName() followed + by create() if that returns null. The advantage is that it does it + in one call so there are no race conditions if using multiple + threads that could cause getByName() to return null, but create() to + fail because another thread created a resource in between. + @see ResourceManager::create + @see ResourceManager::getByName + @returns A pair, the first element being the pointer, and the second being + an indicator specifying whether the resource was newly created. + */ + virtual ResourceCreateOrRetrieveResult createOrRetrieve(const String& name, + const String& group, bool isManual = false, + ManualResourceLoader* loader = 0, + const NameValuePairList* createParams = 0); + + /** Set a limit on the amount of memory this resource handler may use. + @remarks + If, when asked to load a new resource, the manager believes it will exceed this memory + budget, it will temporarily unload a resource to make room for the new one. This unloading + is not permanent and the Resource is not destroyed; it simply needs to be reloaded when + next used. + */ + virtual void setMemoryBudget( size_t bytes); + + /** Get the limit on the amount of memory this resource handler may use. + */ + virtual size_t getMemoryBudget(void) const; + + /** Gets the current memory usage, in bytes. */ + virtual size_t getMemoryUsage(void) const { return mMemoryUsage; } + + /** Unloads a single resource by name. + @remarks + Unloaded resources are not removed, they simply free up their memory + as much as they can and wait to be reloaded. + @see ResourceGroupManager for unloading of resource groups. + */ + virtual void unload(const String& name); + + /** Unloads a single resource by handle. + @remarks + Unloaded resources are not removed, they simply free up their memory + as much as they can and wait to be reloaded. + @see ResourceGroupManager for unloading of resource groups. + */ + virtual void unload(ResourceHandle handle); + + /** Unloads all resources. + @remarks + Unloaded resources are not removed, they simply free up their memory + as much as they can and wait to be reloaded. + @see ResourceGroupManager for unloading of resource groups. + @param reloadableOnly If true (the default), only unload the resource that + is reloadable. Because some resources isn't reloadable, they will be + unloaded but can't load them later. Thus, you might not want to them + unloaded. Or, you might unload all of them, and then populate them + manually later. + @see Resource::isReloadable for resource is reloadable. + */ + virtual void unloadAll(bool reloadableOnly = true); + + /** Caused all currently loaded resources to be reloaded. + @remarks + All resources currently being held in this manager which are also + marked as currently loaded will be unloaded, then loaded again. + @param reloadableOnly If true (the default), only reload the resource that + is reloadable. Because some resources isn't reloadable, they will be + unloaded but can't loaded again. Thus, you might not want to them + unloaded. Or, you might unload all of them, and then populate them + manually later. + @see Resource::isReloadable for resource is reloadable. + */ + virtual void reloadAll(bool reloadableOnly = true); + + /** Unload all resources which are not referenced by any other object. + @remarks + This method behaves like unloadAll, except that it only unloads resources + which are not in use, ie not referenced by other objects. This allows you + to free up some memory selectively whilst still keeping the group around + (and the resources present, just not using much memory). + @par + Some referenced resource may exists 'weak' pointer to their sub-components + (e.g. Entity held pointer to SubMesh), in this case, unload or reload that + resource will cause dangerous pointer access. Use this function instead of + unloadAll allows you avoid fail in those situations. + @param reloadableOnly If true (the default), only unloads resources + which can be subsequently automatically reloaded. + */ + virtual void unloadUnreferencedResources(bool reloadableOnly = true); + + /** Caused all currently loaded but not referenced by any other object + resources to be reloaded. + @remarks + This method behaves like reloadAll, except that it only reloads resources + which are not in use, ie not referenced by other objects. + @par + Some referenced resource may exists 'weak' pointer to their sub-components + (e.g. Entity held pointer to SubMesh), in this case, unload or reload that + resource will cause dangerous pointer access. Use this function instead of + reloadAll allows you avoid fail in those situations. + @param reloadableOnly If true (the default), only reloads resources + which can be subsequently automatically reloaded. + */ + virtual void reloadUnreferencedResources(bool reloadableOnly = true); + + /** Remove a single resource. + @remarks + Removes a single resource, meaning it will be removed from the list + of valid resources in this manager, also causing it to be unloaded. + @note + The word 'Destroy' is not used here, since + if any other pointers are referring to this resource, it will persist + until they have finished with it; however to all intents and purposes + it no longer exists and will likely get destroyed imminently. + @note + If you do have shared pointers to resources hanging around after the + ResourceManager is destroyed, you may get problems on destruction of + these resources if they were relying on the manager (especially if + it is a plugin). If you find you get problems on shutdown in the + destruction of resources, try making sure you release all your + shared pointers before you shutdown OGRE. + */ + virtual void remove(ResourcePtr& r); + + /** Remove a single resource by name. + @remarks + Removes a single resource, meaning it will be removed from the list + of valid resources in this manager, also causing it to be unloaded. + @note + The word 'Destroy' is not used here, since + if any other pointers are referring to this resource, it will persist + until they have finished with it; however to all intents and purposes + it no longer exists and will likely get destroyed imminently. + @note + If you do have shared pointers to resources hanging around after the + ResourceManager is destroyed, you may get problems on destruction of + these resources if they were relying on the manager (especially if + it is a plugin). If you find you get problems on shutdown in the + destruction of resources, try making sure you release all your + shared pointers before you shutdown OGRE. + */ + virtual void remove(const String& name); + + /** Remove a single resource by handle. + @remarks + Removes a single resource, meaning it will be removed from the list + of valid resources in this manager, also causing it to be unloaded. + @note + The word 'Destroy' is not used here, since + if any other pointers are referring to this resource, it will persist + until they have finished with it; however to all intents and purposes + it no longer exists and will likely get destroyed imminently. + @note + If you do have shared pointers to resources hanging around after the + ResourceManager is destroyed, you may get problems on destruction of + these resources if they were relying on the manager (especially if + it is a plugin). If you find you get problems on shutdown in the + destruction of resources, try making sure you release all your + shared pointers before you shutdown OGRE. + */ + virtual void remove(ResourceHandle handle); + /** Removes all resources. + @note + The word 'Destroy' is not used here, since + if any other pointers are referring to these resources, they will persist + until they have been finished with; however to all intents and purposes + the resources no longer exist and will get destroyed imminently. + @note + If you do have shared pointers to resources hanging around after the + ResourceManager is destroyed, you may get problems on destruction of + these resources if they were relying on the manager (especially if + it is a plugin). If you find you get problems on shutdown in the + destruction of resources, try making sure you release all your + shared pointers before you shutdown OGRE. + */ + virtual void removeAll(void); + + /** Retrieves a pointer to a resource by name, or null if the resource does not exist. + */ + virtual ResourcePtr getByName(const String& name); + /** Retrieves a pointer to a resource by handle, or null if the resource does not exist. + */ + virtual ResourcePtr getByHandle(ResourceHandle handle); + + /// Returns whether the named resource exists in this manager + virtual bool resourceExists(const String& name) + { + return !getByName(name).isNull(); + } + /// Returns whether a resource with the given handle exists in this manager + virtual bool resourceExists(ResourceHandle handle) + { + return !getByHandle(handle).isNull(); + } + + /** Notify this manager that a resource which it manages has been + 'touched', ie used. + */ + virtual void _notifyResourceTouched(Resource* res); + + /** Notify this manager that a resource which it manages has been + loaded. + */ + virtual void _notifyResourceLoaded(Resource* res); + + /** Notify this manager that a resource which it manages has been + unloaded. + */ + virtual void _notifyResourceUnloaded(Resource* res); + + /** Generic load method, used to create a Resource specific to this + ResourceManager without using one of the specialised 'load' methods + (containing per-Resource-type parameters). + @param name The name of the Resource + @param group The resource group to which this resource will belong + @param isManual Is the resource to be manually loaded? If so, you should + provide a value for the loader parameter + @param loader The manual loader which is to perform the required actions + when this resource is loaded; only applicable when you specify true + for the previous parameter + @param loadParams Optional pointer to a list of name/value pairs + containing loading parameters for this type of resource. + */ + virtual ResourcePtr load(const String& name, + const String& group, bool isManual = false, + ManualResourceLoader* loader = 0, const NameValuePairList* loadParams = 0); + + /** Gets the file patterns which should be used to find scripts for this + ResourceManager. + @remarks + Some resource managers can read script files in order to define + resources ahead of time. These resources are added to the available + list inside the manager, but none are loaded initially. This allows + you to load the items that are used on demand, or to load them all + as a group if you wish (through ResourceGroupManager). + @par + This method lets you determine the file pattern which will be used + to identify scripts intended for this manager. + @returns + A list of file patterns, in the order they should be searched in. + @see isScriptingSupported, parseScript + */ + virtual const StringVector& getScriptPatterns(void) const { return mScriptPatterns; } + + /** Parse the definition of a set of resources from a script file. + @remarks + Some resource managers can read script files in order to define + resources ahead of time. These resources are added to the available + list inside the manager, but none are loaded initially. This allows + you to load the items that are used on demand, or to load them all + as a group if you wish (through ResourceGroupManager). + @param stream Weak reference to a data stream which is the source of the script + @param groupName The name of the resource group that resources which are + parsed are to become a member of. If this group is loaded or unloaded, + then the resources discovered in this script will be loaded / unloaded + with it. + */ + virtual void parseScript(DataStreamPtr& stream, const String& groupName) {} + + /** Gets the relative loading order of resources of this type. + @remarks + There are dependencies between some kinds of resource in terms of loading + order, and this value enumerates that. Higher values load later during + bulk loading tasks. + */ + virtual Real getLoadingOrder(void) const { return mLoadOrder; } + + /** Gets a string identifying the type of resource this manager handles. */ + const String& getResourceType(void) const { return mResourceType; } + + protected: + + /** Allocates the next handle. */ + ResourceHandle getNextHandle(void); + + /** Create a new resource instance compatible with this manager (no custom + parameters are populated at this point). + @remarks + Subclasses must override this method and create a subclass of Resource. + @param name The unique name of the resource + @param group The name of the resource group to attach this new resource to + @param isManual Is this resource manually loaded? If so, you should really + populate the loader parameter in order that the load process + can call the loader back when loading is required. + @param loader Pointer to a ManualLoader implementation which will be called + when the Resource wishes to load (should be supplied if you set + isManual to true). You can in fact leave this parameter null + if you wish, but the Resource will never be able to reload if + anything ever causes it to unload. Therefore provision of a proper + ManualLoader instance is strongly recommended. + @param createParams If any parameters are required to create an instance, + they should be supplied here as name / value pairs. These do not need + to be set on the instance (handled elsewhere), just used if required + to differentiate which concrete class is created. + + */ + virtual Resource* createImpl(const String& name, ResourceHandle handle, + const String& group, bool isManual, ManualResourceLoader* loader, + const NameValuePairList* createParams) = 0; + /** Add a newly created resource to the manager (note weak reference) */ + virtual void addImpl( ResourcePtr& res ); + /** Remove a resource from this manager; remove it from the lists. */ + virtual void removeImpl( ResourcePtr& res ); + /** Checks memory usage and pages out if required. + */ + virtual void checkUsage(void); + + + public: + typedef HashMap< String, ResourcePtr > ResourceMap; + typedef std::map ResourceHandleMap; + protected: + ResourceHandleMap mResourcesByHandle; + ResourceMap mResources; + ResourceHandle mNextHandle; + size_t mMemoryBudget; // In bytes + size_t mMemoryUsage; // In bytes + + // IMPORTANT - all subclasses must populate the fields below + + /// Patterns to use to look for scripts if supported (e.g. *.overlay) + StringVector mScriptPatterns; + /// Loading order relative to other managers, higher is later + Real mLoadOrder; + /// String identifying the resource type this manager handles + String mResourceType; + + public: + typedef MapIterator ResourceMapIterator; + /** Returns an iterator over all resources in this manager. + @note + Use of this iterator is NOT thread safe! + */ + ResourceMapIterator getResourceIterator(void) + { + return ResourceMapIterator(mResourcesByHandle.begin(), mResourcesByHandle.end()); + } + + + + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreRibbonTrail.h b/school/informatik/verkerhssimulation/src/ogre/OgreRibbonTrail.h new file mode 100644 index 00000000..6ffde1f2 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreRibbonTrail.h @@ -0,0 +1,224 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __RibbonTrail_H__ +#define __RibbonTrail_H__ + +#include "OgrePrerequisites.h" + +#include "OgreBillboardChain.h" +#include "OgreNode.h" +#include "OgreIteratorWrappers.h" +#include "OgreFrameListener.h" +#include "OgreControllerManager.h" + +namespace Ogre { + + /** Subclass of BillboardChain which automatically leaves a trail behind + one or more Node instances. + @remarks + An instance of this class will watch one or more Node instances, and + automatically generate a trail behind them as they move. Because this + class can monitor multiple modes, it generates its own geometry in + world space and thus, even though it has to be attached to a SceneNode + to be visible, changing the position of the scene node it is attached to + makes no difference to the geometry rendered. + @par + The 'head' element grows smoothly in size until it reaches the required size, + then a new element is added. If the segment is full, the tail element + shrinks by the same proportion as the head grows before disappearing. + @par + Elements can be faded out on a time basis, either by altering their colour + or altering their alpha. The width can also alter over time. + @par + 'v' texture coordinates are fixed at 0.0 if used, meaning that you can + use a 1D texture to 'smear' a colour pattern along the ribbon if you wish. + The 'u' coordinates are by default (0.0, 1.0), but you can alter this + using setOtherTexCoordRange if you wish. + */ + class _OgreExport RibbonTrail : public BillboardChain, public Node::Listener + { + public: + /** Constructor (don't use directly, use factory) + @param name The name to give this object + @param maxElements The maximum number of elements per chain + @param numberOfChains The number of separate chain segments contained in this object, + ie the maximum number of nodes that can have trails attached + @param useTextureCoords If true, use texture coordinates from the chain elements + @param useVertexColours If true, use vertex colours from the chain elements (must + be true if you intend to use fading) + */ + RibbonTrail(const String& name, size_t maxElements = 20, size_t numberOfChains = 1, + bool useTextureCoords = true, bool useColours = true); + /// destructor + virtual ~RibbonTrail(); + + typedef std::vector NodeList; + typedef ConstVectorIterator NodeIterator; + + /** Add a node to be tracked. + @param n The node that will be tracked. + */ + virtual void addNode(Node* n); + /** Remove tracking on a given node. */ + virtual void removeNode(Node* n); + /** Get an iterator over the nodes which are being tracked. */ + virtual NodeIterator getNodeIterator(void) const; + + /** Set the length of the trail. + @remarks + This sets the length of the trail, in world units. It also sets how + far apart each segment will be, ie length / max_elements. + @param len The length of the trail in world units + */ + virtual void setTrailLength(Real len); + /** Get the length of the trail. */ + virtual Real getTrailLength(void) const { return mTrailLength; } + + /** @copydoc BillboardChain::setMaxChainElements */ + void setMaxChainElements(size_t maxElements); + /** @copydoc BillboardChain::setNumberOfChains */ + void setNumberOfChains(size_t numChains); + /** @copydoc BillboardChain::clearChain */ + void clearChain(size_t chainIndex); + + /** Set the starting ribbon colour for a given segment. + @param chainIndex The index of the chain + @param col The initial colour + @note + Only used if this instance is using vertex colours. + */ + virtual void setInitialColour(size_t chainIndex, const ColourValue& col); + /** Set the starting ribbon colour. + @param chainIndex The index of the chain + @param r,b,g,a The initial colour + @note + Only used if this instance is using vertex colours. + */ + virtual void setInitialColour(size_t chainIndex, Real r, Real g, Real b, Real a = 1.0); + /** Get the starting ribbon colour. */ + virtual const ColourValue& getInitialColour(size_t chainIndex) const; + + /** Enables / disables fading the trail using colour. + @param chainIndex The index of the chain + @param valuePerSecond The amount to subtract from colour each second + */ + virtual void setColourChange(size_t chainIndex, const ColourValue& valuePerSecond); + + /** Set the starting ribbon width in world units. + @param chainIndex The index of the chain + @param width The initial width of the ribbon + */ + virtual void setInitialWidth(size_t chainIndex, Real width); + /** Get the starting ribbon width in world units. */ + virtual Real getInitialWidth(size_t chainIndex) const; + + /** Set the change in ribbon width per second. + @param chainIndex The index of the chain + @param widthDeltaPerSecond The amount the width will reduce by per second + */ + virtual void setWidthChange(size_t chainIndex, Real widthDeltaPerSecond); + /** Get the change in ribbon width per second. */ + virtual Real getWidthChange(size_t chainIndex) const; + + /** Enables / disables fading the trail using colour. + @param chainIndex The index of the chain + @param r,g,b,a The amount to subtract from each colour channel per second + */ + virtual void setColourChange(size_t chainIndex, Real r, Real g, Real b, Real a); + + /** Get the per-second fading amount */ + virtual const ColourValue& getColourChange(size_t chainIndex) const; + + /// @see Node::Listener::nodeUpdated + void nodeUpdated(const Node* node); + /// @see Node::Listener::nodeDestroyed + void nodeDestroyed(const Node* node); + + /// Perform any fading / width delta required; internal method + virtual void _timeUpdate(Real time); + + /** Overridden from MovableObject */ + const String& getMovableType(void) const; + + protected: + /// List of nodes being trailed + NodeList mNodeList; + /// Total length of trail in world units + Real mTrailLength; + /// length of each element + Real mElemLength; + /// Squared length of each element + Real mSquaredElemLength; + typedef std::vector ColourValueList; + typedef std::vector RealList; + /// Initial colour of the ribbon + ColourValueList mInitialColour; + /// fade amount per second + ColourValueList mDeltaColour; + /// Initial width of the ribbon + RealList mInitialWidth; + /// Delta width of the ribbon + RealList mDeltaWidth; + /// controller used to hook up frame time to fader + Controller* mFadeController; + /// controller value for hooking up frame time to fader + ControllerValueRealPtr mTimeControllerValue; + + /// Manage updates to the time controller + virtual void manageController(void); + /// Node has changed position, update + virtual void updateTrail(size_t index, const Node* node); + /// Reset the tracked chain to initial state + virtual void resetTrail(size_t index, const Node* node); + /// Reset all tracked chains to initial state + virtual void resetAllTrails(void); + + }; + + + /** Factory object for creating RibbonTrail instances */ + class _OgreExport RibbonTrailFactory : public MovableObjectFactory + { + protected: + MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params); + public: + RibbonTrailFactory() {} + ~RibbonTrailFactory() {} + + static String FACTORY_TYPE_NAME; + + const String& getType(void) const; + void destroyInstance( MovableObject* obj); + + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreRoot.h b/school/informatik/verkerhssimulation/src/ogre/OgreRoot.h new file mode 100644 index 00000000..340aa170 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreRoot.h @@ -0,0 +1,844 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ROOT__ +#define __ROOT__ + +// Precompiler options +#include "OgrePrerequisites.h" + +#include "OgreSingleton.h" +#include "OgreString.h" +#include "OgreSceneManagerEnumerator.h" +#include "OgreResourceGroupManager.h" + +#include + +namespace Ogre +{ + typedef std::vector RenderSystemList; + + /** The root class of the Ogre system. + @remarks + The Ogre::Root class represents a starting point for the client + application. From here, the application can gain access to the + fundamentals of the system, namely the rendering systems + available, management of saved configurations, logging, and + access to other classes in the system. Acts as a hub from which + all other objects may be reached. An instance of Root must be + created before any other Ogre operations are called. Once an + instance has been created, the same instance is accessible + throughout the life of that object by using Root::getSingleton + (as a reference) or Root::getSingletonPtr (as a pointer). + */ + class _OgreExport Root : public Singleton + { + // To allow update of active renderer if + // RenderSystem::initialise is used directly + friend class RenderSystem; + private: + RenderSystemList mRenderers; + RenderSystem* mActiveRenderer; + String mVersion; + String mConfigFileName; + bool mQueuedEnd; + // In case multiple render windows are created, only once are the resources loaded. + bool mFirstTimePostWindowInit; + + // Singletons + LogManager* mLogManager; + ControllerManager* mControllerManager; + SceneManagerEnumerator* mSceneManagerEnum; + SceneManager* mCurrentSceneManager; + DynLibManager* mDynLibManager; + ArchiveManager* mArchiveManager; + MaterialManager* mMaterialManager; + MeshManager* mMeshManager; + ParticleSystemManager* mParticleManager; + SkeletonManager* mSkeletonManager; + OverlayElementFactory* mPanelFactory; + OverlayElementFactory* mBorderPanelFactory; + OverlayElementFactory* mTextAreaFactory; + OverlayManager* mOverlayManager; + FontManager* mFontManager; + ArchiveFactory *mZipArchiveFactory; + ArchiveFactory *mFileSystemArchiveFactory; + ResourceGroupManager* mResourceGroupManager; + ResourceBackgroundQueue* mResourceBackgroundQueue; + ShadowTextureManager* mShadowTextureManager; + + Timer* mTimer; + RenderWindow* mAutoWindow; + Profiler* mProfiler; + HighLevelGpuProgramManager* mHighLevelGpuProgramManager; + ExternalTextureSourceManager* mExternalTextureSourceManager; + CompositorManager* mCompositorManager; + unsigned long mCurrentFrame; + Real mFrameSmoothingTime; + + public: + typedef std::vector PluginLibList; + typedef std::vector PluginInstanceList; + protected: + /// List of plugin DLLs loaded + PluginLibList mPluginLibs; + /// List of Plugin instances registered + PluginInstanceList mPlugins; + + typedef std::map MovableObjectFactoryMap; + MovableObjectFactoryMap mMovableObjectFactoryMap; + uint32 mNextMovableObjectTypeFlag; + // stock movable factories + MovableObjectFactory* mEntityFactory; + MovableObjectFactory* mLightFactory; + MovableObjectFactory* mBillboardSetFactory; + MovableObjectFactory* mManualObjectFactory; + MovableObjectFactory* mBillboardChainFactory; + MovableObjectFactory* mRibbonTrailFactory; + + typedef std::map RenderQueueInvocationSequenceMap; + RenderQueueInvocationSequenceMap mRQSequenceMap; + + /// Are we initialised yet? + bool mIsInitialised; + + /** Method reads a plugins configuration file and instantiates all + plugins. + @param + pluginsfile The file that contains plugins information. + Defaults to "plugins.cfg". + */ + void loadPlugins( const String& pluginsfile = "plugins.cfg" ); + /** Initialise all loaded plugins - allows plugins to perform actions + once the renderer is initialised. + */ + void initialisePlugins(); + /** Shuts down all loaded plugins - allows things to be tidied up whilst + all plugins are still loaded. + */ + void shutdownPlugins(); + + /** Unloads all loaded plugins. + */ + void unloadPlugins(); + + // Internal method for one-time tasks after first window creation + void oneTimePostWindowInit(void); + + /** Set of registered frame listeners */ + std::set mFrameListeners; + + /** Set of frame listeners marked for removal*/ + std::set mRemovedFrameListeners; + + /** Indicates the type of event to be considered by calculateEventTime(). */ + enum FrameEventTimeType { + FETT_ANY, FETT_STARTED, FETT_ENDED + }; + + /// Contains the times of recently fired events + std::deque mEventTimes[3]; + + /** Internal method for calculating the average time between recently fired events. + @param now The current time in ms. + @param type The type of event to be considered. + */ + Real calculateEventTime(unsigned long now, FrameEventTimeType type); + public: + + /** Constructor + @param pluginFileName The file that contains plugins information. + Defaults to "plugins.cfg", may be left blank to ignore. + @param configFileName The file that contains the configuration to be loaded. + Defaults to "ogre.cfg", may be left blank to load nothing. + @param logFileName The logfile to create, defaults to Ogre.log, may be + left blank if you've already set up LogManager & Log yourself + */ + Root(const String& pluginFileName = "plugins.cfg", + const String& configFileName = "ogre.cfg", + const String& logFileName = "Ogre.log"); + ~Root(); + + /** Saves the details of the current configuration + @remarks + Stores details of the current configuration so it may be + restored later on. + */ + void saveConfig(void); + + /** Checks for saved video/sound/etc settings + @remarks + This method checks to see if there is a valid saved configuration + from a previous run. If there is, the state of the system will + be restored to that configuration. + + @returns + If a valid configuration was found, true is returned. + @par + If there is no saved configuration, or if the system failed + with the last config settings, false is returned. + */ + bool restoreConfig(void); + + /** Displays a dialog asking the user to choose system settings. + @remarks + This method displays the default dialog allowing the user to + choose the renderering system, video mode etc. If there is are + any settings saved already, they will be restored automatically + before displaying the dialogue. When the user accepts a group of + settings, this will automatically call Root::setRenderSystem, + RenderSystem::setConfigOption and Root::saveConfig with the + user's choices. This is the easiest way to get the system + configured. + @returns + If the user clicked 'Ok', true is returned. + @par + If they clicked 'Cancel' (in which case the app should + strongly consider terminating), false is returned. + */ + bool showConfigDialog(void); + + /** Adds a new rendering subsystem to the list of available renderers. + @remarks + Intended for use by advanced users and plugin writers only! + Calling this method with a pointer to a valid RenderSystem + (sublcass) adds a rendering API implementation to the list of + available ones. Typical examples would be an OpenGL + implementation and a Direct3D implementation. + @note +
This should usually be called from the dllStartPlugin() + function of an extension plug-in. + */ + void addRenderSystem(RenderSystem* newRend); + + /** Retrieve a list of the available render systems. + @remarks + Retrieves a pointer to the list of available renderers as a + list of RenderSystem subclasses. Can be used to build a + custom settings dialog. + */ + RenderSystemList* getAvailableRenderers(void); + + /** Retrieve a pointer to the render system by the given name + @param + name Name of the render system intend to retrieve. + @returns + A pointer to the render system, NULL if no found. + */ + RenderSystem* getRenderSystemByName(const String& name); + + /** Sets the rendering subsystem to be used. + @remarks + This method indicates to OGRE which rendering system is to be + used (e.g. Direct3D, OpenGL etc). This is called + automatically by the default config dialog, and when settings + are restored from a previous configuraion. If used manually + it could be used to set the renderer from a custom settings + dialog. Once this has been done, the renderer can be + initialised using Root::initialise. + @par + This method is also called by render systems if they are + initialised directly. + @param + system Pointer to the render system to use. + @see + RenderSystem + */ + void setRenderSystem(RenderSystem* system); + + /** Retrieve a pointer to the currently selected render system. + */ + RenderSystem* getRenderSystem(void); + + /** Initialises the renderer. + @remarks + This method can only be called after a renderer has been + selected with Root::setRenderSystem, and it will initialise + the selected rendering system ready for use. + @param + autoCreateWindow If true, a rendering window will + automatically be created (saving a call to + RenderSystem::createRenderWindow). The window will be + created based on the options currently set on the render + system. + @returns + A pointer to the automatically created window, if + requested, otherwise NULL. + */ + RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window"); + + /** Returns whether the system is initialised or not. */ + bool isInitialised(void) const { return mIsInitialised; } + + /** Register a new SceneManagerFactory, a factory object for creating instances + of specific SceneManagers. + @remarks + Plugins should call this to register as new SceneManager providers. + */ + void addSceneManagerFactory(SceneManagerFactory* fact); + + /** Unregister a SceneManagerFactory. + */ + void removeSceneManagerFactory(SceneManagerFactory* fact); + + /** Get more information about a given type of SceneManager. + @remarks + The metadata returned tells you a few things about a given type + of SceneManager, which can be created using a factory that has been + registered already. + @param typeName The type name of the SceneManager you want to enquire on. + If you don't know the typeName already, you can iterate over the + metadata for all types using getMetaDataIterator. + */ + const SceneManagerMetaData* getSceneManagerMetaData(const String& typeName) const; + + /** Iterate over all types of SceneManager available for construction, + providing some information about each one. + */ + SceneManagerEnumerator::MetaDataIterator getSceneManagerMetaDataIterator(void) const; + + /** Create a SceneManager instance of a given type. + @remarks + You can use this method to create a SceneManager instance of a + given specific type. You may know this type already, or you may + have discovered it by looking at the results from getMetaDataIterator. + @note + This method throws an exception if the named type is not found. + @param typeName String identifying a unique SceneManager type + @param instanceName Optional name to given the new instance that is + created. If you leave this blank, an auto name will be assigned. + */ + SceneManager* createSceneManager(const String& typeName, + const String& instanceName = StringUtil::BLANK); + + /** Create a SceneManager instance based on scene type support. + @remarks + Creates an instance of a SceneManager which supports the scene types + identified in the parameter. If more than one type of SceneManager + has been registered as handling that combination of scene types, + in instance of the last one registered is returned. + @note This method always succeeds, if a specific scene manager is not + found, the default implementation is always returned. + @param typeMask A mask containing one or more SceneType flags + @param instanceName Optional name to given the new instance that is + created. If you leave this blank, an auto name will be assigned. + */ + SceneManager* createSceneManager(SceneTypeMask typeMask, + const String& instanceName = StringUtil::BLANK); + + /** Destroy an instance of a SceneManager. */ + void destroySceneManager(SceneManager* sm); + + /** Get an existing SceneManager instance that has already been created, + identified by the instance name. + @param instanceName The name of the instance to retrieve. + */ + SceneManager* getSceneManager(const String& instanceName) const; + + /** Get an iterator over all the existing SceneManager instances. */ + SceneManagerEnumerator::SceneManagerIterator getSceneManagerIterator(void); + + /** Retrieves a reference to the current TextureManager. + @remarks + This performs the same function as + TextureManager::getSingleton, but is provided for convenience + particularly to scripting engines. + @par + Note that a TextureManager will NOT be available until the + Ogre system has been initialised by selecting a RenderSystem, + calling Root::initialise and a window having been created + (this may have been done by initialise if required). This is + because the exact runtime subclass which will be implementing + the calls will differ depending on the rendering engine + selected, and these typically require a window upon which to + base texture format decisions. + */ + TextureManager* getTextureManager(void); + + /** Retrieves a reference to the current MeshManager. + @remarks + This performs the same function as MeshManager::getSingleton + and is provided for convenience to scripting engines. + */ + MeshManager* getMeshManager(void); + + /** Utility function for getting a better description of an error + code. + */ + String getErrorDescription(long errorNumber); + + /** Registers a FrameListener which will be called back every frame. + @remarks + A FrameListener is a class which implements methods which + will be called every frame. + @par + See the FrameListener class for more details on the specifics + It is imperitive that the instance passed to this method is + not destroyed before either the rendering loop ends, or the + class is removed from the listening list using + removeFrameListener. + @note +
This method can only be called after Root::initialise has + been called. + @see + FrameListener, Root::removeFrameListener + */ + void addFrameListener(FrameListener* newListener); + + /** Removes a FrameListener from the list of listening classes. + @see + FrameListener, Root::addFrameListener + */ + void removeFrameListener(FrameListener* oldListener); + + /** Queues the end of rendering. + @remarks + This method will do nothing unless startRendering() has + been called, in which case before the next frame is rendered + the rendering loop will bail out. + @see + Root, Root::startRendering + */ + void queueEndRendering(void); + + /** Starts / restarts the automatic rendering cycle. + @remarks + This method begins the automatic rendering of the scene. It + will NOT return until the rendering cycle is halted. + @par + During rendering, any FrameListener classes registered using + addFrameListener will be called back for each frame that is + to be rendered, These classes can tell OGRE to halt the + rendering if required, which will cause this method to + return. + @note +
Users of the OGRE library do not have to use this + automatic rendering loop. It is there as a convenience and is + most useful for high frame rate applications e.g. games. For + applications that don't need to constantly refresh the + rendering targets (e.g. an editor utility), it is better to + manually refresh each render target only when required by + calling RenderTarget::update, or if you want to run your own + render loop you can update all targets on demand using + Root::renderOneFrame. + @note + This frees up the CPU to do other things in between + refreshes, since in this case frame rate is less important. + @note + This method can only be called after Root::initialise has + been called. + */ + void startRendering(void); + + /** Render one frame. + @remarks + Updates all the render targets automatically and then returns, + raising frame events before and after. + */ + bool renderOneFrame(void); + /** Shuts down the system manually. + @remarks + This is normally done by Ogre automatically so don't think + you have to call this yourself. However this is here for + convenience, especially for dealing with unexpected errors or + for systems which need to shut down Ogre on demand. + */ + void shutdown(void); + + /** Adds a location to the list of searchable locations for a + Resource type. + @remarks + Resource files (textures, models etc) need to be loaded from + specific locations. By calling this method, you add another + search location to the list. Locations added first are preferred + over locations added later. + @par + Locations can be folders, compressed archives, even perhaps + remote locations. Facilities for loading from different + locations are provided by plugins which provide + implementations of the Archive class. + All the application user has to do is specify a 'loctype' + string in order to indicate the type of location, which + should map onto one of the provided plugins. Ogre comes + configured with the 'FileSystem' (folders) and 'Zip' (archive + compressed with the pkzip / WinZip etc utilities) types. + @par + You can also supply the name of a resource group which should + have this location applied to it. The + ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME group is the + default, and one resource group which will always exist. You + should consider defining resource groups for your more specific + resources (e.g. per level) so that you can control loading / + unloading better. + @param + name The name of the location, e.g. './data' or + '/compressed/gamedata.zip' + @param + locType A string identifying the location type, e.g. + 'FileSystem' (for folders), 'Zip' etc. Must map to a + registered plugin which deals with this type (FileSystem and + Zip should always be available) + @param + groupName Type of name of the resource group which this location + should apply to; defaults to the General group which applies to + all non-specific resources. + @param + recursive If the resource location has a concept of recursive + directory traversal, enabling this option will mean you can load + resources in subdirectories using only their unqualified name. + The default is to disable this so that resources in subdirectories + with the same name are still unique. + @see + Archive + */ + void addResourceLocation(const String& name, const String& locType, + const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, + bool recursive = false); + + /** Removes a resource location from the list. + @see addResourceLocation + @param name The name of the resource location as specified in addResourceLocation + @param groupName The name of the resource group to which this location + was assigned. + */ + void removeResourceLocation(const String& name, + const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); + + /** Generates a packed data version of the passed in ColourValue suitable for + use with the current RenderSystem. + @remarks + Since different render systems have different colour data formats (eg + RGBA for GL, ARGB for D3D) this method allows you to use 1 method for all. + @param colour The colour to convert + @param pDest Pointer to location to put the result. + */ + void convertColourValue(const ColourValue& colour, uint32* pDest); + + /** Retrieves a pointer to the window that was created automatically + @remarks + When Root is initialised an optional window is created. This + method retreives a pointer to that window. + @note + returns a null pointer when Root has not been initialised with + the option of creating a window. + */ + RenderWindow* getAutoCreatedWindow(void); + + /** @copydoc RenderSystem::createRenderWindow + */ + RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height, + bool fullScreen, const NameValuePairList *miscParams = 0) ; + + /** Destroys a rendering window. + */ + void detachRenderTarget( RenderTarget* pWin ); + + /** Destroys a named rendering window. + */ + void detachRenderTarget( const String & name ); + + /** Retrieves a pointer to the a named render window. + */ + RenderTarget * getRenderTarget(const String &name); + + /** Manually load a Plugin contained in a DLL / DSO. + @remarks + Plugins embedded in DLLs can be loaded at startup using the plugin + configuration file specified when you create Root (default: plugins.cfg). + This method allows you to load plugin DLLs directly in code. + The DLL in question is expected to implement a dllStartPlugin + method which instantiates a Plugin subclass and calls Root::installPlugin. + It should also implement dllStopPlugin (see Root::unloadPlugin) + @param pluginName Name of the plugin library to load + */ + void loadPlugin(const String& pluginName); + + /** Manually unloads a Plugin contained in a DLL / DSO. + @remarks + Plugin DLLs are unloaded at shutdown automatically. This method + allows you to unload plugins in code, but make sure their + dependencies are decoupled first. This method will call the + dllStopPlugin method defined in the DLL, which in turn should call + Root::uninstallPlugin. + @param pluginName Name of the plugin library to unload + */ + void unloadPlugin(const String& pluginName); + + /** Install a new plugin. + @remarks + This installs a new extension to OGRE. The plugin itself may be loaded + from a DLL / DSO, or it might be statically linked into your own + application. Either way, something has to call this method to get + it registered and functioning. You should only call this method directly + if your plugin is not in a DLL that could otherwise be loaded with + loadPlugin, since the DLL function dllStartPlugin should call this + method when the DLL is loaded. + */ + void installPlugin(Plugin* plugin); + + /** Uninstall an existing plugin. + @remarks + This uninstalls an extension to OGRE. Plugins are automatically + uninstalled at shutdown but this lets you remove them early. + If the plugin was loaded from a DLL / DSO you should call unloadPlugin + which should result in this method getting called anyway (if the DLL + is well behaved). + */ + void uninstallPlugin(Plugin* plugin); + + /** Gets a read-only list of the currently installed plugins. */ + const PluginInstanceList& getInstalledPlugins() const { return mPlugins; } + + /** Gets a pointer to the central timer used for all OGRE timings */ + Timer* getTimer(void); + + /** Method for raising frame started events. + @remarks + This method is only for internal use when you use OGRE's inbuilt rendering + loop (Root::startRendering). However, if you run your own rendering loop then + you should call this method to ensure that FrameListener objects are notified + of frame events; processes like texture animation and particle systems rely on + this. + @par + Calling this method also increments the frame number, which is + important for keeping some elements of the engine up to date. + @note + This method takes an event object as a parameter, so you can specify the times + yourself. If you are happy for OGRE to automatically calculate the frame time + for you, then call the other version of this method with no parameters. + @param evt Event object which includes all the timing information which you have + calculated for yourself + @returns False if one or more frame listeners elected that the rendering loop should + be terminated, true otherwise. + */ + bool _fireFrameStarted(FrameEvent& evt); + /** Method for raising frame ended events. + @remarks + This method is only for internal use when you use OGRE's inbuilt rendering + loop (Root::startRendering). However, if you run your own rendering loop then + you should call this method to ensure that FrameListener objects are notified + of frame events; processes like texture animation and particle systems rely on + this. + @note + This method takes an event object as a parameter, so you can specify the times + yourself. If you are happy for OGRE to automatically calculate the frame time + for you, then call the other version of this method with no parameters. + @param evt Event object which includes all the timing information which you have + calculated for yourself + @returns False if one or more frame listeners elected that the rendering loop should + be terminated, true otherwise. + */ + bool _fireFrameEnded(FrameEvent& evt); + /** Method for raising frame started events. + @remarks + This method is only for internal use when you use OGRE's inbuilt rendering + loop (Root::startRendering). However, if you run your own rendering loop then + you should call this method to ensure that FrameListener objects are notified + of frame events; processes like texture animation and particle systems rely on + this. + @par + Calling this method also increments the frame number, which is + important for keeping some elements of the engine up to date. + @note + This method calculates the frame timing information for you based on the elapsed + time. If you want to specify elapsed times yourself you should call the other + version of this method which takes event details as a parameter. + @returns False if one or more frame listeners elected that the rendering loop should + be terminated, true otherwise. + */ + bool _fireFrameStarted(); + /** Method for raising frame ended events. + @remarks + This method is only for internal use when you use OGRE's inbuilt rendering + loop (Root::startRendering). However, if you run your own rendering loop then + you should call this method to ensure that FrameListener objects are notified + of frame events; processes like texture animation and particle systems rely on + this. + @note + This method calculates the frame timing information for you based on the elapsed + time. If you want to specify elapsed times yourself you should call the other + version of this method which takes event details as a parameter. + @returns False if one or more frame listeners elected that the rendering loop should + be terminated, true otherwise. + */ + bool _fireFrameEnded(); + + /** Gets the number of the current frame. */ + unsigned long getCurrentFrameNumber(void) const { return mCurrentFrame; } + + /** Returns the scene manager currently being used to render a frame. + @remarks + This is only intended for internal use; it is only valid during the + rendering of a frame. + */ + SceneManager* _getCurrentSceneManager(void) const { return mCurrentSceneManager; } + /** Sets the scene manager currently being used to render a frame. + @remarks + This is only intended for internal use. + */ + void _setCurrentSceneManager(SceneManager* sm); + + /** Internal method used for updating all RenderTarget objects (windows, + renderable textures etc) which are set to auto-update. + @remarks + You don't need to use this method if you're using Ogre's own internal + rendering loop (Root::startRendering). If you're running your own loop + you may wish to call it to update all the render targets which are + set to auto update (RenderTarget::setAutoUpdated). You can also update + individual RenderTarget instances using their own update() method. + */ + void _updateAllRenderTargets(void); + + /** Create a new RenderQueueInvocationSequence, useful for linking to + Viewport instances to perform custom rendering. + @param name The name to give the new sequence + */ + RenderQueueInvocationSequence* createRenderQueueInvocationSequence( + const String& name); + + /** Get a RenderQueueInvocationSequence. + @param name The name to identify the sequence + */ + RenderQueueInvocationSequence* getRenderQueueInvocationSequence( + const String& name); + + /** Destroy a RenderQueueInvocationSequence. + @remarks + You must ensure that no Viewports are using this sequence. + @param name The name to identify the sequence + */ + void destroyRenderQueueInvocationSequence( + const String& name); + + /** Destroy all RenderQueueInvocationSequences. + @remarks + You must ensure that no Viewports are using custom sequences. + @param name The name to identify the sequence + */ + void destroyAllRenderQueueInvocationSequences(void); + + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static Root& getSingleton(void); + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static Root* getSingletonPtr(void); + + /** Clears the history of all event times. + @remarks + OGRE stores a history of the last few event times in order to smooth + out any inaccuracies and temporary fluctuations. However, if you + pause or don't render for a little while this can cause a lurch, so + if you're resuming rendering after a break, call this method to reset + the stored times + */ + void clearEventTimes(void); + + /** Sets the period over which OGRE smooths out fluctuations in frame times. + @remarks + OGRE by default gives you the raw frame time, but can optionally + smooths it out over several frames, in order to reduce the + noticeable effect of occasional hiccups in framerate. + These smoothed values are passed back as parameters to FrameListener + calls. + @par + This method allow you to tweak the smoothing period, and is expressed + in seconds. Setting it to 0 will result in completely unsmoothed + frame times (the default). + */ + void setFrameSmoothingPeriod(Real period) { mFrameSmoothingTime = period; } + /** Gets the period over which OGRE smooths out fluctuations in frame times. */ + Real getFrameSmoothingPeriod(void) const { return mFrameSmoothingTime; } + + /** Register a new MovableObjectFactory which will create new MovableObject + instances of a particular type, as identified by the getType() method. + @remarks + Plugin creators can create subclasses of MovableObjectFactory which + construct custom subclasses of MovableObject for insertion in the + scene. This is the primary way that plugins can make custom objects + available. + @param fact Pointer to the factory instance + @param overrideExisting Set this to true to override any existing + factories which are registered for the same type. You should only + change this if you are very sure you know what you're doing. + */ + void addMovableObjectFactory(MovableObjectFactory* fact, + bool overrideExisting = false); + /** Removes a previously registered MovableObjectFactory. + @remarks + All instances of objects created by this factory will be destroyed + before removing the factory (by calling back the factories + 'destroyInstance' method). The plugin writer is responsible for actually + destroying the factory. + */ + void removeMovableObjectFactory(MovableObjectFactory* fact); + /// Checks whether a factory is registered for a given MovableObject type + bool hasMovableObjectFactory(const String& typeName) const; + /// Get a MovableObjectFactory for the given type + MovableObjectFactory* getMovableObjectFactory(const String& typeName); + /** Allocate the next MovableObject type flag. + @remarks + This is done automatically if MovableObjectFactory::requestTypeFlags + returns true; don't call this manually unless you're sure you need to. + */ + uint32 _allocateNextMovableObjectTypeFlag(void); + + typedef ConstMapIterator MovableObjectFactoryIterator; + /** Return an iterator over all the MovableObjectFactory instances currently + registered. + */ + MovableObjectFactoryIterator getMovableObjectFactoryIterator(void) const; + }; +} // Namespace Ogre +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreRotationalSpline.h b/school/informatik/verkerhssimulation/src/ogre/OgreRotationalSpline.h new file mode 100644 index 00000000..c2969a3c --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreRotationalSpline.h @@ -0,0 +1,129 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __RotationalSpline_H__ +#define __RotationalSpline_H__ + +#include "OgrePrerequisites.h" +#include "OgreQuaternion.h" + +namespace Ogre { + + /** This class interpolates orientations (rotations) along a spline using + derivatives of quaternions. + @remarks + Like the SimpleSpline class, this class is about interpolating values + smoothly over a spline. Whilst SimpleSpline deals with positions (the normal + sense we think about splines), this class interpolates orientations. The + theory is identical, except we're now in 4-dimensional space instead of 3. + @par + In positional splines, we use the points and tangents on those points to generate + control points for the spline. In this case, we use quaternions and derivatives + of the quaternions (i.e. the rate and direction of change at each point). This is the + same as SimpleSpline since a tangent is a derivative of a position. We effectively + generate an extra quaternion in between each actual quaternion which when take with + the original quaternion forms the 'tangent' of that quaternion. + */ + class _OgreExport RotationalSpline + { + public: + RotationalSpline(); + ~RotationalSpline(); + + /** Adds a control point to the end of the spline. */ + void addPoint(const Quaternion& p); + + /** Gets the detail of one of the control points of the spline. */ + const Quaternion& getPoint(unsigned short index) const; + + /** Gets the number of control points in the spline. */ + unsigned short getNumPoints(void) const; + + /** Clears all the points in the spline. */ + void clear(void); + + /** Updates a single point in the spline. + @remarks + This point must already exist in the spline. + */ + void updatePoint(unsigned short index, const Quaternion& value); + + /** Returns an interpolated point based on a parametric value over the whole series. + @remarks + Given a t value between 0 and 1 representing the parametric distance along the + whole length of the spline, this method returns an interpolated point. + @param t Parametric value. + @param useShortestPath Defines if rotation should take the shortest possible path + */ + Quaternion interpolate(Real t, bool useShortestPath=true); + + /** Interpolates a single segment of the spline given a parametric value. + @param fromIndex The point index to treat as t=0. fromIndex + 1 is deemed to be t=1 + @param t Parametric value + @param useShortestPath Defines if rotation should take the shortest possible path + */ + Quaternion interpolate(unsigned int fromIndex, Real t, bool useShortestPath=true); + + /** Tells the spline whether it should automatically calculate tangents on demand + as points are added. + @remarks + The spline calculates tangents at each point automatically based on the input points. + Normally it does this every time a point changes. However, if you have a lot of points + to add in one go, you probably don't want to incur this overhead and would prefer to + defer the calculation until you are finished setting all the points. You can do this + by calling this method with a parameter of 'false'. Just remember to manually call + the recalcTangents method when you are done. + @param autoCalc If true, tangents are calculated for you whenever a point changes. If false, + you must call reclacTangents to recalculate them when it best suits. + */ + void setAutoCalculate(bool autoCalc); + + /** Recalculates the tangents associated with this spline. + @remarks + If you tell the spline not to update on demand by calling setAutoCalculate(false) + then you must call this after completing your updates to the spline points. + */ + void recalcTangents(void); + + protected: + + bool mAutoCalc; + + + + std::vector mPoints; + std::vector mTangents; + + }; + + +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreSceneManager.h b/school/informatik/verkerhssimulation/src/ogre/OgreSceneManager.h new file mode 100644 index 00000000..02257ad4 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreSceneManager.h @@ -0,0 +1,2871 @@ +/*------------------------------------------------------------------------- +This source file is a part of OGRE +(Object-oriented Graphics Rendering Engine) + +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License (LGPL) as +published by the Free Software Foundation; either version 2.1 of the +License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or go to +http://www.gnu.org/copyleft/lesser.txt + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +-------------------------------------------------------------------------*/ +#ifndef __SceneManager_H__ +#define __SceneManager_H__ + +// Precompiler options +#include "OgrePrerequisites.h" + +#include "OgreString.h" +#include "OgreSceneNode.h" +#include "OgrePlane.h" +#include "OgreQuaternion.h" +#include "OgreColourValue.h" +#include "OgreCommon.h" +#include "OgreSceneQuery.h" +#include "OgreAutoParamDataSource.h" +#include "OgreAnimationState.h" +#include "OgreRenderQueue.h" +#include "OgreRenderQueueSortingGrouping.h" +#include "OgreRectangle2D.h" +#include "OgrePixelFormat.h" +#include "OgreResourceGroupManager.h" +#include "OgreTexture.h" +#include "OgreShadowCameraSetup.h" +#include "OgreShadowTextureManager.h" +#include "OgreCamera.h" +#include "OgreInstancedGeometry.h" + +namespace Ogre { + + /** Structure for holding a position & orientation pair. */ + struct ViewPoint + { + Vector3 position; + Quaternion orientation; + }; + + // Forward declarations + class DefaultIntersectionSceneQuery; + class DefaultRaySceneQuery; + class DefaultSphereSceneQuery; + class DefaultAxisAlignedBoxSceneQuery; + + /** Structure collecting together information about the visible objects + that have been discovered in a scene. + */ + struct VisibleObjectsBoundsInfo + { + /// The axis-aligned bounds of the visible objects + AxisAlignedBox aabb; + /// The closest a visible object is to the camera + Real minDistance; + /// The farthest a visible objects is from the camera + Real maxDistance; + + VisibleObjectsBoundsInfo() + { + reset(); + } + + void reset() + { + aabb.setNull(); + minDistance = std::numeric_limits::infinity(); + maxDistance = 0; + } + + void merge(const AxisAlignedBox& boxBounds, const Sphere& sphereBounds, + const Camera* cam) + { + aabb.merge(boxBounds); + Real camDistToCenter = + (cam->getDerivedPosition() - sphereBounds.getCenter()).length(); + minDistance = (std::min)(minDistance, (std::max)((Real)0, camDistToCenter - sphereBounds.getRadius())); + maxDistance = (std::max)(maxDistance, camDistToCenter + sphereBounds.getRadius()); + } + + + }; + + /** Interface definition for classes which can listen in on the process + of rendering shadows, in order to implement custom behaviour. + */ + class _OgreExport ShadowListener + { + public: + ShadowListener() {} + virtual ~ShadowListener() {} + + /** Event raised after all shadow textures have been rendered into for + all queues / targets but before any other geometry has been rendered + (including main scene geometry and any additional shadow receiver + passes). + @remarks + This callback is useful for those that wish to perform some + additional processing on shadow textures before they are used to + render shadows. For example you could perform some filtering by + rendering the existing shadow textures into another alternative + shadow texture with a shader.] + @note + This event will only be fired when texture shadows are in use. + @param numberOfShadowTextures The number of shadow textures in use + */ + virtual void shadowTexturesUpdated(size_t numberOfShadowTextures) = 0; + + /** This event occurs just before the view & projection matrices are + set for rendering into a shadow texture. + @remarks + You can use this event hook to perform some custom processing, + such as altering the camera being used for rendering the light's + view, including setting custom view & projection matrices if you + want to perform an advanced shadow technique. + @note + This event will only be fired when texture shadows are in use. + @param light Pointer to the light for which shadows are being rendered + @param camera Pointer to the camera being used to render + */ + virtual void shadowTextureCasterPreViewProj(Light* light, + Camera* camera) = 0; + /** This event occurs just before the view & projection matrices are + set for re-rendering a shadow receiver. + @remarks + You can use this event hook to perform some custom processing, + such as altering the projection frustum being used for rendering + the shadow onto the receiver to perform an advanced shadow + technique. + @note + This event will only be fired when texture shadows are in use. + @param light Pointer to the light for which shadows are being rendered + @param frustum Pointer to the projection frustum being used to project + the shadow texture + */ + virtual void shadowTextureReceiverPreViewProj(Light* light, + Frustum* frustum) = 0; + + /** Hook to allow the listener to override the ordering of lights for + the entire frustum. + @remarks + Whilst ordinarily lights are sorted per rendered object + (@see MovableObject::queryLights), texture shadows adds another issue + in that, given there is a finite number of shadow textures, we must + choose which lights to render texture shadows from based on the entire + frustum. These lights should always be listed first in every objects + own list, followed by any other lights which will not cast texture + shadows (either because they have shadow casting off, or there aren't + enough shadow textures to service them). + @par + This hook allows you to override the detailed ordering of the lights + per frustum. The default ordering is shadow casters first (which you + must also respect if you override this method), and ordered + by distance from the camera within those 2 groups. Obviously the closest + lights with shadow casting enabled will be listed first. Only lights + within the range of the frustum will be in the list. + @param lightList The list of lights within range of the frustum which you + may sort. + @returns true if you sorted the list, false otherwise. + */ + virtual bool sortLightsAffectingFrustum(LightList& lightList) { return false; } + + + }; + + /** Manages the organisation and rendering of a 'scene' i.e. a collection + of objects and potentially world geometry. + @remarks + This class defines the interface and the basic behaviour of a + 'Scene Manager'. A SceneManager organises the culling and rendering of + the scene, in conjunction with the RenderQueue. This class is designed + to be extended through subclassing in order to provide more specialised + scene organisation structures for particular needs. The default + SceneManager culls based on a hierarchy of node bounding boxes, other + implementations can use an octree (@see OctreeSceneManager), a BSP + tree (@see BspSceneManager), and many other options. New SceneManager + implementations can be added at runtime by plugins, see + SceneManagerEnumerator for the interfaces for adding new SceneManager + types. + @par + There is a distinction between 'objects' (which subclass MovableObject, + and are movable, discrete objects in the world), and 'world geometry', + which is large, generally static geometry. World geometry tends to + influence the SceneManager organisational structure (e.g. lots of indoor + static geometry might result in a spatial tree structure) and as such + world geometry is generally tied to a given SceneManager implementation, + whilst MovableObject instances can be used with any SceneManager. + Subclasses are free to define world geometry however they please. + @par + Multiple SceneManager instances can exist at one time, each one with + a distinct scene. Which SceneManager is used to render a scene is + dependent on the Camera, which will always call back the SceneManager + which created it to render the scene. + */ + class _OgreExport SceneManager + { + public: + /// Query type mask which will be used for world geometry @see SceneQuery + static uint32 WORLD_GEOMETRY_TYPE_MASK; + /// Query type mask which will be used for entities @see SceneQuery + static uint32 ENTITY_TYPE_MASK; + /// Query type mask which will be used for effects like billboardsets / particle systems @see SceneQuery + static uint32 FX_TYPE_MASK; + /// Query type mask which will be used for StaticGeometry @see SceneQuery + static uint32 STATICGEOMETRY_TYPE_MASK; + /// Query type mask which will be used for lights @see SceneQuery + static uint32 LIGHT_TYPE_MASK; + /// User type mask limit + static uint32 USER_TYPE_MASK_LIMIT; + /** Comparator for material map, for sorting materials into render order (e.g. transparent last). + */ + struct materialLess + { + _OgreExport bool operator()(const Material* x, const Material* y) const; + }; + /// Comparator for sorting lights relative to a point + struct lightLess + { + _OgreExport bool operator()(const Light* a, const Light* b) const; + }; + + /// Describes the stage of rendering when performing complex illumination + enum IlluminationRenderStage + { + /// No special illumination stage + IRS_NONE, + /// Render to texture stage, used for texture based shadows + IRS_RENDER_TO_TEXTURE, + /// Render from shadow texture to receivers stage + IRS_RENDER_RECEIVER_PASS + }; + + /** Enumeration of the possible modes allowed for processing the special case + render queue list. + @see SceneManager::setSpecialCaseRenderQueueMode + */ + enum SpecialCaseRenderQueueMode + { + /// Render only the queues in the special case list + SCRQM_INCLUDE, + /// Render all except the queues in the special case list + SCRQM_EXCLUDE + }; + + struct SkyDomeGenParameters + { + Real skyDomeCurvature; + Real skyDomeTiling; + Real skyDomeDistance; + int skyDomeXSegments; + int skyDomeYSegments; + int skyDomeYSegments_keep; + }; + + struct SkyPlaneGenParameters + { + Real skyPlaneScale; + Real skyPlaneTiling; + Real skyPlaneBow; + int skyPlaneXSegments; + int skyPlaneYSegments; + }; + + struct SkyBoxGenParameters + { + Real skyBoxDistance; + }; + + protected: + /// Instance name + String mName; + + /// Queue of objects for rendering + RenderQueue* mRenderQueue; + + /// Current ambient light, cached for RenderSystem + ColourValue mAmbientLight; + + /// The rendering system to send the scene to + RenderSystem *mDestRenderSystem; + + typedef std::map CameraList; + + /** Central list of cameras - for easy memory management and lookup. + */ + CameraList mCameras; + + typedef std::map StaticGeometryList; + StaticGeometryList mStaticGeometryList; + typedef std::map InstancedGeometryList; + InstancedGeometryList mInstancedGeometryList; + + typedef std::map SceneNodeList; + + /** Central list of SceneNodes - for easy memory management. + @note + Note that this list is used only for memory management; the structure of the scene + is held using the hierarchy of SceneNodes starting with the root node. However you + can look up nodes this way. + */ + SceneNodeList mSceneNodes; + + /// Camera in progress + Camera* mCameraInProgress; + /// Current Viewport + Viewport* mCurrentViewport; + + /// Root scene node + SceneNode* mSceneRoot; + + /// Autotracking scene nodes + typedef std::set AutoTrackingSceneNodes; + AutoTrackingSceneNodes mAutoTrackingSceneNodes; + + // Sky params + // Sky plane + Entity* mSkyPlaneEntity; + Entity* mSkyDomeEntity[5]; + Entity* mSkyBoxEntity[6]; + + SceneNode* mSkyPlaneNode; + SceneNode* mSkyDomeNode; + SceneNode* mSkyBoxNode; + + // Sky plane + bool mSkyPlaneEnabled; + bool mSkyPlaneDrawFirst; + Plane mSkyPlane; + SkyPlaneGenParameters mSkyPlaneGenParameters; + // Sky box + bool mSkyBoxEnabled; + bool mSkyBoxDrawFirst; + Quaternion mSkyBoxOrientation; + SkyBoxGenParameters mSkyBoxGenParameters; + // Sky dome + bool mSkyDomeEnabled; + bool mSkyDomeDrawFirst; + Quaternion mSkyDomeOrientation; + SkyDomeGenParameters mSkyDomeGenParameters; + + // Fog + FogMode mFogMode; + ColourValue mFogColour; + Real mFogStart; + Real mFogEnd; + Real mFogDensity; + + typedef std::set SpecialCaseRenderQueueList; + SpecialCaseRenderQueueList mSpecialCaseQueueList; + SpecialCaseRenderQueueMode mSpecialCaseQueueMode; + uint8 mWorldGeometryRenderQueue; + + unsigned long mLastFrameNumber; + Matrix4 mTempXform[256]; + bool mResetIdentityView; + bool mResetIdentityProj; + + protected: + + /** Visible objects bounding box list. + @remarks + Holds an ABB for each camera that contains the physical extends of the visible + scene elements by each camera. The map is crutial for shadow algorithms which + have a focus step to limit the shadow sample distribution to only valid visible + scene elements. + */ + typedef std::map< const Camera*, VisibleObjectsBoundsInfo> CamVisibleObjectsMap; + CamVisibleObjectsMap mCamVisibleObjectsMap; + + /** ShadowCamera to light mapping */ + typedef std::map< const Camera*, const Light* > ShadowCamLightMapping; + ShadowCamLightMapping mShadowCamLightMapping; + + /// Cached light information, used to tracking light's changes + struct _OgreExport LightInfo + { + Light* light; // Just a pointer for comparison, the light might destroyed for some reason + int type; // Use int instead of Light::LightTypes to avoid header file dependence + Real range; // Sets to zero if directional light + Vector3 position; // Sets to zero if directional light + + bool operator== (const LightInfo& rhs) const + { + return light == rhs.light && type == rhs.type && + range == rhs.range && position == rhs.position; + } + + bool operator!= (const LightInfo& rhs) const + { + return !(*this == rhs); + } + }; + + typedef std::vector LightInfoList; + + LightList mLightsAffectingFrustum; + LightInfoList mCachedLightInfos; + LightInfoList mTestLightInfos; // potentially new list + ulong mLightsDirtyCounter; + + typedef std::map MovableObjectMap; + /// Simple structure to hold MovableObject map and a mutex to go with it. + struct MovableObjectCollection + { + MovableObjectMap map; + OGRE_MUTEX(mutex) + }; + typedef std::map MovableObjectCollectionMap; + MovableObjectCollectionMap mMovableObjectCollectionMap; + /** Gets the movable object collection for the given type name. + @remarks + This method create new collection if the collection does not exist. + */ + MovableObjectCollection* getMovableObjectCollection(const String& typeName); + /** Gets the movable object collection for the given type name. + @remarks + This method throw exception if the collection does not exist. + */ + const MovableObjectCollection* getMovableObjectCollection(const String& typeName) const; + /// Mutex over the collection of MovableObject types + OGRE_MUTEX(mMovableObjectCollectionMapMutex) + + /** Internal method for initialising the render queue. + @remarks + Subclasses can use this to install their own RenderQueue implementation. + */ + virtual void initRenderQueue(void); + /// A pass designed to let us render shadow colour on white for texture shadows + Pass* mShadowCasterPlainBlackPass; + /// A pass designed to let us render shadow receivers for texture shadows + Pass* mShadowReceiverPass; + /** Internal method for turning a regular pass into a shadow caster pass. + @remarks + This is only used for texture shadows, basically we're trying to + ensure that objects are rendered solid black. + This method will usually return the standard solid black pass for + all fixed function passes, but will merge in a vertex program + and fudge the AutpoParamDataSource to set black lighting for + passes with vertex programs. + */ + const Pass* deriveShadowCasterPass(const Pass* pass); + /** Internal method for turning a regular pass into a shadow receiver pass. + @remarks + This is only used for texture shadows, basically we're trying to + ensure that objects are rendered with a projective texture. + This method will usually return a standard single-texture pass for + all fixed function passes, but will merge in a vertex program + for passes with vertex programs. + */ + const Pass* deriveShadowReceiverPass(const Pass* pass); + + /** Internal method to validate whether a Pass should be allowed to render. + @remarks + Called just before a pass is about to be used for rendering a group to + allow the SceneManager to omit it if required. A return value of false + skips this pass. + */ + bool validatePassForRendering(const Pass* pass); + + /** Internal method to validate whether a Renderable should be allowed to render. + @remarks + Called just before a pass is about to be used for rendering a Renderable to + allow the SceneManager to omit it if required. A return value of false + skips it. + */ + bool validateRenderableForRendering(const Pass* pass, const Renderable* rend); + + enum BoxPlane + { + BP_FRONT = 0, + BP_BACK = 1, + BP_LEFT = 2, + BP_RIGHT = 3, + BP_UP = 4, + BP_DOWN = 5 + }; + + /* Internal utility method for creating the planes of a skybox. + */ + MeshPtr createSkyboxPlane( + BoxPlane bp, + Real distance, + const Quaternion& orientation, + const String& groupName); + + /* Internal utility method for creating the planes of a skydome. + */ + MeshPtr createSkydomePlane( + BoxPlane bp, + Real curvature, Real tiling, Real distance, + const Quaternion& orientation, + int xsegments, int ysegments, int ySegmentsToKeep, + const String& groupName); + + // Flag indicating whether SceneNodes will be rendered as a set of 3 axes + bool mDisplayNodes; + + /// Storage of animations, lookup by name + typedef std::map AnimationList; + AnimationList mAnimationsList; + OGRE_MUTEX(mAnimationsListMutex) + AnimationStateSet mAnimationStates; + + + /** Internal method used by _renderSingleObject to deal with renderables + which override the camera's own view / projection materices. */ + void useRenderableViewProjMode(const Renderable* pRend); + + /** Internal method used by _renderSingleObject to deal with renderables + which override the camera's own view / projection matrices. */ + void resetViewProjMode(void); + + typedef std::vector RenderQueueListenerList; + RenderQueueListenerList mRenderQueueListeners; + + typedef std::vector ShadowListenerList; + ShadowListenerList mShadowListeners; + /// Internal method for firing the queue start event, returns true if queue is to be skipped + bool fireRenderQueueStarted(uint8 id, const String& invocation); + /// Internal method for firing the queue end event, returns true if queue is to be repeated + bool fireRenderQueueEnded(uint8 id, const String& invocation); + + /// Internal method for firing the texture shadows updated event + void fireShadowTexturesUpdated(size_t numberOfShadowTextures); + /// Internal method for firing the pre caster texture shadows event + void fireShadowTexturesPreCaster(Light* light, Camera* camera); + /// Internal method for firing the pre receiver texture shadows event + void fireShadowTexturesPreReceiver(Light* light, Frustum* f); + /** Internal method for setting the destination viewport for the next render. */ + virtual void setViewport(Viewport *vp); + + /** Flag that indicates if all of the scene node's bounding boxes should be shown as a wireframe. */ + bool mShowBoundingBoxes; + + /** Internal method for rendering all objects using the default queue sequence. */ + virtual void renderVisibleObjectsDefaultSequence(void); + /** Internal method for rendering all objects using a custom queue sequence. */ + virtual void renderVisibleObjectsCustomSequence(RenderQueueInvocationSequence* s); + /** Internal method for preparing the render queue for use with each render. */ + virtual void prepareRenderQueue(void); + + + /** Internal utility method for rendering a single object. + @remarks + Assumes that the pass has already been set up. + @param rend The renderable to issue to the pipeline + @param pass The pass which is being used + @param doLightIteration If true, this method will issue the renderable to + the pipeline possibly multiple times, if the pass indicates it should be + done once per light + @param manualLightList Only applicable if doLightIteration is false, this + method allows you to pass in a previously determined set of lights + which will be used for a single render of this object. + */ + virtual void renderSingleObject(const Renderable* rend, const Pass* pass, + bool doLightIteration, const LightList* manualLightList = 0); + + /// Utility class for calculating automatic parameters for gpu programs + AutoParamDataSource mAutoParamDataSource; + + ShadowTechnique mShadowTechnique; + bool mDebugShadows; + ColourValue mShadowColour; + Pass* mShadowDebugPass; + Pass* mShadowStencilPass; + Pass* mShadowModulativePass; + bool mShadowMaterialInitDone; + HardwareIndexBufferSharedPtr mShadowIndexBuffer; + size_t mShadowIndexBufferSize; + Rectangle2D* mFullScreenQuad; + Real mShadowDirLightExtrudeDist; + IlluminationRenderStage mIlluminationStage; + ShadowTextureConfigList mShadowTextureConfigList; + bool mShadowTextureConfigDirty; + ShadowTextureList mShadowTextures; + TexturePtr mNullShadowTexture; + typedef std::vector ShadowTextureCameraList; + ShadowTextureCameraList mShadowTextureCameras; + Texture* mCurrentShadowTexture; + bool mShadowUseInfiniteFarPlane; + bool mShadowCasterRenderBackFaces; + + /// default shadow camera setup + ShadowCameraSetupPtr mDefaultShadowCameraSetup; + + /** Default sorting routine which sorts lights which cast shadows + to the front of a list, sub-sorting by distance. + @remarks + Since shadow textures are generated from lights based on the + frustum rather than individual objects, a shadow and camera-wise sort is + required to pick the best lights near the start of the list. Up to + the number of shadow textures will be generated from this. + */ + struct lightsForShadowTextureLess + { + _OgreExport bool operator()(const Light* l1, const Light* l2) const; + }; + + + /** Internal method for locating a list of lights which could be affecting the frustum. + @remarks + Custom scene managers are encouraged to override this method to make use of their + scene partitioning scheme to more efficiently locate lights, and to eliminate lights + which may be occluded by word geometry. + */ + virtual void findLightsAffectingFrustum(const Camera* camera); + /// Internal method for setting up materials for shadows + virtual void initShadowVolumeMaterials(void); + /// Internal method for creating shadow textures (texture-based shadows) + virtual void ensureShadowTexturesCreated(); + /// Internal method for destroying shadow textures (texture-based shadows) + virtual void destroyShadowTextures(void); + /// Internal method for preparing shadow textures ready for use in a regular render + virtual void prepareShadowTextures(Camera* cam, Viewport* vp); + + /** Internal method for rendering all the objects for a given light into the + stencil buffer. + @param light The light source + @param cam The camera being viewed from + */ + virtual void renderShadowVolumesToStencil(const Light* light, const Camera* cam); + /** Internal utility method for setting stencil state for rendering shadow volumes. + @param secondpass Is this the second pass? + @param zfail Should we be using the zfail method? + @param twosided Should we use a 2-sided stencil? + */ + virtual void setShadowVolumeStencilState(bool secondpass, bool zfail, bool twosided); + /** Render a set of shadow renderables. */ + void renderShadowVolumeObjects(ShadowCaster::ShadowRenderableListIterator iShadowRenderables, + Pass* pass, const LightList *manualLightList, unsigned long flags, + bool secondpass, bool zfail, bool twosided); + typedef std::vector ShadowCasterList; + ShadowCasterList mShadowCasterList; + SphereSceneQuery* mShadowCasterSphereQuery; + AxisAlignedBoxSceneQuery* mShadowCasterAABBQuery; + Real mShadowFarDist; + Real mShadowFarDistSquared; + Real mShadowTextureOffset; // proportion of texture offset in view direction e.g. 0.4 + Real mShadowTextureFadeStart; // as a proportion e.g. 0.6 + Real mShadowTextureFadeEnd; // as a proportion e.g. 0.9 + bool mShadowTextureSelfShadow; + Pass* mShadowTextureCustomCasterPass; + Pass* mShadowTextureCustomReceiverPass; + String mShadowTextureCustomCasterVertexProgram; + String mShadowTextureCustomReceiverVertexProgram; + String mShadowTextureCustomReceiverFragmentProgram; + GpuProgramParametersSharedPtr mShadowTextureCustomCasterVPParams; + GpuProgramParametersSharedPtr mShadowTextureCustomReceiverVPParams; + GpuProgramParametersSharedPtr mShadowTextureCustomReceiverFPParams; + + /// Visibility mask used to show / hide objects + uint32 mVisibilityMask; + bool mFindVisibleObjects; + + /// Suppress render state changes? + bool mSuppressRenderStateChanges; + /// Suppress shadows? + bool mSuppressShadows; + + + GpuProgramParametersSharedPtr mInfiniteExtrusionParams; + GpuProgramParametersSharedPtr mFiniteExtrusionParams; + + /// Inner class to use as callback for shadow caster scene query + class _OgreExport ShadowCasterSceneQueryListener : public SceneQueryListener + { + protected: + SceneManager* mSceneMgr; + ShadowCasterList* mCasterList; + bool mIsLightInFrustum; + const PlaneBoundedVolumeList* mLightClipVolumeList; + const Camera* mCamera; + const Light* mLight; + Real mFarDistSquared; + public: + ShadowCasterSceneQueryListener(SceneManager* sm) : mSceneMgr(sm), + mCasterList(0), mIsLightInFrustum(false), mLightClipVolumeList(0), + mCamera(0) {} + // Prepare the listener for use with a set of parameters + void prepare(bool lightInFrustum, + const PlaneBoundedVolumeList* lightClipVolumes, + const Light* light, const Camera* cam, ShadowCasterList* casterList, + Real farDistSquared) + { + mCasterList = casterList; + mIsLightInFrustum = lightInFrustum; + mLightClipVolumeList = lightClipVolumes; + mCamera = cam; + mLight = light; + mFarDistSquared = farDistSquared; + } + bool queryResult(MovableObject* object); + bool queryResult(SceneQuery::WorldFragment* fragment); + }; + + ShadowCasterSceneQueryListener* mShadowCasterQueryListener; + + /** Internal method for locating a list of shadow casters which + could be affecting the frustum for a given light. + @remarks + Custom scene managers are encouraged to override this method to add optimisations, + and to add their own custom shadow casters (perhaps for world geometry) + */ + virtual const ShadowCasterList& findShadowCastersForLight(const Light* light, + const Camera* camera); + /** Render a group in the ordinary way */ + virtual void renderBasicQueueGroupObjects(RenderQueueGroup* pGroup, + QueuedRenderableCollection::OrganisationMode om); + /** Render a group with the added complexity of additive stencil shadows. */ + virtual void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* group, + QueuedRenderableCollection::OrganisationMode om); + /** Render a group with the added complexity of modulative stencil shadows. */ + virtual void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* group, + QueuedRenderableCollection::OrganisationMode om); + /** Render a group rendering only shadow casters. */ + virtual void renderTextureShadowCasterQueueGroupObjects(RenderQueueGroup* group, + QueuedRenderableCollection::OrganisationMode om); + /** Render a group rendering only shadow receivers. */ + virtual void renderTextureShadowReceiverQueueGroupObjects(RenderQueueGroup* group, + QueuedRenderableCollection::OrganisationMode om); + /** Render a group with the added complexity of modulative texture shadows. */ + virtual void renderModulativeTextureShadowedQueueGroupObjects(RenderQueueGroup* group, + QueuedRenderableCollection::OrganisationMode om); + + /** Render a group with additive texture shadows. */ + virtual void renderAdditiveTextureShadowedQueueGroupObjects(RenderQueueGroup* group, + QueuedRenderableCollection::OrganisationMode om); + /** Render a set of objects, see renderSingleObject for param definitions */ + virtual void renderObjects(const QueuedRenderableCollection& objs, + QueuedRenderableCollection::OrganisationMode om, + bool doLightIteration, const LightList* manualLightList = 0); + /** Render those objects in the transparent pass list which have shadow casting forced on + @remarks + This function is intended to be used to render the shadows of transparent objects which have + transparency_casts_shadows set to 'on' in their material + */ + virtual void renderTransparentShadowCasterObjects(const QueuedRenderableCollection& objs, + QueuedRenderableCollection::OrganisationMode om, + bool doLightIteration, const LightList* manualLightList = 0); + + /** Update the state of the global render queue splitting based on a shadow + option change. */ + virtual void updateRenderQueueSplitOptions(void); + /** Update the state of the render queue group splitting based on a shadow + option change. */ + virtual void updateRenderQueueGroupSplitOptions(RenderQueueGroup* group, + bool suppressShadows, bool suppressRenderState); + + /** Inner helper class to implement the visitor pattern for rendering objects + in a queue. + */ + class _OgreExport SceneMgrQueuedRenderableVisitor : public QueuedRenderableVisitor + { + protected: + /// Pass that was actually used at the grouping level + const Pass* mUsedPass; + public: + SceneMgrQueuedRenderableVisitor() + :transparentShadowCastersMode(false) {} + ~SceneMgrQueuedRenderableVisitor() {} + void visit(const Renderable* r); + bool visit(const Pass* p); + void visit(const RenderablePass* rp); + + /// Target SM to send renderables to + SceneManager* targetSceneMgr; + /// Are we in transparent shadow caster mode? + bool transparentShadowCastersMode; + /// Automatic light handling? + bool autoLights; + /// Manual light list + const LightList* manualLightList; + + }; + /// Allow visitor helper to access protected methods + friend class SceneMgrQueuedRenderableVisitor; + /// The active renderable visitor class - subclasses could override this + SceneMgrQueuedRenderableVisitor* mActiveQueuedRenderableVisitor; + /// Storage for default renderable visitor + SceneMgrQueuedRenderableVisitor mDefaultQueuedRenderableVisitor; + + public: + /** Constructor. + */ + SceneManager(const String& instanceName); + + /** Default destructor. + */ + virtual ~SceneManager(); + + + /** Mutex to protect the scene graph from simultaneous access from + multiple threads. + @remarks + If you are updating the scene in a separate thread from the rendering + thread, then you should lock this mutex before making any changes to + the scene graph - that means creating, modifying or deleting a + scene node, or attaching / detaching objects. It is your + responsibility to take out this lock, the detail methods on the nodes + will not do it for you (for the reasons discussed below). + @par + Note that locking this mutex will prevent the scene being rendered until + it is unlocked again. Therefore you should do this sparingly. Try + to create any objects you need separately and fully prepare them + before doing all your scene graph work in one go, thus keeping this + lock for the shortest time possible. + @note + A single global lock is used rather than a per-node lock since + it keeps the number of locks required during rendering down to a + minimum. Obtaining a lock, even if there is no contention, is not free + so for performance it is good to do it as little as possible. + Since modifying the scene in a separate thread is a fairly + rare occurrence (relative to rendering), it is better to keep the + locking required during rendering lower than to make update locks + more granular. + */ + OGRE_MUTEX(sceneGraphMutex) + + /** Return the instance name of this SceneManager. */ + const String& getName(void) const { return mName; } + + /** Retrieve the type name of this scene manager. + @remarks + This method has to be implemented by subclasses. It should + return the type name of this SceneManager which agrees with + the type name of the SceneManagerFactory which created it. + */ + virtual const String& getTypeName(void) const = 0; + + /** Creates a camera to be managed by this scene manager. + @remarks + This camera must be added to the scene at a later time using + the attachObject method of the SceneNode class. + @param + name Name to give the new camera. + */ + virtual Camera* createCamera(const String& name); + + /** Retrieves a pointer to the named camera. + @note Throws an exception if the named instance does not exist + */ + virtual Camera* getCamera(const String& name) const; + + /** Returns whether a camera with the given name exists. + */ + virtual bool hasCamera(const String& name) const; + + /** Removes a camera from the scene. + @remarks + This method removes a previously added camera from the scene. + The camera is deleted so the caller must ensure no references + to it's previous instance (e.g. in a SceneNode) are used. + @param + cam Pointer to the camera to remove + */ + virtual void destroyCamera(Camera *cam); + + /** Removes a camera from the scene. + @remarks + This method removes an camera from the scene based on the + camera's name rather than a pointer. + */ + virtual void destroyCamera(const String& name); + + /** Removes (and destroys) all cameras from the scene. + @remarks + Some cameras are internal created to dealing with texture shadow, + their aren't supposed to destroy outside. So, while you are using + texture shadow, don't call this method, or you can set the shadow + technique other than texture-based, which will destroy all internal + created shadow cameras and textures. + */ + virtual void destroyAllCameras(void); + + /** Creates a light for use in the scene. + @remarks + Lights can either be in a fixed position and independent of the + scene graph, or they can be attached to SceneNodes so they derive + their position from the parent node. Either way, they are created + using this method so that the SceneManager manages their + existence. + @param + name The name of the new light, to identify it later. + */ + virtual Light* createLight(const String& name); + + /** Returns a pointer to the named Light which has previously been added to the scene. + @note Throws an exception if the named instance does not exist + */ + virtual Light* getLight(const String& name) const; + + /** Returns whether a light with the given name exists. + */ + virtual bool hasLight(const String& name) const; + + /** Removes the named light from the scene and destroys it. + @remarks + Any pointers held to this light after calling this method will be invalid. + */ + virtual void destroyLight(const String& name); + + /** Removes the light from the scene and destroys it based on a pointer. + @remarks + Any pointers held to this light after calling this method will be invalid. + */ + virtual void destroyLight(Light* light); + /** Removes and destroys all lights in the scene. + */ + virtual void destroyAllLights(void); + + /** Advance method to increase the lights dirty counter due lights changed. + @remarks + Scene manager tracking lights that affecting the frustum, if changes + detected (the changes includes light list itself and the light's position + and attenuation range), then increase the lights dirty counter. + @par + For some reason, you can call this method to force whole scene objects + re-populate their light list. But near in mind, call to this method + will harm performance, so should avoid if possible. + */ + virtual void _notifyLightsDirty(void); + + /** Advance method to gets the lights dirty counter. + @remarks + Scene manager tracking lights that affecting the frustum, if changes + detected (the changes includes light list itself and the light's position + and attenuation range), then increase the lights dirty counter. + @par + When implementing customise lights finding algorithm relied on either + SceneManager::_getLightsAffectingFrustum or SceneManager::_populateLightList, + might check this value for sure that the light list are really need to + re-populate, otherwise, returns cached light list (if exists) for better + performance. + */ + ulong _getLightsDirtyCounter(void) const { return mLightsDirtyCounter; } + + /** Get the list of lights which could be affecting the frustum. + @remarks + Note that default implementation of this method returns a cached light list, + which is populated when rendering the scene. So by default the list of lights + is only available during scene rendering. + */ + virtual const LightList& _getLightsAffectingFrustum(void) const; + + /** Populate a light list with an ordered set of the lights which are closest + to the position specified. + @remarks + Note that since directional lights have no position, they are always considered + closer than any point lights and as such will always take precedence. + @par + Subclasses of the default SceneManager may wish to take into account other issues + such as possible visibility of the light if that information is included in their + data structures. This basic scenemanager simply orders by distance, eliminating + those lights which are out of range or could not be affecting the frustum (i.e. + only the lights returned by SceneManager::_getLightsAffectingFrustum are take into + account). + @par + The number of items in the list max exceed the maximum number of lights supported + by the renderer, but the extraneous ones will never be used. In fact the limit will + be imposed by Pass::getMaxSimultaneousLights. + @param position The position at which to evaluate the list of lights + @param radius The bounding radius to test + @param destList List to be populated with ordered set of lights; will be cleared by + this method before population. + */ + virtual void _populateLightList(const Vector3& position, Real radius, LightList& destList); + + + /** Creates an instance of a SceneNode. + @remarks + Note that this does not add the SceneNode to the scene hierarchy. + This method is for convenience, since it allows an instance to + be created for which the SceneManager is responsible for + allocating and releasing memory, which is convenient in complex + scenes. + @par + To include the returned SceneNode in the scene, use the addChild + method of the SceneNode which is to be it's parent. + @par + Note that this method takes no parameters, and the node created is unnamed (it is + actually given a generated name, which you can retrieve if you want). + If you wish to create a node with a specific name, call the alternative method + which takes a name parameter. + */ + virtual SceneNode* createSceneNode(void); + + /** Creates an instance of a SceneNode with a given name. + @remarks + Note that this does not add the SceneNode to the scene hierarchy. + This method is for convenience, since it allows an instance to + be created for which the SceneManager is responsible for + allocating and releasing memory, which is convenient in complex + scenes. + @par + To include the returned SceneNode in the scene, use the addChild + method of the SceneNode which is to be it's parent. + @par + Note that this method takes a name parameter, which makes the node easier to + retrieve directly again later. + */ + virtual SceneNode* createSceneNode(const String& name); + + /** Destroys a SceneNode with a given name. + @remarks + This allows you to physically delete an individual SceneNode if you want to. + Note that this is not normally recommended, it's better to allow SceneManager + to delete the nodes when the scene is cleared. + */ + virtual void destroySceneNode(const String& name); + + /** Gets the SceneNode at the root of the scene hierarchy. + @remarks + The entire scene is held as a hierarchy of nodes, which + allows things like relative transforms, general changes in + rendering state etc (See the SceneNode class for more info). + In this basic SceneManager class, the application using + Ogre is free to structure this hierarchy however it likes, + since it has no real significance apart from making transforms + relative to each node (more specialised subclasses will + provide utility methods for building specific node structures + e.g. loading a BSP tree). + @par + However, in all cases there is only ever one root node of + the hierarchy, and this method returns a pointer to it. + */ + virtual SceneNode* getRootSceneNode(void) const; + + /** Retrieves a named SceneNode from the scene graph. + @remarks + If you chose to name a SceneNode as you created it, or if you + happened to make a note of the generated name, you can look it + up wherever it is in the scene graph using this method. + @note Throws an exception if the named instance does not exist + */ + virtual SceneNode* getSceneNode(const String& name) const; + + /** Returns whether a scene node with the given name exists. + */ + virtual bool hasSceneNode(const String& name) const; + + + /** Create an Entity (instance of a discrete mesh). + @param + entityName The name to be given to the entity (must be unique). + @param + meshName The name of the Mesh it is to be based on (e.g. 'knot.oof'). The + mesh will be loaded if it is not already. + */ + virtual Entity* createEntity(const String& entityName, const String& meshName); + + /** Prefab shapes available without loading a model. + @note + Minimal implementation at present. + @todo + Add more prefabs (teapots, teapots!!!) + */ + enum PrefabType { + PT_PLANE, + PT_CUBE, + PT_SPHERE + }; + + /** Create an Entity (instance of a discrete mesh) from a range of prefab shapes. + @param + entityName The name to be given to the entity (must be unique). + @param + ptype The prefab type. + */ + virtual Entity* createEntity(const String& entityName, PrefabType ptype); + /** Retrieves a pointer to the named Entity. + @note Throws an exception if the named instance does not exist + */ + virtual Entity* getEntity(const String& name) const; + /** Returns whether an entity with the given name exists. + */ + virtual bool hasEntity(const String& name) const; + + /** Removes & destroys an Entity from the SceneManager. + @warning + Must only be done if the Entity is not attached + to a SceneNode. It may be safer to wait to clear the whole + scene if you are unsure use clearScene. + @see + SceneManager::clearScene + */ + virtual void destroyEntity(Entity* ent); + + /** Removes & destroys an Entity from the SceneManager by name. + @warning + Must only be done if the Entity is not attached + to a SceneNode. It may be safer to wait to clear the whole + scene if you are unsure use clearScene. + @see + SceneManager::clearScene + */ + virtual void destroyEntity(const String& name); + + /** Removes & destroys all Entities. + @warning + Again, use caution since no Entity must be referred to + elsewhere e.g. attached to a SceneNode otherwise a crash + is likely. Use clearScene if you are unsure (it clears SceneNode + entries too.) + @see + SceneManager::clearScene + */ + virtual void destroyAllEntities(void); + + /** Create a ManualObject, an object which you populate with geometry + manually through a GL immediate-mode style interface. + @param + name The name to be given to the object (must be unique). + */ + virtual ManualObject* createManualObject(const String& name); + /** Retrieves a pointer to the named ManualObject. + @note Throws an exception if the named instance does not exist + */ + virtual ManualObject* getManualObject(const String& name) const; + /** Returns whether a manual object with the given name exists. + */ + virtual bool hasManualObject(const String& name) const; + + /** Removes & destroys a ManualObject from the SceneManager. + */ + virtual void destroyManualObject(ManualObject* obj); + /** Removes & destroys a ManualObject from the SceneManager. + */ + virtual void destroyManualObject(const String& name); + /** Removes & destroys all ManualObjects from the SceneManager. + */ + virtual void destroyAllManualObjects(void); + /** Create a BillboardChain, an object which you can use to render + a linked chain of billboards. + @param + name The name to be given to the object (must be unique). + */ + virtual BillboardChain* createBillboardChain(const String& name); + /** Retrieves a pointer to the named BillboardChain. + @note Throws an exception if the named instance does not exist + */ + virtual BillboardChain* getBillboardChain(const String& name) const; + /** Returns whether a billboard chain with the given name exists. + */ + virtual bool hasBillboardChain(const String& name) const; + + /** Removes & destroys a BillboardChain from the SceneManager. + */ + virtual void destroyBillboardChain(BillboardChain* obj); + /** Removes & destroys a BillboardChain from the SceneManager. + */ + virtual void destroyBillboardChain(const String& name); + /** Removes & destroys all BillboardChains from the SceneManager. + */ + virtual void destroyAllBillboardChains(void); + /** Create a RibbonTrail, an object which you can use to render + a linked chain of billboards which follows one or more nodes. + @param + name The name to be given to the object (must be unique). + */ + virtual RibbonTrail* createRibbonTrail(const String& name); + /** Retrieves a pointer to the named RibbonTrail. + @note Throws an exception if the named instance does not exist + */ + virtual RibbonTrail* getRibbonTrail(const String& name) const; + /** Returns whether a ribbon trail with the given name exists. + */ + virtual bool hasRibbonTrail(const String& name) const; + + /** Removes & destroys a RibbonTrail from the SceneManager. + */ + virtual void destroyRibbonTrail(RibbonTrail* obj); + /** Removes & destroys a RibbonTrail from the SceneManager. + */ + virtual void destroyRibbonTrail(const String& name); + /** Removes & destroys all RibbonTrails from the SceneManager. + */ + virtual void destroyAllRibbonTrails(void); + + /** Creates a particle system based on a template. + @remarks + This method creates a new ParticleSystem instance based on the named template + (defined through ParticleSystemManager::createTemplate) and returns a + pointer to the caller. The caller should not delete this object, it will be freed at system shutdown, + or can be released earlier using the destroyParticleSystem method. + @par + Each system created from a template takes the template's settings at the time of creation, + but is completely separate from the template from there on. + @par + Creating a particle system does not make it a part of the scene. As with other MovableObject + subclasses, a ParticleSystem is not rendered until it is attached to a SceneNode. + @par + This is probably the more useful particle system creation method since it does not require manual + setup of the system. Note that the initial quota is based on the template but may be changed later. + @param + name The name to give the new particle system instance. + @param + templateName The name of the template to base the new instance on. + */ + virtual ParticleSystem* createParticleSystem(const String& name, + const String& templateName); + /** Create a blank particle system. + @remarks + This method creates a new, blank ParticleSystem instance and returns a pointer to it. + The caller should not delete this object, it will be freed at system shutdown, or can + be released earlier using the destroyParticleSystem method. + @par + The instance returned from this method won't actually do anything because on creation a + particle system has no emitters. The caller should manipulate the instance through it's + ParticleSystem methods to actually create a real particle effect. + @par + Creating a particle system does not make it a part of the scene. As with other MovableObject + subclasses, a ParticleSystem is not rendered until it is attached to a SceneNode. + @param + name The name to give the ParticleSystem. + @param + quota The maximum number of particles to allow in this system. + @param + resourceGroup The resource group which will be used to load dependent resources + */ + virtual ParticleSystem* createParticleSystem(const String& name, + size_t quota = 500, + const String& resourceGroup = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); + /** Retrieves a pointer to the named ParticleSystem. + @note Throws an exception if the named instance does not exist + */ + virtual ParticleSystem* getParticleSystem(const String& name) const; + /** Returns whether a particle system with the given name exists. + */ + virtual bool hasParticleSystem(const String& name) const; + + /** Removes & destroys a ParticleSystem from the SceneManager. + */ + virtual void destroyParticleSystem(ParticleSystem* obj); + /** Removes & destroys a ParticleSystem from the SceneManager. + */ + virtual void destroyParticleSystem(const String& name); + /** Removes & destroys all ParticleSystems from the SceneManager. + */ + virtual void destroyAllParticleSystems(void); + + /** Empties the entire scene, inluding all SceneNodes, Entities, Lights, + BillboardSets etc. Cameras are not deleted at this stage since + they are still referenced by viewports, which are not destroyed during + this process. + */ + virtual void clearScene(void); + + /** Sets the ambient light level to be used for the scene. + @remarks + This sets the colour and intensity of the ambient light in the scene, i.e. the + light which is 'sourceless' and illuminates all objects equally. + The colour of an object is affected by a combination of the light in the scene, + and the amount of light that object reflects (in this case based on the Material::ambient + property). + @remarks + By default the ambient light in the scene is ColourValue::Black, i.e. no ambient light. This + means that any objects rendered with a Material which has lighting enabled (see Material::setLightingEnabled) + will not be visible unless you have some dynamic lights in your scene. + */ + void setAmbientLight(const ColourValue& colour); + + /** Returns the ambient light level to be used for the scene. + */ + const ColourValue& getAmbientLight(void) const; + + /** Sets the source of the 'world' geometry, i.e. the large, mainly static geometry + making up the world e.g. rooms, landscape etc. + @remarks + Depending on the type of SceneManager (subclasses will be specialised + for particular world geometry types) you have requested via the Root or + SceneManagerEnumerator classes, you can pass a filename to this method and it + will attempt to load the world-level geometry for use. If you try to load + an inappropriate type of world data an exception will be thrown. The default + SceneManager cannot handle any sort of world geometry and so will always + throw an exception. However subclasses like BspSceneManager can load + particular types of world geometry e.g. "q3dm1.bsp". + */ + virtual void setWorldGeometry(const String& filename); + + /** Sets the source of the 'world' geometry, i.e. the large, mainly + static geometry making up the world e.g. rooms, landscape etc. + @remarks + Depending on the type of SceneManager (subclasses will be + specialised for particular world geometry types) you have + requested via the Root or SceneManagerEnumerator classes, you + can pass a stream to this method and it will attempt to load + the world-level geometry for use. If the manager can only + handle one input format the typeName parameter is not required. + The stream passed will be read (and it's state updated). + @param stream Data stream containing data to load + @param typeName String identifying the type of world geometry + contained in the stream - not required if this manager only + supports one type of world geometry. + */ + virtual void setWorldGeometry(DataStreamPtr& stream, + const String& typeName = StringUtil::BLANK); + + /** Estimate the number of loading stages required to load the named + world geometry. + @remarks + This method should be overridden by SceneManagers that provide + custom world geometry that can take some time to load. They should + return from this method a count of the number of stages of progress + they can report on whilst loading. During real loading (setWorldGeomtry), + they should call ResourceGroupManager::_notifyWorldGeometryProgress exactly + that number of times when loading the geometry for real. + @note + The default is to return 0, ie to not report progress. + */ + virtual size_t estimateWorldGeometry(const String& filename) { return 0; } + + /** Estimate the number of loading stages required to load the named + world geometry. + @remarks + Operates just like the version of this method which takes a + filename, but operates on a stream instead. Note that since the + stream is updated, you'll need to reset the stream or reopen it + when it comes to loading it for real. + @param stream Data stream containing data to load + @param typeName String identifying the type of world geometry + contained in the stream - not required if this manager only + supports one type of world geometry. + */ + virtual size_t estimateWorldGeometry(DataStreamPtr& stream, + const String& typeName = StringUtil::BLANK) { return 0; } + /** Asks the SceneManager to provide a suggested viewpoint from which the scene should be viewed. + @remarks + Typically this method returns the origin unless a) world geometry has been loaded using + SceneManager::setWorldGeometry and b) that world geometry has suggested 'start' points. + If there is more than one viewpoint which the scene manager can suggest, it will always suggest + the first one unless the random parameter is true. + @param + random If true, and there is more than one possible suggestion, a random one will be used. If false + the same one will always be suggested. + @return + On success, true is returned. + @par + On failiure, false is returned. + */ + virtual ViewPoint getSuggestedViewpoint(bool random = false); + + /** Method for setting a specific option of the Scene Manager. These options are usually + specific for a certain implemntation of the Scene Manager class, and may (and probably + will) not exist across different implementations. + @param + strKey The name of the option to set + @param + pValue A pointer to the value - the size should be calculated by the scene manager + based on the key + @return + On success, true is returned. + @par + On failiure, false is returned. + */ + virtual bool setOption( const String& strKey, const void* pValue ) { return false; } + + /** Method for getting the value of an implementation-specific Scene Manager option. + @param + strKey The name of the option + @param + pDestValue A pointer to a memory location where the value will + be copied. Currently, the memory will be allocated by the + scene manager, but this may change + @return + On success, true is returned and pDestValue points to the value of the given + option. + @par + On failiure, false is returned and pDestValue is set to NULL. + */ + virtual bool getOption( const String& strKey, void* pDestValue ) { return false; } + + /** Method for verifying wether the scene manager has an implementation-specific + option. + @param + strKey The name of the option to check for. + @return + If the scene manager contains the given option, true is returned. + @remarks + If it does not, false is returned. + */ + virtual bool hasOption( const String& strKey ) const { return false; } + /** Method for getting all possible values for a specific option. When this list is too large + (i.e. the option expects, for example, a float), the return value will be true, but the + list will contain just one element whose size will be set to 0. + Otherwise, the list will be filled with all the possible values the option can + accept. + @param + strKey The name of the option to get the values for. + @param + refValueList A reference to a list that will be filled with the available values. + @return + On success (the option exists), true is returned. + @par + On failure, false is returned. + */ + virtual bool getOptionValues( const String& strKey, StringVector& refValueList ) { return false; } + + /** Method for getting all the implementation-specific options of the scene manager. + @param + refKeys A reference to a list that will be filled with all the available options. + @return + On success, true is returned. On failiure, false is returned. + */ + virtual bool getOptionKeys( StringVector& refKeys ) { return false; } + + /** Internal method for updating the scene graph ie the tree of SceneNode instances managed by this class. + @remarks + This must be done before issuing objects to the rendering pipeline, since derived transformations from + parent nodes are not updated until required. This SceneManager is a basic implementation which simply + updates all nodes from the root. This ensures the scene is up to date but requires all the nodes + to be updated even if they are not visible. Subclasses could trim this such that only potentially visible + nodes are updated. + */ + virtual void _updateSceneGraph(Camera* cam); + + /** Internal method which parses the scene to find visible objects to render. + @remarks + If you're implementing a custom scene manager, this is the most important method to + override since it's here you can apply your custom world partitioning scheme. Once you + have added the appropriate objects to the render queue, you can let the default + SceneManager objects _renderVisibleObjects handle the actual rendering of the objects + you pick. + @par + Any visible objects will be added to a rendering queue, which is indexed by material in order + to ensure objects with the same material are rendered together to minimise render state changes. + */ + virtual void _findVisibleObjects(Camera* cam, VisibleObjectsBoundsInfo* visibleBounds, bool onlyShadowCasters); + + /** Internal method for applying animations to scene nodes. + @remarks + Uses the internally stored AnimationState objects to apply animation to SceneNodes. + */ + virtual void _applySceneAnimations(void); + + /** Sends visible objects found in _findVisibleObjects to the rendering engine. + */ + virtual void _renderVisibleObjects(void); + + /** Prompts the class to send its contents to the renderer. + @remarks + This method prompts the scene manager to send the + contents of the scene it manages to the rendering + pipeline, possibly preceded by some sorting, culling + or other scene management tasks. Note that this method is not normally called + directly by the user application; it is called automatically + by the Ogre rendering loop. + @param camera Pointer to a camera from whose viewpoint the scene is to + be rendered. + @param vp The target viewport + @param includeOverlays Whether or not overlay objects should be rendered + */ + virtual void _renderScene(Camera* camera, Viewport* vp, bool includeOverlays); + + /** Internal method for queueing the sky objects with the params as + previously set through setSkyBox, setSkyPlane and setSkyDome. + */ + virtual void _queueSkiesForRendering(Camera* cam); + + + + /** Notifies the scene manager of its destination render system + @remarks + Called automatically by RenderSystem::addSceneManager + this method simply notifies the manager of the render + system to which its output must be directed. + @param + sys Pointer to the RenderSystem subclass to be used as a render target. + */ + virtual void _setDestinationRenderSystem(RenderSystem* sys); + + /** Enables / disables a 'sky plane' i.e. a plane at constant + distance from the camera representing the sky. + @remarks + You can create sky planes yourself using the standard mesh and + entity methods, but this creates a plane which the camera can + never get closer or further away from - it moves with the camera. + (NB you could create this effect by creating a world plane which + was attached to the same SceneNode as the Camera too, but this + would only apply to a single camera whereas this plane applies to + any camera using this scene manager). + @note + To apply scaling, scrolls etc to the sky texture(s) you + should use the TextureUnitState class methods. + @param + enable True to enable the plane, false to disable it + @param + plane Details of the plane, i.e. it's normal and it's + distance from the camera. + @param + materialName The name of the material the plane will use + @param + scale The scaling applied to the sky plane - higher values + mean a bigger sky plane - you may want to tweak this + depending on the size of plane.d and the other + characteristics of your scene + @param + tiling How many times to tile the texture across the sky. + Applies to all texture layers. If you need finer control use + the TextureUnitState texture coordinate transformation methods. + @param + drawFirst If true, the plane is drawn before all other + geometry in the scene, without updating the depth buffer. + This is the safest rendering method since all other objects + will always appear in front of the sky. However this is not + the most efficient way if most of the sky is often occluded + by other objects. If this is the case, you can set this + parameter to false meaning it draws after all other + geometry which can be an optimisation - however you must + ensure that the plane.d value is large enough that no objects + will 'poke through' the sky plane when it is rendered. + @param + bow If zero, the plane will be completely flat (like previous + versions. If above zero, the plane will be curved, allowing + the sky to appear below camera level. Curved sky planes are + simular to skydomes, but are more compatable with fog. + @param xsegments, ysegments + Determines the number of segments the plane will have to it. This + is most important when you are bowing the plane, but may also be useful + if you need tesselation on the plane to perform per-vertex effects. + @param groupName + The name of the resource group to which to assign the plane mesh. + */ + virtual void setSkyPlane( + bool enable, + const Plane& plane, const String& materialName, Real scale = 1000, + Real tiling = 10, bool drawFirst = true, Real bow = 0, + int xsegments = 1, int ysegments = 1, + const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); + + /** Return whether a key plane is enabled */ + virtual bool isSkyPlaneEnabled(void) const { return mSkyPlaneEnabled; } + + /** Get the sky plane node, if enabled. */ + virtual SceneNode* getSkyPlaneNode(void) const { return mSkyPlaneNode; } + + /** Get the parameters used to construct the SkyPlane, if any **/ + virtual const SkyPlaneGenParameters& getSkyPlaneGenParameters(void) const { return mSkyPlaneGenParameters; } + + /** Enables / disables a 'sky box' i.e. a 6-sided box at constant + distance from the camera representing the sky. + @remarks + You could create a sky box yourself using the standard mesh and + entity methods, but this creates a plane which the camera can + never get closer or further away from - it moves with the camera. + (NB you could create this effect by creating a world box which + was attached to the same SceneNode as the Camera too, but this + would only apply to a single camera whereas this skybox applies + to any camera using this scene manager). + @par + The material you use for the skybox can either contain layers + which are single textures, or they can be cubic textures, i.e. + made up of 6 images, one for each plane of the cube. See the + TextureUnitState class for more information. + @param + enable True to enable the skybox, false to disable it + @param + materialName The name of the material the box will use + @param + distance Distance in world coorinates from the camera to + each plane of the box. The default is normally OK. + @param + drawFirst If true, the box is drawn before all other + geometry in the scene, without updating the depth buffer. + This is the safest rendering method since all other objects + will always appear in front of the sky. However this is not + the most efficient way if most of the sky is often occluded + by other objects. If this is the case, you can set this + parameter to false meaning it draws after all other + geometry which can be an optimisation - however you must + ensure that the distance value is large enough that no + objects will 'poke through' the sky box when it is rendered. + @param + orientation Optional parameter to specify the orientation + of the box. By default the 'top' of the box is deemed to be + in the +y direction, and the 'front' at the -z direction. + You can use this parameter to rotate the sky if you want. + @param groupName + The name of the resource group to which to assign the plane mesh. + */ + virtual void setSkyBox( + bool enable, const String& materialName, Real distance = 5000, + bool drawFirst = true, const Quaternion& orientation = Quaternion::IDENTITY, + const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); + + /** Return whether a skybox is enabled */ + virtual bool isSkyBoxEnabled(void) const { return mSkyBoxEnabled; } + + /** Get the skybox node, if enabled. */ + virtual SceneNode* getSkyBoxNode(void) const { return mSkyBoxNode; } + + /** Get the parameters used to generate the current SkyBox, if any */ + virtual const SkyBoxGenParameters& getSkyBoxGenParameters(void) const { return mSkyBoxGenParameters; } + + /** Enables / disables a 'sky dome' i.e. an illusion of a curved sky. + @remarks + A sky dome is actually formed by 5 sides of a cube, but with + texture coordinates generated such that the surface appears + curved like a dome. Sky domes are appropriate where you need a + realistic looking sky where the scene is not going to be + 'fogged', and there is always a 'floor' of some sort to prevent + the viewer looking below the horizon (the distortion effect below + the horizon can be pretty horrible, and there is never anyhting + directly below the viewer). If you need a complete wrap-around + background, use the setSkyBox method instead. You can actually + combine a sky box and a sky dome if you want, to give a positional + backdrop with an overlayed curved cloud layer. + @par + Sky domes work well with 2D repeating textures like clouds. You + can change the apparant 'curvature' of the sky depending on how + your scene is viewed - lower curvatures are better for 'open' + scenes like landscapes, whilst higher curvatures are better for + say FPS levels where you don't see a lot of the sky at once and + the exaggerated curve looks good. + @param + enable True to enable the skydome, false to disable it + @param + materialName The name of the material the dome will use + @param + curvature The curvature of the dome. Good values are + between 2 and 65. Higher values are more curved leading to + a smoother effect, lower values are less curved meaning + more distortion at the horizons but a better distance effect. + @param + tiling How many times to tile the texture(s) across the + dome. + @param + distance Distance in world coorinates from the camera to + each plane of the box the dome is rendered on. The default + is normally OK. + @param + drawFirst If true, the dome is drawn before all other + geometry in the scene, without updating the depth buffer. + This is the safest rendering method since all other objects + will always appear in front of the sky. However this is not + the most efficient way if most of the sky is often occluded + by other objects. If this is the case, you can set this + parameter to false meaning it draws after all other + geometry which can be an optimisation - however you must + ensure that the distance value is large enough that no + objects will 'poke through' the sky when it is rendered. + @param + orientation Optional parameter to specify the orientation + of the dome. By default the 'top' of the dome is deemed to + be in the +y direction, and the 'front' at the -z direction. + You can use this parameter to rotate the sky if you want. + @param groupName + The name of the resource group to which to assign the plane mesh. + */ + virtual void setSkyDome( + bool enable, const String& materialName, Real curvature = 10, + Real tiling = 8, Real distance = 4000, bool drawFirst = true, + const Quaternion& orientation = Quaternion::IDENTITY, + int xsegments = 16, int ysegments = 16, int ysegments_keep = -1, + const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); + + /** Return whether a skydome is enabled */ + virtual bool isSkyDomeEnabled(void) const { return mSkyDomeEnabled; } + + /** Get the sky dome node, if enabled. */ + virtual SceneNode* getSkyDomeNode(void) const { return mSkyDomeNode; } + + /** Get the parameters used to generate the current SkyDome, if any */ + virtual const SkyDomeGenParameters& getSkyDomeGenParameters(void) const { return mSkyDomeGenParameters; } + + /** Sets the fogging mode applied to the scene. + @remarks + This method sets up the scene-wide fogging effect. These settings + apply to all geometry rendered, UNLESS the material with which it + is rendered has it's own fog settings (see Material::setFog). + @param + mode Set up the mode of fog as described in the FogMode + enum, or set to FOG_NONE to turn off. + @param + colour The colour of the fog. Either set this to the same + as your viewport background colour, or to blend in with a + skydome or skybox. + @param + expDensity The density of the fog in FOG_EXP or FOG_EXP2 + mode, as a value between 0 and 1. The default is 0.001. + @param + linearStart Distance in world units at which linear fog starts to + encroach. Only applicable if mode is + FOG_LINEAR. + @param + linearEnd Distance in world units at which linear fog becomes completely + opaque. Only applicable if mode is + FOG_LINEAR. + */ + void setFog( + FogMode mode = FOG_NONE, const ColourValue& colour = ColourValue::White, + Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0); + + /** Returns the fog mode for the scene. + */ + virtual FogMode getFogMode(void) const; + + /** Returns the fog colour for the scene. + */ + virtual const ColourValue& getFogColour(void) const; + + /** Returns the fog start distance for the scene. + */ + virtual Real getFogStart(void) const; + + /** Returns the fog end distance for the scene. + */ + virtual Real getFogEnd(void) const; + + /** Returns the fog density for the scene. + */ + virtual Real getFogDensity(void) const; + + + /** Creates a new BillboardSet for use with this scene manager. + @remarks + This method creates a new BillboardSet which is registered with + the SceneManager. The SceneManager will destroy this object when + it shuts down or when the SceneManager::clearScene method is + called, so the caller does not have to worry about destroying + this object (in fact, it definitely should not do this). + @par + See the BillboardSet documentations for full details of the + returned class. + @param + name The name to give to this billboard set. Must be unique. + @param + poolSize The initial size of the pool of billboards (see BillboardSet for more information) + @see + BillboardSet + */ + virtual BillboardSet* createBillboardSet(const String& name, unsigned int poolSize = 20); + + /** Retrieves a pointer to the named BillboardSet. + @note Throws an exception if the named instance does not exist + */ + virtual BillboardSet* getBillboardSet(const String& name) const; + /** Returns whether a billboardset with the given name exists. + */ + virtual bool hasBillboardSet(const String& name) const; + + /** Removes & destroys an BillboardSet from the SceneManager. + @warning + Must only be done if the BillboardSet is not attached + to a SceneNode. It may be safer to wait to clear the whole + scene. If you are unsure, use clearScene. + */ + virtual void destroyBillboardSet(BillboardSet* set); + + /** Removes & destroys an BillboardSet from the SceneManager by name. + @warning + Must only be done if the BillboardSet is not attached + to a SceneNode. It may be safer to wait to clear the whole + scene. If you are unsure, use clearScene. + */ + virtual void destroyBillboardSet(const String& name); + + /** Removes & destroys all BillboardSets. + @warning + Again, use caution since no BillboardSet must be referred to + elsewhere e.g. attached to a SceneNode otherwise a crash + is likely. Use clearScene if you are unsure (it clears SceneNode + entries too.) + @see + SceneManager::clearScene + */ + virtual void destroyAllBillboardSets(void); + + /** Tells the SceneManager whether it should render the SceneNodes which + make up the scene as well as the objects in the scene. + @remarks + This method is mainly for debugging purposes. If you set this to 'true', + each node will be rendered as a set of 3 axes to allow you to easily see + the orientation of the nodes. + */ + virtual void setDisplaySceneNodes(bool display); + /** Returns true if all scene nodes axis are to be displayed */ + virtual bool getDisplaySceneNodes(void) const {return mDisplayNodes;} + + /** Creates an animation which can be used to animate scene nodes. + @remarks + An animation is a collection of 'tracks' which over time change the position / orientation + of Node objects. In this case, the animation will likely have tracks to modify the position + / orientation of SceneNode objects, e.g. to make objects move along a path. + @par + You don't need to use an Animation object to move objects around - you can do it yourself + using the methods of the Node in your FrameListener class. However, when you need relatively + complex scripted animation, this is the class to use since it will interpolate between + keyframes for you and generally make the whole process easier to manage. + @par + A single animation can affect multiple Node objects (each AnimationTrack affects a single Node). + In addition, through animation blending a single Node can be affected by multiple animations, + athough this is more useful when performing skeletal animation (see Skeleton::createAnimation). + @par + Note that whilst it uses the same classes, the animations created here are kept separate from the + skeletal animations of meshes (each Skeleton owns those animations). + @param name The name of the animation, must be unique within this SceneManager. + @param length The total length of the animation. + */ + virtual Animation* createAnimation(const String& name, Real length); + + /** Looks up an Animation object previously created with createAnimation. + @note Throws an exception if the named instance does not exist + */ + virtual Animation* getAnimation(const String& name) const; + /** Returns whether an animation with the given name exists. + */ + virtual bool hasAnimation(const String& name) const; + + /** Destroys an Animation. + @remarks + You should ensure that none of your code is referencing this animation objects since the + memory will be freed. + */ + virtual void destroyAnimation(const String& name); + + /** Removes all animations created using this SceneManager. */ + virtual void destroyAllAnimations(void); + + /** Create an AnimationState object for managing application of animations. + @remarks + You can create Animation objects for animating SceneNode obejcts using the + createAnimation method. However, in order to actually apply those animations + you have to call methods on Node and Animation in a particular order (namely + Node::resetToInitialState and Animation::apply). To make this easier and to + help track the current time position of animations, the AnimationState object + is provided.

+ So if you don't want to control animation application manually, call this method, + update the returned object as you like every frame and let SceneManager apply + the animation state for you. + @par + Remember, AnimationState objects are disabled by default at creation time. + Turn them on when you want them using their setEnabled method. + @par + Note that any SceneNode affected by this automatic animation will have it's state + reset to it's initial position before application of the animation. Unless specifically + modified using Node::setInitialState the Node assumes it's initial state is at the + origin. If you want the base state of the SceneNode to be elsewhere, make your changes + to the node using the standard transform methods, then call setInitialState to + 'bake' this reference position into the node. + @par + If the target of your animation is to be a generic AnimableValue, you + should ensure that it has a base value set (unlike nodes this has no + default). @see AnimableValue::setAsBaseValue. + @param animName The name of an animation created already with createAnimation. + */ + virtual AnimationState* createAnimationState(const String& animName); + + /** Retrieves animation state as previously created using createAnimationState. + @note Throws an exception if the named instance does not exist + */ + virtual AnimationState* getAnimationState(const String& animName) const; + /** Returns whether an animation state with the given name exists. + */ + virtual bool hasAnimationState(const String& name) const; + + /** Destroys an AnimationState. + @remarks + You should ensure that none of your code is referencing this animation + state object since the memory will be freed. + */ + virtual void destroyAnimationState(const String& name); + + /** Removes all animation states created using this SceneManager. */ + virtual void destroyAllAnimationStates(void); + + /** Manual rendering method, for advanced users only. + @remarks + This method allows you to send rendering commands through the pipeline on + demand, bypassing OGRE's normal world processing. You should only use this if you + really know what you're doing; OGRE does lots of things for you that you really should + let it do. However, there are times where it may be useful to have this manual interface, + for example overlaying something on top of the scene rendered by OGRE. + @par + Because this is an instant rendering method, timing is important. The best + time to call it is from a RenderTargetListener event handler. + @par + Don't call this method a lot, it's designed for rare (1 or 2 times per frame) use. + Calling it regularly per frame will cause frame rate drops! + @param rend A RenderOperation object describing the rendering op + @param pass The Pass to use for this render + @param vp Pointer to the viewport to render to + @param worldMatrix The transform to apply from object to world space + @param viewMatrix The transform to apply from world to view space + @param projMatrix The transform to apply from view to screen space + @param doBeginEndFrame If true, beginFrame() and endFrame() are called, + otherwise not. You should leave this as false if you are calling + this within the main render loop. + */ + virtual void manualRender(RenderOperation* rend, Pass* pass, Viewport* vp, + const Matrix4& worldMatrix, const Matrix4& viewMatrix, const Matrix4& projMatrix, + bool doBeginEndFrame = false) ; + + /** Retrieves the internal render queue, for advanced users only. + @remarks + The render queue is mainly used internally to manage the scene object + rendering queue, it also exports some methods to allow advanced users + to configure the behavior of rendering process. + Most methods provided by RenderQueue are supposed to be used + internally only, you should reference to the RenderQueue API for + more information. Do not access this directly unless you know what + you are doing. + */ + virtual RenderQueue* getRenderQueue(void); + + /** Registers a new RenderQueueListener which will be notified when render queues + are processed. + */ + virtual void addRenderQueueListener(RenderQueueListener* newListener); + + /** Removes a listener previously added with addRenderQueueListener. */ + virtual void removeRenderQueueListener(RenderQueueListener* delListener); + + /** Adds an item to the 'special case' render queue list. + @remarks + Normally all render queues are rendered, in their usual sequence, + only varying if a RenderQueueListener nominates for the queue to be + repeated or skipped. This method allows you to add a render queue to + a 'special case' list, which varies the behaviour. The effect of this + list depends on the 'mode' in which this list is in, which might be + to exclude these render queues, or to include them alone (excluding + all other queues). This allows you to perform broad selective + rendering without requiring a RenderQueueListener. + @param qid The identifier of the queue which should be added to the + special case list. Nothing happens if the queue is already in the list. + */ + virtual void addSpecialCaseRenderQueue(uint8 qid); + /** Removes an item to the 'special case' render queue list. + @see SceneManager::addSpecialCaseRenderQueue + @param qid The identifier of the queue which should be removed from the + special case list. Nothing happens if the queue is not in the list. + */ + virtual void removeSpecialCaseRenderQueue(uint8 qid); + /** Clears the 'special case' render queue list. + @see SceneManager::addSpecialCaseRenderQueue + */ + virtual void clearSpecialCaseRenderQueues(void); + /** Sets the way the special case render queue list is processed. + @see SceneManager::addSpecialCaseRenderQueue + @param mode The mode of processing + */ + virtual void setSpecialCaseRenderQueueMode(SpecialCaseRenderQueueMode mode); + /** Gets the way the special case render queue list is processed. */ + virtual SpecialCaseRenderQueueMode getSpecialCaseRenderQueueMode(void); + /** Returns whether or not the named queue will be rendered based on the + current 'special case' render queue list and mode. + @see SceneManager::addSpecialCaseRenderQueue + @param qid The identifier of the queue which should be tested + @returns true if the queue will be rendered, false otherwise + */ + virtual bool isRenderQueueToBeProcessed(uint8 qid); + + /** Sets the render queue that the world geometry (if any) this SceneManager + renders will be associated with. + @remarks + SceneManagers which provide 'world geometry' should place it in a + specialised render queue in order to make it possible to enable / + disable it easily using the addSpecialCaseRenderQueue method. Even + if the SceneManager does not use the render queues to render the + world geometry, it should still pick a queue to represent it's manual + rendering, and check isRenderQueueToBeProcessed before rendering. + @note + Setting this may not affect the actual ordering of rendering the + world geometry, if the world geometry is being rendered manually + by the SceneManager. If the SceneManager feeds world geometry into + the queues, however, the ordering will be affected. + */ + virtual void setWorldGeometryRenderQueue(uint8 qid); + /** Gets the render queue that the world geometry (if any) this SceneManager + renders will be associated with. + @remarks + SceneManagers which provide 'world geometry' should place it in a + specialised render queue in order to make it possible to enable / + disable it easily using the addSpecialCaseRenderQueue method. Even + if the SceneManager does not use the render queues to render the + world geometry, it should still pick a queue to represent it's manual + rendering, and check isRenderQueueToBeProcessed before rendering. + */ + virtual uint8 getWorldGeometryRenderQueue(void); + + /** Allows all bounding boxes of scene nodes to be displayed. */ + virtual void showBoundingBoxes(bool bShow); + + /** Returns if all bounding boxes of scene nodes are to be displayed */ + virtual bool getShowBoundingBoxes() const; + + /** Internal method for notifying the manager that a SceneNode is autotracking. */ + virtual void _notifyAutotrackingSceneNode(SceneNode* node, bool autoTrack); + + + /** Creates an AxisAlignedBoxSceneQuery for this scene manager. + @remarks + This method creates a new instance of a query object for this scene manager, + for an axis aligned box region. See SceneQuery and AxisAlignedBoxSceneQuery + for full details. + @par + The instance returned from this method must be destroyed by calling + SceneManager::destroyQuery when it is no longer required. + @param box Details of the box which describes the region for this query. + @param mask The query mask to apply to this query; can be used to filter out + certain objects; see SceneQuery for details. + */ + virtual AxisAlignedBoxSceneQuery* + createAABBQuery(const AxisAlignedBox& box, unsigned long mask = 0xFFFFFFFF); + /** Creates a SphereSceneQuery for this scene manager. + @remarks + This method creates a new instance of a query object for this scene manager, + for a spherical region. See SceneQuery and SphereSceneQuery + for full details. + @par + The instance returned from this method must be destroyed by calling + SceneManager::destroyQuery when it is no longer required. + @param sphere Details of the sphere which describes the region for this query. + @param mask The query mask to apply to this query; can be used to filter out + certain objects; see SceneQuery for details. + */ + virtual SphereSceneQuery* + createSphereQuery(const Sphere& sphere, unsigned long mask = 0xFFFFFFFF); + /** Creates a PlaneBoundedVolumeListSceneQuery for this scene manager. + @remarks + This method creates a new instance of a query object for this scene manager, + for a region enclosed by a set of planes (normals pointing inwards). + See SceneQuery and PlaneBoundedVolumeListSceneQuery for full details. + @par + The instance returned from this method must be destroyed by calling + SceneManager::destroyQuery when it is no longer required. + @param volumes Details of the volumes which describe the region for this query. + @param mask The query mask to apply to this query; can be used to filter out + certain objects; see SceneQuery for details. + */ + virtual PlaneBoundedVolumeListSceneQuery* + createPlaneBoundedVolumeQuery(const PlaneBoundedVolumeList& volumes, unsigned long mask = 0xFFFFFFFF); + + + /** Creates a RaySceneQuery for this scene manager. + @remarks + This method creates a new instance of a query object for this scene manager, + looking for objects which fall along a ray. See SceneQuery and RaySceneQuery + for full details. + @par + The instance returned from this method must be destroyed by calling + SceneManager::destroyQuery when it is no longer required. + @param ray Details of the ray which describes the region for this query. + @param mask The query mask to apply to this query; can be used to filter out + certain objects; see SceneQuery for details. + */ + virtual RaySceneQuery* + createRayQuery(const Ray& ray, unsigned long mask = 0xFFFFFFFF); + //PyramidSceneQuery* createPyramidQuery(const Pyramid& p, unsigned long mask = 0xFFFFFFFF); + /** Creates an IntersectionSceneQuery for this scene manager. + @remarks + This method creates a new instance of a query object for locating + intersecting objects. See SceneQuery and IntersectionSceneQuery + for full details. + @par + The instance returned from this method must be destroyed by calling + SceneManager::destroyQuery when it is no longer required. + @param mask The query mask to apply to this query; can be used to filter out + certain objects; see SceneQuery for details. + */ + virtual IntersectionSceneQuery* + createIntersectionQuery(unsigned long mask = 0xFFFFFFFF); + + /** Destroys a scene query of any type. */ + virtual void destroyQuery(SceneQuery* query); + + typedef MapIterator CameraIterator; + typedef MapIterator AnimationIterator; + + /** Returns a specialised MapIterator over all cameras in the scene. + */ + CameraIterator getCameraIterator(void) { + return CameraIterator(mCameras.begin(), mCameras.end()); + } + /** Returns a specialised MapIterator over all animations in the scene. */ + AnimationIterator getAnimationIterator(void) { + return AnimationIterator(mAnimationsList.begin(), mAnimationsList.end()); + } + /** Returns a specialised MapIterator over all animation states in the scene. */ + AnimationStateIterator getAnimationStateIterator(void) { + return mAnimationStates.getAnimationStateIterator(); + } + + /** Sets the general shadow technique to be used in this scene. + @remarks + There are multiple ways to generate shadows in a scene, and each has + strengths and weaknesses. +
  • Stencil-based approaches can be used to + draw very long, extreme shadows without loss of precision and the 'additive' + version can correctly show the shadowing of complex effects like bump mapping + because they physically exclude the light from those areas. However, the edges + are very sharp and stencils cannot handle transparency, and they involve a + fair amount of CPU work in order to calculate the shadow volumes, especially + when animated objects are involved.
  • +
  • Texture-based approaches are good for handling transparency (they can, for + example, correctly shadow a mesh which uses alpha to represent holes), and they + require little CPU overhead, and can happily shadow geometry which is deformed + by a vertex program, unlike stencil shadows. However, they have a fixed precision + which can introduce 'jaggies' at long range and have fillrate issues of their own.
  • +
+ @par + We support 2 kinds of stencil shadows, and 2 kinds of texture-based shadows, and one + simple decal approach. The 2 stencil approaches differ in the amount of multipass work + that is required - the modulative approach simply 'darkens' areas in shadow after the + main render, which is the least expensive, whilst the additive approach has to perform + a render per light and adds the cumulative effect, whcih is more expensive but more + accurate. The texture based shadows both work in roughly the same way, the only difference is + that the shadowmap approach is slightly more accurate, but requires a more recent + graphics card. + @par + Note that because mixing many shadow techniques can cause problems, only one technique + is supported at once. Also, you should call this method at the start of the + scene setup. + @param technique The shadowing technique to use for the scene. + */ + virtual void setShadowTechnique(ShadowTechnique technique); + + /** Gets the current shadow technique. */ + virtual ShadowTechnique getShadowTechnique(void) const { return mShadowTechnique; } + + /** Enables / disables the rendering of debug information for shadows. */ + virtual void setShowDebugShadows(bool debug) { mDebugShadows = debug; } + /** Are debug shadows shown? */ + virtual bool getShowDebugShadows(void ) const { return mDebugShadows; } + + /** Set the colour used to modulate areas in shadow. + @remarks This is only applicable for shadow techniques which involve + darkening the area in shadow, as opposed to masking out the light. + This colour provided is used as a modulative value to darken the + areas. + */ + virtual void setShadowColour(const ColourValue& colour); + /** Get the colour used to modulate areas in shadow. + @remarks This is only applicable for shadow techniques which involve + darkening the area in shadow, as opposed to masking out the light. + This colour provided is used as a modulative value to darken the + areas. + */ + virtual const ColourValue& getShadowColour(void) const; + /** Sets the distance a shadow volume is extruded for a directional light. + @remarks + Although directional lights are essentially infinite, there are many + reasons to limit the shadow extrusion distance to a finite number, + not least of which is compatibility with older cards (which do not + support infinite positions), and shadow caster elimination. + @par + The default value is 10,000 world units. This does not apply to + point lights or spotlights, since they extrude up to their + attenuation range. + */ + virtual void setShadowDirectionalLightExtrusionDistance(Real dist); + /** Gets the distance a shadow volume is extruded for a directional light. + */ + virtual Real getShadowDirectionalLightExtrusionDistance(void) const; + /** Sets the maximum distance away from the camera that shadows + will be visible. + @remarks + Shadow techniques can be expensive, therefore it is a good idea + to limit them to being rendered close to the camera if possible, + and to skip the expense of rendering shadows for distance objects. + This method allows you to set the distance at which shadows will no + longer be rendered. + @note + Each shadow technique can interpret this subtely differently. + For example, one technique may use this to eliminate casters, + another might use it to attenuate the shadows themselves. + You should tweak this value to suit your chosen shadow technique + and scene setup. + */ + virtual void setShadowFarDistance(Real distance); + /** Gets the maximum distance away from the camera that shadows + will be visible. + */ + virtual Real getShadowFarDistance(void) const + { return mShadowFarDist; } + + /** Sets the maximum size of the index buffer used to render shadow + primitives. + @remarks + This method allows you to tweak the size of the index buffer used + to render shadow primitives (including stencil shadow volumes). The + default size is 51,200 entries, which is 100k of GPU memory, or + enough to render approximately 17,000 triangles. You can reduce this + as long as you do not have any models / world geometry chunks which + could require more than the amount you set. + @par + The maximum number of triangles required to render a single shadow + volume (including light and dark caps when needed) will be 3x the + number of edges on the light silhouette, plus the number of + light-facing triangles. On average, half the + triangles will be facing toward the light, but the number of + triangles in the silhouette entirely depends on the mesh - + angular meshes will have a higher silhouette tris/mesh tris + ratio than a smooth mesh. You can estimate the requirements for + your particular mesh by rendering it alone in a scene with shadows + enabled and a single light - rotate it or the light and make a note + of how high the triangle count goes (remembering to subtract the + mesh triangle count) + @param size The number of indexes; divide this by 3 to determine the + number of triangles. + */ + virtual void setShadowIndexBufferSize(size_t size); + /// Get the size of the shadow index buffer + virtual size_t getShadowIndexBufferSize(void) const + { return mShadowIndexBufferSize; } + /** Set the size of the texture used for all texture-based shadows. + @remarks + The larger the shadow texture, the better the detail on + texture based shadows, but obviously this takes more memory. + The default size is 512. Sizes must be a power of 2. + @note This is the simple form, see setShadowTextureConfig for the more + complex form. + */ + virtual void setShadowTextureSize(unsigned short size); + + /** Set the detailed configuration for a shadow texture. + @param shadowIndex The index of the texture to configure, must be < the + number of shadow textures setting + @param width, height The dimensions of the texture + @param format The pixel format of the texture + */ + virtual void setShadowTextureConfig(size_t shadowIndex, unsigned short width, + unsigned short height, PixelFormat format); + /** Set the detailed configuration for a shadow texture. + @param shadowIndex The index of the texture to configure, must be < the + number of shadow textures setting + @param config Configuration structure + */ + virtual void setShadowTextureConfig(size_t shadowIndex, + const ShadowTextureConfig& config); + + /** Get an iterator over the current shadow texture settings. */ + ConstShadowTextureConfigIterator getShadowTextureConfigIterator() const; + + /** Set the pixel format of the textures used for texture-based shadows. + @remarks + By default, a colour texture is used (PF_X8R8G8B8) for texture shadows, + but if you want to use more advanced texture shadow types you can + alter this. If you do, you will have to also call + setShadowTextureCasterMaterial and setShadowTextureReceiverMaterial + to provide shader-based materials to use these customised shadow + texture formats. + @note This is the simple form, see setShadowTextureConfig for the more + complex form. + */ + virtual void setShadowTexturePixelFormat(PixelFormat fmt); + /** Set the number of textures allocated for texture-based shadows. + @remarks + The default number of textures assigned to deal with texture based + shadows is 1; however this means you can only have one light casting + shadows at the same time. You can increase this number in order to + make this more flexible, but be aware of the texture memory it will use. + */ + virtual void setShadowTextureCount(size_t count); + /// Get the number of the textures allocated for texture based shadows + size_t getShadowTextureCount(void) const {return mShadowTextureConfigList.size(); } + /** Sets the size and count of textures used in texture-based shadows. + @remarks + @see setShadowTextureSize and setShadowTextureCount for details, this + method just allows you to change both at once, which can save on + reallocation if the textures have already been created. + @note This is the simple form, see setShadowTextureConfig for the more + complex form. + */ + virtual void setShadowTextureSettings(unsigned short size, unsigned short count, + PixelFormat fmt = PF_X8R8G8B8); + + /** Get a reference to the shadow texture currently in use at the given index. + @note + If you change shadow settings, this reference may no longer + be correct, so be sure not to hold the returned reference over + texture shadow configuration changes. + */ + virtual const TexturePtr& getShadowTexture(size_t shadowIndex); + + /** Sets the proportional distance which a texture shadow which is generated from a + directional light will be offset into the camera view to make best use of texture space. + @remarks + When generating a shadow texture from a directional light, an approximation is used + since it is not possible to render the entire scene to one texture. + The texture is projected onto an area centred on the camera, and is + the shadow far distance * 2 in length (it is square). This wastes + a lot of texture space outside the frustum though, so this offset allows + you to move the texture in front of the camera more. However, be aware + that this can cause a little shadow 'jittering' during rotation, and + that if you move it too far then you'll start to get artefacts close + to the camera. The value is represented as a proportion of the shadow + far distance, and the default is 0.6. + */ + virtual void setShadowDirLightTextureOffset(Real offset) { mShadowTextureOffset = offset;} + /** Gets the proportional distance which a texture shadow which is generated from a + directional light will be offset into the camera view to make best use of texture space. + */ + virtual Real getShadowDirLightTextureOffset(void) const { return mShadowTextureOffset; } + /** Sets the proportional distance at which texture shadows begin to fade out. + @remarks + To hide the edges where texture shadows end (in directional lights) + Ogre will fade out the shadow in the distance. This value is a proportional + distance of the entire shadow visibility distance at which the shadow + begins to fade out. The default is 0.7 + */ + virtual void setShadowTextureFadeStart(Real fadeStart) + { mShadowTextureFadeStart = fadeStart; } + /** Sets the proportional distance at which texture shadows finish to fading out. + @remarks + To hide the edges where texture shadows end (in directional lights) + Ogre will fade out the shadow in the distance. This value is a proportional + distance of the entire shadow visibility distance at which the shadow + is completely invisible. The default is 0.9. + */ + virtual void setShadowTextureFadeEnd(Real fadeEnd) + { mShadowTextureFadeEnd = fadeEnd; } + + /** Sets whether or not texture shadows should attempt to self-shadow. + @remarks + The default implementation of texture shadows uses a fixed-function + colour texture projection approach for maximum compatibility, and + as such cannot support self-shadowing. However, if you decide to + implement a more complex shadowing technique using the + setShadowTextureCasterMaterial and setShadowTextureReceiverMaterial + there is a possibility you may be able to support + self-shadowing (e.g by implementing a shader-based shadow map). In + this case you might want to enable this option. + @param selfShadow Whether to attempt self-shadowing with texture shadows + */ + virtual void setShadowTextureSelfShadow(bool selfShadow); + + /// Gets whether or not texture shadows attempt to self-shadow. + virtual bool getShadowTextureSelfShadow(void) const + { return mShadowTextureSelfShadow; } + /** Sets the default material to use for rendering shadow casters. + @remarks + By default shadow casters are rendered into the shadow texture using + an automatically generated fixed-function pass. This allows basic + projective texture shadows, but it's possible to use more advanced + shadow techniques by overriding the caster and receiver materials, for + example providing vertex and fragment programs to implement shadow + maps. + @par + You can rely on the ambient light in the scene being set to the + requested texture shadow colour, if that's useful. + @note + Individual objects may also override the vertex program in + your default material if their materials include + shadow_caster_vertex_program_ref shadow_receiver_vertex_program_ref + entries, so if you use both make sure they are compatible. + @note + Only a single pass is allowed in your material, although multiple + techniques may be used for hardware fallback. + */ + virtual void setShadowTextureCasterMaterial(const String& name); + /** Sets the default material to use for rendering shadow receivers. + @remarks + By default shadow receivers are rendered as a post-pass using basic + modulation. This allows basic projective texture shadows, but it's + possible to use more advanced shadow techniques by overriding the + caster and receiver materials, for example providing vertex and + fragment programs to implement shadow maps. + @par + You can rely on texture unit 0 containing the shadow texture, and + for the unit to be set to use projective texturing from the light + (only useful if you're using fixed-function, which is unlikely; + otherwise you should rely on the texture_viewproj_matrix auto binding) + @note + Individual objects may also override the vertex program in + your default material if their materials include + shadow_caster_vertex_program_ref shadow_receiver_vertex_program_ref + entries, so if you use both make sure they are compatible. + @note + Only a single pass is allowed in your material, although multiple + techniques may be used for hardware fallback. + */ + virtual void setShadowTextureReceiverMaterial(const String& name); + + /** Sets whether or not shadow casters should be rendered into shadow + textures using their back faces rather than their front faces. + @remarks + Rendering back faces rather than front faces into a shadow texture + can help minimise depth comparison issues, if you're using depth + shadowmapping. You will probably still need some biasing but you + won't need as much. For solid objects the result is the same anyway, + if you have objects with holes you may want to turn this option off. + The default is to enable this option. + */ + virtual void setShadowCasterRenderBackFaces(bool bf) { mShadowCasterRenderBackFaces = bf; } + + /** Gets whether or not shadow casters should be rendered into shadow + textures using their back faces rather than their front faces. + */ + virtual bool getShadowCasterRenderBackFaces() const { return mShadowCasterRenderBackFaces; } + + /** Set the shadow camera setup to use for all lights which don't have + their own shadow camera setup. + @see ShadowCameraSetup + */ + virtual void setShadowCameraSetup(const ShadowCameraSetupPtr& shadowSetup); + + /** Get the shadow camera setup in use for all lights which don't have + their own shadow camera setup. + @see ShadowCameraSetup + */ + virtual const ShadowCameraSetupPtr& getShadowCameraSetup() const; + + /** Sets whether we should use an inifinite camera far plane + when rendering stencil shadows. + @remarks + Stencil shadow coherency is very reliant on the shadow volume + not being clipped by the far plane. If this clipping happens, you + get a kind of 'negative' shadow effect. The best way to achieve + coherency is to move the far plane of the camera out to infinity, + thus preventing the far plane from clipping the shadow volumes. + When combined with vertex program extrusion of the volume to + infinity, which Ogre does when available, this results in very + robust shadow volumes. For this reason, when you enable stencil + shadows, Ogre automatically changes your camera settings to + project to infinity if the card supports it. You can disable this + behaviour if you like by calling this method; although you can + never enable infinite projection if the card does not support it. + @par + If you disable infinite projection, or it is not available, + you need to be far more careful with your light attenuation / + directional light extrusion distances to avoid clipping artefacts + at the far plane. + @note + Recent cards will generally support infinite far plane projection. + However, we have found some cases where they do not, especially + on Direct3D. There is no standard capability we can check to + validate this, so we use some heuristics based on experience: +
    +
  • OpenGL always seems to support it no matter what the card
  • +
  • Direct3D on non-vertex program capable systems (including + vertex program capable cards on Direct3D7) does not + support it
  • +
  • Direct3D on GeForce3 and GeForce4 Ti does not seem to support + infinite projection
  • +
+ Therefore in the RenderSystem implementation, we may veto the use + of an infinite far plane based on these heuristics. + */ + virtual void setShadowUseInfiniteFarPlane(bool enable) { + mShadowUseInfiniteFarPlane = enable; } + + /** Is there a stencil shadow based shadowing technique in use? */ + virtual bool isShadowTechniqueStencilBased(void) const + { return (mShadowTechnique & SHADOWDETAILTYPE_STENCIL) != 0; } + /** Is there a texture shadow based shadowing technique in use? */ + virtual bool isShadowTechniqueTextureBased(void) const + { return (mShadowTechnique & SHADOWDETAILTYPE_TEXTURE) != 0; } + /** Is there a modulative shadowing technique in use? */ + virtual bool isShadowTechniqueModulative(void) const + { return (mShadowTechnique & SHADOWDETAILTYPE_MODULATIVE) != 0; } + /** Is there an additive shadowing technique in use? */ + virtual bool isShadowTechniqueAdditive(void) const + { return (mShadowTechnique & SHADOWDETAILTYPE_ADDITIVE) != 0; } + /** Is the shadow technique integrated into primary materials? */ + virtual bool isShadowTechniqueIntegrated(void) const + { return (mShadowTechnique & SHADOWDETAILTYPE_INTEGRATED) != 0; } + /** Is there any shadowing technique in use? */ + virtual bool isShadowTechniqueInUse(void) const + { return mShadowTechnique != SHADOWTYPE_NONE; } + + /** Add a shadow listener which will get called back on shadow + events. + */ + virtual void addShadowListener(ShadowListener* s); + /** Remove a shadow listener + */ + virtual void removeShadowListener(ShadowListener* s); + + /** Creates a StaticGeometry instance suitable for use with this + SceneManager. + @remarks + StaticGeometry is a way of batching up geometry into a more + efficient form at the expense of being able to move it. Please + read the StaticGeometry class documentation for full information. + @param name The name to give the new object + @returns The new StaticGeometry instance + */ + virtual StaticGeometry* createStaticGeometry(const String& name); + /** Retrieve a previously created StaticGeometry instance. + @note Throws an exception if the named instance does not exist + */ + virtual StaticGeometry* getStaticGeometry(const String& name) const; + /** Returns whether a static geometry instance with the given name exists. */ + virtual bool hasStaticGeometry(const String& name) const; + /** Remove & destroy a StaticGeometry instance. */ + virtual void destroyStaticGeometry(StaticGeometry* geom); + /** Remove & destroy a StaticGeometry instance. */ + virtual void destroyStaticGeometry(const String& name); + /** Remove & destroy all StaticGeometry instances. */ + virtual void destroyAllStaticGeometry(void); + + /** Creates a InstancedGeometry instance suitable for use with this + SceneManager. + @remarks + InstancedGeometry is a way of batching up geometry into a more + efficient form, and still be able to move it. Please + read the InstancedGeometry class documentation for full information. + @param name The name to give the new object + @returns The new InstancedGeometry instance + */ + virtual InstancedGeometry* createInstancedGeometry(const String& name); + /** Retrieve a previously created InstancedGeometry instance. */ + virtual InstancedGeometry* getInstancedGeometry(const String& name) const; + /** Remove & destroy a InstancedGeometry instance. */ + virtual void destroyInstancedGeometry(InstancedGeometry* geom); + /** Remove & destroy a InstancedGeometry instance. */ + virtual void destroyInstancedGeometry(const String& name); + /** Remove & destroy all InstancedGeometry instances. */ + virtual void destroyAllInstancedGeometry(void); + + + /** Create a movable object of the type specified. + @remarks + This is the generalised form of MovableObject creation where you can + create a MovableObject of any specialised type generically, including + any new types registered using plugins. + @param name The name to give the object. Must be unique within type. + @param typeName The type of object to create + @param params Optional name/value pair list to give extra parameters to + the created object. + */ + virtual MovableObject* createMovableObject(const String& name, + const String& typeName, const NameValuePairList* params = 0); + /** Destroys a MovableObject with the name specified, of the type specified. + @remarks + The MovableObject will automatically detach itself from any nodes + on destruction. + */ + virtual void destroyMovableObject(const String& name, const String& typeName); + /** Destroys a MovableObject. + @remarks + The MovableObject will automatically detach itself from any nodes + on destruction. + */ + virtual void destroyMovableObject(MovableObject* m); + /** Destroy all MovableObjects of a given type. */ + virtual void destroyAllMovableObjectsByType(const String& typeName); + /** Destroy all MovableObjects. */ + virtual void destroyAllMovableObjects(void); + /** Get a reference to a previously created MovableObject. + @note Throws an exception if the named instance does not exist + */ + virtual MovableObject* getMovableObject(const String& name, const String& typeName) const; + /** Returns whether a movable object instance with the given name exists. */ + virtual bool hasMovableObject(const String& name, const String& typeName) const; + typedef MapIterator MovableObjectIterator; + /** Get an iterator over all MovableObect instances of a given type. + @note + The iterator returned from this method is not thread safe, do not use this + if you are creating or deleting objects of this type in another thread. + */ + virtual MovableObjectIterator getMovableObjectIterator(const String& typeName); + /** Inject a MovableObject instance created externally. + @remarks + This method 'injects' a MovableObject instance created externally into + the MovableObject instance registry held in the SceneManager. You + might want to use this if you have a MovableObject which you don't + want to register a factory for; for example a MovableObject which + cannot be generally constructed by clients. + @note + It is important that the MovableObject has a unique name for the type, + and that its getMovableType() method returns a proper type name. + */ + virtual void injectMovableObject(MovableObject* m); + /** Extract a previously injected MovableObject. + @remarks + Essentially this does the same as destroyMovableObject, but only + removes the instance from the internal lists, it does not attempt + to destroy it. + */ + virtual void extractMovableObject(const String& name, const String& typeName); + /** Extract a previously injected MovableObject. + @remarks + Essentially this does the same as destroyMovableObject, but only + removes the instance from the internal lists, it does not attempt + to destroy it. + */ + virtual void extractMovableObject(MovableObject* m); + /** Extract all injected MovableObjects of a given type. + @remarks + Essentially this does the same as destroyAllMovableObjectsByType, + but only removes the instances from the internal lists, it does not + attempt to destroy them. + */ + virtual void extractAllMovableObjectsByType(const String& typeName); + + /** Sets a mask which is bitwise 'and'ed with objects own visibility masks + to determine if the object is visible. + @remarks + Note that this is combined with any per-viewport visibility mask + through an 'and' operation. @see Viewport::setVisibilityMask + */ + virtual void setVisibilityMask(uint32 vmask) { mVisibilityMask = vmask; } + + /** Gets a mask which is bitwise 'and'ed with objects own visibility masks + to determine if the object is visible. + */ + virtual uint32 getVisibilityMask(void) { return mVisibilityMask; } + + /** Internal method for getting the combination between the global visibility + mask and the per-viewport visibility mask. + */ + uint32 _getCombinedVisibilityMask(void) const; + + /** Sets whether the SceneManager should search for visible objects, or + whether they are being manually handled. + @remarks + This is an advanced function, you should not use this unless you know + what you are doing. + */ + virtual void setFindVisibleObjects(bool find) { mFindVisibleObjects = find; } + + /** Gets whether the SceneManager should search for visible objects, or + whether they are being manually handled. + */ + virtual bool getFindVisibleObjects(void) { return mFindVisibleObjects; } + + /** Render something as if it came from the current queue. + @param pass Material pass to use for setting up this quad. + @param rend Renderable to render + @param shadowDerivation Whether passes should be replaced with shadow caster / receiver passes + */ + virtual void _injectRenderWithPass(Pass *pass, Renderable *rend, bool shadowDerivation = true); + + /** Indicates to the SceneManager whether it should suppress changing + the RenderSystem states when rendering objects. + @remarks + This method allows you to tell the SceneManager not to change any + RenderSystem state until you tell it to. This method is only + intended for advanced use, don't use it if you're unsure of the + effect. The only RenderSystems calls made are to set the world + matrix for each object (note - view an projection matrices are NOT + SET - they are under your control) and to render the object; it is up to + the caller to do everything else, including enabling any vertex / + fragment programs and updating their parameter state, and binding + parameters to the RenderSystem. + @note + Calling this implicitly disables shadow processing since no shadows + can be rendered without changing state. + @param suppress If true, no RenderSystem state changes will be issued + until this method is called again with a parameter of false. + */ + virtual void _suppressRenderStateChanges(bool suppress); + + /** Are render state changes suppressed? + @see _suppressRenderStateChanges + */ + virtual bool _areRenderStateChangesSuppressed(void) const + { return mSuppressRenderStateChanges; } + + /** Internal method for setting up the renderstate for a rendering pass. + @param pass The Pass details to set. + @param evenIfSuppressed Sets the pass details even if render state + changes are suppressed; if you are using this to manually set state + when render state changes are suppressed, you should set this to + true. + @param shadowDerivation If false, disables the derivation of shadow + passes from original passes + @returns + A Pass object that was used instead of the one passed in, can + happen when rendering shadow passes + */ + virtual const Pass* _setPass(const Pass* pass, + bool evenIfSuppressed = false, bool shadowDerivation = true); + + + /** Indicates to the SceneManager whether it should suppress the + active shadow rendering technique until told otherwise. + @remarks + This is a temporary alternative to setShadowTechnique to suppress + the rendering of shadows and forcing all processing down the + standard rendering path. This is intended for internal use only. + @param suppress If true, no shadow rendering will occur until this + method is called again with a parameter of false. + */ + virtual void _suppressShadows(bool suppress); + + /** Are shadows suppressed? + @see _suppressShadows + */ + virtual bool _areShadowsSuppressed(void) const + { return mSuppressShadows; } + + /** Render the objects in a given queue group + @remarks You should only call this from a RenderQueueInvocation implementation + */ + virtual void _renderQueueGroupObjects(RenderQueueGroup* group, + QueuedRenderableCollection::OrganisationMode om); + + /** Advanced method for supplying an alternative visitor, used for parsing the + render queues and sending the results to the renderer. + @remarks + You can use this method to insert your own implementation of the + QueuedRenderableVisitor interface, which receives calls as the queued + renderables are parsed in a given order (determined by RenderQueueInvocationSequence) + and are sent to the renderer. If you provide your own implementation of + this visitor, you are responsible for either calling the rendersystem, + or passing the calls on to the base class implementation. + @note + Ownership is not taken of this pointer, you are still required to + delete it yourself once you're finished. + @param visitor Your implementation of SceneMgrQueuedRenderableVisitor. + If you pass 0, the default implementation will be used. + */ + void setQueuedRenderableVisitor(SceneMgrQueuedRenderableVisitor* visitor); + + /** Gets the current visitor object which processes queued renderables. */ + SceneMgrQueuedRenderableVisitor* getQueuedRenderableVisitor(void) const; + + + /** Get the rendersystem subclass to which the output of this Scene Manager + gets sent + */ + RenderSystem *getDestinationRenderSystem(); + + /** Gets the current viewport being rendered (advanced use only, only + valid during viewport update. */ + Viewport* getCurrentViewport(void) const { return mCurrentViewport; } + + /** Returns a visibility boundary box for a specific camera. */ + const VisibleObjectsBoundsInfo& getVisibleObjectsBoundsInfo(const Camera* cam) const; + + /** Returns the shadow caster AAB for a specific light-camera combination */ + const VisibleObjectsBoundsInfo& getShadowCasterBoundsInfo(const Light* light) const; + }; + + /** Default implementation of IntersectionSceneQuery. */ + class _OgreExport DefaultIntersectionSceneQuery : + public IntersectionSceneQuery + { + public: + DefaultIntersectionSceneQuery(SceneManager* creator); + ~DefaultIntersectionSceneQuery(); + + /** See IntersectionSceneQuery. */ + void execute(IntersectionSceneQueryListener* listener); + }; + + /** Default implementation of RaySceneQuery. */ + class _OgreExport DefaultRaySceneQuery : public RaySceneQuery + { + public: + DefaultRaySceneQuery(SceneManager* creator); + ~DefaultRaySceneQuery(); + + /** See RayScenQuery. */ + void execute(RaySceneQueryListener* listener); + }; + /** Default implementation of SphereSceneQuery. */ + class _OgreExport DefaultSphereSceneQuery : public SphereSceneQuery + { + public: + DefaultSphereSceneQuery(SceneManager* creator); + ~DefaultSphereSceneQuery(); + + /** See SceneQuery. */ + void execute(SceneQueryListener* listener); + }; + /** Default implementation of PlaneBoundedVolumeListSceneQuery. */ + class _OgreExport DefaultPlaneBoundedVolumeListSceneQuery : public PlaneBoundedVolumeListSceneQuery + { + public: + DefaultPlaneBoundedVolumeListSceneQuery(SceneManager* creator); + ~DefaultPlaneBoundedVolumeListSceneQuery(); + + /** See SceneQuery. */ + void execute(SceneQueryListener* listener); + }; + /** Default implementation of AxisAlignedBoxSceneQuery. */ + class _OgreExport DefaultAxisAlignedBoxSceneQuery : public AxisAlignedBoxSceneQuery + { + public: + DefaultAxisAlignedBoxSceneQuery(SceneManager* creator); + ~DefaultAxisAlignedBoxSceneQuery(); + + /** See RayScenQuery. */ + void execute(SceneQueryListener* listener); + }; + + + /// Bitmask containing scene types + typedef uint16 SceneTypeMask; + + /** Classification of a scene to allow a decision of what type of + SceenManager to provide back to the application. + */ + enum SceneType + { + ST_GENERIC = 1, + ST_EXTERIOR_CLOSE = 2, + ST_EXTERIOR_FAR = 4, + ST_EXTERIOR_REAL_FAR = 8, + ST_INTERIOR = 16 + }; + + /** Structure containing information about a scene manager. */ + struct SceneManagerMetaData + { + /// A globally unique string identifying the scene manager type + String typeName; + /// A text description of the scene manager + String description; + /// A mask describing which sorts of scenes this manager can handle + SceneTypeMask sceneTypeMask; + /// Flag indicating whether world geometry is supported + bool worldGeometrySupported; + }; + + + + /** Class which will create instances of a given SceneManager. */ + class _OgreExport SceneManagerFactory + { + protected: + mutable SceneManagerMetaData mMetaData; + mutable bool mMetaDataInit; + /// Internal method to initialise the metadata, must be implemented + virtual void initMetaData(void) const = 0; + public: + SceneManagerFactory() : mMetaDataInit(true) {} + virtual ~SceneManagerFactory() {} + /** Get information about the SceneManager type created by this factory. */ + virtual const SceneManagerMetaData& getMetaData(void) const + { + if (mMetaDataInit) + { + initMetaData(); + mMetaDataInit = false; + } + return mMetaData; + } + /** Create a new instance of a SceneManager. + @remarks + Don't call directly, use SceneManagerEnumerator::createSceneManager. + */ + virtual SceneManager* createInstance(const String& instanceName) = 0; + /** Destroy an instance of a SceneManager. */ + virtual void destroyInstance(SceneManager* instance) = 0; + + }; + + + +} // Namespace + + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreSceneManagerEnumerator.h b/school/informatik/verkerhssimulation/src/ogre/OgreSceneManagerEnumerator.h new file mode 100644 index 00000000..26a6614c --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreSceneManagerEnumerator.h @@ -0,0 +1,221 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __SceneManagerEnumerator_H__ +#define __SceneManagerEnumerator_H__ + +#include "OgrePrerequisites.h" + +#include "OgreSceneManager.h" +#include "OgreSingleton.h" +#include "OgreIteratorWrappers.h" + +namespace Ogre { + + /// Factory for default scene manager + class _OgreExport DefaultSceneManagerFactory : public SceneManagerFactory + { + protected: + void initMetaData(void) const; + public: + DefaultSceneManagerFactory() {} + ~DefaultSceneManagerFactory() {} + /// Factory type name + static const String FACTORY_TYPE_NAME; + SceneManager* createInstance(const String& instanceName); + void destroyInstance(SceneManager* instance); + }; + /// Default scene manager + class _OgreExport DefaultSceneManager : public SceneManager + { + public: + DefaultSceneManager(const String& name); + ~DefaultSceneManager(); + const String& getTypeName(void) const; + }; + + /** Enumerates the SceneManager classes available to applications. + @remarks + As described in the SceneManager class, SceneManagers are responsible + for organising the scene and issuing rendering commands to the + RenderSystem. Certain scene types can benefit from different + rendering approaches, and it is intended that subclasses will + be created to special case this. + @par + In order to give applications easy access to these implementations, + this class has a number of methods to create or retrieve a SceneManager + which is appropriate to the scene type. + @par + SceneManagers are created by SceneManagerFactory instances. New factories + for new types of SceneManager can be registered with this class to make + them available to clients. + @par + Note that you can still plug in your own custom SceneManager without + using a factory, should you choose, it's just not as flexible that way. + Just instantiate your own SceneManager manually and use it directly. + */ + class _OgreExport SceneManagerEnumerator : public Singleton + { + public: + /// Scene manager instances, indexed by instance name + typedef std::map Instances; + /// List of available scene manager types as meta data + typedef std::vector MetaDataList; + private: + /// Scene manager factories + typedef std::list Factories; + Factories mFactories; + Instances mInstances; + /// Stored separately to allow iteration + MetaDataList mMetaDataList; + /// Factory for default scene manager + DefaultSceneManagerFactory mDefaultFactory; + /// Count of creations for auto-naming + unsigned long mInstanceCreateCount; + /// Currently assigned render system + RenderSystem* mCurrentRenderSystem; + + + public: + SceneManagerEnumerator(); + ~SceneManagerEnumerator(); + + /** Register a new SceneManagerFactory. + @remarks + Plugins should call this to register as new SceneManager providers. + */ + void addFactory(SceneManagerFactory* fact); + + /** Remove a SceneManagerFactory. + */ + void removeFactory(SceneManagerFactory* fact); + + /** Get more information about a given type of SceneManager. + @remarks + The metadata returned tells you a few things about a given type + of SceneManager, which can be created using a factory that has been + registered already. + @param typeName The type name of the SceneManager you want to enquire on. + If you don't know the typeName already, you can iterate over the + metadata for all types using getMetaDataIterator. + */ + const SceneManagerMetaData* getMetaData(const String& typeName) const; + + typedef ConstVectorIterator MetaDataIterator; + /** Iterate over all types of SceneManager available for construction, + providing some information about each one. + */ + MetaDataIterator getMetaDataIterator(void) const; + + /** Create a SceneManager instance of a given type. + @remarks + You can use this method to create a SceneManager instance of a + given specific type. You may know this type already, or you may + have discovered it by looking at the results from getMetaDataIterator. + @note + This method throws an exception if the named type is not found. + @param typeName String identifying a unique SceneManager type + @param instanceName Optional name to given the new instance that is + created. If you leave this blank, an auto name will be assigned. + */ + SceneManager* createSceneManager(const String& typeName, + const String& instanceName = StringUtil::BLANK); + + /** Create a SceneManager instance based on scene type support. + @remarks + Creates an instance of a SceneManager which supports the scene types + identified in the parameter. If more than one type of SceneManager + has been registered as handling that combination of scene types, + in instance of the last one registered is returned. + @note This method always succeeds, if a specific scene manager is not + found, the default implementation is always returned. + @param typeMask A mask containing one or more SceneType flags + @param instanceName Optional name to given the new instance that is + created. If you leave this blank, an auto name will be assigned. + */ + SceneManager* createSceneManager(SceneTypeMask typeMask, + const String& instanceName = StringUtil::BLANK); + + /** Destroy an instance of a SceneManager. */ + void destroySceneManager(SceneManager* sm); + + /** Get an existing SceneManager instance that has already been created, + identified by the instance name. + @param instanceName The name of the instance to retrieve. + */ + SceneManager* getSceneManager(const String& instanceName) const; + + typedef MapIterator SceneManagerIterator; + /** Get an iterator over all the existing SceneManager instances. */ + SceneManagerIterator getSceneManagerIterator(void); + + /** Notifies all SceneManagers of the destination rendering system. + */ + void setRenderSystem(RenderSystem* rs); + + /// Utility method to control shutdown of the managers + void shutdownAll(void); + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static SceneManagerEnumerator& getSingleton(void); + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static SceneManagerEnumerator* getSingletonPtr(void); + + }; + + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreSceneNode.h b/school/informatik/verkerhssimulation/src/ogre/OgreSceneNode.h new file mode 100644 index 00000000..5d185a02 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreSceneNode.h @@ -0,0 +1,448 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _SceneNode_H__ +#define _SceneNode_H__ + +#include "OgrePrerequisites.h" + +#include "OgreNode.h" +#include "OgreIteratorWrappers.h" +#include "OgreAxisAlignedBox.h" + +namespace Ogre { + + // forward decl + struct VisibleObjectsBoundsInfo; + + /** Class representing a node in the scene graph. + @remarks + A SceneNode is a type of Node which is used to organise objects in a scene. + It has the same hierarchical transformation properties of the generic Node class, + but also adds the ability to attach world objects to the node, and stores hierarchical + bounding volumes of the nodes in the tree. + Child nodes are contained within the bounds of the parent, and so on down the + tree, allowing for fast culling. + */ + class _OgreExport SceneNode : public Node + { + public: + typedef HashMap ObjectMap; + typedef MapIterator ObjectIterator; + typedef ConstMapIterator ConstObjectIterator; + + protected: + ObjectMap mObjectsByName; + + /// Pointer to a Wire Bounding Box for this Node + WireBoundingBox *mWireBoundingBox; + /// Flag that determines if the bounding box of the node should be displayed + bool mShowBoundingBox; + + /// SceneManager which created this node + SceneManager* mCreator; + + /// World-Axis aligned bounding box, updated only through _update + AxisAlignedBox mWorldAABB; + + /** @copydoc Node::updateFromParentImpl. */ + void updateFromParentImpl(void) const; + + /** See Node. */ + Node* createChildImpl(void); + + /** See Node. */ + Node* createChildImpl(const String& name); + + /** See Node */ + void setParent(Node* parent); + + /** Internal method for setting whether the node is in the scene + graph. + */ + virtual void setInSceneGraph(bool inGraph); + + /// Whether to yaw around a fixed axis. + bool mYawFixed; + /// Fixed axis to yaw around + Vector3 mYawFixedAxis; + + /// Auto tracking target + SceneNode* mAutoTrackTarget; + /// Tracking offset for fine tuning + Vector3 mAutoTrackOffset; + /// Local 'normal' direction vector + Vector3 mAutoTrackLocalDirection; + /// Is this node a current part of the scene graph? + bool mIsInSceneGraph; + public: + /** Constructor, only to be called by the creator SceneManager. + @remarks + Creates a node with a generated name. + */ + SceneNode(SceneManager* creator); + /** Constructor, only to be called by the creator SceneManager. + @remarks + Creates a node with a specified name. + */ + SceneNode(SceneManager* creator, const String& name); + ~SceneNode(); + + /** Adds an instance of a scene object to this node. + @remarks + Scene objects can include Entity objects, Camera objects, Light objects, + ParticleSystem objects etc. Anything that subclasses from MovableObject. + */ + virtual void attachObject(MovableObject* obj); + + /** Reports the number of objects attached to this node. + */ + virtual unsigned short numAttachedObjects(void) const; + + /** Retrieves a pointer to an attached object. + @remarks Retrieves by index, see alternate version to retrieve by name. The index + of an object may change as other objects are added / removed. + */ + virtual MovableObject* getAttachedObject(unsigned short index); + + /** Retrieves a pointer to an attached object. + @remarks Retrieves by object name, see alternate version to retrieve by index. + */ + virtual MovableObject* getAttachedObject(const String& name); + + /** Detaches the indexed object from this scene node. + @remarks + Detaches by index, see the alternate version to detach by name. Object indexes + may change as other objects are added / removed. + */ + virtual MovableObject* detachObject(unsigned short index); + /** Detaches an object by pointer. */ + virtual void detachObject(MovableObject* obj); + + /** Detaches the named object from this node and returns a pointer to it. */ + virtual MovableObject* detachObject(const String& name); + + /** Detaches all objects attached to this node. + */ + virtual void detachAllObjects(void); + + /** Determines whether this node is in the scene graph, ie + whether it's ulitimate ancestor is the root scene node. + */ + virtual bool isInSceneGraph(void) const { return mIsInSceneGraph; } + + /** Notifies this SceneNode that it is the root scene node. + @remarks + Only SceneManager should call this! + */ + virtual void _notifyRootNode(void) { mIsInSceneGraph = true; } + + + /** Internal method to update the Node. + @note + Updates this scene node and any relevant children to incorporate transforms etc. + Don't call this yourself unless you are writing a SceneManager implementation. + @param + updateChildren If true, the update cascades down to all children. Specify false if you wish to + update children separately, e.g. because of a more selective SceneManager implementation. + @param + parentHasChanged This flag indicates that the parent xform has changed, + so the child should retrieve the parent's xform and combine it with its own + even if it hasn't changed itself. + */ + virtual void _update(bool updateChildren, bool parentHasChanged); + + /** Tells the SceneNode to update the world bound info it stores. + */ + virtual void _updateBounds(void); + + /** Internal method which locates any visible objects attached to this node and adds them to the passed in queue. + @remarks + Should only be called by a SceneManager implementation, and only after the _updat method has been called to + ensure transforms and world bounds are up to date. + SceneManager implementations can choose to let the search cascade automatically, or choose to prevent this + and select nodes themselves based on some other criteria. + @param + cam The active camera + @param + queue The SceneManager's rendering queue + @param + visibleBounds bounding information created on the fly containing all visible objects by the camera + @param + includeChildren If true, the call is cascaded down to all child nodes automatically. + @param + displayNodes If true, the nodes themselves are rendered as a set of 3 axes as well + as the objects being rendered. For debugging purposes. + */ + virtual void _findVisibleObjects(Camera* cam, RenderQueue* queue, + VisibleObjectsBoundsInfo* visibleBounds, + bool includeChildren = true, bool displayNodes = false, bool onlyShadowCasters = false); + + /** Gets the axis-aligned bounding box of this node (and hence all subnodes). + @remarks + Recommended only if you are extending a SceneManager, because the bounding box returned + from this method is only up to date after the SceneManager has called _update. + */ + virtual const AxisAlignedBox& _getWorldAABB(void) const; + + /** Retrieves an iterator which can be used to efficiently step through the objects + attached to this node. + @remarks + This is a much faster way to go through all the objects attached to the node + than using getAttachedObject. But the iterator returned is only valid until a change + is made to the collection (ie an addition or removal) so treat the returned iterator + as transient, and don't add / remove items as you go through the iterator, save changes + until the end, or retrieve a new iterator after making the change. Making changes to + the object returned through the iterator is OK though. + */ + virtual ObjectIterator getAttachedObjectIterator(void); + /** Retrieves an iterator which can be used to efficiently step through the objects + attached to this node. + @remarks + This is a much faster way to go through all the objects attached to the node + than using getAttachedObject. But the iterator returned is only valid until a change + is made to the collection (ie an addition or removal) so treat the returned iterator + as transient, and don't add / remove items as you go through the iterator, save changes + until the end, or retrieve a new iterator after making the change. Making changes to + the object returned through the iterator is OK though. + */ + virtual ConstObjectIterator getAttachedObjectIterator(void) const; + + /** Gets the creator of this scene node. + @remarks + This method returns the SceneManager which created this node. + This can be useful for destroying this node. + */ + SceneManager* getCreator(void) const { return mCreator; } + + /** This method removes and destroys the named child and all of its children. + @remarks + Unlike removeChild, which removes a single named child from this + node but does not destroy it, this method destroys the child + and all of it's children. + @par + Use this if you wish to recursively destroy a node as well as + detaching it from it's parent. Note that any objects attached to + the nodes will be detached but will not themselves be destroyed. + */ + virtual void removeAndDestroyChild(const String& name); + + /** This method removes and destroys the child and all of its children. + @remarks + Unlike removeChild, which removes a single named child from this + node but does not destroy it, this method destroys the child + and all of it's children. + @par + Use this if you wish to recursively destroy a node as well as + detaching it from it's parent. Note that any objects attached to + the nodes will be detached but will not themselves be destroyed. + */ + virtual void removeAndDestroyChild(unsigned short index); + + /** Removes and destroys all children of this node. + @remarks + Use this to destroy all child nodes of this node and remove + them from the scene graph. Note that all objects attached to this + node will be detached but will not be destroyed. + */ + virtual void removeAndDestroyAllChildren(void); + + /** Allows the showing of the node's bounding box. + @remarks + Use this to show or hide the bounding box of the node. + */ + virtual void showBoundingBox(bool bShow); + + /** Add the bounding box to the rendering queue. + */ + virtual void _addBoundingBoxToQueue(RenderQueue* queue); + + /** This allows scene managers to determine if the node's bounding box + should be added to the rendering queue. + @remarks + Scene Managers that implement their own _findVisibleObjects will have to + check this flag and then use _addBoundingBoxToQueue to add the bounding box + wireframe. + */ + virtual bool getShowBoundingBox() const; + + /** Creates an unnamed new SceneNode as a child of this node. + @param + translate Initial translation offset of child relative to parent + @param + rotate Initial rotation relative to parent + */ + virtual SceneNode* createChildSceneNode( + const Vector3& translate = Vector3::ZERO, + const Quaternion& rotate = Quaternion::IDENTITY ); + + /** Creates a new named SceneNode as a child of this node. + @remarks + This creates a child node with a given name, which allows you to look the node up from + the parent which holds this collection of nodes. + @param + translate Initial translation offset of child relative to parent + @param + rotate Initial rotation relative to parent + */ + virtual SceneNode* createChildSceneNode(const String& name, const Vector3& translate = Vector3::ZERO, const Quaternion& rotate = Quaternion::IDENTITY); + + /** Allows retrieval of the nearest lights to the centre of this SceneNode. + @remarks + This method allows a list of lights, ordered by proximity to the centre + of this SceneNode, to be retrieved. Can be useful when implementing + MovableObject::queryLights and Renderable::getLights. + @par + Note that only lights could be affecting the frustum will take into + account, which cached in scene manager. + @see SceneManager::_getLightsAffectingFrustum + @see SceneManager::_populateLightList + @param destList List to be populated with ordered set of lights; will be + cleared by this method before population. + @param radius Parameter to specify lights intersecting a given radius of + this SceneNode's centre. + */ + virtual void findLights(LightList& destList, Real radius) const; + + /** Tells the node whether to yaw around it's own local Y axis or a fixed axis of choice. + @remarks + This method allows you to change the yaw behaviour of the node - by default, it + yaws around it's own local Y axis when told to yaw with TS_LOCAL, this makes it + yaw around a fixed axis. + You only really need this when you're using auto tracking (see setAutoTracking, + because when you're manually rotating a node you can specify the TransformSpace + in which you wish to work anyway. + @param + useFixed If true, the axis passed in the second parameter will always be the yaw axis no + matter what the node orientation. If false, the node returns to it's default behaviour. + @param + fixedAxis The axis to use if the first parameter is true. + */ + virtual void setFixedYawAxis( bool useFixed, const Vector3& fixedAxis = Vector3::UNIT_Y ); + + /** Rotate the node around the Y-axis. + */ + virtual void yaw(const Radian& angle, TransformSpace relativeTo = TS_LOCAL); +#ifndef OGRE_FORCE_ANGLE_TYPES + inline void yaw(Real degrees, TransformSpace relativeTo = TS_LOCAL) { + yaw ( Angle(degrees), relativeTo ); + } +#endif//OGRE_FORCE_ANGLE_TYPES + /** Sets the node's direction vector ie it's local -z. + @remarks + Note that the 'up' vector for the orientation will automatically be + recalculated based on the current 'up' vector (i.e. the roll will + remain the same). If you need more control, use setOrientation. + @param x,y,z The components of the direction vector + @param relativeTo The space in which this direction vector is expressed + @param localDirectionVector The vector which normally describes the natural + direction of the node, usually -Z + */ + virtual void setDirection(Real x, Real y, Real z, + TransformSpace relativeTo = TS_LOCAL, + const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z); + + /** Sets the node's direction vector ie it's local -z. + @remarks + Note that the 'up' vector for the orientation will automatically be + recalculated based on the current 'up' vector (i.e. the roll will + remain the same). If you need more control, use setOrientation. + @param vec The direction vector + @param relativeTo The space in which this direction vector is expressed + @param localDirectionVector The vector which normally describes the natural + direction of the node, usually -Z + */ + virtual void setDirection(const Vector3& vec, TransformSpace relativeTo = TS_LOCAL, + const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z); + /** Points the local -Z direction of this node at a point in space. + @param targetPoint A vector specifying the look at point. + @param relativeTo The space in which the point resides + @param localDirectionVector The vector which normally describes the natural + direction of the node, usually -Z + */ + virtual void lookAt( const Vector3& targetPoint, TransformSpace relativeTo, + const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z); + /** Enables / disables automatic tracking of another SceneNode. + @remarks + If you enable auto-tracking, this SceneNode will automatically rotate to + point it's -Z at the target SceneNode every frame, no matter how + it or the other SceneNode move. Note that by default the -Z points at the + origin of the target SceneNode, if you want to tweak this, provide a + vector in the 'offset' parameter and the target point will be adjusted. + @param enabled If true, tracking will be enabled and the next + parameter cannot be null. If false tracking will be disabled and the + current orientation will be maintained. + @param target Pointer to the SceneNode to track. Make sure you don't + delete this SceneNode before turning off tracking (e.g. SceneManager::clearScene will + delete it so be careful of this). Can be null if and only if the enabled param is false. + @param localDirectionVector The local vector considered to be the usual 'direction' + of the node; normally the local -Z but can be another direction. + @param offset If supplied, this is the target point in local space of the target node + instead of the origin of the target node. Good for fine tuning the look at point. + */ + virtual void setAutoTracking(bool enabled, SceneNode* target = 0, + const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z, + const Vector3& offset = Vector3::ZERO); + /** Get the auto tracking target for this node, if any. */ + virtual SceneNode* getAutoTrackTarget(void) { return mAutoTrackTarget; } + /** Get the auto tracking offset for this node, if the node is auto tracking. */ + virtual const Vector3& getAutoTrackOffset(void) { return mAutoTrackOffset; } + /** Get the auto tracking local direction for this node, if it is auto tracking. */ + virtual const Vector3& getAutoTrackLocalDirection(void) { return mAutoTrackLocalDirection; } + /** Internal method used by OGRE to update auto-tracking cameras. */ + void _autoTrack(void); + /** Gets the parent of this SceneNode. */ + SceneNode* getParentSceneNode(void) const; + /** Makes all objects attached to this node become visible / invisble. + @remarks + This is a shortcut to calling setVisible() on the objects attached + to this node, and optionally to all objects attached to child + nodes. + @param visible Whether the objects are to be made visible or invisible + @param cascade If true, this setting cascades into child nodes too. + */ + virtual void setVisible(bool visible, bool cascade = true); + /** Inverts the visibility of all objects attached to this node. + @remarks + This is a shortcut to calling setVisible(!isVisible()) on the objects attached + to this node, and optionally to all objects attached to child + nodes. + @param cascade If true, this setting cascades into child nodes too. + */ + virtual void flipVisibility(bool cascade = true); + + + + + + }; + + +}// namespace + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreSceneQuery.h b/school/informatik/verkerhssimulation/src/ogre/OgreSceneQuery.h new file mode 100644 index 00000000..eba22344 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreSceneQuery.h @@ -0,0 +1,557 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __SceneQuery_H__ +#define __SceneQuery_H__ + +#include "OgrePrerequisites.h" +#include "OgreAxisAlignedBox.h" +#include "OgreSphere.h" +#include "OgreRay.h" +#include "OgreRenderOperation.h" +#include "OgrePlaneBoundedVolume.h" + +namespace Ogre { + + // forward declaration + class SceneQueryListener; + /** A class for performing queries on a scene. + @remarks + This is an abstract class for performing a query on a scene, i.e. to retrieve + a list of objects and/or world geometry sections which are potentially intersecting a + given region. Note the use of the word 'potentially': the results of a scene query + are generated based on bounding volumes, and as such are not correct at a triangle + level; the user of the SceneQuery is expected to filter the results further if + greater accuracy is required. + @par + Different SceneManagers will implement these queries in different ways to + exploit their particular scene organisation, and thus will provide their own + concrete subclasses. In fact, these subclasses will be derived from subclasses + of this class rather than directly because there will be region-type classes + in between. + @par + These queries could have just been implemented as methods on the SceneManager, + however, they are wrapped up as objects to allow 'compilation' of queries + if deemed appropriate by the implementation; i.e. each concrete subclass may + precalculate information (such as fixed scene partitions involved in the query) + to speed up the repeated use of the query. + @par + You should never try to create a SceneQuery object yourself, they should be created + using the SceneManager interfaces for the type of query required, e.g. + SceneManager::createSphereSceneQuery. + */ + class _OgreExport SceneQuery + { + public: + /** This type can be used by collaborating applications & SceneManagers to + agree on the type of world geometry to be returned from queries. Not all + these types will be supported by all SceneManagers; once the application + has decided which SceneManager specialisation to use, it is expected that + it will know which type of world geometry abstraction is available to it. + */ + enum WorldFragmentType { + /// Return no world geometry hits at all + WFT_NONE, + /// Return pointers to convex plane-bounded regions + WFT_PLANE_BOUNDED_REGION, + /// Return a single intersection point (typically RaySceneQuery only) + WFT_SINGLE_INTERSECTION, + /// Custom geometry as defined by the SceneManager + WFT_CUSTOM_GEOMETRY, + /// General RenderOperation structure + WFT_RENDER_OPERATION + }; + + /** Represents part of the world geometry that is a result of a SceneQuery. + @remarks + Since world geometry is normally vast and sprawling, we need a way of + retrieving parts of it based on a query. That is what this struct is for; + note there are potentially as many data structures for world geometry as there + are SceneManagers, however this structure includes a few common abstractions as + well as a more general format. + @par + The type of world fragment that is returned from a query depends on the + SceneManager, and the option set using SceneQuery::setWorldFragmentType. + You can see what fragment types are supported on the query in question by + calling SceneQuery::getSupportedWorldFragmentTypes(). + */ + struct WorldFragment { + /// The type of this world fragment + WorldFragmentType fragmentType; + /// Single intersection point, only applicable for WFT_SINGLE_INTERSECTION + Vector3 singleIntersection; + /// Planes bounding a convex region, only applicable for WFT_PLANE_BOUNDED_REGION + std::list* planes; + /// Custom geometry block, only applicable for WFT_CUSTOM_GEOMETRY + void* geometry; + /// General render operation structure, fallback if nothing else is available + RenderOperation* renderOp; + + }; + protected: + SceneManager* mParentSceneMgr; + uint32 mQueryMask; + uint32 mQueryTypeMask; + std::set mSupportedWorldFragments; + WorldFragmentType mWorldFragmentType; + + public: + /** Standard constructor, should be called by SceneManager. */ + SceneQuery(SceneManager* mgr); + virtual ~SceneQuery(); + + /** Sets the mask for results of this query. + @remarks + This method allows you to set a 'mask' to limit the results of this + query to certain types of result. The actual meaning of this value is + up to the application; basically MovableObject instances will only be returned + from this query if a bitwise AND operation between this mask value and the + MovableObject::getQueryFlags value is non-zero. The application will + have to decide what each of the bits means. + */ + virtual void setQueryMask(uint32 mask); + /** Returns the current mask for this query. */ + virtual uint32 getQueryMask(void) const; + + /** Sets the type mask for results of this query. + @remarks + This method allows you to set a 'type mask' to limit the results of this + query to certain types of objects. Whilst setQueryMask deals with flags + set per instance of object, this method deals with setting a mask on + flags set per type of object. Both may exclude an object from query + results. + */ + virtual void setQueryTypeMask(uint32 mask); + /** Returns the current mask for this query. */ + virtual uint32 getQueryTypeMask(void) const; + + /** Tells the query what kind of world geometry to return from queries; + often the full renderable geometry is not what is needed. + @remarks + The application receiving the world geometry is expected to know + what to do with it; inevitably this means that the application must + have knowledge of at least some of the structures + used by the custom SceneManager. + @par + The default setting is WFT_NONE. + */ + virtual void setWorldFragmentType(enum WorldFragmentType wft); + + /** Gets the current world fragment types to be returned from the query. */ + virtual WorldFragmentType getWorldFragmentType(void) const; + + /** Returns the types of world fragments this query supports. */ + virtual const std::set* getSupportedWorldFragmentTypes(void) const + {return &mSupportedWorldFragments;} + + + }; + + /** This optional class allows you to receive per-result callbacks from + SceneQuery executions instead of a single set of consolidated results. + @remarks + You should override this with your own subclass. Note that certain query + classes may refine this listener interface. + */ + class _OgreExport SceneQueryListener + { + public: + virtual ~SceneQueryListener() { } + /** Called when a MovableObject is returned by a query. + @remarks + The implementor should return 'true' to continue returning objects, + or 'false' to abandon any further results from this query. + */ + virtual bool queryResult(MovableObject* object) = 0; + /** Called when a WorldFragment is returned by a query. + @remarks + The implementor should return 'true' to continue returning objects, + or 'false' to abandon any further results from this query. + */ + virtual bool queryResult(SceneQuery::WorldFragment* fragment) = 0; + + }; + + typedef std::list SceneQueryResultMovableList; + typedef std::list SceneQueryResultWorldFragmentList; + /** Holds the results of a scene query. */ + struct _OgreExport SceneQueryResult + { + /// List of movable objects in the query (entities, particle systems etc) + SceneQueryResultMovableList movables; + /// List of world fragments + SceneQueryResultWorldFragmentList worldFragments; + }; + + /** Abstract class defining a query which returns single results from a region. + @remarks + This class is simply a generalisation of the subtypes of query that return + a set of individual results in a region. See the SceneQuery class for abstract + information, and subclasses for the detail of each query type. + */ + class _OgreExport RegionSceneQuery + : public SceneQuery, public SceneQueryListener + { + protected: + SceneQueryResult* mLastResult; + public: + /** Standard constructor, should be called by SceneManager. */ + RegionSceneQuery(SceneManager* mgr); + virtual ~RegionSceneQuery(); + /** Executes the query, returning the results back in one list. + @remarks + This method executes the scene query as configured, gathers the results + into one structure and returns a reference to that structure. These + results will also persist in this query object until the next query is + executed, or clearResults() is called. An more lightweight version of + this method that returns results through a listener is also available. + */ + virtual SceneQueryResult& execute(void); + + /** Executes the query and returns each match through a listener interface. + @remarks + Note that this method does not store the results of the query internally + so does not update the 'last result' value. This means that this version of + execute is more lightweight and therefore more efficient than the version + which returns the results as a collection. + */ + virtual void execute(SceneQueryListener* listener) = 0; + + /** Gets the results of the last query that was run using this object, provided + the query was executed using the collection-returning version of execute. + */ + virtual SceneQueryResult& getLastResults(void) const; + /** Clears the results of the last query execution. + @remarks + You only need to call this if you specifically want to free up the memory + used by this object to hold the last query results. This object clears the + results itself when executing and when destroying itself. + */ + virtual void clearResults(void); + + /** Self-callback in order to deal with execute which returns collection. */ + bool queryResult(MovableObject* first); + /** Self-callback in order to deal with execute which returns collection. */ + bool queryResult(SceneQuery::WorldFragment* fragment); + }; + + /** Specialises the SceneQuery class for querying within an axis aligned box. */ + class _OgreExport AxisAlignedBoxSceneQuery : public RegionSceneQuery + { + protected: + AxisAlignedBox mAABB; + public: + AxisAlignedBoxSceneQuery(SceneManager* mgr); + virtual ~AxisAlignedBoxSceneQuery(); + + /** Sets the size of the box you wish to query. */ + void setBox(const AxisAlignedBox& box); + + /** Gets the box which is being used for this query. */ + const AxisAlignedBox& getBox(void) const; + + }; + + /** Specialises the SceneQuery class for querying within a sphere. */ + class _OgreExport SphereSceneQuery : public RegionSceneQuery + { + protected: + Sphere mSphere; + public: + SphereSceneQuery(SceneManager* mgr); + virtual ~SphereSceneQuery(); + /** Sets the sphere which is to be used for this query. */ + void setSphere(const Sphere& sphere); + + /** Gets the sphere which is being used for this query. */ + const Sphere& getSphere() const; + + }; + + /** Specialises the SceneQuery class for querying within a plane-bounded volume. + */ + class _OgreExport PlaneBoundedVolumeListSceneQuery : public RegionSceneQuery + { + protected: + PlaneBoundedVolumeList mVolumes; + public: + PlaneBoundedVolumeListSceneQuery(SceneManager* mgr); + virtual ~PlaneBoundedVolumeListSceneQuery(); + /** Sets the volume which is to be used for this query. */ + void setVolumes(const PlaneBoundedVolumeList& volumes); + + /** Gets the volume which is being used for this query. */ + const PlaneBoundedVolumeList& getVolumes() const; + + }; + + + /* + /// Specialises the SceneQuery class for querying within a pyramid. + class _OgreExport PyramidSceneQuery : public RegionSceneQuery + { + public: + PyramidSceneQuery(SceneManager* mgr); + virtual ~PyramidSceneQuery(); + }; + */ + + /** Alternative listener class for dealing with RaySceneQuery. + @remarks + Because the RaySceneQuery returns results in an extra bit of information, namely + distance, the listener interface must be customised from the standard SceneQueryListener. + */ + class _OgreExport RaySceneQueryListener + { + public: + virtual ~RaySceneQueryListener() { } + /** Called when a movable objects intersects the ray. + @remarks + As with SceneQueryListener, the implementor of this method should return 'true' + if further results are required, or 'false' to abandon any further results from + the current query. + */ + virtual bool queryResult(MovableObject* obj, Real distance) = 0; + + /** Called when a world fragment is intersected by the ray. + @remarks + As with SceneQueryListener, the implementor of this method should return 'true' + if further results are required, or 'false' to abandon any further results from + the current query. + */ + virtual bool queryResult(SceneQuery::WorldFragment* fragment, Real distance) = 0; + + }; + + /** This struct allows a single comparison of result data no matter what the type */ + struct _OgreExport RaySceneQueryResultEntry + { + /// Distance along the ray + Real distance; + /// The movable, or NULL if this is not a movable result + MovableObject* movable; + /// The world fragment, or NULL if this is not a fragment result + SceneQuery::WorldFragment* worldFragment; + /// Comparison operator for sorting + bool operator < (const RaySceneQueryResultEntry& rhs) const + { + return this->distance < rhs.distance; + } + + }; + typedef std::vector RaySceneQueryResult; + + /** Specialises the SceneQuery class for querying along a ray. */ + class _OgreExport RaySceneQuery : public SceneQuery, public RaySceneQueryListener + { + protected: + Ray mRay; + bool mSortByDistance; + ushort mMaxResults; + RaySceneQueryResult mResult; + + public: + RaySceneQuery(SceneManager* mgr); + virtual ~RaySceneQuery(); + /** Sets the ray which is to be used for this query. */ + virtual void setRay(const Ray& ray); + /** Gets the ray which is to be used for this query. */ + virtual const Ray& getRay(void) const; + /** Sets whether the results of this query will be sorted by distance along the ray. + @remarks + Often you want to know what was the first object a ray intersected with, and this + method allows you to ask the query to sort the results so that the nearest results + are listed first. + @par + Note that because the query returns results based on bounding volumes, the ray may not + actually intersect the detail of the objects returned from the query, just their + bounding volumes. For this reason the caller is advised to use more detailed + intersection tests on the results if a more accurate result is required; OGRE uses + bounds checking in order to give the most speedy results since not all applications + need extreme accuracy. + @param sort If true, results will be sorted. + @param maxresults If sorting is enabled, this value can be used to constrain the maximum number + of results that are returned. Please note (as above) that the use of bounding volumes mean that + accuracy is not guaranteed; if in doubt, allow more results and filter them in more detail. + 0 means unlimited results. + */ + virtual void setSortByDistance(bool sort, ushort maxresults = 0); + /** Gets whether the results are sorted by distance. */ + virtual bool getSortByDistance(void) const; + /** Gets the maximum number of results returned from the query (only relevant if + results are being sorted) */ + virtual ushort getMaxResults(void) const; + /** Executes the query, returning the results back in one list. + @remarks + This method executes the scene query as configured, gathers the results + into one structure and returns a reference to that structure. These + results will also persist in this query object until the next query is + executed, or clearResults() is called. An more lightweight version of + this method that returns results through a listener is also available. + */ + virtual RaySceneQueryResult& execute(void); + + /** Executes the query and returns each match through a listener interface. + @remarks + Note that this method does not store the results of the query internally + so does not update the 'last result' value. This means that this version of + execute is more lightweight and therefore more efficient than the version + which returns the results as a collection. + */ + virtual void execute(RaySceneQueryListener* listener) = 0; + + /** Gets the results of the last query that was run using this object, provided + the query was executed using the collection-returning version of execute. + */ + virtual RaySceneQueryResult& getLastResults(void); + /** Clears the results of the last query execution. + @remarks + You only need to call this if you specifically want to free up the memory + used by this object to hold the last query results. This object clears the + results itself when executing and when destroying itself. + */ + virtual void clearResults(void); + + /** Self-callback in order to deal with execute which returns collection. */ + bool queryResult(MovableObject* obj, Real distance); + /** Self-callback in order to deal with execute which returns collection. */ + bool queryResult(SceneQuery::WorldFragment* fragment, Real distance); + + + + + }; + + /** Alternative listener class for dealing with IntersectionSceneQuery. + @remarks + Because the IntersectionSceneQuery returns results in pairs, rather than singularly, + the listener interface must be customised from the standard SceneQueryListener. + */ + class _OgreExport IntersectionSceneQueryListener + { + public: + virtual ~IntersectionSceneQueryListener() { } + /** Called when 2 movable objects intersect one another. + @remarks + As with SceneQueryListener, the implementor of this method should return 'true' + if further results are required, or 'false' to abandon any further results from + the current query. + */ + virtual bool queryResult(MovableObject* first, MovableObject* second) = 0; + + /** Called when a movable intersects a world fragment. + @remarks + As with SceneQueryListener, the implementor of this method should return 'true' + if further results are required, or 'false' to abandon any further results from + the current query. + */ + virtual bool queryResult(MovableObject* movable, SceneQuery::WorldFragment* fragment) = 0; + + /* NB there are no results for world fragments intersecting other world fragments; + it is assumed that world geometry is either static or at least that self-intersections + are irrelevant or dealt with elsewhere (such as the custom scene manager) */ + + + }; + + typedef std::pair SceneQueryMovableObjectPair; + typedef std::pair SceneQueryMovableObjectWorldFragmentPair; + typedef std::list SceneQueryMovableIntersectionList; + typedef std::list SceneQueryMovableWorldFragmentIntersectionList; + /** Holds the results of an intersection scene query (pair values). */ + struct _OgreExport IntersectionSceneQueryResult + { + /// List of movable / movable intersections (entities, particle systems etc) + SceneQueryMovableIntersectionList movables2movables; + /// List of movable / world intersections + SceneQueryMovableWorldFragmentIntersectionList movables2world; + + + + }; + + /** Separate SceneQuery class to query for pairs of objects which are + possibly intersecting one another. + @remarks + This SceneQuery subclass considers the whole world and returns pairs of objects + which are close enough to each other that they may be intersecting. Because of + this slightly different focus, the return types and listener interface are + different for this class. + */ + class _OgreExport IntersectionSceneQuery + : public SceneQuery, public IntersectionSceneQueryListener + { + protected: + IntersectionSceneQueryResult* mLastResult; + public: + IntersectionSceneQuery(SceneManager* mgr); + virtual ~IntersectionSceneQuery(); + + /** Executes the query, returning the results back in one list. + @remarks + This method executes the scene query as configured, gathers the results + into one structure and returns a reference to that structure. These + results will also persist in this query object until the next query is + executed, or clearResults() is called. An more lightweight version of + this method that returns results through a listener is also available. + */ + virtual IntersectionSceneQueryResult& execute(void); + + /** Executes the query and returns each match through a listener interface. + @remarks + Note that this method does not store the results of the query internally + so does not update the 'last result' value. This means that this version of + execute is more lightweight and therefore more efficient than the version + which returns the results as a collection. + */ + virtual void execute(IntersectionSceneQueryListener* listener) = 0; + + /** Gets the results of the last query that was run using this object, provided + the query was executed using the collection-returning version of execute. + */ + virtual IntersectionSceneQueryResult& getLastResults(void) const; + /** Clears the results of the last query execution. + @remarks + You only need to call this if you specifically want to free up the memory + used by this object to hold the last query results. This object clears the + results itself when executing and when destroying itself. + */ + virtual void clearResults(void); + + /** Self-callback in order to deal with execute which returns collection. */ + bool queryResult(MovableObject* first, MovableObject* second); + /** Self-callback in order to deal with execute which returns collection. */ + bool queryResult(MovableObject* movable, SceneQuery::WorldFragment* fragment); + }; + + +} + + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreScriptLoader.h b/school/informatik/verkerhssimulation/src/ogre/OgreScriptLoader.h new file mode 100644 index 00000000..6a863660 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreScriptLoader.h @@ -0,0 +1,89 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ScriptLoader_H__ +#define __ScriptLoader_H__ + +#include "OgrePrerequisites.h" +#include "OgreDataStream.h" +#include "OgreStringVector.h" + +namespace Ogre { + + /** Abstract class defining the interface used by classes which wish + to perform script loading to define instances of whatever they manage. + @remarks + Typically classes of this type wish to either parse individual script files + on demand, or be called with a group of files matching a certain pattern + at the appropriate time. Normally this will coincide with resource loading, + although the script use does not necessarily have to be a ResourceManager + (which subclasses from this class), it may be simply a script loader which + manages non-resources but needs to be synchronised at the same loading points. + @par + Subclasses should add themselves to the ResourceGroupManager as a script loader + if they wish to be called at the point a resource group is loaded, at which + point the parseScript method will be called with each file which matches a + the pattern returned from getScriptPatterns. + */ + class _OgreExport ScriptLoader + { + public: + virtual ~ScriptLoader(); + /** Gets the file patterns which should be used to find scripts for this + class. + @remarks + This method is called when a resource group is loaded if you use + ResourceGroupManager::_registerScriptLoader. + @returns + A list of file patterns, in the order they should be searched in. + */ + virtual const StringVector& getScriptPatterns(void) const = 0; + + /** Parse a script file. + @param stream Weak reference to a data stream which is the source of the script + @param groupName The name of a resource group which should be used if any resources + are created during the parse of this script. + */ + virtual void parseScript(DataStreamPtr& stream, const String& groupName) = 0; + + /** Gets the relative loading order of scripts of this type. + @remarks + There are dependencies between some kinds of scripts, and to enforce + this all implementors of this interface must define a loading order. + @returns A value representing the relative loading order of these scripts + compared to other script users, where higher values load later. + */ + virtual Real getLoadingOrder(void) const = 0; + + }; + + +} + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreSearchOps.h b/school/informatik/verkerhssimulation/src/ogre/OgreSearchOps.h new file mode 100644 index 00000000..c11a9a6a --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreSearchOps.h @@ -0,0 +1,65 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +// Emulate _findfirst, _findnext on non-Windows platforms + + +#include +#include +#include +#include + +#include "OgrePlatform.h" + +#if OGRE_PLATFORM != OGRE_PLATFORM_WIN32 + +#include +#include +#include + +/* Our simplified data entry structure */ +struct _finddata_t +{ + char *name; + int attrib; + unsigned long size; +}; + +#define _A_NORMAL 0x00 /* Normalfile-Noread/writerestrictions */ +#define _A_RDONLY 0x01 /* Read only file */ +#define _A_HIDDEN 0x02 /* Hidden file */ +#define _A_SYSTEM 0x04 /* System file */ +#define _A_SUBDIR 0x10 /* Subdirectory */ +#define _A_ARCH 0x20 /* Archive file */ + +long _findfirst(const char *pattern, struct _finddata_t *data); +int _findnext(long id, struct _finddata_t *data); +int _findclose(long id); + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreSerializer.h b/school/informatik/verkerhssimulation/src/ogre/OgreSerializer.h new file mode 100644 index 00000000..70cb6e0d --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreSerializer.h @@ -0,0 +1,113 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __Serializer_H__ +#define __Serializer_H__ + +#include "OgrePrerequisites.h" +#include "OgreString.h" +#include "OgreDataStream.h" + +namespace Ogre { + + /** Generic class for serialising data to / from binary stream-based files. + @remarks + This class provides a number of useful methods for exporting / importing data + from stream-oriented binary files (e.g. .mesh and .skeleton). + */ + class _OgreExport Serializer + { + public: + Serializer(); + virtual ~Serializer(); + + /// The endianness of written files + enum Endian + { + /// Use the platform native endian + ENDIAN_NATIVE, + /// Use big endian (0x1000 is serialised as 0x10 0x00) + ENDIAN_BIG, + /// Use little endian (0x1000 is serialised as 0x00 0x10) + ENDIAN_LITTLE + }; + + + protected: + + uint32 mCurrentstreamLen; + FILE* mpfFile; + String mVersion; + bool mFlipEndian; // default to native endian, derive from header + + // Internal methods + virtual void writeFileHeader(void); + virtual void writeChunkHeader(uint16 id, size_t size); + + void writeFloats(const float* const pfloat, size_t count); + void writeFloats(const double* const pfloat, size_t count); + void writeShorts(const uint16* const pShort, size_t count); + void writeInts(const uint32* const pInt, size_t count); + void writeBools(const bool* const pLong, size_t count); + void writeObject(const Vector3& vec); + void writeObject(const Quaternion& q); + + void writeString(const String& string); + void writeData(const void* const buf, size_t size, size_t count); + + virtual void readFileHeader(DataStreamPtr& stream); + virtual unsigned short readChunk(DataStreamPtr& stream); + + void readBools(DataStreamPtr& stream, bool* pDest, size_t count); + void readFloats(DataStreamPtr& stream, float* pDest, size_t count); + void readFloats(DataStreamPtr& stream, double* pDest, size_t count); + void readShorts(DataStreamPtr& stream, uint16* pDest, size_t count); + void readInts(DataStreamPtr& stream, uint32* pDest, size_t count); + void readObject(DataStreamPtr& stream, Vector3& pDest); + void readObject(DataStreamPtr& stream, Quaternion& pDest); + + String readString(DataStreamPtr& stream); + String readString(DataStreamPtr& stream, size_t numChars); + + virtual void flipToLittleEndian(void* pData, size_t size, size_t count = 1); + virtual void flipFromLittleEndian(void* pData, size_t size, size_t count = 1); + + virtual void flipEndian(void * pData, size_t size, size_t count); + virtual void flipEndian(void * pData, size_t size); + + /// Determine the endianness of the incoming stream compared to native + virtual void determineEndianness(DataStreamPtr& stream); + /// Determine the endianness to write with based on option + virtual void determineEndianness(Endian requestedEndian); + }; + +} + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreShadowCameraSetup.h b/school/informatik/verkerhssimulation/src/ogre/OgreShadowCameraSetup.h new file mode 100644 index 00000000..d66bbba6 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreShadowCameraSetup.h @@ -0,0 +1,100 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ShadowCameraSetup_H__ +#define __ShadowCameraSetup_H__ + +#include "OgrePrerequisites.h" +#include "OgreMovablePlane.h" +#include "OgreSharedPtr.h" + + +namespace Ogre { + + /** This class allows you to plug in new ways to define the camera setup when + rendering and projecting shadow textures. + @remarks + The default projection used when rendering shadow textures is a uniform + frustum. This is pretty straight forward but doesn't make the best use of + the space in the shadow map since texels closer to the camera will be larger, + resulting in 'jaggies'. There are several ways to distribute the texels + in the shadow texture differently, and this class allows you to override + that. + @par + Ogre is provided with several alternative shadow camera setups, including + LiSPSM (LiSPSMShadowCameraSetup) and Plane Optimal (PlaneOptimalShadowCameraSetup). + Others can of course be written to incorporate other algorithms. All you + have to do is instantiate one of these classes and enable it using + SceneManager::setShadowCameraSetup (global) or Light::setCustomShadowCameraSetup + (per light). In both cases the instance is wrapped in a SharedPtr which means + it will be deleted automatically when no more references to it exist. + @note + Shadow map matrices, being projective matrices, have 15 degrees of freedom. + 3 of these degrees of freedom are fixed by the light's position. 4 are used to + affinely affect z values. 6 affinely affect u,v sampling. 2 are projective + degrees of freedom. This class is meant to allow custom methods for + handling optimization. + */ + class _OgreExport ShadowCameraSetup + { + public: + /// Function to implement -- must set the shadow camera properties + virtual void getShadowCamera (const SceneManager *sm, const Camera *cam, + const Viewport *vp, const Light *light, Camera *texCam) const = 0; + /// Need virtual destructor in case subclasses use it + virtual ~ShadowCameraSetup() {} + + }; + + + + /** Implements default shadow camera setup + @remarks + This implements the default shadow camera setup algorithm. This is what might + be referred to as "normal" shadow mapping. + */ + class _OgreExport DefaultShadowCameraSetup : public ShadowCameraSetup + { + public: + /// Default constructor + DefaultShadowCameraSetup(); + /// Destructor + virtual ~DefaultShadowCameraSetup(); + + /// Default shadow camera setup + virtual void getShadowCamera (const SceneManager *sm, const Camera *cam, + const Viewport *vp, const Light *light, Camera *texCam) const; + }; + + + + typedef SharedPtr ShadowCameraSetupPtr; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreShadowCameraSetupFocused.h b/school/informatik/verkerhssimulation/src/ogre/OgreShadowCameraSetupFocused.h new file mode 100644 index 00000000..a5defb71 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreShadowCameraSetupFocused.h @@ -0,0 +1,281 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2006 Torus Knot Software Ltd +Copyright (c) 2006 Matthias Fink, netAllied GmbH +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ShadowCameraSetupFocused_H__ +#define __ShadowCameraSetupFocused_H__ + +#include "OgrePrerequisites.h" +#include "OgreShadowCameraSetup.h" +#include "OgrePolygon.h" +#include "OgreConvexBody.h" + + +namespace Ogre { + + class ConvexBody; + + /** Implements the uniform shadow mapping algorithm in focused mode. + @remarks + Differs from the default shadow mapping projection in that it focuses the + shadow map on the visible areas of the scene. This results in better + shadow map texel usage, at the expense of some 'swimming' of the shadow + texture on receivers as the basis is constantly being reevaluated. + @note + Original implementation by Matthias Fink , 2006. + */ + class _OgreExport FocusedShadowCameraSetup : public ShadowCameraSetup + { + protected: + /** Transform to or from light space as defined by Wimmer et al. + @remarks + Point and spot lights need to be converted to directional lights to enable a 1:1 + light mapping. Otherwise a directional light may become a point light or a point + sink (opposite of a light source) or point/spot lights may become directional lights + or light sinks. The light direction is always -y. + */ + static const Matrix4 msNormalToLightSpace; + static const Matrix4 msLightSpaceToNormal; + + /** Temporary preallocated frustum to set up a projection matrix in + ::calculateShadowMappingMatrix() + */ + Frustum* mTempFrustum; + + /** Temporary preallocated camera to set up a light frustum for clipping in ::calculateB. + */ + Camera* mLightFrustumCamera; + mutable bool mLightFrustumCameraCalculated; + + /// Use tighter focus region? + bool mUseAggressiveRegion; + + /** Internal class holding a point list representation of a convex body. + */ + class _OgreExport PointListBody + { + Polygon::VertexList mBodyPoints; + AxisAlignedBox mAAB; + + public: + PointListBody(); + PointListBody(const ConvexBody& body); + ~PointListBody(); + + /** Merges a second PointListBody into this one. + */ + void merge(const PointListBody& plb); + + /** Builds a point list body from a 'real' body. + @remarks + Inserts all vertices from a body into the point list with or without adding duplicate vertices. + */ + void build(const ConvexBody& body, bool filterDuplicates = true); + + /** Builds a PointListBody from a Body and includes all the space in a given direction. + @remarks + Intersects the bounding box with a ray from each available point of the body with the given + direction. Base and intersection points are stored in a PointListBody structure. + @note + Duplicate vertices are not filtered. + @note + Body is not checked for correctness. + */ + void buildAndIncludeDirection(const ConvexBody& body, + const AxisAlignedBox& aabMax, const Vector3& dir); + + /** Returns the bounding box representation. + */ + const AxisAlignedBox& getAAB(void) const; + + /** Adds a specific point to the body list. + */ + void addPoint(const Vector3& point); + + /** Adds all points of an AAB. + */ + void addAAB(const AxisAlignedBox& aab); + + /** Returns a point. + */ + const Vector3& getPoint(size_t cnt) const; + + /** Returns the point count. + */ + size_t getPointCount(void) const; + + /** Resets the body. + */ + void reset(void); + + }; + + // Persistent calculations to prevent reallocation + mutable ConvexBody mBodyB; + mutable PointListBody mPointListBodyB; + mutable PointListBody mPointListBodyLVS; + + protected: + /** Calculates the standard shadow mapping matrix. + @remarks + Provides the view and projection matrix for standard shadow mapping. + @note + You can choose which things you want to have: view matrix and/or projection + matrix and/or shadow camera. Passing a NULL value as parameter ignores the + generation of this specific value. + @param sm: scene manager + @param cam: currently active camera + @param light: currently active light + @param out_view: calculated uniform view shadow mapping matrix (may be NULL) + @param out_proj: calculated uniform projection shadow mapping matrix (may be NULL) + @param out_cam: calculated uniform shadow camera (may be NULL) + */ + void calculateShadowMappingMatrix(const SceneManager& sm, const Camera& cam, + const Light& light, Matrix4 *out_view, + Matrix4 *out_proj, Camera *out_cam) const; + + /** Calculates the intersection bodyB. + @remarks + The intersection bodyB consists of the concatenation the cam frustum clipped + by the scene bounding box followed by a convex hullification with the light's + position and the clipping with the scene bounding box and the light frustum: + ((V \cap S) + l) \cap S \cap L (\cap: convex intersection, +: convex hull + operation). + For directional lights the bodyB is assembled out of the camera frustum + clipped by the scene bounding box followed by the extrusion of all available + bodyB points towards the negative light direction. The rays are intersected + by a maximum bounding box and added to the bodyB points to form the final + intersection bodyB point list. + @param sm: scene manager + @param cam: currently active camera + @param light: currently active light + @param sceneBB: scene bounding box for clipping operations + @param out_bodyB: final intersection bodyB point list + */ + void calculateB(const SceneManager& sm, const Camera& cam, const Light& light, + const AxisAlignedBox& sceneBB, PointListBody *out_bodyB) const; + + /** Calculates the bodyLVS. + @remarks + Calculates the bodyLVS which consists of the convex intersection operation + affecting the light frustum, the view frustum, and the current scene bounding + box is used to find suitable positions in the viewer's frustum to build the + rotation matrix L_r. This matrix is applied after the projection matrix L_p to + avoid an accidental flip of the frustum orientation for views tilted with + respect to the shadow map. + @param scene: holds all potential occluders / receivers as one single bounding box + of the currently active scene node + @param cam: current viewer camera + @param light: current light + @param out_LVS: intersection body LVS (world coordinates) + */ + void calculateLVS(const SceneManager& sm, const Camera& cam, const Light& light, + const AxisAlignedBox& sceneBB, PointListBody *out_LVS) const; + + /** Returns the projection view direction. + @remarks + After the matrix L_p is applied the orientation of the light space may tilt for + non-identity projections. To prevent a false shadow cast the real view direction + is evaluated and applied to the light matrix L. + @param lightSpace: matrix of the light space transformation + @param cam: current viewer camera + @param bodyLVS: intersection body LVS (relevant space in front of the camera) + */ + Vector3 getLSProjViewDir(const Matrix4& lightSpace, const Camera& cam, + const PointListBody& bodyLVS) const; + + /** Returns a valid near-point seen by the camera. + @remarks + Returns a point that is situated near the camera by analyzing the bodyLVS that + contains all the relevant scene space in front of the light and the camera in + a point list array. The view matrix is relevant because the nearest point in + front of the camera should be determined. + @param viewMatrix: view matrix of the current camera + @param bodyLVS: intersection body LVS (relevant space in front of the camera) + */ + Vector3 getNearCameraPoint_ws(const Matrix4& viewMatrix, + const PointListBody& bodyLVS) const; + + /** Transforms a given body to the unit cube (-1,-1,-1) / (+1,+1,+1) with a specific + shadow matrix enabled. + @remarks + Transforms a given point list body object with the matrix m and then maps its + extends to a (-1,-1,-1) / (+1,+1,+1) unit cube + @param m: transformation matrix applied on the point list body + @param body: contains the points of the extends of all valid scene elements which + are mapped to the unit cube + */ + Matrix4 transformToUnitCube(const Matrix4& m, const PointListBody& body) const; + + /** Builds a view matrix. + @remarks + Builds a standard view matrix out of a given position, direction and up vector. + */ + Matrix4 buildViewMatrix(const Vector3& pos, const Vector3& dir, const Vector3& up) const; + + public: + /** Default constructor. + @remarks + Temporary frustum and camera set up here. + */ + FocusedShadowCameraSetup(void); + + /** Default destructor. + @remarks + Temporary frustum and camera destroyed here. + */ + virtual ~FocusedShadowCameraSetup(void); + + /** Returns a uniform shadow camera with a focused view. + */ + virtual void getShadowCamera(const SceneManager *sm, const Camera *cam, + const Viewport *vp, const Light *light, Camera *texCam) const; + + /** Sets whether or not to use the more agressive approach to deciding on + the focus region or not. + @note + There are 2 approaches that can be used to define the focus region, + the more aggressive way introduced by Wimmer et al, or the original + way as described in Stamminger et al. Wimmer et al's way tends to + come up with a tighter focus region but in rare cases (mostly highly + glancing angles) can cause some shadow casters to be clipped + incorrectly. By default the more aggressive approach is used since it + leads to significantly better results in most cases, but if you experience + clipping issues, you can use the less agressive version. + @param aggressive True to use the more agressive approach, false otherwise. + */ + void setUseAggressiveFocusRegion(bool aggressive) { mUseAggressiveRegion = aggressive; } + + bool getUseAggressiveFocusRegion() const { return mUseAggressiveRegion; } + + }; + + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreShadowCameraSetupLiSPSM.h b/school/informatik/verkerhssimulation/src/ogre/OgreShadowCameraSetupLiSPSM.h new file mode 100644 index 00000000..caafce8d --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreShadowCameraSetupLiSPSM.h @@ -0,0 +1,226 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2006 Torus Knot Software Ltd +Copyright (c) 2006 Matthias Fink, netAllied GmbH +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ShadowCameraSetupLiSPSM_H__ +#define __ShadowCameraSetupLiSPSM_H__ + +#include "OgrePrerequisites.h" +#include "OgreShadowCameraSetupFocused.h" + + +namespace Ogre +{ + + /** Implements the Light Space Perspective Shadow Mapping Algorithm. + @remarks + Implements the LiSPSM algorithm for an advanced shadow map generation. LiSPSM was + developed by Michael Wimmer, Daniel Scherzer and Werner Purgathofer of the TU Wien. + The algorithm was presented on the Eurographics Symposium on Rendering 2004. + @note + Shadow mapping was introduced by Williams in 1978. First a depth image is rendered + from the light's view and compared in a second pass with depth values of the normal + camera view. In case the depth camera's depth value is greater than the depth seen + by the light the fragment lies in the shadow. + The concept has a major draw back named perspective aliasing. The shadow map distri- + butes the samples uniformly meaning the position of the viewer is ignored. For the + viewer however the perspective projection affects near objects to be displayed + bigger than further away objects. The same thing happens with the shadow map texels: + Near shadows appear very coarse and far away shadows are perfectly sampled. + In 2002 Stamminger et al. presented an algorithm called Perspective Shadow Maps + (PSM). PSM battles the perspective aliasing by distributing 50% of the shadow map + texels for objects in the range of to + which inverts the problem: The shadows near the viewer are perfectly sampled, + however far away shadow may contain aliasing artefacts. A near clipping plane may be + a problem. But this is not the only one. In the post-perspective space the light + sources are non-intuitively mapped: Directional lights may become point light and + point lights may become directional lights. Also light sinks (opposite of a light + source) may appear. Another problem are shadow casters located behind the viewer. + In post-projective space objects behind the viewer are mapped in front of him with + a flipped up-vector. + LiSPSM battles the light source problem of the post-projective space by rearranging + the light space before transformation in such a way that no special cases appear. + This is done by converting point/spot lights into directional lights. The light + space is arranged in such a way that the light direction equals the inverse UNIT_Y. + In this combination the directional light will neither change its type nor its + direction. Furthermore all visible objects and shadow casters affecting the user's + visible area lie in front of the shadow camera: After building the intersection body + that contains all these objects (body intersection building was introduced with PSM; + have a look at the description for the method "calculateB" for further info) a + frustum around the body's light space bounding box is created. A parameter (called + 'n') automatically adjusts the shadow map sample distribution by specifying the + frustum's view point - near plane which affects the perspective warp. In case the + distance is small the perspecive warp will be strong. As a consequence near objects + will gain quality. + However there are still problems. PSM as well as LiSPSM only devote to minimize + perspective aliasing. Projection aliasing is still a problem, also 'swimming + artefacts' still occur. The LiSPSM quality distribution is very good but not the + best available: Some sources say logarithmic shadow mapping is the non plus ultra, + however others reject this thought. There is a research project on logarithmic shadow + maps. The web page url is http://gamma.cs.unc.edu/logsm/. However there is no techical + report available yet (Oct 23rd, 2006). + @note + More information can be found on the webpage of the TU Wien: + http://www.cg.tuwien.ac.at/research/vr/lispsm/ + @note + Original implementation by Matthias Fink , 2006. + */ + class _OgreExport LiSPSMShadowCameraSetup : public FocusedShadowCameraSetup + { + protected: + /// Warp factor adjustment + Real mOptAdjustFactor; + /// Use simple nopt derivation? + bool mUseSimpleNOpt; + + /** Calculates the LiSPSM projection matrix P. + @remarks + The LiSPSM projection matrix will be built around the axis aligned bounding box + of the intersection body B in light space. The distance between the near plane + and the projection center is chosen in such a way (distance is set by the para- + meter n) that the perspective error is the same on the near and far plane. In + case P equals the identity matrix the algorithm falls back to a uniform shadow + mapping matrix. + @param lightSpace: matrix of the light space transformation + @param bodyB: intersection body B + @param bodyLVS: intersection body LVS (relevant space in front of the camera) + @param sm: scene manager + @param cam: currently active camera + @param light: currently active light + */ + Matrix4 calculateLiSPSM(const Matrix4& lightSpace, const PointListBody& bodyB, + const PointListBody& bodyLVS, const SceneManager& sm, + const Camera& cam, const Light& light) const; + + /** Calculates the distance between camera position and near clipping plane. + @remarks + n_opt determines the distance between light space origin (shadow camera position) + and the near clipping plane to achieve an optimal perspective forshortening effect. + In this way the texel distibution over the shadow map is controlled. + + Formula: + d + n_opt = --------------- + sqrt(z1/z0) - 1 + + Parameters: + d: distance between the near and the far clipping plane + z0: located on the near clipping plane of the intersection body b + z1: located on the far clipping plane with the same x/y values as z0 + @note + A positive value is applied as the distance between viewer and near clipping plane. + In case null is returned uniform shadow mapping will be applied. + @param lightSpace: matrix of the light space transformation + @param bodyBABB_ls: bounding box of the tranformed (light space) bodyB + @param bodyLVS: point list of the bodyLVS which describes the scene space which is in + front of the light and the camera + @param cam: currently active camera + */ + Real calculateNOpt(const Matrix4& lightSpace, const AxisAlignedBox& bodyBABB_ls, + const PointListBody& bodyLVS, const Camera& cam) const; + + /** Calculates a simpler version than the one above. + */ + Real calculateNOptSimple(const PointListBody& bodyLVS, + const Camera& cam) const; + + /** Calculates the visible point on the near plane for the n_opt calculation + @remarks + z0 lies on the parallel plane to the near plane through e and on the near plane of + the frustum C (plane z = bodyB_zMax_ls) and on the line x = e.x. + @param lightSpace: matrix of the light space transformation + @param e: the LiSPSM parameter e is located near or on the near clipping plane of the + LiSPSM frustum C + @param bodyB_zMax_ls: maximum z-value of the light space bodyB bounding box + @param cam: currently active camera + */ + Vector3 calculateZ0_ls(const Matrix4& lightSpace, const Vector3& e, Real bodyB_zMax_ls, + const Camera& cam) const; + + /** Builds a frustum matrix. + @remarks + Builds a standard frustum matrix out of the distance infos of the six frustum + clipping planes. + */ + Matrix4 buildFrustumProjection(Real left, Real right, Real bottom, + Real top, Real near, Real far) const; + + public: + /** Default constructor. + @remarks + Nothing done here. + */ + LiSPSMShadowCameraSetup(void); + + /** Default destructor. + @remarks + Nothing done here. + */ + virtual ~LiSPSMShadowCameraSetup(void); + + /** Returns a LiSPSM shadow camera. + @remarks + Builds and returns a LiSPSM shadow camera. + More information can be found on the webpage of the TU Wien: + http://www.cg.tuwien.ac.at/research/vr/lispsm/ + */ + virtual void getShadowCamera(const SceneManager *sm, const Camera *cam, + const Viewport *vp, const Light *light, Camera *texCam) const; + + /** Adjusts the parameter n to produce optimal shadows. + @remarks + The smaller the parameter n, the stronger the perspective warping effect. + The consequence of a stronger warping is that the near shadows will gain + quality while the far ones will lose it. Depending on your scene and light + types you may want to tweak this value - for example directional lights + tend to benefit from higher values of n than other types of light, + especially if you expect to see more distant shadows (say if the viewpoint is + higher above the ground plane). Remember that you can supply separate + ShadowCameraSetup instances configured differently per light if you wish. + @param n The adjustment factor - default is 0.1f. + */ + virtual void setOptimalAdjustFactor(Real n) { mOptAdjustFactor = n; } + /** Get the parameter n used to produce optimal shadows. + @see setOptimalAdjustFactor + */ + virtual Real getOptimalAdjustFactor() const { return mOptAdjustFactor; } + /** Sets whether or not to use a slightly simpler version of the + camera near point derivation (default is true) + */ + virtual void setUseSimpleOptimalAdjust(bool s) { mUseSimpleNOpt = s; } + /** Gets whether or not to use a slightly simpler version of the + camera near point derivation (default is true) + */ + virtual bool getUseSimpleOptimalAdjust() const { return mUseSimpleNOpt; } + + }; + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreShadowCameraSetupPlaneOptimal.h b/school/informatik/verkerhssimulation/src/ogre/OgreShadowCameraSetupPlaneOptimal.h new file mode 100644 index 00000000..209e16d1 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreShadowCameraSetupPlaneOptimal.h @@ -0,0 +1,81 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ShadowCameraSetupPlaneOptimal_H__ +#define __ShadowCameraSetupPlaneOptimal_H__ + +#include "OgrePrerequisites.h" +#include "OgreShadowCameraSetup.h" + +namespace Ogre { + + + /** Implements the plane optimal shadow camera algorithm. + @remarks + Given a plane of interest, it is possible to set up the shadow camera + matrix such that the mapping between screen and shadow map is the identity + (when restricted to pixels that view the plane of interest). Therefore, + if the shadow map resolution matches the screen space resolution (of the + seen planar receiver), we can get pixel perfect shadowing on the plane. + Off the plane, the shadowing is not guaranteed to be perfect and will + likely exhibit the usual sampling artifacts associated with shadow mapping. + @note Important: this routine requires double-precision calculations. When you + are running under Direct3D, you must ensure that you set the floating + point mode to 'Consistent' rather than 'Fastest' to ensure this precision. + This does allegedly come with some performance cost but when measuring + it appears to be negligible in modern systems for normal usage. + @note Second important note: this projection also only works for lights with + a finite position. Therefore you cannot use it for directional lights + at this time. + */ + class _OgreExport PlaneOptimalShadowCameraSetup : public ShadowCameraSetup + { + private: + MovablePlane* m_plane; ///< pointer to plane of interest + private: + PlaneOptimalShadowCameraSetup() {} ///< Default constructor is private + + /// helper function computing projection matrix given constraints + Matrix4 computeConstrainedProjection( const Vector4& pinhole, + const std::vector& fpoint, + const std::vector& constraint) const; + + public: + /// Constructor -- requires a plane of interest + PlaneOptimalShadowCameraSetup(MovablePlane *plane); + /// Destructor + virtual ~PlaneOptimalShadowCameraSetup(); + + /// Returns shadow camera configured to get 1-1 homography between screen and shadow map when restricted to plane + virtual void getShadowCamera (const SceneManager *sm, const Camera *cam, + const Viewport *vp, const Light *light, Camera *texCam) const; + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreShadowCaster.h b/school/informatik/verkerhssimulation/src/ogre/OgreShadowCaster.h new file mode 100644 index 00000000..534cb97e --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreShadowCaster.h @@ -0,0 +1,215 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ShadowCaster_H__ +#define __ShadowCaster_H__ + +#include "OgrePrerequisites.h" +#include "OgreRenderable.h" + + +namespace Ogre { + + + /** Class which represents the renderable aspects of a set of shadow volume faces. + @remarks + Note that for casters comprised of more than one set of vertex buffers (e.g. SubMeshes each + using their own geometry), it will take more than one ShadowRenderable to render the + shadow volume. Therefore for shadow caster geometry, it is best to stick to one set of + vertex buffers (not necessarily one buffer, but the positions for the entire geometry + should come from one buffer if possible) + */ + class _OgreExport ShadowRenderable : public Renderable + { + protected: + MaterialPtr mMaterial; + RenderOperation mRenderOp; + ShadowRenderable* mLightCap; // used only if isLightCapSeparate == true + public: + ShadowRenderable() : mMaterial(), mLightCap(0) {} + virtual ~ShadowRenderable() { delete mLightCap; } + /** Set the material to be used by the shadow, should be set by the caller + before adding to a render queue + */ + void setMaterial(const MaterialPtr& mat) { mMaterial = mat; } + /// Overridden from Renderable + const MaterialPtr& getMaterial(void) const { return mMaterial; } + /// Overridden from Renderable + void getRenderOperation(RenderOperation& op) { op = mRenderOp; } + /// Get the internal render operation for set up + RenderOperation* getRenderOperationForUpdate(void) {return &mRenderOp;} + /// Overridden from Renderable + void getWorldTransforms(Matrix4* xform) const = 0; + /// Overridden from Renderable + const Quaternion& getWorldOrientation(void) const = 0; + /// Overridden from Renderable + const Vector3& getWorldPosition(void) const = 0; + /// Overridden from Renderable + Real getSquaredViewDepth(const Camera*) const{ return 0; /* not used */} + /// Overridden from Renderable + const LightList& getLights(void) const; + /** Does this renderable require a separate light cap? + @remarks + If possible, the light cap (when required) should be contained in the + usual geometry of the shadow renderable. However, if for some reason + the normal depth function (less than) could cause artefacts, then a + separate light cap with a depth function of 'always fail' can be used + instead. The primary example of this is when there are floating point + inaccuracies caused by calculating the shadow geometry separately from + the real geometry. + */ + bool isLightCapSeparate(void) const { return mLightCap != 0; } + + /// Get the light cap version of this renderable + ShadowRenderable* getLightCapRenderable(void) { return mLightCap; } + /// Should this ShadowRenderable be treated as visible? + virtual bool isVisible(void) const { return true; } + + }; + + /** A set of flags that can be used to influence ShadowRenderable creation. */ + enum ShadowRenderableFlags + { + /// For shadow volume techniques only, generate a light cap on the volume + SRF_INCLUDE_LIGHT_CAP = 0x00000001, + /// For shadow volume techniques only, generate a dark cap on the volume + SRF_INCLUDE_DARK_CAP = 0x00000002, + /// For shadow volume techniques only, indicates volume is extruded to infinity + SRF_EXTRUDE_TO_INFINITY = 0x00000004 + }; + + /** This class defines the interface that must be implemented by shadow casters. + */ + class _OgreExport ShadowCaster + { + public: + virtual ~ShadowCaster() { } + /** Returns whether or not this object currently casts a shadow. */ + virtual bool getCastShadows(void) const = 0; + + /** Returns details of the edges which might be used to determine a silhouette. */ + virtual EdgeData* getEdgeList(void) = 0; + /** Returns whether the object has a valid edge list. */ + virtual bool hasEdgeList(void) = 0; + + /** Get the world bounding box of the caster. */ + virtual const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const = 0; + /** Gets the world space bounding box of the light cap */ + virtual const AxisAlignedBox& getLightCapBounds(void) const = 0; + /** Gets the world space bounding box of the dark cap, as extruded using the light provided */ + virtual const AxisAlignedBox& getDarkCapBounds(const Light& light, Real dirLightExtrusionDist) const = 0; + + typedef std::vector ShadowRenderableList; + typedef VectorIterator ShadowRenderableListIterator; + + /** Gets an iterator over the renderables required to render the shadow volume. + @remarks + Shadowable geometry should ideally be designed such that there is only one + ShadowRenderable required to render the the shadow; however this is not a necessary + limitation and it can be exceeded if required. + @param shadowTechnique The technique being used to generate the shadow + @param light The light to generate the shadow from + @param indexBuffer The index buffer to build the renderables into, + the current contents are assumed to be disposable. + @param extrudeVertices If true, this means this class should extrude + the vertices of the back of the volume in software. If false, it + will not be done (a vertex program is assumed). + @param extrusionDistance The distance to extrude the shadow volume + @param flags Technique-specific flags, see ShadowRenderableFlags + */ + virtual ShadowRenderableListIterator getShadowVolumeRenderableIterator( + ShadowTechnique shadowTechnique, const Light* light, + HardwareIndexBufferSharedPtr* indexBuffer, + bool extrudeVertices, Real extrusionDistance, unsigned long flags = 0 ) = 0; + + /** Utility method for extruding vertices based on a light. + @remarks + Unfortunately, because D3D cannot handle homogenous (4D) position + coordinates in the fixed-function pipeline (GL can, but we have to + be cross-API), when we extrude in software we cannot extrude to + infinity the way we do in the vertex program (by setting w to + 0.0f). Therefore we extrude by a fixed distance, which may cause + some problems with larger scenes. Luckily better hardware (ie + vertex programs) can fix this. + @param vertexBuffer The vertex buffer containing ONLY xyz position + values, which must be originalVertexCount * 2 * 3 floats long. + @param originalVertexCount The count of the original number of + vertices, ie the number in the mesh, not counting the doubling + which has already been done (by VertexData::prepareForShadowVolume) + to provide the extruded area of the buffer. + @param lightPos 4D light position in object space, when w=0.0f this + represents a directional light + @param extrudeDist The distance to extrude + */ + static void extrudeVertices(const HardwareVertexBufferSharedPtr& vertexBuffer, + size_t originalVertexCount, const Vector4& lightPos, Real extrudeDist); + /** Get the distance to extrude for a point/spot light */ + virtual Real getPointExtrusionDistance(const Light* l) const = 0; + protected: + /// Helper moethod for calculating extrusion distance + Real getExtrusionDistance(const Vector3& objectPos, const Light* light) const; + /** Tells the caster to perform the tasks necessary to update the + edge data's light listing. Can be overridden if the subclass needs + to do additional things. + @param edgeData The edge information to update + @param lightPos 4D vector representing the light, a directional light + has w=0.0 + */ + virtual void updateEdgeListLightFacing(EdgeData* edgeData, + const Vector4& lightPos); + + /** Generates the indexes required to render a shadow volume into the + index buffer which is passed in, and updates shadow renderables + to use it. + @param edgeData The edge information to use + @param indexBuffer The buffer into which to write data into; current + contents are assumed to be discardable. + @param light The light, mainly for type info as silhouette calculations + should already have been done in updateEdgeListLightFacing + @param shadowRenderables A list of shadow renderables which has + already been constructed but will need populating with details of + the index ranges to be used. + @param flags Additional controller flags, see ShadowRenderableFlags + */ + virtual void generateShadowVolume(EdgeData* edgeData, + const HardwareIndexBufferSharedPtr& indexBuffer, const Light* light, + ShadowRenderableList& shadowRenderables, unsigned long flags); + /** Utility method for extruding a bounding box. + @param box Original bounding box, will be updated in-place + @param lightPos 4D light position in object space, when w=0.0f this + represents a directional light + @param extrudeDist The distance to extrude + */ + virtual void extrudeBounds(AxisAlignedBox& box, const Vector4& lightPos, + Real extrudeDist) const; + + + }; +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreShadowTextureManager.h b/school/informatik/verkerhssimulation/src/ogre/OgreShadowTextureManager.h new file mode 100644 index 00000000..96456779 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreShadowTextureManager.h @@ -0,0 +1,145 @@ +/*------------------------------------------------------------------------- +This source file is a part of OGRE +(Object-oriented Graphics Rendering Engine) + +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License (LGPL) as +published by the Free Software Foundation; either version 2.1 of the +License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or go to +http://www.gnu.org/copyleft/lesser.txt + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +-------------------------------------------------------------------------*/ +#ifndef __ShadowTextureManager_H__ +#define __ShadowTextureManager_H__ + +// Precompiler options +#include "OgrePrerequisites.h" +#include "OgreSingleton.h" +#include "OgrePixelFormat.h" +#include "OgreTexture.h" +#include "OgreIteratorWrappers.h" + + +namespace Ogre +{ + typedef std::vector ShadowTextureList; + + /** Structure containing the configuration for one shadow texture. */ + struct ShadowTextureConfig + { + unsigned int width; + unsigned int height; + PixelFormat format; + + ShadowTextureConfig() + : width(512), height(512), format(PF_X8R8G8B8) {} + }; + + typedef std::vector ShadowTextureConfigList; + typedef ConstVectorIterator ConstShadowTextureConfigIterator; + + inline _OgreExport bool operator== ( const ShadowTextureConfig& lhs, const ShadowTextureConfig& rhs ); + inline _OgreExport bool operator!= ( const ShadowTextureConfig& lhs, const ShadowTextureConfig& rhs ); + + + /** Class to manage the available shadow textures which may be shared between + many SceneManager instances if formats agree. + @remarks + The management of the list of shadow textures has been separated out into + a dedicated class to enable the clean management of shadow textures + across many scene manager instances. Where multiple scene managers are + used with shadow textures, the configuration of those shadows may or may + not be consistent - if it is, it is good to centrally manage the textures + so that creation and destruction responsibility is clear. + */ + class _OgreExport ShadowTextureManager : public Singleton + { + protected: + ShadowTextureList mTextureList; + ShadowTextureList mNullTextureList; + size_t mCount; + + public: + ShadowTextureManager(); + virtual ~ShadowTextureManager(); + + /** Populate an incoming list with shadow texture references as requested + in the configuration list. + */ + virtual void getShadowTextures(const ShadowTextureConfigList& config, + ShadowTextureList& listToPopulate); + + /** Get an appropriately defined 'null' texture, ie one which will always + result in no shadows. + */ + virtual TexturePtr getNullShadowTexture(PixelFormat format); + + /** Remove any shadow textures that are no longer being referenced. + @remarks + This should be called fairly regularly since references may take a + little while to disappear in some cases (if referenced by materials) + */ + virtual void clearUnused(); + /** Dereference all the shadow textures kept in this class and remove them + from TextureManager; note that it is up to the SceneManagers to clear + their local references. + */ + virtual void clear(); + + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static ShadowTextureManager& getSingleton(void); + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static ShadowTextureManager* getSingletonPtr(void); + + }; + +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreShadowVolumeExtrudeProgram.h b/school/informatik/verkerhssimulation/src/ogre/OgreShadowVolumeExtrudeProgram.h new file mode 100644 index 00000000..13131224 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreShadowVolumeExtrudeProgram.h @@ -0,0 +1,233 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __SHADOWVOLUMEEXTRUDEPROGRAM_H__ +#define __SHADOWVOLUMEEXTRUDEPROGRAM_H__ + +#include "OgrePrerequisites.h" +#include "OgreLight.h" + +namespace Ogre { + /** Static class containing source for vertex programs for extruding shadow volumes + @remarks + This exists so we don't have to be dependent on an external media files. + Assembler is used so we don't have to rely on particular plugins. + The assembler contents of this file were generated from the following Cg: + @code + // Point light shadow volume extrude + void shadowVolumeExtrudePointLight_vp ( + float4 position : POSITION, + float wcoord : TEXCOORD0, + + out float4 oPosition : POSITION, + + uniform float4x4 worldViewProjMatrix, + uniform float4 lightPos // homogenous, object space + ) + { + // extrusion in object space + // vertex unmodified if w==1, extruded if w==0 + float4 newpos = + (wcoord.xxxx * lightPos) + + float4(position.xyz - lightPos.xyz, 0); + + oPosition = mul(worldViewProjMatrix, newpos); + + } + + // Directional light extrude + void shadowVolumeExtrudeDirLight_vp ( + float4 position : POSITION, + float wcoord : TEXCOORD0, + + out float4 oPosition : POSITION, + + uniform float4x4 worldViewProjMatrix, + uniform float4 lightPos // homogenous, object space + ) + { + // extrusion in object space + // vertex unmodified if w==1, extruded if w==0 + float4 newpos = + (wcoord.xxxx * (position + lightPos)) - lightPos; + + oPosition = mul(worldViewProjMatrix, newpos); + + } + // Point light shadow volume extrude - FINITE + void shadowVolumeExtrudePointLightFinite_vp ( + float4 position : POSITION, + float wcoord : TEXCOORD0, + + out float4 oPosition : POSITION, + + uniform float4x4 worldViewProjMatrix, + uniform float4 lightPos, // homogenous, object space + uniform float extrusionDistance // how far to extrude + ) + { + // extrusion in object space + // vertex unmodified if w==1, extruded if w==0 + float3 extrusionDir = position.xyz - lightPos.xyz; + extrusionDir = normalize(extrusionDir); + + float4 newpos = float4(position.xyz + + ((1 - wcoord.x) * extrusionDistance * extrusionDir), 1); + + oPosition = mul(worldViewProjMatrix, newpos); + + } + + // Directional light extrude - FINITE + void shadowVolumeExtrudeDirLightFinite_vp ( + float4 position : POSITION, + float wcoord : TEXCOORD0, + + out float4 oPosition : POSITION, + + uniform float4x4 worldViewProjMatrix, + uniform float4 lightPos, // homogenous, object space + uniform float extrusionDistance // how far to extrude + ) + { + // extrusion in object space + // vertex unmodified if w==1, extruded if w==0 + // -ve lightPos is direction + float4 newpos = float4(position.xyz - + (wcoord.x * extrusionDistance * lightPos.xyz), 1); + + oPosition = mul(worldViewProjMatrix, newpos); + + } + @endcode + */ + class _OgreExport ShadowVolumeExtrudeProgram + { + private: + static String mPointArbvp1; + static String mPointVs_1_1; + static String mDirArbvp1; + static String mDirVs_1_1; + // same as above, except the color is set to 1 to enable debug volumes to be seen + static String mPointArbvp1Debug; + static String mPointVs_1_1Debug; + static String mDirArbvp1Debug; + static String mDirVs_1_1Debug; + + static String mPointArbvp1Finite; + static String mPointVs_1_1Finite; + static String mDirArbvp1Finite; + static String mDirVs_1_1Finite; + // same as above, except the color is set to 1 to enable debug volumes to be seen + static String mPointArbvp1FiniteDebug; + static String mPointVs_1_1FiniteDebug; + static String mDirArbvp1FiniteDebug; + static String mDirVs_1_1FiniteDebug; + + static bool mInitialised; + + public: +#define OGRE_NUM_SHADOW_EXTRUDER_PROGRAMS 8 + enum Programs + { + // Point light extruder, infinite distance + POINT_LIGHT = 0, + // Point light extruder, infinite distance, debug mode + POINT_LIGHT_DEBUG = 1, + // Directional light extruder, infinite distance + DIRECTIONAL_LIGHT = 2, + // Directional light extruder, infinite distance, debug mode + DIRECTIONAL_LIGHT_DEBUG = 3, + // Point light extruder, finite distance + POINT_LIGHT_FINITE = 4, + // Point light extruder, finite distance, debug mode + POINT_LIGHT_FINITE_DEBUG = 5, + // Directional light extruder, finite distance + DIRECTIONAL_LIGHT_FINITE = 6, + // Directional light extruder, finite distance, debug mode + DIRECTIONAL_LIGHT_FINITE_DEBUG = 7 + + }; + static const String programNames[OGRE_NUM_SHADOW_EXTRUDER_PROGRAMS]; + + /// Initialise the creation of these vertex programs + static void initialise(void); + /// Shutdown & destroy the vertex programs + static void shutdown(void); + /// Get extruder program source for point lights, compatible with arbvp1 + static const String& getPointLightExtruderArbvp1(void) { return mPointArbvp1; } + /// Get extruder program source for point lights, compatible with vs_1_1 + static const String& getPointLightExtruderVs_1_1(void) { return mPointVs_1_1; } + /// Get extruder program source for directional lights, compatible with arbvp1 + static const String& getDirectionalLightExtruderArbvp1(void) { return mDirArbvp1; } + /// Get extruder program source for directional lights, compatible with vs_1_1 + static const String& getDirectionalLightExtruderVs_1_1(void) { return mDirVs_1_1; } + + /// Get extruder program source for debug point lights, compatible with arbvp1 + static const String& getPointLightExtruderArbvp1Debug(void) { return mPointArbvp1Debug; } + /// Get extruder program source for debug point lights, compatible with vs_1_1 + static const String& getPointLightExtruderVs_1_1Debug(void) { return mPointVs_1_1Debug; } + /// Get extruder program source for debug directional lights, compatible with arbvp1 + static const String& getDirectionalLightExtruderArbvp1Debug(void) { return mDirArbvp1Debug; } + /// Get extruder program source for debug directional lights, compatible with vs_1_1 + static const String& getDirectionalLightExtruderVs_1_1Debug(void) { return mDirVs_1_1Debug; } + /// General purpose method to get any of the program sources + static const String& getProgramSource(Light::LightTypes lightType, const String syntax, + bool finite, bool debug); + + static const String& getProgramName(Light::LightTypes lightType, bool finite, bool debug); + + + + + + /// Get FINITE extruder program source for point lights, compatible with arbvp1 + static const String& getPointLightExtruderArbvp1Finite(void) { return mPointArbvp1Finite; } + /// Get FINITE extruder program source for point lights, compatible with vs_1_1 + static const String& getPointLightExtruderVs_1_1Finite(void) { return mPointVs_1_1Finite; } + /// Get FINITE extruder program source for directional lights, compatible with arbvp1 + static const String& getDirectionalLightExtruderArbvp1Finite(void) { return mDirArbvp1Finite; } + /// Get FINITE extruder program source for directional lights, compatible with vs_1_1 + static const String& getDirectionalLightExtruderVs_1_1Finite(void) { return mDirVs_1_1Finite; } + + /// Get FINITE extruder program source for debug point lights, compatible with arbvp1 + static const String& getPointLightExtruderArbvp1FiniteDebug(void) { return mPointArbvp1FiniteDebug; } + /// Get extruder program source for debug point lights, compatible with vs_1_1 + static const String& getPointLightExtruderVs_1_1FiniteDebug(void) { return mPointVs_1_1FiniteDebug; } + /// Get FINITE extruder program source for debug directional lights, compatible with arbvp1 + static const String& getDirectionalLightExtruderArbvp1FiniteDebug(void) { return mDirArbvp1FiniteDebug; } + /// Get FINITE extruder program source for debug directional lights, compatible with vs_1_1 + static const String& getDirectionalLightExtruderVs_1_1FiniteDebug(void) { return mDirVs_1_1FiniteDebug; } + + + + + }; +} +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreSharedPtr.h b/school/informatik/verkerhssimulation/src/ogre/OgreSharedPtr.h new file mode 100644 index 00000000..17eeb2e2 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreSharedPtr.h @@ -0,0 +1,229 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __SharedPtr_H__ +#define __SharedPtr_H__ + +#include "OgrePrerequisites.h" + +namespace Ogre { + + /** Reference-counted shared pointer, used for objects where implicit destruction is + required. + @remarks + This is a standard shared pointer implementation which uses a reference + count to work out when to delete the object. OGRE does not use this class + very often, because it is usually more efficient to make the destruction + of objects more intentional (in blocks, say). However in some cases you + really cannot tell how many people are using an object, and this approach is + worthwhile (e.g. ControllerValue) + @par + If OGRE_THREAD_SUPPORT is defined to be 1, use of this class is thread-safe. + */ + template class SharedPtr { + protected: + T* pRep; + unsigned int* pUseCount; + public: + OGRE_AUTO_SHARED_MUTEX // public to allow external locking + /** Constructor, does not initialise the SharedPtr. + @remarks + Dangerous! You have to call bind() before using the SharedPtr. + */ + SharedPtr() : pRep(0), pUseCount(0) + { + OGRE_SET_AUTO_SHARED_MUTEX_NULL + } + + template< class Y> + explicit SharedPtr(Y* rep) : pRep(rep), pUseCount(new unsigned int(1)) + { + OGRE_SET_AUTO_SHARED_MUTEX_NULL + OGRE_NEW_AUTO_SHARED_MUTEX + } + SharedPtr(const SharedPtr& r) + : pRep(0), pUseCount(0) + { + // lock & copy other mutex pointer + + OGRE_SET_AUTO_SHARED_MUTEX_NULL + OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME) + { + OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME) + OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME) + pRep = r.pRep; + pUseCount = r.pUseCount; + // Handle zero pointer gracefully to manage STL containers + if(pUseCount) + { + ++(*pUseCount); + } + } + } + SharedPtr& operator=(const SharedPtr& r) { + if (pRep == r.pRep) + return *this; + // Swap current data into a local copy + // this ensures we deal with rhs and this being dependent + SharedPtr tmp(r); + swap(tmp); + return *this; + } + + template< class Y> + SharedPtr(const SharedPtr& r) + : pRep(0), pUseCount(0) + { + // lock & copy other mutex pointer + + OGRE_SET_AUTO_SHARED_MUTEX_NULL + OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME) + { + OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME) + OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME) + pRep = r.getPointer(); + pUseCount = r.useCountPointer(); + // Handle zero pointer gracefully to manage STL containers + if(pUseCount) + { + ++(*pUseCount); + } + } + } + template< class Y> + SharedPtr& operator=(const SharedPtr& r) { + if (pRep == r.pRep) + return *this; + // Swap current data into a local copy + // this ensures we deal with rhs and this being dependent + SharedPtr tmp(r); + swap(tmp); + return *this; + } + virtual ~SharedPtr() { + release(); + } + + + inline T& operator*() const { assert(pRep); return *pRep; } + inline T* operator->() const { assert(pRep); return pRep; } + inline T* get() const { return pRep; } + + /** Binds rep to the SharedPtr. + @remarks + Assumes that the SharedPtr is uninitialised! + */ + void bind(T* rep) { + assert(!pRep && !pUseCount); + OGRE_NEW_AUTO_SHARED_MUTEX + OGRE_LOCK_AUTO_SHARED_MUTEX + pUseCount = new unsigned int(1); + pRep = rep; + } + + inline bool unique() const { OGRE_LOCK_AUTO_SHARED_MUTEX assert(pUseCount); return *pUseCount == 1; } + inline unsigned int useCount() const { OGRE_LOCK_AUTO_SHARED_MUTEX assert(pUseCount); return *pUseCount; } + inline unsigned int* useCountPointer() const { return pUseCount; } + + inline T* getPointer() const { return pRep; } + + inline bool isNull(void) const { return pRep == 0; } + + inline void setNull(void) { + if (pRep) + { + // can't scope lock mutex before release incase deleted + release(); + pRep = 0; + pUseCount = 0; + } + } + + protected: + + inline void release(void) + { + bool destroyThis = false; + + /* If the mutex is not initialized to a non-zero value, then + neither is pUseCount nor pRep. + */ + + OGRE_MUTEX_CONDITIONAL(OGRE_AUTO_MUTEX_NAME) + { + // lock own mutex in limited scope (must unlock before destroy) + OGRE_LOCK_AUTO_SHARED_MUTEX + if (pUseCount) + { + if (--(*pUseCount) == 0) + { + destroyThis = true; + } + } + } + if (destroyThis) + destroy(); + + OGRE_SET_AUTO_SHARED_MUTEX_NULL + } + + virtual void destroy(void) + { + // IF YOU GET A CRASH HERE, YOU FORGOT TO FREE UP POINTERS + // BEFORE SHUTTING OGRE DOWN + // Use setNull() before shutdown or make sure your pointer goes + // out of scope before OGRE shuts down to avoid this. + delete pRep; + delete pUseCount; + OGRE_DELETE_AUTO_SHARED_MUTEX + } + + virtual void swap(SharedPtr &other) + { + std::swap(pRep, other.pRep); + std::swap(pUseCount, other.pUseCount); +#if OGRE_THREAD_SUPPORT + std::swap(OGRE_AUTO_MUTEX_NAME, other.OGRE_AUTO_MUTEX_NAME); +#endif + } + }; + + template inline bool operator==(SharedPtr const& a, SharedPtr const& b) + { + return a.get() == b.get(); + } + + template inline bool operator!=(SharedPtr const& a, SharedPtr const& b) + { + return a.get() != b.get(); + } +} + + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreSimpleRenderable.h b/school/informatik/verkerhssimulation/src/ogre/OgreSimpleRenderable.h new file mode 100644 index 00000000..1a78ebb6 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreSimpleRenderable.h @@ -0,0 +1,98 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __SimpleRenderable_H__ +#define __SimpleRenderable_H__ + +#include "OgrePrerequisites.h" + +#include "OgreMovableObject.h" +#include "OgreRenderable.h" +#include "OgreAxisAlignedBox.h" +#include "OgreMaterial.h" + +namespace Ogre { + + class _OgreExport SimpleRenderable : public MovableObject, public Renderable + { + protected: + RenderOperation mRenderOp; + + Matrix4 m_matWorldTransform; + AxisAlignedBox mBox; + + String m_strMatName; + MaterialPtr m_pMaterial; + + /// The scene manager for the current frame. + SceneManager *m_pParentSceneManager; + + /// The camera for the current frame. + Camera *m_pCamera; + + /// Static member used to automatically generate names for SimpleRendaerable objects. + static uint ms_uGenNameCount; + + public: + SimpleRenderable(); + + void setMaterial( const String& matName ); + virtual const MaterialPtr& getMaterial(void) const; + + virtual void setRenderOperation( const RenderOperation& rend ); + virtual void getRenderOperation(RenderOperation& op); + + void setWorldTransform( const Matrix4& xform ); + virtual void getWorldTransforms( Matrix4* xform ) const; + /** @copydoc Renderable::getWorldOrientation */ + const Quaternion& getWorldOrientation(void) const; + /** @copydoc Renderable::getWorldPosition */ + const Vector3& getWorldPosition(void) const; + + + virtual void _notifyCurrentCamera(Camera* cam); + + void setBoundingBox( const AxisAlignedBox& box ); + virtual const AxisAlignedBox& getBoundingBox(void) const; + + virtual void _updateRenderQueue(RenderQueue* queue); + + virtual ~SimpleRenderable(); + + + /** Overridden from MovableObject */ + virtual const String& getMovableType(void) const; + + /** @copydoc Renderable::getLights */ + const LightList& getLights(void) const; + + }; +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreSimpleSpline.h b/school/informatik/verkerhssimulation/src/ogre/OgreSimpleSpline.h new file mode 100644 index 00000000..ae810d59 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreSimpleSpline.h @@ -0,0 +1,130 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __SimpleSpline_H__ +#define __SimpleSpline_H__ + +#include "OgrePrerequisites.h" +#include "OgreVector3.h" +#include "OgreMatrix4.h" + +namespace Ogre { + + + /** A very simple spline class which implements the Catmull-Rom class of splines. + @remarks + Splines are bendy lines. You define a series of points, and the spline forms + a smoother line between the points to eliminate the sharp angles. + @par + Catmull-Rom splines are a specialisation of the general Hermite spline. With + a Hermite spline, you define the start and end point of the line, and 2 tangents, + one at the start of the line and one at the end. The Catmull-Rom spline simplifies + this by just asking you to define a series of points, and the tangents are + created for you. + */ + class _OgreExport SimpleSpline + { + public: + SimpleSpline(); + ~SimpleSpline(); + + /** Adds a control point to the end of the spline. */ + void addPoint(const Vector3& p); + + /** Gets the detail of one of the control points of the spline. */ + const Vector3& getPoint(unsigned short index) const; + + /** Gets the number of control points in the spline. */ + unsigned short getNumPoints(void) const; + + /** Clears all the points in the spline. */ + void clear(void); + + /** Updates a single point in the spline. + @remarks + This point must already exist in the spline. + */ + void updatePoint(unsigned short index, const Vector3& value); + + /** Returns an interpolated point based on a parametric value over the whole series. + @remarks + Given a t value between 0 and 1 representing the parametric distance along the + whole length of the spline, this method returns an interpolated point. + @param t Parametric value. + */ + Vector3 interpolate(Real t); + + /** Interpolates a single segment of the spline given a parametric value. + @param fromIndex The point index to treat as t=0. fromIndex + 1 is deemed to be t=1 + @param t Parametric value + */ + Vector3 interpolate(unsigned int fromIndex, Real t); + + + /** Tells the spline whether it should automatically calculate tangents on demand + as points are added. + @remarks + The spline calculates tangents at each point automatically based on the input points. + Normally it does this every time a point changes. However, if you have a lot of points + to add in one go, you probably don't want to incur this overhead and would prefer to + defer the calculation until you are finished setting all the points. You can do this + by calling this method with a parameter of 'false'. Just remember to manually call + the recalcTangents method when you are done. + @param autoCalc If true, tangents are calculated for you whenever a point changes. If false, + you must call reclacTangents to recalculate them when it best suits. + */ + void setAutoCalculate(bool autoCalc); + + /** Recalculates the tangents associated with this spline. + @remarks + If you tell the spline not to update on demand by calling setAutoCalculate(false) + then you must call this after completing your updates to the spline points. + */ + void recalcTangents(void); + + protected: + + bool mAutoCalc; + + std::vector mPoints; + std::vector mTangents; + + /// Matrix of coefficients + Matrix4 mCoeffs; + + + + }; + + +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreSingleton.h b/school/informatik/verkerhssimulation/src/ogre/OgreSingleton.h new file mode 100644 index 00000000..13c591cb --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreSingleton.h @@ -0,0 +1,85 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +/* Original version Copyright (C) Scott Bilas, 2000. + * All rights reserved worldwide. + * + * This software is provided "as is" without express or implied + * warranties. You may freely copy and compile this source into + * applications you distribute provided that the copyright text + * below is included in the resulting source code, for example: + * "Portions Copyright (C) Scott Bilas, 2000" + */ +#ifndef _SINGLETON_H__ +#define _SINGLETON_H__ + +// Added by Steve Streeting for Ogre +#include "OgrePrerequisites.h" + +#if OGRE_COMPILER == OGRE_COMPILER_MSVC +// Turn off warnings generated by this singleton implementation +# pragma warning (disable : 4311) +# pragma warning (disable : 4312) +#endif + +#if defined ( OGRE_GCC_VISIBILITY ) +# pragma GCC visibility push(default) +#endif +namespace Ogre { +// End SJS additions + /** Template class for creating single-instance global classes. + */ + template class Singleton + { + protected: + + static T* ms_Singleton; + + public: + Singleton( void ) + { + assert( !ms_Singleton ); +#if defined( _MSC_VER ) && _MSC_VER < 1200 + int offset = (int)(T*)1 - (int)(Singleton *)(T*)1; + ms_Singleton = (T*)((int)this + offset); +#else + ms_Singleton = static_cast< T* >( this ); +#endif + } + ~Singleton( void ) + { assert( ms_Singleton ); ms_Singleton = 0; } + static T& getSingleton( void ) + { assert( ms_Singleton ); return ( *ms_Singleton ); } + static T* getSingletonPtr( void ) + { return ms_Singleton; } + }; +} +#if defined ( OGRE_GCC_VISIBILITY ) +# pragma GCC visibility pop +#endif +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreSkeleton.h b/school/informatik/verkerhssimulation/src/ogre/OgreSkeleton.h new file mode 100644 index 00000000..f7305db5 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreSkeleton.h @@ -0,0 +1,519 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __Skeleton_H__ +#define __Skeleton_H__ + +#include "OgrePrerequisites.h" +#include "OgreResource.h" +#include "OgreQuaternion.h" +#include "OgreVector3.h" +#include "OgreIteratorWrappers.h" +#include "OgreStringVector.h" + +namespace Ogre { + + /** */ + enum SkeletonAnimationBlendMode { + /// Animations are applied by calculating a weighted average of all animations + ANIMBLEND_AVERAGE, + /// Animations are applied by calculating a weighted cumulative total + ANIMBLEND_CUMULATIVE + }; + +#define OGRE_MAX_NUM_BONES 256 + + + struct LinkedSkeletonAnimationSource; + + /** A collection of Bone objects used to animate a skinned mesh. + @remarks + Skeletal animation works by having a collection of 'bones' which are + actually just joints with a position and orientation, arranged in a tree structure. + For example, the wrist joint is a child of the elbow joint, which in turn is a + child of the shoulder joint. Rotating the shoulder automatically moves the elbow + and wrist as well due to this hierarchy. + @par + So how does this animate a mesh? Well every vertex in a mesh is assigned to one or more + bones which affects it's position when the bone is moved. If a vertex is assigned to + more than one bone, then weights must be assigned to determine how much each bone affects + the vertex (actually a weight of 1.0 is used for single bone assignments). + Weighted vertex assignments are especially useful around the joints themselves + to avoid 'pinching' of the mesh in this region. + @par + Therefore by moving the skeleton using preset animations, we can animate the mesh. The + advantage of using skeletal animation is that you store less animation data, especially + as vertex counts increase. In addition, you are able to blend multiple animations together + (e.g. walking and looking around, running and shooting) and provide smooth transitions + between animations without incurring as much of an overhead as would be involved if you + did this on the core vertex data. + @par + Skeleton definitions are loaded from datafiles, namely the .skeleton file format. They + are loaded on demand, especially when referenced by a Mesh. + */ + class _OgreExport Skeleton : public Resource + { + friend class SkeletonInstance; + protected: + /// Internal constructor for use by SkeletonInstance only + Skeleton(); + + public: + /** Constructor, don't call directly, use SkeletonManager. + @remarks + On creation, a Skeleton has a no bones, you should create them and link + them together appropriately. + */ + Skeleton(ResourceManager* creator, const String& name, ResourceHandle handle, + const String& group, bool isManual = false, ManualResourceLoader* loader = 0); + virtual ~Skeleton(); + + + /** Creates a brand new Bone owned by this Skeleton. + @remarks + This method creates an unattached new Bone for this skeleton. + Unless this is to be a root bone (there may be more than one of + these), you must attach it to another Bone in the skeleton using addChild for it to be any use. + For this reason you will likely be better off creating child bones using the + Bone::createChild method instead, once you have created the root bone. + @par + Note that this method automatically generates a handle for the bone, which you + can retrieve using Bone::getHandle. If you wish the new Bone to have a specific + handle, use the alternate form of this method which takes a handle as a parameter, + although you should note the restrictions. + */ + virtual Bone* createBone(void); + + /** Creates a brand new Bone owned by this Skeleton. + @remarks + This method creates an unattached new Bone for this skeleton and assigns it a + specific handle. Unless this is to be a root bone (there may be more than one of + these), you must attach it to another Bone in the skeleton using addChild for it to be any use. + For this reason you will likely be better off creating child bones using the + Bone::createChild method instead, once you have created a root bone. + @param handle The handle to give to this new bone - must be unique within this skeleton. + You should also ensure that all bone handles are eventually contiguous (this is to simplify + their compilation into an indexed array of transformation matrices). For this reason + it is advised that you use the simpler createBone method which automatically assigns a + sequential handle starting from 0. + */ + virtual Bone* createBone(unsigned short handle); + + /** Creates a brand new Bone owned by this Skeleton. + @remarks + This method creates an unattached new Bone for this skeleton and assigns it a + specific name.Unless this is to be a root bone (there may be more than one of + these), you must attach it to another Bone in the skeleton using addChild for it to be any use. + For this reason you will likely be better off creating child bones using the + Bone::createChild method instead, once you have created the root bone. + @param name The name to give to this new bone - must be unique within this skeleton. + Note that the way OGRE looks up bones is via a numeric handle, so if you name a + Bone this way it will be given an automatic sequential handle. The name is just + for your convenience, although it is recommended that you only use the handle to + retrieve the bone in performance-critical code. + */ + virtual Bone* createBone(const String& name); + + /** Creates a brand new Bone owned by this Skeleton. + @remarks + This method creates an unattached new Bone for this skeleton and assigns it a + specific name and handle. Unless this is to be a root bone (there may be more than one of + these), you must attach it to another Bone in the skeleton using addChild for it to be any use. + For this reason you will likely be better off creating child bones using the + Bone::createChild method instead, once you have created the root bone. + @param name The name to give to this new bone - must be unique within this skeleton. + @param handle The handle to give to this new bone - must be unique within this skeleton. + */ + virtual Bone* createBone(const String& name, unsigned short handle); + + /** Returns the number of bones in this skeleton. */ + virtual unsigned short getNumBones(void) const; + + /** Gets the root bone of the skeleton: deprecated in favour of getRootBoneIterator. + @remarks + The system derives the root bone the first time you ask for it. The root bone is the + only bone in the skeleton which has no parent. The system locates it by taking the + first bone in the list and going up the bone tree until there are no more parents, + and saves this top bone as the root. If you are building the skeleton manually using + createBone then you must ensure there is only one bone which is not a child of + another bone, otherwise your skeleton will not work properly. If you use createBone + only once, and then use Bone::createChild from then on, then inherently the first + bone you create will by default be the root. + */ + virtual Bone* getRootBone(void) const; + + typedef std::vector BoneList; + typedef VectorIterator BoneIterator; + /// Get an iterator over the root bones in the skeleton, ie those with no parents + virtual BoneIterator getRootBoneIterator(void); + /// Get an iterator over all the bones in the skeleton + virtual BoneIterator getBoneIterator(void); + + /** Gets a bone by it's handle. */ + virtual Bone* getBone(unsigned short handle) const; + + /** Gets a bone by it's name. */ + virtual Bone* getBone(const String& name) const; + + /** Sets the current position / orientation to be the 'binding pose' ie the layout in which + bones were originally bound to a mesh. + */ + virtual void setBindingPose(void); + + /** Resets the position and orientation of all bones in this skeleton to their original binding position. + @remarks + A skeleton is bound to a mesh in a binding pose. Bone positions are then modified from this + position during animation. This method returns all the bones to their original position and + orientation. + @param resetManualBones If set to true, causes the state of manual bones to be reset + too, which is normally not done to allow the manual state to persist even + when keyframe animation is applied. + */ + virtual void reset(bool resetManualBones = false); + + /** Creates a new Animation object for animating this skeleton. + @param name The name of this animation + @param length The length of the animation in seconds + */ + virtual Animation* createAnimation(const String& name, Real length); + + /** Returns the named Animation object. + @remarks + Will pick up animations in linked skeletons + (@see addLinkedSkeletonAnimationSource). + @param name The name of the animation + @param linker Optional pointer to a pointer to the linked skeleton animation + where this is coming from. + */ + virtual Animation* getAnimation(const String& name, + const LinkedSkeletonAnimationSource** linker = 0) const; + + /// Internal accessor for animations (returns null if animation does not exist) + virtual Animation* _getAnimationImpl(const String& name, + const LinkedSkeletonAnimationSource** linker = 0) const; + + + /** Returns whether this skeleton contains the named animation. */ + virtual bool hasAnimation(const String& name); + + /** Removes an Animation from this skeleton. */ + virtual void removeAnimation(const String& name); + + /** Changes the state of the skeleton to reflect the application of the passed in collection of animations. + @remarks + Animating a skeleton involves both interpolating between keyframes of a specific animation, + and blending between the animations themselves. Calling this method sets the state of + the skeleton so that it reflects the combination of all the passed in animations, at the + time index specified for each, using the weights specified. Note that the weights between + animations do not have to sum to 1.0, because some animations may affect only subsets + of the skeleton. If the weights exceed 1.0 for the same area of the skeleton, the + movement will just be exaggerated. + @param + */ + virtual void setAnimationState(const AnimationStateSet& animSet); + + + /** Initialise an animation set suitable for use with this skeleton. + @remarks + Only recommended for use inside the engine, not by applications. + */ + virtual void _initAnimationState(AnimationStateSet* animSet); + + /** Refresh an animation set suitable for use with this skeleton. + @remarks + Only recommended for use inside the engine, not by applications. + */ + virtual void _refreshAnimationState(AnimationStateSet* animSet); + + /** Populates the passed in array with the bone matrices based on the current position. + @remarks + Internal use only. The array pointed to by the passed in pointer must + be at least as large as the number of bones. + Assumes animation has already been updated. + */ + virtual void _getBoneMatrices(Matrix4* pMatrices); + + /** Gets the number of animations on this skeleton. */ + virtual unsigned short getNumAnimations(void) const; + + /** Gets a single animation by index. + @remarks + Will NOT pick up animations in linked skeletons + (@see addLinkedSkeletonAnimationSource). + */ + virtual Animation* getAnimation(unsigned short index) const; + + + /** Gets the animation blending mode which this skeleton will use. */ + virtual SkeletonAnimationBlendMode getBlendMode() const; + /** Sets the animation blending mode this skeleton will use. */ + virtual void setBlendMode(SkeletonAnimationBlendMode state); + + /// Updates all the derived transforms in the skeleton + virtual void _updateTransforms(void); + + /** Optimise all of this skeleton's animations. + @see Animation::optimise + @param + preservingIdentityNodeTracks If true, don't destroy identity node tracks. + */ + virtual void optimiseAllAnimations(bool preservingIdentityNodeTracks = false); + + /** Allows you to use the animations from another Skeleton object to animate + this skeleton. + @remarks + If you have skeletons of identical structure (that means identically + named bones with identical handles, and with the same hierarchy), but + slightly different proportions or binding poses, you can re-use animations + from one in the other. Because animations are actually stored as + changes to bones from their bind positions, it's possible to use the + same animation data for different skeletons, provided the skeletal + structure matches and the 'deltas' stored in the keyframes apply + equally well to the other skeletons bind position (so they must be + roughly similar, but don't have to be identical). You can use the + 'scale' option to adjust the translation and scale keyframes where + there are large differences in size between the skeletons. + @note + This method takes a skeleton name, rather than a more specific + animation name, for two reasons; firstly it allows some validation + of compatibility of skeletal structure, and secondly skeletons are + the unit of loading. Linking a skeleton to another in this way means + that the linkee will be prevented from being destroyed until the + linker is destroyed. + + You cannot set up cyclic relationships, e.g. SkeletonA uses SkeletonB's + animations, and SkeletonB uses SkeletonA's animations. This is because + it would set up a circular dependency which would prevent proper + unloading - make one of the skeletons the 'master' in this case. + @param skelName Name of the skeleton to link animations from. This + skeleton will be loaded immediately if this skeleton is already + loaded, otherwise it will be loaded when this skeleton is. + @param scale A scale factor to apply to translation and scaling elements + of the keyframes in the other skeleton when applying the animations + to this one. Compensates for skeleton size differences. + */ + virtual void addLinkedSkeletonAnimationSource(const String& skelName, + Real scale = 1.0f); + /// Remove all links to other skeletons for the purposes of sharing animation + virtual void removeAllLinkedSkeletonAnimationSources(void); + + typedef std::vector + LinkedSkeletonAnimSourceList; + typedef ConstVectorIterator + LinkedSkeletonAnimSourceIterator; + /// Get an iterator over the linked skeletons used as animation sources + virtual LinkedSkeletonAnimSourceIterator + getLinkedSkeletonAnimationSourceIterator(void) const; + + /// Internal method for marking the manual bones as dirty + virtual void _notifyManualBonesDirty(void); + /// Internal method for notifying that a bone is manual + virtual void _notifyManualBoneStateChange(Bone* bone); + + /// Have manual bones been modified since the skeleton was last updated? + virtual bool getManualBonesDirty(void) const { return mManualBonesDirty; } + /// Are there any manually controlled bones? + virtual bool hasManualBones(void) const { return !mManualBones.empty(); } + + /// Map to translate bone handle from one skeleton to another skeleton. + typedef std::vector BoneHandleMap; + + /** Merge animations from another Skeleton object into this skeleton. + @remarks + This function allow merge two structures compatible skeletons. The + 'compatible' here means identically bones will have same hierarchy, + but skeletons are not necessary to have same number of bones (if + number bones of source skeleton's more than this skeleton, they will + copied as is, except that duplicate names are unallowed; and in the + case of bones missing in source skeleton, nothing happen for those + bones). + @par + There are also unnecessary to have same binding poses, this function + will adjust keyframes of the source skeleton to match this skeleton + automatically. + @par + It's useful for export skeleton animations seperately. i.e. export + mesh and 'master' skeleton at the same time, and then other animations + will export seperately (even if used completely difference binding + pose), finally, merge seperately exported animations into 'master' + skeleton. + @param + source Pointer to source skeleton. It'll keep unmodified. + @param + boneHandleMap A map to translate identically bone's handle from source + skeleton to this skeleton. If mapped bone handle doesn't exists in this + skeleton, it'll created. You can populate bone handle map manually, or + use predefined functions build bone handle map for you. (@see + _buildMapBoneByHandle, _buildMapBoneByName) + @param + animations A list name of animations to merge, if empty, all animations + of source skeleton are used to merge. Note that the animation names + must not presented in this skeleton, and will NOT pick up animations + in linked skeletons (@see addLinkedSkeletonAnimationSource). + */ + virtual void _mergeSkeletonAnimations(const Skeleton* source, + const BoneHandleMap& boneHandleMap, + const StringVector& animations = StringVector()); + + /** Build the bone handle map to use with Skeleton::_mergeSkeletonAnimations. + @remarks + Identically bones are determine by handle. + */ + virtual void _buildMapBoneByHandle(const Skeleton* source, + BoneHandleMap& boneHandleMap) const; + + /** Build the bone handle map to use with Skeleton::_mergeSkeletonAnimations. + @remarks + Identically bones are determine by name. + */ + virtual void _buildMapBoneByName(const Skeleton* source, + BoneHandleMap& boneHandleMap) const; + + protected: + SkeletonAnimationBlendMode mBlendState; + /// Storage of bones, indexed by bone handle + BoneList mBoneList; + /// Lookup by bone name + typedef std::map BoneListByName; + BoneListByName mBoneListByName; + + + /// Pointer to root bones (can now have multiple roots) + mutable BoneList mRootBones; + /// Bone automatic handles + unsigned short mNextAutoHandle; + typedef std::set BoneSet; + /// Manual bones + BoneSet mManualBones; + /// Manual bones dirty? + bool mManualBonesDirty; + + + /// Storage of animations, lookup by name + typedef std::map AnimationList; + AnimationList mAnimationsList; + + /// List of references to other skeletons to use animations from + mutable LinkedSkeletonAnimSourceList mLinkedSkeletonAnimSourceList; + + /** Internal method which parses the bones to derive the root bone. + @remarks + Must be const because called in getRootBone but mRootBone is mutable + since lazy-updated. + */ + void deriveRootBone(void) const; + + /// Debugging method + void _dumpContents(const String& filename); + + /** @copydoc Resource::loadImpl + */ + void loadImpl(void); + + /** @copydoc Resource::unloadImpl + */ + void unloadImpl(void); + /// @copydoc Resource::calculateSize + size_t calculateSize(void) const { return 0; } // TODO + + }; + + /** Specialisation of SharedPtr to allow SharedPtr to be assigned to SkeletonPtr + @note Has to be a subclass since we need operator=. + We could templatise this instead of repeating per Resource subclass, + except to do so requires a form VC6 does not support i.e. + ResourceSubclassPtr : public SharedPtr + */ + class _OgreExport SkeletonPtr : public SharedPtr + { + public: + SkeletonPtr() : SharedPtr() {} + explicit SkeletonPtr(Skeleton* rep) : SharedPtr(rep) {} + SkeletonPtr(const SkeletonPtr& r) : SharedPtr(r) {} + SkeletonPtr(const ResourcePtr& r) : SharedPtr() + { + // lock & copy other mutex pointer + OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME) + { + OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME) + OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME) + pRep = static_cast(r.getPointer()); + pUseCount = r.useCountPointer(); + if (pUseCount) + { + ++(*pUseCount); + } + } + } + + /// Operator used to convert a ResourcePtr to a SkeletonPtr + SkeletonPtr& operator=(const ResourcePtr& r) + { + if (pRep == static_cast(r.getPointer())) + return *this; + release(); + // lock & copy other mutex pointer + OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME) + { + OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME) + OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME) + pRep = static_cast(r.getPointer()); + pUseCount = r.useCountPointer(); + if (pUseCount) + { + ++(*pUseCount); + } + } + else + { + // RHS must be a null pointer + assert(r.isNull() && "RHS must be null if it has no mutex!"); + setNull(); + } + return *this; + } + }; + + /// Link to another skeleton to share animations + struct LinkedSkeletonAnimationSource + { + String skeletonName; + SkeletonPtr pSkeleton; + Real scale; + LinkedSkeletonAnimationSource(const String& skelName, Real scl) + : skeletonName(skelName), scale(scl) {} + LinkedSkeletonAnimationSource(const String& skelName, Real scl, + SkeletonPtr skelPtr) + : skeletonName(skelName), pSkeleton(skelPtr), scale(scl) {} + }; +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreSkeletonFileFormat.h b/school/informatik/verkerhssimulation/src/ogre/OgreSkeletonFileFormat.h new file mode 100644 index 00000000..17339a4f --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreSkeletonFileFormat.h @@ -0,0 +1,102 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __SkeletonFileFormat_H__ +#define __SkeletonFileFormat_H__ + +#include "OgrePrerequisites.h" + +namespace Ogre { + +/** Definition of the OGRE .skeleton file format + + .skeleton files are binary files (for read efficiency at runtime) and are arranged into chunks + of data, very like 3D Studio's format. + A chunk always consists of: + unsigned short CHUNK_ID : one of the following chunk ids identifying the chunk + unsigned long LENGTH : length of the chunk in bytes, including this header + void* DATA : the data, which may contain other sub-chunks (various data types) + + A .skeleton file contains both the definition of the Skeleton object and the animations it contains. It + contains only a single skeleton but can contain multiple animations. + + +*/ + enum SkeletonChunkID { + SKELETON_HEADER = 0x1000, + // char* version : Version number check + SKELETON_BONE = 0x2000, + // Repeating section defining each bone in the system. + // Bones are assigned indexes automatically based on their order of declaration + // starting with 0. + + // char* name : name of the bone + // unsigned short handle : handle of the bone, should be contiguous & start at 0 + // Vector3 position : position of this bone relative to parent + // Quaternion orientation : orientation of this bone relative to parent + // Vector3 scale : scale of this bone relative to parent + + SKELETON_BONE_PARENT = 0x3000, + // Record of the parent of a single bone, used to build the node tree + // Repeating section, listed in Bone Index order, one per Bone + + // unsigned short handle : child bone + // unsigned short parentHandle : parent bone + + SKELETON_ANIMATION = 0x4000, + // A single animation for this skeleton + + // char* name : Name of the animation + // float length : Length of the animation in seconds + + SKELETON_ANIMATION_TRACK = 0x4100, + // A single animation track (relates to a single bone) + // Repeating section (within SKELETON_ANIMATION) + + // unsigned short boneIndex : Index of bone to apply to + + SKELETON_ANIMATION_TRACK_KEYFRAME = 0x4110, + // A single keyframe within the track + // Repeating section + + // float time : The time position (seconds) + // Quaternion rotate : Rotation to apply at this keyframe + // Vector3 translate : Translation to apply at this keyframe + // Vector3 scale : Scale to apply at this keyframe + SKELETON_ANIMATION_LINK = 0x5000 + // Link to another skeleton, to re-use its animations + + // char* skeletonName : name of skeleton to get animations from + // float scale : scale to apply to trans/scale keys + + }; + +} // namespace + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreSkeletonInstance.h b/school/informatik/verkerhssimulation/src/ogre/OgreSkeletonInstance.h new file mode 100644 index 00000000..6366b950 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreSkeletonInstance.h @@ -0,0 +1,156 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __SkeletonInstance_H__ +#define __SkeletonInstance_H__ + +#include "OgrePrerequisites.h" +#include "OgreSkeleton.h" + +namespace Ogre { + + /** A SkeletonInstance is a single instance of a Skeleton used by a world object. + @remarks + The difference between a Skeleton and a SkeletonInstance is that the + Skeleton is the 'master' version much like Mesh is a 'master' version of + Entity. Many SkeletonInstance objects can be based on a single Skeleton, + and are copies of it when created. Any changes made to this are not + reflected in the master copy. The exception is animations; these are + shared on the Skeleton itself and may not be modified here. + */ + class _OgreExport SkeletonInstance : public Skeleton + { + public: + /** Constructor, don't call directly, this will be created automatically + when you create an Entity based on a skeletally animated Mesh. + */ + SkeletonInstance(const SkeletonPtr& masterCopy); + ~SkeletonInstance(); + + /** Gets the number of animations on this skeleton. */ + unsigned short getNumAnimations(void) const; + + /** Gets a single animation by index. */ + Animation* getAnimation(unsigned short index) const; + /// Internal accessor for animations (returns null if animation does not exist) + Animation* _getAnimationImpl(const String& name, + const LinkedSkeletonAnimationSource** linker = 0) const; + + /** Creates a new Animation object for animating this skeleton. + @remarks + This method updates the reference skeleton, not just this instance! + @param name The name of this animation + @param length The length of the animation in seconds + */ + Animation* createAnimation(const String& name, Real length); + + /** Returns the named Animation object. */ + Animation* getAnimation(const String& name, + const LinkedSkeletonAnimationSource** linker = 0) const; + + /** Removes an Animation from this skeleton. + @remarks + This method updates the reference skeleton, not just this instance! + */ + void removeAnimation(const String& name); + + + /** Creates a TagPoint ready to be attached to a bone */ + TagPoint* createTagPointOnBone(Bone* bone, + const Quaternion &offsetOrientation = Quaternion::IDENTITY, + const Vector3 &offsetPosition = Vector3::ZERO); + + /** Frees a TagPoint that already attached to a bone */ + void freeTagPoint(TagPoint* tagPoint); + + /// @copydoc Skeleton::addLinkedSkeletonAnimationSource + void addLinkedSkeletonAnimationSource(const String& skelName, + Real scale = 1.0f); + /// @copydoc Skeleton::removeAllLinkedSkeletonAnimationSources + void removeAllLinkedSkeletonAnimationSources(void); + /// @copydoc Skeleton::getLinkedSkeletonAnimationSourceIterator + LinkedSkeletonAnimSourceIterator + getLinkedSkeletonAnimationSourceIterator(void) const; + + /// @copydoc Skeleton::_initAnimationState + void _initAnimationState(AnimationStateSet* animSet); + + /// @copydoc Skeleton::_refreshAnimationState + void _refreshAnimationState(AnimationStateSet* animSet); + + /// @copydoc Resource::getName + const String& getName(void) const; + /// @copydoc Resource::getHandle + ResourceHandle getHandle(void) const; + /// @copydoc Resource::getGroup + const String& getGroup(void); + + protected: + /// Pointer back to master Skeleton + SkeletonPtr mSkeleton; + + typedef std::list TagPointList; + + /** Active tag point list. + @remarks + This is a linked list of pointers to actived tag point + @par + This allows very fast instertions and deletions from anywhere in the list to activate / deactivate + tag points (required for weapon / equip systems etc) as well as resuse of TagPoint instances + without construction & destruction which avoids memory thrashing. + */ + TagPointList mActiveTagPoints; + + /** Free tag point list. + @remarks + This contains a list of the tag points free for use as new instances + as required by the set. When a TagPoint instances are deactived, there will are referenced on this + list. As they get used this list reduces, as they get released back to to the set they get added + back to the list. + */ + TagPointList mFreeTagPoints; + + /// TagPoint automatic handles + unsigned short mNextTagPointAutoHandle; + + void cloneBoneAndChildren(Bone* source, Bone* parent); + /** Overridden from Skeleton + */ + void loadImpl(void); + /** Overridden from Skeleton + */ + void unloadImpl(void); + + }; + +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreSkeletonManager.h b/school/informatik/verkerhssimulation/src/ogre/OgreSkeletonManager.h new file mode 100644 index 00000000..c8e41a48 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreSkeletonManager.h @@ -0,0 +1,98 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __SkeletonManager_H__ +#define __SkeletonManager_H__ + +#include "OgrePrerequisites.h" + +#include "OgreResourceManager.h" +#include "OgreSingleton.h" + +namespace Ogre { + + /** Handles the management of skeleton resources. + @remarks + This class deals with the runtime management of + skeleton data; like other resource managers it handles + the creation of resources (in this case skeleton data), + working within a fixed memory budget. + */ + class _OgreExport SkeletonManager: public ResourceManager, public Singleton + { + public: + /// Constructor + SkeletonManager(); + ~SkeletonManager(); + + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static SkeletonManager& getSingleton(void); + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static SkeletonManager* getSingletonPtr(void); + protected: + + /// @copydoc ResourceManager::createImpl + Resource* createImpl(const String& name, ResourceHandle handle, + const String& group, bool isManual, ManualResourceLoader* loader, + const NameValuePairList* createParams); + + }; + + +} + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreSkeletonSerializer.h b/school/informatik/verkerhssimulation/src/ogre/OgreSkeletonSerializer.h new file mode 100644 index 00000000..94ade403 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreSkeletonSerializer.h @@ -0,0 +1,117 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __SkeletonSerializer_H__ +#define __SkeletonSerializer_H__ + +#include "OgrePrerequisites.h" +#include "OgreSkeleton.h" +#include "OgreSerializer.h" + +namespace Ogre { + + /** Class for serialising skeleton data to/from an OGRE .skeleton file. + @remarks + This class allows exporters to write OGRE .skeleton files easily, and allows the + OGRE engine to import .skeleton files into instatiated OGRE Skeleton objects. + Note that a .skeleton file includes not only the Skeleton, but also definitions of + any Animations it uses. + @par + To export a Skeleton:
    +
  1. Create a Skeleton object and populate it using it's methods.
  2. +
  3. Call the exportSkeleton method
  4. +
+ */ + class _OgreExport SkeletonSerializer : public Serializer + { + public: + SkeletonSerializer(); + virtual ~SkeletonSerializer(); + + + /** Exports a skeleton to the file specified. + @remarks + This method takes an externally created Skeleton object, and exports both it + and animations it uses to a .skeleton file. + @param pSkeleton Weak reference to the Skeleton to export + @param filename The destination filename + @param endianMode The endian mode to write in + */ + void exportSkeleton(const Skeleton* pSkeleton, const String& filename, + Endian endianMode = ENDIAN_NATIVE); + + /** Imports Skeleton and animation data from a .skeleton file DataStream. + @remarks + This method imports data from a DataStream opened from a .skeleton file and places it's + contents into the Skeleton object which is passed in. + @param stream The DataStream holding the .skeleton data. Must be initialised (pos at the start of the buffer). + @param pDest Weak reference to the Skeleton object which will receive the data. Should be blank already. + */ + void importSkeleton(DataStreamPtr& stream, Skeleton* pDest); + + // TODO: provide Cal3D importer? + + protected: + // Internal export methods + void writeSkeleton(const Skeleton* pSkel); + void writeBone(const Skeleton* pSkel, const Bone* pBone); + void writeBoneParent(const Skeleton* pSkel, unsigned short boneId, unsigned short parentId); + void writeAnimation(const Skeleton* pSkel, const Animation* anim); + void writeAnimationTrack(const Skeleton* pSkel, const NodeAnimationTrack* track); + void writeKeyFrame(const Skeleton* pSkel, const TransformKeyFrame* key); + void writeSkeletonAnimationLink(const Skeleton* pSkel, + const LinkedSkeletonAnimationSource& link); + + // Internal import methods + void readBone(DataStreamPtr& stream, Skeleton* pSkel); + void readBoneParent(DataStreamPtr& stream, Skeleton* pSkel); + void readAnimation(DataStreamPtr& stream, Skeleton* pSkel); + void readAnimationTrack(DataStreamPtr& stream, Animation* anim, Skeleton* pSkel); + void readKeyFrame(DataStreamPtr& stream, NodeAnimationTrack* track, Skeleton* pSkel); + void readSkeletonAnimationLink(DataStreamPtr& stream, Skeleton* pSkel); + + size_t calcBoneSize(const Skeleton* pSkel, const Bone* pBone); + size_t calcBoneSizeWithoutScale(const Skeleton* pSkel, const Bone* pBone); + size_t calcBoneParentSize(const Skeleton* pSkel); + size_t calcAnimationSize(const Skeleton* pSkel, const Animation* pAnim); + size_t calcAnimationTrackSize(const Skeleton* pSkel, const NodeAnimationTrack* pTrack); + size_t calcKeyFrameSize(const Skeleton* pSkel, const TransformKeyFrame* pKey); + size_t calcKeyFrameSizeWithoutScale(const Skeleton* pSkel, const TransformKeyFrame* pKey); + size_t calcSkeletonAnimationLinkSize(const Skeleton* pSkel, + const LinkedSkeletonAnimationSource& link); + + + + + }; + +} + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreSphere.h b/school/informatik/verkerhssimulation/src/ogre/OgreSphere.h new file mode 100644 index 00000000..513f8917 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreSphere.h @@ -0,0 +1,101 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Sphere_H_ +#define __Sphere_H_ + +// Precompiler options +#include "OgrePrerequisites.h" + +#include "OgreVector3.h" + +namespace Ogre { + + + /** A sphere primitive, mostly used for bounds checking. + @remarks + A sphere in math texts is normally represented by the function + x^2 + y^2 + z^2 = r^2 (for sphere's centered on the origin). Ogre stores spheres + simply as a center point and a radius. + */ + class _OgreExport Sphere + { + protected: + Real mRadius; + Vector3 mCenter; + public: + /** Standard constructor - creates a unit sphere around the origin.*/ + Sphere() : mRadius(1.0), mCenter(Vector3::ZERO) {} + /** Constructor allowing arbitrary spheres. + @param center The center point of the sphere. + @param radius The radius of the sphere. + */ + Sphere(const Vector3& center, Real radius) + : mRadius(radius), mCenter(center) {} + + /** Returns the radius of the sphere. */ + Real getRadius(void) const { return mRadius; } + + /** Sets the radius of the sphere. */ + void setRadius(Real radius) { mRadius = radius; } + + /** Returns the center point of the sphere. */ + const Vector3& getCenter(void) const { return mCenter; } + + /** Sets the center point of the sphere. */ + void setCenter(const Vector3& center) { mCenter = center; } + + /** Returns whether or not this sphere interects another sphere. */ + bool intersects(const Sphere& s) const + { + return (s.mCenter - mCenter).squaredLength() <= + Math::Sqr(s.mRadius + mRadius); + } + /** Returns whether or not this sphere interects a box. */ + bool intersects(const AxisAlignedBox& box) const + { + return Math::intersects(*this, box); + } + /** Returns whether or not this sphere interects a plane. */ + bool intersects(const Plane& plane) const + { + return Math::intersects(*this, plane); + } + /** Returns whether or not this sphere interects a point. */ + bool intersects(const Vector3& v) const + { + return ((v - mCenter).squaredLength() <= Math::Sqr(mRadius)); + } + + + }; + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreSpotShadowFadePng.h b/school/informatik/verkerhssimulation/src/ogre/OgreSpotShadowFadePng.h new file mode 100644 index 00000000..5c370753 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreSpotShadowFadePng.h @@ -0,0 +1,648 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __SPOT_SHADOW_FADE_PNG_H__ +#define __SPOT_SHADOW_FADE_PNG_H__ + +namespace Ogre { + + // This exists so we don't have to be dependent on an external .png file + // for this core feature (PNG used to fade out the edges of spotlight shadows) + #define SPOT_SHADOW_FADE_PNG_SIZE 9728 + unsigned char SPOT_SHADOW_FADE_PNG[SPOT_SHADOW_FADE_PNG_SIZE] = { + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52 + , 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x08, 0x02, 0x00, 0x00, 0x00, 0x4c, 0x5c, 0xf6 + , 0x9c, 0x00, 0x00, 0x00, 0x04, 0x67, 0x41, 0x4d, 0x41, 0x00, 0x00, 0xb1, 0x8e, 0x7c, 0xfb, 0x51 + , 0x93, 0x00, 0x00, 0x00, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x00, 0x00, 0x7a, 0x25, 0x00, 0x00, 0x80 + , 0x83, 0x00, 0x00, 0xf9, 0xff, 0x00, 0x00, 0x80, 0xe8, 0x00, 0x00, 0x75, 0x30, 0x00, 0x00, 0xea + , 0x60, 0x00, 0x00, 0x3a, 0x97, 0x00, 0x00, 0x17, 0x6f, 0x97, 0xa9, 0x99, 0xd4, 0x00, 0x00, 0x25 + , 0x8a, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0x62, 0xfc, 0xff, 0xff, 0x3f, 0xc3, 0x28, 0x18, 0x38 + , 0x00, 0x10, 0x80, 0x58, 0x2a, 0xc8, 0x01, 0x00, 0x04, 0x41, 0x40, 0xfd, 0xff, 0xc7, 0x61, 0x66 + , 0xeb, 0x5a, 0xc7, 0x60, 0x32, 0x98, 0x17, 0xdc, 0xec, 0xbf, 0x0b, 0x3c, 0x90, 0xff, 0x11, 0x8e + , 0x61, 0x87, 0xd7, 0x54, 0x32, 0xca, 0xed, 0x6d, 0x2a, 0x89, 0x48, 0x21, 0x04, 0x82, 0x92, 0x28 + , 0x1e, 0xa3, 0x96, 0xe4, 0xef, 0x2b, 0x2e, 0x98, 0x02, 0x30, 0x47, 0xe6, 0x48, 0x00, 0x02, 0x20 + , 0x10, 0x93, 0xe3, 0xff, 0x2f, 0x46, 0x34, 0x69, 0xac, 0xec, 0x75, 0x19, 0x42, 0x4d, 0xf6, 0x8f + , 0x05, 0xa0, 0x7a, 0xce, 0x61, 0xc9, 0xac, 0xbb, 0x70, 0x69, 0x61, 0x85, 0x25, 0x88, 0xeb, 0x70 + , 0x9e, 0xd0, 0x40, 0xa8, 0x1e, 0xed, 0x11, 0xa5, 0xfc, 0x2a, 0xed, 0x77, 0xb6, 0xb7, 0x1b, 0x14 + , 0xc8, 0xfc, 0xee, 0xb3, 0x97, 0xdc, 0x02, 0x30, 0x4f, 0x06, 0x37, 0x00, 0x80, 0x20, 0x0c, 0x94 + , 0x08, 0xfb, 0x0f, 0x0c, 0x1a, 0xaf, 0xe8, 0x10, 0x92, 0x58, 0x1a, 0x9e, 0xed, 0xf9, 0x4b, 0x01 + , 0xc2, 0x7c, 0x55, 0x12, 0x7c, 0xa5, 0x5e, 0x56, 0xdb, 0x52, 0x0f, 0x34, 0xd1, 0xc2, 0xec, 0x5b + , 0xc3, 0xfd, 0x09, 0xc2, 0x1f, 0x31, 0x01, 0x6e, 0xa3, 0xa1, 0x87, 0x76, 0x91, 0xff, 0x82, 0x57 + , 0xe2, 0xa4, 0x8f, 0xb0, 0x7c, 0x86, 0x07, 0x26, 0xe4, 0xfb, 0x32, 0xed, 0x83, 0x32, 0x8e, 0x00 + , 0xc4, 0x94, 0x5b, 0x0a, 0x00, 0x20, 0x08, 0x04, 0x31, 0xb2, 0xfb, 0x9f, 0xb7, 0xe8, 0xb1, 0x63 + , 0x41, 0x47, 0x70, 0xa3, 0x10, 0x03, 0x3f, 0x46, 0xd7, 0xe4, 0x06, 0x88, 0x9f, 0x60, 0x0f, 0x88 + , 0xc7, 0xdb, 0x91, 0xb8, 0x77, 0x12, 0x04, 0x64, 0xe9, 0x83, 0x34, 0x31, 0xc6, 0x0c, 0x33, 0xec + , 0xf5, 0x3d, 0x60, 0x54, 0x61, 0xea, 0xd9, 0x41, 0x06, 0xfa, 0xc2, 0xec, 0x5f, 0xd5, 0x20, 0xfe + , 0xc8, 0x7b, 0xe3, 0x28, 0x68, 0xee, 0x71, 0xaf, 0xf4, 0x65, 0x96, 0xb6, 0xa5, 0x8e, 0x00, 0xc4 + , 0x94, 0x41, 0x12, 0xc0, 0x20, 0x08, 0x03, 0x0f, 0x15, 0xf8, 0xff, 0x73, 0x01, 0x47, 0x9b, 0x00 + , 0x6f, 0x68, 0x99, 0x51, 0x31, 0x07, 0x0f, 0x1b, 0xc9, 0x6f, 0x06, 0x14, 0xd7, 0x4c, 0x8f, 0x00 + , 0xe9, 0x70, 0xf7, 0xc4, 0x42, 0x13, 0x14, 0x12, 0x02, 0x8f, 0xe4, 0x65, 0x8f, 0x07, 0x35, 0x02 + , 0x7b, 0xb2, 0x88, 0x31, 0x74, 0xf0, 0x4c, 0x65, 0xd0, 0xed, 0x09, 0xe0, 0xdf, 0x6f, 0xfa, 0xd8 + , 0xd7, 0xd4, 0x53, 0xac, 0x17, 0x49, 0xab, 0x69, 0x97, 0x08, 0x3b, 0x33, 0x83, 0x62, 0x52, 0x82 + , 0xb6, 0x13, 0xdf, 0x73, 0x78, 0x05, 0xe0, 0xa5, 0x4c, 0x52, 0x00, 0x08, 0x61, 0x20, 0xa8, 0xe0 + , 0xf6, 0xff, 0xd7, 0x46, 0x2f, 0xda, 0xd5, 0xc8, 0x30, 0x2f, 0xd0, 0x98, 0xe5, 0x10, 0x14, 0xaa + , 0x8d, 0xcf, 0xaf, 0xdc, 0x1b, 0xae, 0x26, 0x0f, 0xf6, 0x19, 0x11, 0x0a, 0x98, 0xf2, 0x52, 0x5a + , 0x81, 0x0a, 0x08, 0xc0, 0x34, 0xa8, 0xd5, 0x83, 0xe0, 0x11, 0xc0, 0xe1, 0x0f, 0x7d, 0x1f, 0x95 + , 0xd2, 0x1d, 0x82, 0x8c, 0xff, 0x35, 0x28, 0xf7, 0xa3, 0xa9, 0xc5, 0x68, 0x5b, 0xed, 0xbc, 0xfe + , 0xfe, 0x2d, 0x95, 0x83, 0x8d, 0xb9, 0x54, 0x68, 0x74, 0x20, 0xc6, 0x4b, 0x1e, 0x47, 0x00, 0xde + , 0xca, 0x25, 0x07, 0x60, 0x10, 0x84, 0x82, 0xa9, 0x6d, 0x2c, 0xdc, 0xff, 0xb0, 0x60, 0x62, 0x62 + , 0x65, 0xa8, 0x1e, 0x41, 0x16, 0x7c, 0x5c, 0xb8, 0x98, 0x87, 0xcf, 0x73, 0x02, 0x8c, 0x44, 0x1f + , 0xb4, 0x03, 0xb6, 0xbb, 0x79, 0x84, 0x19, 0xd5, 0x18, 0x1b, 0x1d, 0xfc, 0x5b, 0x3e, 0x82, 0xfe + , 0x6f, 0x3e, 0xd6, 0xc3, 0xea, 0xe7, 0xfa, 0x0f, 0x62, 0x5f, 0x8e, 0x85, 0x14, 0x4c, 0xa8, 0xf0 + , 0x03, 0x5f, 0xf7, 0xb2, 0xa2, 0x87, 0x54, 0x17, 0xfe, 0x24, 0xaf, 0x22, 0xa2, 0xfa, 0xce, 0x14 + , 0x35, 0x26, 0xe1, 0x48, 0xb6, 0x40, 0x53, 0x86, 0x23, 0xb6, 0xf4, 0x09, 0xc0, 0x6b, 0x15, 0xe4 + , 0x00, 0x08, 0x83, 0xb0, 0x10, 0xb2, 0x0c, 0xf8, 0xff, 0x5b, 0xd5, 0x2d, 0x31, 0x0a, 0xed, 0xf4 + , 0x07, 0x5a, 0xb2, 0x25, 0xdb, 0xb1, 0x05, 0xda, 0x9f, 0x04, 0xc0, 0x6e, 0x1f, 0xa4, 0x79, 0x07 + , 0xb6, 0x3a, 0x85, 0xf5, 0x38, 0x56, 0xa5, 0x06, 0xb3, 0x9a, 0x1d, 0x9e, 0xf0, 0xb0, 0x7f, 0xc2 + , 0x01, 0x88, 0x8b, 0xf5, 0x0a, 0x80, 0x28, 0x24, 0x68, 0x7f, 0x06, 0x21, 0x11, 0xf8, 0x40, 0xd1 + , 0xcf, 0xdc, 0xa3, 0xda, 0xb4, 0x61, 0x1c, 0x72, 0x28, 0xd2, 0x03, 0xba, 0x81, 0xf0, 0x82, 0x85 + , 0x87, 0x79, 0x04, 0x2f, 0x0f, 0xe7, 0x2f, 0x14, 0xe9, 0x58, 0x59, 0x5f, 0x33, 0x73, 0x0b, 0x40 + , 0x6b, 0xb9, 0xe3, 0x00, 0x0c, 0xc3, 0x20, 0x74, 0x89, 0xf2, 0x31, 0xf7, 0x3f, 0xaa, 0xe7, 0x16 + , 0xb0, 0xdb, 0x1b, 0x44, 0x8a, 0x62, 0x65, 0x05, 0xe7, 0xc1, 0x75, 0x03, 0xa8, 0xa3, 0x95, 0x97 + , 0xf0, 0x29, 0xad, 0x93, 0xa2, 0x67, 0xea, 0x70, 0xea, 0x25, 0x1f, 0xe4, 0x8b, 0x89, 0x43, 0xda + , 0xf8, 0xea, 0xdd, 0x37, 0x78, 0xb8, 0xf9, 0x8d, 0xfe, 0xe7, 0xeb, 0xa1, 0x6e, 0x41, 0x5d, 0x43 + , 0x9d, 0x00, 0xb5, 0xff, 0xc5, 0xa0, 0x2e, 0x42, 0x4e, 0x64, 0x39, 0x30, 0x8a, 0x48, 0x7f, 0x18 + , 0x4f, 0x07, 0x30, 0x77, 0x7c, 0x87, 0x6c, 0x40, 0x80, 0xe2, 0x23, 0x7a, 0x02, 0x87, 0x66, 0xe0 + , 0x44, 0x7d, 0x8d, 0xb9, 0x36, 0x11, 0x76, 0x4f, 0x9f, 0x57, 0x00, 0xda, 0xcb, 0x1e, 0x0b, 0x60 + , 0x10, 0x84, 0xc1, 0x0b, 0xaf, 0x43, 0xcb, 0xfd, 0x4f, 0xaa, 0xfd, 0xa1, 0x4b, 0xc3, 0x27, 0xf5 + , 0x06, 0xf2, 0x14, 0x9d, 0x1c, 0x82, 0x49, 0x60, 0xe1, 0xd3, 0x82, 0x4c, 0x6a, 0x7e, 0xe7, 0xff + , 0x16, 0xce, 0xda, 0xbd, 0x01, 0xbc, 0x72, 0x6f, 0x6d, 0xdc, 0x15, 0xc8, 0x4d, 0x44, 0x99, 0x6f + , 0x60, 0x10, 0x74, 0x3d, 0x6f, 0xa9, 0xbe, 0x40, 0xcf, 0xb1, 0x60, 0x52, 0x60, 0x16, 0xa0, 0x24 + , 0x08, 0x07, 0x80, 0x05, 0x63, 0x0e, 0xa8, 0x69, 0x00, 0x0e, 0x98, 0x91, 0xe8, 0x87, 0x20, 0x81 + , 0xfd, 0xbd, 0x4f, 0x5a, 0xef, 0x76, 0xa6, 0x25, 0x4b, 0x92, 0x40, 0xff, 0x70, 0x56, 0x86, 0xfb + , 0xc5, 0xf9, 0x88, 0x13, 0x7b, 0xa8, 0x12, 0xaa, 0x83, 0x4a, 0xba, 0x02, 0xa5, 0x4f, 0x00, 0xda + , 0xab, 0x20, 0x07, 0x40, 0x10, 0x86, 0x69, 0x48, 0xd4, 0xb8, 0xf1, 0xff, 0x7f, 0x3a, 0x34, 0xc0 + , 0xc9, 0xb2, 0x95, 0x27, 0x00, 0x64, 0x1c, 0xe0, 0x40, 0xba, 0xd1, 0xb5, 0xab, 0x12, 0xe0, 0x1c + , 0x5e, 0xa3, 0xd8, 0x11, 0x0a, 0x87, 0x19, 0x90, 0xb7, 0x82, 0x88, 0x83, 0x1a, 0x97, 0x00, 0x7a + , 0xeb, 0x8d, 0xd0, 0x77, 0x6a, 0xd2, 0x90, 0x3d, 0x93, 0x83, 0x9c, 0xff, 0x69, 0x87, 0x69, 0x02 + , 0xb6, 0x70, 0xc9, 0x6c, 0x03, 0x6c, 0xc1, 0x7b, 0xd8, 0x30, 0x67, 0xa1, 0x44, 0x27, 0x36, 0xf5 + , 0x68, 0x18, 0x01, 0xac, 0x34, 0x3f, 0xc0, 0x98, 0xae, 0x85, 0x0e, 0x14, 0xc8, 0xf9, 0x18, 0xe0 + , 0x57, 0x95, 0x2c, 0x59, 0xdf, 0x4f, 0x91, 0x03, 0x64, 0x01, 0x5b, 0x93, 0x1b, 0x6f, 0x1b, 0xec + , 0x74, 0xad, 0x60, 0xa4, 0x5f, 0x00, 0x56, 0xac, 0x2d, 0x07, 0x40, 0x10, 0x86, 0x61, 0x8c, 0x18 + , 0x15, 0xb8, 0xff, 0x39, 0x1d, 0x7e, 0x18, 0x9f, 0x5d, 0xd9, 0x12, 0x0f, 0xe0, 0x08, 0x7c, 0xf0 + , 0x45, 0xba, 0xad, 0x6b, 0xf9, 0x3f, 0x01, 0x00, 0x4a, 0x89, 0x5c, 0xc9, 0x66, 0x13, 0x16, 0xbb + , 0x00, 0x76, 0x91, 0x55, 0xb8, 0xab, 0xe0, 0x86, 0x8a, 0xc7, 0x74, 0x0f, 0x55, 0xcf, 0x4e, 0xb9 + , 0x73, 0x78, 0x34, 0xec, 0x79, 0x2a, 0xff, 0xdc, 0x97, 0xd7, 0x3f, 0x5d, 0x70, 0xfb, 0x88, 0x78 + , 0xc2, 0x67, 0x0a, 0x77, 0x96, 0x82, 0xc0, 0x14, 0x98, 0x21, 0x56, 0x4f, 0xa0, 0xb3, 0xd8, 0x69 + , 0xa8, 0xb7, 0x16, 0x88, 0x03, 0x1b, 0x41, 0xe1, 0x8f, 0xa3, 0x2f, 0x84, 0x92, 0x24, 0x8a, 0x64 + , 0xa9, 0x39, 0xa5, 0x5c, 0x0a, 0x9a, 0x36, 0x63, 0x26, 0x41, 0x34, 0xe0, 0x89, 0xd0, 0x62, 0xe7 + , 0x4c, 0x4e, 0x9a, 0xfe, 0xf5, 0xd2, 0xaf, 0x00, 0xac, 0x58, 0x5b, 0x0a, 0xc0, 0x20, 0x0c, 0x2b + , 0x7b, 0xc0, 0xee, 0x7f, 0xd4, 0x22, 0x63, 0xdd, 0x70, 0x5b, 0xd2, 0x07, 0x5e, 0xc0, 0x8a, 0xe2 + , 0x8f, 0x20, 0x89, 0x6d, 0x52, 0x27, 0x13, 0x00, 0xf0, 0x42, 0x5c, 0x51, 0x61, 0x08, 0x3c, 0x43 + , 0x55, 0x39, 0xb1, 0x34, 0x6d, 0x90, 0x59, 0x57, 0x5a, 0xb7, 0x9e, 0x44, 0xdf, 0xb2, 0x13, 0x88 + , 0x0e, 0x8c, 0xe0, 0xdf, 0x04, 0xff, 0xa9, 0xe6, 0x97, 0x5f, 0x11, 0xd5, 0xfd, 0xbe, 0xfd, 0x1b + , 0x06, 0x08, 0x3b, 0x91, 0x14, 0x60, 0x19, 0x3e, 0x34, 0x85, 0x58, 0x96, 0x8a, 0xad, 0xd2, 0xa0 + , 0x08, 0x58, 0xa3, 0x0e, 0x31, 0x0f, 0xe8, 0x76, 0xf6, 0x60, 0x00, 0xaa, 0x7b, 0x61, 0xd8, 0x01 + , 0xb5, 0x3a, 0x5d, 0xa8, 0xc2, 0x20, 0xb8, 0x55, 0xf3, 0x5b, 0x5a, 0xbc, 0x8c, 0x0e, 0x0e, 0x70 + , 0x74, 0x16, 0x62, 0xbf, 0x00, 0xac, 0x58, 0x5b, 0x0a, 0xc0, 0x20, 0x0c, 0x1b, 0x8c, 0x09, 0xc2 + , 0xee, 0x7f, 0xcf, 0x0e, 0x86, 0x2b, 0xb8, 0x47, 0x9a, 0xa8, 0xbb, 0x80, 0x08, 0xfd, 0xd6, 0xa4 + , 0xa6, 0x69, 0x66, 0x12, 0x80, 0x96, 0x3e, 0xa3, 0x89, 0xa2, 0xe9, 0x71, 0xec, 0x30, 0xc0, 0x6e + , 0xd6, 0xaa, 0xcc, 0x0f, 0x1e, 0xe4, 0x45, 0x66, 0xd3, 0x9b, 0xf8, 0xd3, 0x6e, 0x82, 0x85, 0xca + , 0x52, 0x99, 0x47, 0x08, 0x7c, 0x94, 0x57, 0xe6, 0xf3, 0x8f, 0x1f, 0x98, 0xc5, 0x2d, 0xdc, 0x00 + , 0x9e, 0x11, 0x05, 0x29, 0x92, 0xd3, 0x3e, 0xdb, 0x45, 0x68, 0x1d, 0x93, 0x80, 0xf8, 0xf7, 0x59 + , 0xb0, 0x29, 0x8b, 0x10, 0x01, 0x89, 0x22, 0xc4, 0x8f, 0x80, 0x8e, 0x48, 0x17, 0x58, 0xf0, 0x1c + , 0x70, 0x67, 0xdc, 0x2d, 0xfc, 0x41, 0x69, 0x1c, 0xe8, 0xaa, 0xf2, 0x06, 0x7b, 0xbd, 0x21, 0x48 + , 0x58, 0x20, 0xa6, 0x80, 0xf6, 0x09, 0xc0, 0x8a, 0x99, 0x23, 0x01, 0x08, 0xc3, 0x30, 0x70, 0x86 + , 0x9b, 0xff, 0x7f, 0x34, 0x98, 0x02, 0x12, 0x12, 0x40, 0xb6, 0x1c, 0x4a, 0x1a, 0xf8, 0x82, 0x0f + , 0x49, 0xab, 0x7f, 0x16, 0x80, 0xb1, 0xe0, 0xaa, 0x55, 0x73, 0x54, 0xe4, 0x57, 0xb1, 0xd9, 0x07 + , 0x4c, 0x7d, 0x09, 0x12, 0x04, 0xdb, 0xf0, 0xdc, 0xa9, 0xd7, 0xbf, 0x91, 0xbe, 0x68, 0x00, 0x86 + , 0xc0, 0x14, 0x9f, 0x5c, 0x93, 0xe7, 0x61, 0xb2, 0x93, 0x6b, 0xe9, 0x80, 0x25, 0x9c, 0x57, 0x79 + , 0x1a, 0x38, 0xea, 0xce, 0x5b, 0x85, 0x5e, 0xbf, 0xc0, 0x4a, 0x51, 0x03, 0x02, 0xe6, 0xd2, 0xae + , 0x75, 0x42, 0x63, 0x35, 0xe4, 0x5e, 0xdc, 0x0f, 0x51, 0x61, 0x78, 0x8c, 0x2a, 0x43, 0x10, 0x9b + , 0x3d, 0xcd, 0x13, 0xef, 0x22, 0x19, 0x0a, 0x12, 0x4e, 0xd4, 0xaa, 0xa2, 0x53, 0x7a, 0xb1, 0x74 + , 0x00, 0x51, 0x84, 0x39, 0x37, 0x9f, 0x3b, 0x8c, 0x5b, 0x00, 0x56, 0xac, 0x20, 0x05, 0x60, 0x18 + , 0x84, 0xc1, 0xf6, 0xff, 0xb7, 0xb6, 0x3b, 0x2a, 0xb4, 0x34, 0x89, 0x8a, 0xe7, 0xb1, 0x09, 0x3d + , 0xf4, 0x56, 0x8c, 0x49, 0x13, 0x7f, 0x00, 0x00, 0x2a, 0x81, 0xee, 0x4a, 0x73, 0x28, 0xf5, 0x68 + , 0xfa, 0xe4, 0x41, 0x3d, 0x73, 0x0c, 0x09, 0x52, 0xf7, 0xbf, 0x18, 0xad, 0x3c, 0xe6, 0x56, 0xce + , 0x27, 0x56, 0x3e, 0x1d, 0xbb, 0x7a, 0xee, 0x95, 0x79, 0x5f, 0x55, 0x9a, 0x24, 0x10, 0x64, 0xe9 + , 0x2e, 0x49, 0x8a, 0x58, 0x70, 0xf5, 0x9f, 0x9c, 0xeb, 0x21, 0x62, 0xe0, 0x20, 0x83, 0x29, 0xa0 + , 0xb9, 0x11, 0x04, 0xe7, 0x50, 0x04, 0x04, 0x8a, 0xe2, 0x78, 0x70, 0x11, 0x35, 0x13, 0xf9, 0xda + , 0xe9, 0x09, 0x10, 0x24, 0xee, 0x6f, 0xee, 0xe8, 0x08, 0xc0, 0x9a, 0x19, 0xec, 0x00, 0x08, 0x83 + , 0x30, 0xd4, 0x93, 0xff, 0xff, 0xa7, 0xc3, 0x78, 0xd0, 0x19, 0x62, 0x7c, 0x14, 0x66, 0xbc, 0x4f + , 0x0e, 0x9c, 0x96, 0x65, 0xa1, 0xa1, 0x94, 0x6e, 0x16, 0x00, 0x1e, 0xc3, 0xb0, 0x92, 0xbe, 0xd9 + , 0x37, 0x85, 0x51, 0xf5, 0x66, 0xcd, 0x0c, 0x28, 0x8e, 0x60, 0x53, 0x41, 0x70, 0x72, 0xea, 0x2d + , 0x7f, 0x51, 0x7f, 0x11, 0xbf, 0xfb, 0x67, 0xeb, 0xca, 0x81, 0xeb, 0x7f, 0xfe, 0x12, 0x25, 0x73 + , 0xdd, 0x34, 0xd5, 0x92, 0x46, 0xb5, 0xc6, 0xc2, 0xf0, 0x2a, 0xb4, 0x17, 0xac, 0xa4, 0x10, 0x63 + , 0xbd, 0x03, 0x42, 0x5a, 0x20, 0xf2, 0x4a, 0xae, 0x12, 0x64, 0x91, 0xca, 0x9d, 0x1a, 0xd6, 0x20 + , 0x41, 0x8b, 0x72, 0x2f, 0x5b, 0xc3, 0x8c, 0x89, 0xf4, 0x08, 0x40, 0x8b, 0x15, 0xe4, 0x00, 0x08 + , 0xc2, 0x30, 0x09, 0x99, 0xfc, 0xff, 0xa3, 0xec, 0xa4, 0x07, 0x96, 0x19, 0xd7, 0x55, 0x78, 0x80 + , 0x46, 0xc2, 0x03, 0x9a, 0x6e, 0xb4, 0xa5, 0x9f, 0x06, 0x10, 0x20, 0x10, 0x31, 0x21, 0xf7, 0xc1 + , 0x76, 0x68, 0x8e, 0x6a, 0x4f, 0xf2, 0xbb, 0x22, 0x6e, 0x1e, 0xd3, 0xca, 0x4e, 0x4a, 0xe9, 0x53 + , 0x36, 0x70, 0xf7, 0xd3, 0x78, 0x6d, 0x06, 0x4e, 0x76, 0x6d, 0x17, 0x8d, 0xf5, 0xbf, 0x83, 0xf2 + , 0xd5, 0x7d, 0x73, 0x2f, 0xc5, 0xf8, 0x10, 0xa4, 0x56, 0x80, 0x10, 0x09, 0xf3, 0x1f, 0xb6, 0x37 + , 0x84, 0x00, 0xb3, 0x96, 0x59, 0x6c, 0x2c, 0xbe, 0x8d, 0x7b, 0x9f, 0x83, 0xc0, 0xf5, 0x05, 0x37 + , 0x13, 0x71, 0xfc, 0xa1, 0xc3, 0x5a, 0xde, 0x41, 0xba, 0x05, 0x10, 0xf9, 0x11, 0x00, 0x74, 0x1d + , 0xa8, 0xb5, 0x03, 0xae, 0x6c, 0x3f, 0x02, 0xc3, 0xfe, 0xc3, 0xfb, 0x77, 0xef, 0xde, 0xbd, 0x07 + , 0xc1, 0xb7, 0x5f, 0xbf, 0x80, 0xfb, 0x58, 0xdf, 0xa1, 0x1d, 0x5d, 0x48, 0xf1, 0x03, 0x2b, 0x7b + , 0x7e, 0x40, 0x06, 0xda, 0xa0, 0x8d, 0x4e, 0xa8, 0xcf, 0xfe, 0xe1, 0x2f, 0xd6, 0xa9, 0x0e, 0x40 + , 0x31, 0x01, 0x19, 0xe3, 0x06, 0x66, 0x04, 0xe8, 0xc0, 0xec, 0x6f, 0x56, 0x50, 0xd0, 0xff, 0x81 + , 0xb5, 0x84, 0x61, 0xce, 0x83, 0xa7, 0x78, 0x70, 0xc3, 0x00, 0x34, 0x52, 0x0e, 0x2e, 0x82, 0xe0 + , 0x23, 0x53, 0x0c, 0xe0, 0x16, 0x19, 0xb0, 0x1f, 0xc7, 0x4a, 0x56, 0x3e, 0x00, 0x08, 0x20, 0x32 + , 0x23, 0x00, 0xe8, 0x3e, 0x50, 0x95, 0xfb, 0xe5, 0x0b, 0xb8, 0xcc, 0x01, 0x15, 0x3a, 0xc0, 0xd0 + , 0x7f, 0x0b, 0x8c, 0x80, 0xf7, 0xef, 0x21, 0x3d, 0x5d, 0x50, 0xf2, 0x87, 0x0e, 0x33, 0x7c, 0xfb + , 0x81, 0x14, 0xfc, 0x90, 0x7e, 0x2f, 0xc4, 0x87, 0x90, 0x74, 0x4f, 0x9e, 0x03, 0xa8, 0x05, 0x60 + , 0x61, 0xfb, 0x87, 0x05, 0x08, 0xff, 0xc0, 0x66, 0x81, 0xfe, 0x40, 0x3b, 0xe3, 0x7f, 0xff, 0xc0 + , 0xc6, 0xa3, 0x20, 0x49, 0x1e, 0x14, 0xf0, 0xa0, 0x60, 0x87, 0x54, 0x52, 0xf0, 0xf6, 0x30, 0x24 + , 0xed, 0x70, 0x73, 0x03, 0xcb, 0x22, 0x92, 0xf3, 0x01, 0x40, 0x00, 0x91, 0x13, 0x01, 0xa0, 0x92 + , 0xe7, 0xeb, 0x37, 0x50, 0xe8, 0x7f, 0xfa, 0x08, 0x2e, 0x6f, 0x40, 0x81, 0xff, 0xf6, 0x2d, 0x28 + , 0xf4, 0xc1, 0x43, 0x0c, 0xa0, 0x51, 0x06, 0xd0, 0x90, 0x03, 0x38, 0xfc, 0xc1, 0x81, 0x0f, 0x22 + , 0x20, 0x2d, 0x39, 0x20, 0xfe, 0x03, 0x69, 0x6d, 0xfe, 0xfd, 0x43, 0xdf, 0x44, 0x8f, 0x0f, 0xfc + , 0x01, 0x57, 0x3e, 0x2c, 0x90, 0x99, 0x37, 0x10, 0x87, 0xed, 0x0f, 0x6c, 0x22, 0xee, 0x0f, 0xb4 + , 0x23, 0x8e, 0xd4, 0x2a, 0x00, 0x4d, 0x51, 0xff, 0xfb, 0x0b, 0x1b, 0x93, 0x85, 0x0c, 0x8b, 0x03 + , 0xfb, 0x21, 0xc0, 0x06, 0x11, 0x30, 0x1f, 0x00, 0x6b, 0x16, 0x92, 0xac, 0x06, 0x08, 0x20, 0x92 + , 0x23, 0x00, 0xe8, 0x10, 0x60, 0xa8, 0x02, 0xc3, 0x19, 0xd8, 0xba, 0x07, 0x85, 0x3e, 0x30, 0xe8 + , 0xc1, 0xc1, 0x0f, 0x64, 0x83, 0x87, 0x18, 0xa0, 0xc9, 0x1f, 0x54, 0x02, 0x41, 0x4a, 0x1f, 0x68 + , 0xb7, 0x0b, 0xdc, 0xf2, 0x81, 0x8e, 0xb5, 0xfd, 0xa5, 0x75, 0x59, 0x4f, 0x0e, 0xf8, 0x0f, 0x4a + , 0x58, 0xff, 0x20, 0x03, 0x7f, 0x7f, 0xa0, 0x81, 0xfe, 0x0f, 0x36, 0x35, 0xfd, 0xef, 0xcf, 0x3f + , 0x44, 0x7f, 0xe4, 0x1f, 0x68, 0x55, 0x00, 0x6c, 0x4d, 0x00, 0x74, 0x3c, 0x0a, 0xb2, 0x26, 0x80 + , 0x81, 0x91, 0x89, 0x87, 0x9b, 0x0b, 0xd8, 0xd6, 0x22, 0xde, 0x5a, 0x80, 0x00, 0x22, 0x2d, 0x02 + , 0x80, 0x36, 0x82, 0x87, 0x18, 0x80, 0x6d, 0x1e, 0x68, 0xc9, 0x03, 0x4c, 0xf7, 0xc0, 0xd0, 0x87 + , 0xa4, 0x7d, 0xf0, 0x30, 0x03, 0x08, 0x02, 0xfb, 0xc1, 0xe0, 0xd4, 0xff, 0xf5, 0x3b, 0x78, 0xdc + , 0xff, 0x27, 0x64, 0x84, 0x1f, 0xd2, 0x88, 0x1e, 0xe8, 0x32, 0x07, 0x3f, 0x00, 0x06, 0x2c, 0x28 + , 0x81, 0x80, 0x12, 0x39, 0x6c, 0x0c, 0xea, 0x2f, 0xa8, 0xad, 0x03, 0x0a, 0xfd, 0xff, 0x7f, 0xe1 + , 0xc3, 0xe0, 0xf0, 0xc2, 0x07, 0xa4, 0x87, 0x91, 0x91, 0x11, 0xa9, 0xeb, 0x01, 0x6c, 0xf2, 0x72 + , 0x73, 0x71, 0x11, 0x3f, 0xdb, 0x0c, 0x10, 0x40, 0xa4, 0x45, 0x00, 0xb0, 0x24, 0x01, 0x26, 0xed + , 0x4f, 0x9f, 0x3f, 0x81, 0xda, 0xf8, 0xa0, 0x5a, 0x17, 0x98, 0xfa, 0xdf, 0x7c, 0x00, 0x87, 0x3e + , 0x78, 0x9c, 0xed, 0x0b, 0x74, 0xc0, 0x13, 0x5a, 0xf7, 0x7e, 0x83, 0xb5, 0xf9, 0x41, 0x6d, 0x1e + , 0x60, 0xed, 0xf5, 0x6f, 0x10, 0x26, 0x7c, 0x6c, 0x00, 0xbc, 0x10, 0x03, 0x29, 0xc1, 0x83, 0x02 + , 0xff, 0x3f, 0x78, 0xb5, 0xc6, 0x7f, 0x06, 0x94, 0xde, 0x20, 0x23, 0x6c, 0x31, 0x06, 0xac, 0xa3 + , 0x01, 0xeb, 0x7d, 0x73, 0x71, 0x71, 0x11, 0x69, 0x17, 0x40, 0x00, 0x91, 0x10, 0x01, 0xc0, 0x84 + , 0x0c, 0x4c, 0xd4, 0xa0, 0xc1, 0x1d, 0x60, 0x8b, 0xf3, 0x03, 0xb0, 0xe8, 0xff, 0x00, 0xaa, 0x74 + , 0x3f, 0x00, 0x4b, 0x1e, 0xc8, 0xf8, 0xe6, 0x17, 0x70, 0x05, 0xf0, 0x15, 0xd2, 0xfa, 0x84, 0x8e + , 0x3a, 0xfc, 0x00, 0x25, 0x7e, 0x60, 0x13, 0x1a, 0x58, 0xe8, 0x93, 0x13, 0x12, 0x03, 0x07, 0x80 + , 0x41, 0x0c, 0xac, 0xb1, 0xa0, 0x7d, 0xba, 0x7f, 0x90, 0xe1, 0x6f, 0xd8, 0x48, 0x38, 0x03, 0x6c + , 0x14, 0x16, 0xba, 0x14, 0x83, 0x01, 0xdc, 0xd1, 0x03, 0x8f, 0x76, 0x30, 0x32, 0xb1, 0x40, 0xd6 + , 0xbe, 0x30, 0x33, 0x11, 0x39, 0x56, 0x01, 0x10, 0x40, 0xc4, 0x46, 0x00, 0xb0, 0xf4, 0x00, 0x16 + , 0xea, 0xa0, 0xc1, 0xcc, 0x4f, 0xe0, 0xd2, 0x07, 0x98, 0xec, 0xdf, 0xbd, 0x05, 0xb7, 0x79, 0xc0 + , 0x65, 0xcf, 0x17, 0x58, 0xdb, 0x07, 0x3c, 0xfc, 0xfc, 0xe3, 0xdb, 0x37, 0x78, 0xb3, 0x07, 0xd2 + , 0x96, 0x23, 0x3b, 0x20, 0x06, 0x16, 0x00, 0x1d, 0x0f, 0xce, 0x02, 0x90, 0xb1, 0x3f, 0xa4, 0x19 + , 0x08, 0x06, 0x06, 0xa4, 0x81, 0x3f, 0xf0, 0x42, 0x24, 0x70, 0xb8, 0x83, 0x46, 0x9b, 0x58, 0xa1 + , 0x7d, 0x6d, 0x66, 0x26, 0x66, 0x62, 0xc6, 0xec, 0x00, 0x02, 0x88, 0xa8, 0x08, 0x00, 0xe6, 0x46 + , 0x60, 0x82, 0x86, 0x8c, 0x6f, 0x7e, 0x00, 0xa5, 0x7e, 0x50, 0xda, 0x07, 0x86, 0x3f, 0x52, 0xaa + , 0x07, 0xb6, 0xfc, 0xbf, 0x7c, 0x05, 0xcf, 0x70, 0x41, 0x26, 0x18, 0x41, 0x33, 0x5c, 0xe0, 0x62 + , 0x1f, 0x58, 0x84, 0x52, 0x12, 0x04, 0x03, 0x0e, 0x80, 0xc5, 0x11, 0x34, 0x27, 0xfc, 0x43, 0x6e + , 0xb5, 0xfd, 0x87, 0x0c, 0xfd, 0x31, 0xc2, 0x26, 0x21, 0xc0, 0xb3, 0x9f, 0xe0, 0xf9, 0x06, 0x66 + , 0x56, 0x56, 0xd8, 0x78, 0x13, 0x64, 0x81, 0x06, 0x7e, 0xf3, 0x01, 0x02, 0x88, 0xa8, 0x08, 0xf8 + , 0x09, 0x1a, 0xa1, 0x05, 0xf6, 0xb9, 0xbe, 0x7e, 0x82, 0xf4, 0xb9, 0xde, 0x83, 0xaa, 0x5f, 0xe8 + , 0x84, 0x16, 0xa4, 0xc8, 0x07, 0x91, 0x90, 0xa9, 0x45, 0x50, 0xab, 0x1f, 0xd2, 0xe6, 0x01, 0xf6 + , 0xb5, 0xc8, 0x18, 0xc9, 0x19, 0x84, 0x00, 0x58, 0x11, 0x03, 0x0b, 0x24, 0x06, 0xc8, 0x10, 0x2c + , 0x08, 0x80, 0xc7, 0xbf, 0x61, 0xcb, 0x1f, 0x21, 0xa5, 0x3e, 0x64, 0x70, 0x83, 0x15, 0x3a, 0xc0 + , 0x04, 0x1a, 0xdf, 0x00, 0xd2, 0xc0, 0x38, 0x21, 0x58, 0x19, 0x00, 0x04, 0x10, 0xe1, 0x08, 0x00 + , 0x36, 0xdd, 0x41, 0xed, 0x4e, 0x50, 0xf2, 0xff, 0x04, 0x2a, 0xfd, 0x41, 0x4d, 0x7f, 0xe8, 0x48 + , 0x03, 0xb8, 0xb9, 0x0f, 0x29, 0x75, 0xbe, 0x7e, 0x83, 0x0f, 0x77, 0xc2, 0x06, 0x6f, 0x87, 0x47 + , 0xe8, 0x43, 0x00, 0xb0, 0x4e, 0x06, 0xe6, 0x03, 0x10, 0x0b, 0x3a, 0xed, 0x00, 0x1d, 0xe2, 0x83 + , 0x54, 0xba, 0xcc, 0x90, 0xa9, 0x1f, 0x66, 0x16, 0xe8, 0x1a, 0x23, 0xc8, 0xc2, 0x23, 0xf0, 0x92 + , 0x30, 0x66, 0x16, 0x16, 0x76, 0xbc, 0xf3, 0x68, 0x00, 0x01, 0x44, 0x20, 0x02, 0xc0, 0xd3, 0x5b + , 0xdf, 0x21, 0x43, 0x0e, 0xa0, 0x61, 0x7d, 0xf0, 0x58, 0x27, 0xb0, 0x1a, 0x80, 0x84, 0xfc, 0xb7 + , 0x2f, 0x5f, 0xbe, 0x41, 0xc2, 0x1e, 0x3c, 0xe2, 0x86, 0x98, 0xbb, 0x18, 0x5e, 0xa1, 0x0f, 0x01 + , 0x40, 0x1f, 0x01, 0xfd, 0xc5, 0x00, 0xa9, 0x7a, 0x99, 0x18, 0x20, 0x4d, 0x4e, 0xf0, 0xfa, 0x17 + , 0x66, 0xe8, 0xd4, 0x27, 0xb8, 0xfe, 0x05, 0x47, 0x00, 0x3b, 0x08, 0xb1, 0xb2, 0xb1, 0xb2, 0xb3 + , 0x83, 0xe7, 0x40, 0x59, 0xf0, 0xcc, 0x27, 0x03, 0x04, 0x10, 0x81, 0x08, 0x00, 0x06, 0x27, 0x30 + , 0x65, 0x83, 0xc7, 0xf9, 0x41, 0xb3, 0x5a, 0xe0, 0xd6, 0xe7, 0x07, 0x48, 0x59, 0xff, 0x0d, 0x5e + , 0xde, 0x43, 0x06, 0x1a, 0xc0, 0x83, 0xfc, 0xe0, 0x72, 0xff, 0xe7, 0xf0, 0x0b, 0x7d, 0x08, 0x00 + , 0xc5, 0xc1, 0xef, 0xdf, 0xf0, 0x66, 0x3f, 0xac, 0xf0, 0x81, 0xa5, 0x7f, 0xf0, 0x18, 0xf7, 0x47 + , 0x96, 0x8f, 0xec, 0xd0, 0xa5, 0x5e, 0xe0, 0xf9, 0x66, 0xf0, 0xaa, 0x30, 0x2e, 0x4e, 0x9c, 0x05 + , 0x11, 0x40, 0x00, 0xe1, 0x8b, 0x00, 0x60, 0xfb, 0x05, 0x58, 0x97, 0x02, 0x43, 0xfa, 0x33, 0x64 + , 0xb4, 0x19, 0x34, 0xaf, 0xf5, 0xf1, 0x1b, 0x0c, 0x7c, 0x87, 0x91, 0xdf, 0x7f, 0x40, 0xdb, 0x9c + , 0x90, 0xb9, 0xdd, 0xe1, 0x1a, 0xfa, 0x10, 0x00, 0xec, 0x92, 0x01, 0x9b, 0x46, 0xf0, 0xf9, 0x4e + , 0x26, 0xd8, 0xac, 0x3f, 0x64, 0x82, 0x01, 0x32, 0xeb, 0x0f, 0x0c, 0x27, 0xc8, 0xaa, 0x2f, 0x0e + , 0x0e, 0xf0, 0xea, 0x47, 0x36, 0x76, 0xf0, 0xfa, 0x3c, 0xec, 0x41, 0x0d, 0x10, 0x40, 0xf8, 0x22 + , 0xe0, 0xd7, 0x2f, 0xd0, 0x28, 0x3e, 0xa8, 0x6b, 0x0b, 0x2c, 0x7f, 0x40, 0x81, 0xff, 0x09, 0xd8 + , 0x08, 0x85, 0x34, 0xf1, 0xe1, 0xe1, 0x0e, 0xce, 0x00, 0xa0, 0x0e, 0x2f, 0x64, 0x6e, 0x0b, 0xd8 + , 0x66, 0xa0, 0x8d, 0xc7, 0x07, 0x11, 0x00, 0xb6, 0xaa, 0xe1, 0xeb, 0xc0, 0x20, 0xcb, 0x20, 0x61 + , 0xab, 0x5e, 0x58, 0x41, 0x2d, 0x20, 0x70, 0x24, 0x70, 0x7c, 0xe4, 0x04, 0x86, 0x3e, 0x08, 0x73 + , 0x70, 0xb2, 0x71, 0xb0, 0x83, 0x57, 0x22, 0xf1, 0x60, 0x35, 0x0d, 0x20, 0x80, 0x70, 0x46, 0x00 + , 0xb0, 0xbc, 0x03, 0x06, 0x2c, 0x78, 0xd8, 0xe7, 0x0b, 0x64, 0x3d, 0x03, 0xb0, 0x08, 0x02, 0x86 + , 0x36, 0x64, 0x76, 0xeb, 0x1b, 0xa8, 0x5d, 0x04, 0x99, 0x2d, 0xfd, 0x01, 0x5d, 0x53, 0x0b, 0x1e + , 0xc1, 0xa5, 0x99, 0xaf, 0x07, 0x17, 0x00, 0xfa, 0x95, 0x89, 0xf1, 0x17, 0xa4, 0xfc, 0x81, 0xac + , 0x74, 0x87, 0x2e, 0x04, 0x06, 0xaf, 0xbc, 0x06, 0xd6, 0xc4, 0xc0, 0xf4, 0x0a, 0x5a, 0xf2, 0x05 + , 0x5e, 0xcc, 0xc2, 0x09, 0xc9, 0x09, 0x60, 0x80, 0x69, 0x14, 0x40, 0x00, 0xe1, 0x88, 0x80, 0xff + , 0xff, 0x81, 0x09, 0xfa, 0x3b, 0x64, 0xdc, 0x07, 0x12, 0x01, 0x9f, 0x3e, 0x7f, 0x87, 0x04, 0x39 + , 0x2c, 0xd9, 0xc3, 0x66, 0x57, 0xc0, 0xbd, 0x2d, 0xf0, 0x38, 0x0f, 0x6d, 0x3d, 0x3d, 0xc8, 0x00 + , 0xb0, 0x7b, 0xc9, 0xf4, 0xfb, 0x17, 0x13, 0x33, 0x3c, 0x07, 0x80, 0x92, 0x3e, 0x64, 0xed, 0x35 + , 0x24, 0xac, 0x81, 0xe9, 0x15, 0xbc, 0xda, 0x11, 0x18, 0x07, 0x5c, 0xe0, 0x28, 0xc0, 0xbe, 0xde + , 0x14, 0x20, 0x80, 0xb0, 0x47, 0x00, 0x68, 0x46, 0xee, 0x27, 0xb8, 0xfc, 0xf9, 0x0a, 0x2e, 0x81 + , 0xc0, 0x2b, 0x7b, 0xbe, 0xc3, 0xc1, 0x0f, 0xe8, 0x38, 0xc3, 0xcf, 0x1f, 0x3f, 0xa1, 0x73, 0xd7 + , 0x7f, 0x7e, 0xff, 0x1f, 0xd6, 0x45, 0x3f, 0x26, 0x00, 0x56, 0x75, 0xbf, 0x7f, 0xfd, 0x61, 0x64 + , 0xfa, 0xcd, 0xc2, 0xf4, 0x93, 0x05, 0x69, 0xc9, 0x11, 0x3c, 0x06, 0x80, 0x41, 0xc6, 0xcd, 0xfd + , 0x99, 0x1b, 0xb4, 0xdc, 0x91, 0x0b, 0xb2, 0xe0, 0x14, 0xb2, 0x08, 0x0c, 0xcd, 0x1c, 0x80, 0x00 + , 0xc2, 0x16, 0x01, 0xff, 0x19, 0xc0, 0xc9, 0x1f, 0x54, 0xff, 0x42, 0xd3, 0xff, 0xe7, 0xcf, 0x3f + , 0x7e, 0x40, 0x92, 0x3d, 0x7c, 0x9d, 0x0c, 0x74, 0x66, 0x11, 0x32, 0x6f, 0xfa, 0xf7, 0xcf, 0xd0 + , 0xee, 0xee, 0x92, 0x07, 0xfe, 0xfc, 0xfd, 0xc3, 0xf8, 0x9b, 0xf1, 0x17, 0x30, 0x13, 0xfc, 0x04 + , 0xe7, 0x00, 0x36, 0xd6, 0x1f, 0x3f, 0x20, 0x11, 0xc0, 0xfa, 0x1d, 0xb4, 0xe4, 0x8e, 0x03, 0x18 + , 0x6e, 0xa0, 0x05, 0x8e, 0x5c, 0x20, 0xf4, 0x9d, 0xf3, 0x3b, 0x3b, 0x27, 0xb0, 0x59, 0x8a, 0x9e + , 0x09, 0x00, 0x02, 0x08, 0x4b, 0xfb, 0x14, 0xb4, 0x86, 0xfc, 0xd7, 0x4f, 0x60, 0x58, 0x03, 0x5b + , 0xfa, 0xe0, 0xe9, 0x15, 0xd0, 0x70, 0x03, 0xb0, 0x87, 0x0b, 0x5e, 0x3b, 0x0e, 0x2f, 0x75, 0xa0 + , 0xcb, 0xc7, 0x21, 0xbb, 0x58, 0xe8, 0xe4, 0xe3, 0xc1, 0x07, 0xfe, 0x80, 0xa7, 0x92, 0x21, 0x0b + , 0xcb, 0xa0, 0xbb, 0x1c, 0x40, 0x0b, 0x9f, 0x20, 0x8c, 0xef, 0xe0, 0x11, 0x32, 0x50, 0x5f, 0xe9 + , 0x2b, 0x78, 0x70, 0x0c, 0x54, 0x60, 0x60, 0x84, 0x15, 0x40, 0x00, 0x61, 0x89, 0x00, 0xa0, 0x22 + , 0x90, 0x21, 0x90, 0x76, 0x26, 0x78, 0xde, 0x11, 0xba, 0xa0, 0xff, 0x07, 0x64, 0x31, 0x09, 0x64 + , 0x80, 0x19, 0xbc, 0x48, 0x06, 0x9c, 0xfc, 0xff, 0x8d, 0xe0, 0x8d, 0xae, 0xe0, 0xb9, 0xe5, 0xbf + , 0xe0, 0xd5, 0xad, 0xe0, 0xe9, 0x3e, 0x48, 0x48, 0xfd, 0xfc, 0x0e, 0x0d, 0xaf, 0x1f, 0x3f, 0xc1 + , 0xe3, 0x94, 0xa0, 0x28, 0x00, 0xd6, 0xa7, 0x3f, 0xc0, 0xc3, 0xf2, 0x68, 0x26, 0x00, 0x04, 0x10 + , 0x7a, 0x04, 0x00, 0x8d, 0x03, 0x2f, 0x9c, 0xfa, 0x0e, 0x5e, 0x51, 0x02, 0x9d, 0xdc, 0x02, 0xa7 + , 0x79, 0xd8, 0xd0, 0x3e, 0xac, 0xd1, 0xf3, 0x0b, 0xb6, 0x64, 0x80, 0x5e, 0x9e, 0x1d, 0xa4, 0x00 + , 0x1c, 0x08, 0xa0, 0x49, 0x6e, 0xe8, 0xac, 0xd3, 0x2f, 0x70, 0xd9, 0x0c, 0x49, 0xad, 0x3f, 0x7e + , 0x7c, 0x85, 0x4e, 0xd1, 0x82, 0xf2, 0x00, 0x30, 0x5e, 0x80, 0xb2, 0x7f, 0x51, 0x43, 0x0c, 0x20 + , 0x80, 0xd0, 0x23, 0x00, 0x5c, 0xfe, 0xfc, 0x02, 0x16, 0xf5, 0xdf, 0xc0, 0x4b, 0xf9, 0xc1, 0xa1 + , 0x0f, 0x2e, 0x6f, 0x7e, 0x80, 0xe7, 0xd3, 0x61, 0x4b, 0xc9, 0x41, 0x6b, 0x36, 0x40, 0xb6, 0x8e + , 0xc4, 0xa2, 0x1f, 0x13, 0x80, 0x16, 0x53, 0x82, 0x83, 0x04, 0x92, 0x0b, 0xc0, 0x39, 0xe1, 0x27 + , 0xac, 0x67, 0xfa, 0x0b, 0x31, 0x48, 0x0c, 0xd9, 0xfd, 0x83, 0x5a, 0x0a, 0x01, 0x04, 0x10, 0x4a + , 0x04, 0x40, 0x66, 0x21, 0x7e, 0x41, 0x1a, 0xa0, 0x60, 0x00, 0x8c, 0x38, 0x70, 0xc4, 0x82, 0x0c + , 0x83, 0xec, 0xdd, 0x82, 0xad, 0xe4, 0xff, 0x0d, 0x5e, 0x42, 0x38, 0xd2, 0x93, 0x3f, 0x04, 0xfc + , 0x85, 0xae, 0x6b, 0xf9, 0x0d, 0x59, 0xe4, 0x0a, 0xdb, 0xf1, 0x00, 0x59, 0x7f, 0xfc, 0x13, 0xba + , 0xd4, 0x17, 0x1c, 0x01, 0x40, 0x2e, 0x50, 0x19, 0xf2, 0xe6, 0x2a, 0x80, 0x00, 0x42, 0x89, 0x00 + , 0x70, 0x5f, 0xea, 0x17, 0xa4, 0xa5, 0x03, 0x89, 0x03, 0xd0, 0x5a, 0xc9, 0x9f, 0xd0, 0x65, 0x9c + , 0xbf, 0x21, 0x4b, 0x09, 0xe1, 0x8b, 0x4a, 0x46, 0x64, 0xcb, 0x07, 0x17, 0x80, 0x2c, 0x2e, 0xfb + , 0xfd, 0x0b, 0xba, 0xae, 0x0e, 0x52, 0x5c, 0x80, 0x96, 0x96, 0x82, 0x56, 0xe1, 0xff, 0x02, 0xd5 + , 0x01, 0xdf, 0x20, 0x03, 0xc5, 0x3f, 0x20, 0x8b, 0x01, 0xe1, 0x1a, 0x01, 0x02, 0x88, 0x09, 0xd5 + , 0x14, 0x90, 0x09, 0x60, 0x3d, 0xd0, 0xe1, 0x86, 0x9f, 0x30, 0xe3, 0xc0, 0x85, 0x3e, 0xb4, 0xc3 + , 0x05, 0x5b, 0x3c, 0x3e, 0x9a, 0xfc, 0x11, 0x00, 0xb4, 0x92, 0xe2, 0x37, 0x74, 0x95, 0x25, 0xb8 + , 0x59, 0xf4, 0x1b, 0xba, 0xe8, 0x1e, 0x5c, 0x2b, 0x40, 0x36, 0xc2, 0x41, 0xd6, 0x27, 0xfc, 0x44 + , 0x2d, 0x85, 0x00, 0x02, 0x08, 0x11, 0x01, 0xff, 0xc0, 0xbb, 0x18, 0x7f, 0x42, 0xab, 0x60, 0xc8 + , 0x00, 0xdb, 0x77, 0x48, 0x44, 0xfe, 0x86, 0x6d, 0xd9, 0x85, 0xac, 0x61, 0x1e, 0xad, 0x7b, 0xb1 + , 0x02, 0xd0, 0xd2, 0x45, 0xe8, 0xee, 0x9e, 0x5f, 0xb0, 0xac, 0x00, 0x2e, 0x37, 0x80, 0x09, 0xfa + , 0x1b, 0xa4, 0x0f, 0x05, 0xde, 0x12, 0xf1, 0xeb, 0x27, 0x50, 0x01, 0xbc, 0xe9, 0x08, 0x10, 0x40 + , 0x88, 0x08, 0x00, 0x45, 0xe1, 0x6f, 0x68, 0xde, 0x81, 0xf4, 0xb6, 0x60, 0xab, 0x37, 0x21, 0xc5 + , 0xfe, 0xaf, 0x3f, 0xa0, 0xf5, 0x54, 0xbf, 0x20, 0x6b, 0xb3, 0x87, 0xf7, 0x90, 0x27, 0x79, 0xe0 + , 0x1f, 0x78, 0x41, 0xfd, 0x1f, 0x70, 0x18, 0x41, 0x0a, 0xf3, 0x5f, 0xf0, 0xb8, 0x80, 0x14, 0xec + , 0x90, 0xf1, 0x1b, 0xd0, 0xba, 0xd8, 0x3f, 0xff, 0x60, 0x29, 0x18, 0x20, 0x80, 0x10, 0x11, 0x00 + , 0x0e, 0xff, 0xdf, 0xd0, 0xba, 0xe3, 0x07, 0xa8, 0x27, 0x0c, 0x5d, 0xbe, 0x09, 0x69, 0xef, 0x40 + , 0xb7, 0xaf, 0x40, 0x57, 0xec, 0x8d, 0x46, 0x00, 0x26, 0xf8, 0xf7, 0xff, 0x1f, 0x6c, 0x37, 0x39 + , 0x28, 0xb4, 0xa0, 0x1b, 0x7f, 0x60, 0xcb, 0x7c, 0xbf, 0xc3, 0x67, 0xab, 0x7e, 0x42, 0xc2, 0x14 + , 0x1a, 0x01, 0x00, 0x01, 0x84, 0x94, 0x03, 0x20, 0x91, 0x06, 0xae, 0x37, 0xc0, 0xbd, 0xad, 0xef + , 0xbf, 0x7f, 0x23, 0x0a, 0x1f, 0xe8, 0x6a, 0xc9, 0xdf, 0xd0, 0xc5, 0xfb, 0x03, 0xe4, 0xc7, 0xc1 + , 0x0e, 0x40, 0x4b, 0xe9, 0x20, 0x5b, 0x0b, 0xa1, 0x1b, 0x1e, 0xa0, 0x6b, 0x7c, 0xc1, 0x87, 0x31 + , 0x20, 0x76, 0xda, 0x40, 0xd6, 0x66, 0x42, 0xb4, 0x00, 0x04, 0x10, 0x34, 0x02, 0x40, 0xf3, 0x0c + , 0x7f, 0xc0, 0x6d, 0xd9, 0x9f, 0xbf, 0x7f, 0xfd, 0x84, 0xad, 0x22, 0x04, 0x17, 0xf8, 0xb0, 0x3d + , 0xa3, 0x90, 0xdd, 0x13, 0xbf, 0x21, 0x8b, 0x24, 0x07, 0xce, 0x8f, 0x83, 0x1a, 0xfc, 0x83, 0xc4 + , 0xc0, 0x6f, 0x68, 0x7d, 0x0c, 0x5b, 0x69, 0x0d, 0xdd, 0x62, 0x00, 0x69, 0xe2, 0x83, 0x82, 0x18 + , 0x1a, 0x98, 0xa0, 0x60, 0x04, 0x08, 0x20, 0x68, 0x04, 0x80, 0x34, 0x82, 0xc3, 0x1b, 0xd2, 0x9f + , 0x06, 0x45, 0x00, 0xec, 0x00, 0x13, 0xc4, 0x02, 0x6d, 0xd8, 0x8e, 0xd1, 0xd1, 0x43, 0xb6, 0x70 + , 0x01, 0xc8, 0xfa, 0x2d, 0xf0, 0xda, 0xd2, 0xbf, 0xe0, 0x63, 0x77, 0xfe, 0xc2, 0xb7, 0x3c, 0x03 + , 0xc3, 0x12, 0x36, 0x82, 0xf6, 0xeb, 0xf7, 0x2f, 0xe8, 0x36, 0x74, 0xa0, 0x16, 0x80, 0x00, 0x82 + , 0x45, 0x00, 0xf8, 0x5c, 0x1e, 0x48, 0x91, 0x03, 0xe9, 0x52, 0xff, 0x85, 0xec, 0x15, 0xfd, 0x0d + , 0xdd, 0x2f, 0x8d, 0x7c, 0x54, 0xc9, 0x80, 0xfa, 0x71, 0xb0, 0x03, 0xf8, 0xb9, 0x16, 0xe0, 0x50 + , 0x03, 0x57, 0xac, 0xd0, 0x9a, 0x01, 0x7c, 0x04, 0x0c, 0x64, 0x9f, 0x13, 0x58, 0xec, 0x1f, 0xb8 + , 0x24, 0x07, 0x08, 0x20, 0x68, 0x04, 0xfc, 0x81, 0x86, 0xf5, 0x6f, 0xc8, 0xd6, 0x09, 0xd8, 0xce + , 0x21, 0xc8, 0xee, 0x09, 0xd8, 0x69, 0x49, 0x90, 0x55, 0xd9, 0xa3, 0x11, 0x80, 0x17, 0x40, 0x8e + , 0xf5, 0x82, 0xef, 0xf2, 0x04, 0xe7, 0x05, 0xe8, 0x16, 0x9b, 0x9f, 0xb0, 0x5d, 0x29, 0xd0, 0xc0 + , 0x05, 0x2f, 0x59, 0x03, 0x08, 0x20, 0x50, 0x04, 0x80, 0x32, 0xce, 0x5f, 0x70, 0x0e, 0x00, 0x8d + , 0x69, 0x80, 0xca, 0x21, 0xc8, 0x86, 0x04, 0x78, 0xd8, 0xff, 0x81, 0x2e, 0x90, 0x07, 0x1f, 0x15 + , 0x33, 0x1a, 0x01, 0x78, 0x01, 0x28, 0xfc, 0xff, 0x43, 0xf2, 0x00, 0x24, 0x0a, 0x60, 0x61, 0x09 + , 0xa9, 0x9e, 0xc1, 0x6d, 0x23, 0x48, 0xd2, 0xfe, 0xf7, 0x07, 0xb4, 0xdf, 0x1f, 0x20, 0x80, 0x20 + , 0x11, 0x00, 0x8d, 0x33, 0x68, 0x2f, 0x02, 0xdc, 0xd1, 0xfd, 0x0b, 0xdd, 0x99, 0xf0, 0xef, 0x2f + , 0x52, 0xea, 0x07, 0x2d, 0xd2, 0x1e, 0x68, 0x1f, 0x0e, 0x7e, 0x00, 0x89, 0x01, 0x10, 0xf8, 0xf3 + , 0xef, 0x2f, 0x3c, 0x13, 0x80, 0xe3, 0x01, 0xd2, 0x45, 0x80, 0x6c, 0x85, 0x86, 0x24, 0x68, 0x80 + , 0x00, 0x02, 0x45, 0xc0, 0x3f, 0x78, 0x7c, 0xfd, 0x81, 0x56, 0x19, 0xe0, 0x9d, 0x09, 0x7f, 0x61 + , 0x25, 0xcf, 0xdf, 0x7f, 0x14, 0x6c, 0x1a, 0x1d, 0x81, 0xe0, 0x3f, 0xe4, 0x48, 0x8b, 0x7f, 0x88 + , 0xad, 0x35, 0xd0, 0xd3, 0x8e, 0xfe, 0xfe, 0x45, 0x6a, 0xd0, 0x80, 0x02, 0x17, 0xa8, 0x10, 0x20 + , 0x80, 0x40, 0x11, 0x00, 0x39, 0x83, 0x0d, 0xda, 0x82, 0x85, 0xed, 0x46, 0xfb, 0x0f, 0x2b, 0x73 + , 0xfe, 0x41, 0x4b, 0xb5, 0xbf, 0xd0, 0x0d, 0x69, 0xa3, 0x80, 0x10, 0x80, 0x1c, 0x66, 0x81, 0x48 + , 0xb3, 0x90, 0x28, 0x00, 0x85, 0xe8, 0xbf, 0x3f, 0xc8, 0xc1, 0x0f, 0x0e, 0x53, 0x80, 0x00, 0x02 + , 0x17, 0x41, 0xd0, 0xd3, 0xa8, 0xfe, 0x82, 0x8f, 0xc5, 0x03, 0xe5, 0x15, 0xa8, 0x2e, 0xf0, 0xee + , 0x5a, 0xf8, 0x09, 0x31, 0xff, 0x50, 0x0f, 0xa9, 0x1a, 0x05, 0xb8, 0x00, 0x74, 0x2f, 0xc1, 0xdf + , 0xff, 0xd0, 0xa4, 0x0b, 0x0d, 0xdd, 0x3f, 0xc0, 0x92, 0xfe, 0xcf, 0x1f, 0x78, 0xc9, 0xfe, 0x0f + , 0x52, 0xa1, 0x02, 0x04, 0x10, 0xb8, 0x08, 0x02, 0xe7, 0x19, 0x58, 0x69, 0x03, 0x3e, 0x25, 0xe0 + , 0x3f, 0x54, 0x33, 0xf4, 0x74, 0x3c, 0xc8, 0x1a, 0x79, 0xd8, 0x71, 0xa9, 0xa3, 0x00, 0x3f, 0x80 + , 0x6d, 0x61, 0x42, 0x3a, 0xe0, 0x0b, 0xb6, 0xb7, 0xef, 0x2f, 0xfc, 0x04, 0x4e, 0x48, 0xe0, 0xfe + , 0xfb, 0x0f, 0x10, 0x40, 0xe0, 0x66, 0x28, 0xf4, 0x10, 0x0c, 0x68, 0x2c, 0x80, 0x25, 0x80, 0xbd + , 0x34, 0x48, 0xe0, 0x43, 0xf6, 0x25, 0x80, 0x63, 0x93, 0x61, 0x34, 0xfc, 0x89, 0x02, 0x28, 0xdb + , 0x69, 0xe0, 0x87, 0x4b, 0xfd, 0x87, 0x6e, 0x77, 0xfa, 0x0f, 0xa9, 0x13, 0xa0, 0x27, 0xaf, 0xfd + , 0x03, 0x08, 0x20, 0x48, 0x25, 0x0c, 0x29, 0xb3, 0xfe, 0x83, 0xcb, 0x79, 0xd8, 0xc9, 0xb4, 0xff + , 0xa0, 0x14, 0xf8, 0xa0, 0x60, 0xc8, 0xe9, 0x84, 0xff, 0xe9, 0xbc, 0x9d, 0x7a, 0xe8, 0x02, 0xe8 + , 0x26, 0x4a, 0xe8, 0x29, 0x3b, 0x88, 0x6d, 0x4e, 0xb0, 0x62, 0x05, 0x7a, 0xd4, 0x04, 0x50, 0x08 + , 0x20, 0x80, 0xa0, 0xfd, 0x80, 0xff, 0xb0, 0xc3, 0x60, 0xa0, 0xb1, 0xc4, 0x00, 0xdf, 0x0b, 0xf5 + , 0x1f, 0x1a, 0xf6, 0xa3, 0xe5, 0x3f, 0x49, 0x00, 0x11, 0x60, 0xff, 0xa0, 0x47, 0x5d, 0xc3, 0xc2 + , 0xf3, 0x1f, 0xd2, 0xb9, 0x2f, 0x40, 0x00, 0x10, 0x40, 0x4c, 0x30, 0xd5, 0xf0, 0xd0, 0x06, 0x1f + , 0x83, 0xf4, 0x0f, 0x23, 0xec, 0xff, 0x8f, 0xb6, 0x80, 0x48, 0x05, 0xe0, 0x8d, 0x65, 0xff, 0x91 + , 0xea, 0x04, 0xa8, 0x30, 0x4a, 0x80, 0x02, 0x04, 0x10, 0x38, 0x07, 0x80, 0x16, 0x6b, 0x41, 0xf3 + , 0x0c, 0xa8, 0xb4, 0x81, 0x6d, 0xc2, 0x84, 0x9d, 0x0b, 0x06, 0x3b, 0x9a, 0x90, 0x71, 0x34, 0x06 + , 0x88, 0x05, 0xe0, 0x30, 0x86, 0x84, 0x17, 0x34, 0x23, 0x80, 0xcb, 0x6f, 0x44, 0xca, 0x87, 0xd4 + , 0xa7, 0xc0, 0xe0, 0x05, 0x08, 0x20, 0xc8, 0x58, 0x10, 0x2c, 0xfd, 0x83, 0x16, 0x5d, 0xff, 0x87 + , 0x10, 0xd8, 0xcc, 0xa4, 0xa3, 0x0f, 0x86, 0x3c, 0x80, 0xa6, 0x69, 0x44, 0x48, 0x32, 0xfe, 0x87 + , 0x09, 0x83, 0x12, 0xfc, 0x7f, 0x46, 0x70, 0x9a, 0xfe, 0xcf, 0x00, 0x10, 0x40, 0x4c, 0x08, 0xf5 + , 0xe0, 0xf3, 0x1f, 0xc1, 0x2a, 0xc1, 0xd9, 0x86, 0x11, 0xd9, 0x2c, 0xc8, 0xde, 0xa8, 0x51, 0x40 + , 0x2c, 0x00, 0x27, 0x61, 0xd4, 0x00, 0x03, 0x05, 0x28, 0x38, 0xe0, 0x61, 0x61, 0x09, 0x8e, 0x02 + , 0x06, 0x80, 0x00, 0x02, 0x47, 0x00, 0x23, 0xe4, 0x58, 0x29, 0x88, 0x04, 0x13, 0x64, 0xf7, 0x31 + , 0x23, 0x2c, 0x52, 0x60, 0xb1, 0x82, 0x6e, 0xe0, 0x28, 0xc0, 0x0b, 0x18, 0x61, 0x49, 0x1e, 0xbc + , 0x9f, 0x95, 0x11, 0x7a, 0xb4, 0x20, 0x78, 0x6b, 0x2b, 0x13, 0x94, 0x05, 0x62, 0x30, 0x02, 0x04 + , 0x10, 0x94, 0x83, 0x38, 0x77, 0x13, 0x92, 0xdc, 0x99, 0xa0, 0xa7, 0xc1, 0x33, 0x42, 0x99, 0x20 + , 0xf6, 0x68, 0x0c, 0x90, 0x04, 0xc0, 0xc1, 0xc7, 0x08, 0x0b, 0x5c, 0xc8, 0x69, 0x06, 0xb0, 0xcd + , 0xf5, 0xa0, 0x42, 0x1e, 0x7a, 0xed, 0x01, 0x40, 0x00, 0x81, 0x22, 0x80, 0x09, 0x16, 0xf6, 0xf0 + , 0xa3, 0x0e, 0x18, 0x61, 0xb1, 0xc2, 0xc8, 0x04, 0xdb, 0x8d, 0xc3, 0xc0, 0x38, 0x80, 0x87, 0xec + , 0x0f, 0x3d, 0x80, 0x48, 0xf7, 0xa0, 0x42, 0x85, 0x89, 0x89, 0x81, 0x11, 0x76, 0xbe, 0x38, 0x64 + , 0x6b, 0x31, 0xfc, 0x84, 0x59, 0x80, 0x00, 0x02, 0xe7, 0x00, 0xf8, 0x59, 0xa7, 0xcc, 0x90, 0xa3 + , 0x97, 0x19, 0xa1, 0x18, 0xa2, 0x11, 0xa6, 0x14, 0x62, 0xee, 0xc0, 0xfa, 0x6b, 0xa8, 0x00, 0x26 + , 0xc4, 0x95, 0x2a, 0x48, 0xa7, 0xa9, 0x00, 0xc3, 0x17, 0x92, 0xc0, 0x99, 0x19, 0x21, 0x27, 0x5c + , 0x03, 0x05, 0x01, 0x02, 0x08, 0x52, 0x07, 0x20, 0x0e, 0x5b, 0x66, 0x86, 0xc9, 0x43, 0xe3, 0x08 + , 0xb2, 0x17, 0x16, 0x16, 0x2b, 0x03, 0x7f, 0xe3, 0xc7, 0x50, 0x00, 0x8c, 0x8c, 0xb0, 0xd4, 0xcd + , 0x08, 0xbe, 0xc9, 0x06, 0x12, 0x78, 0x90, 0x53, 0xc5, 0xc1, 0x5b, 0x5a, 0x99, 0xa0, 0xc7, 0xbb + , 0x83, 0xc2, 0x15, 0x20, 0x80, 0xc0, 0x45, 0x10, 0x23, 0xe4, 0x94, 0x5f, 0xd8, 0x79, 0xef, 0xcc + , 0x4c, 0x30, 0x15, 0x70, 0x65, 0xd0, 0x18, 0x61, 0x18, 0x8d, 0x02, 0x22, 0x00, 0xa4, 0xe6, 0x44 + , 0x94, 0x34, 0x4c, 0x88, 0x62, 0x87, 0x99, 0x89, 0x05, 0xbc, 0x6d, 0x1b, 0x72, 0xb4, 0x0a, 0x28 + , 0x43, 0x00, 0x04, 0x10, 0x38, 0x02, 0x60, 0xb7, 0x4e, 0x80, 0xa5, 0xc1, 0x47, 0xbd, 0x33, 0x31 + , 0xc2, 0x22, 0x01, 0x1a, 0x13, 0xb0, 0x93, 0x41, 0x46, 0x8b, 0x20, 0xc2, 0x00, 0x72, 0x70, 0x2f + , 0x13, 0xec, 0x3a, 0x0f, 0xf8, 0x66, 0x62, 0xd0, 0xe1, 0xbd, 0xa0, 0xb3, 0x54, 0x58, 0x20, 0x29 + , 0x1d, 0x92, 0xa6, 0x01, 0x02, 0x08, 0x9a, 0x03, 0x20, 0x19, 0x03, 0xb1, 0xdf, 0x12, 0x1c, 0x4d + , 0x90, 0x33, 0x10, 0xe0, 0x65, 0x13, 0x33, 0xe4, 0x7e, 0xae, 0x51, 0x40, 0x08, 0xc0, 0xca, 0x0d + , 0xa4, 0x32, 0x9d, 0x09, 0x1a, 0x9c, 0xe0, 0x04, 0x0e, 0x39, 0xca, 0x1d, 0x12, 0xb6, 0x8c, 0x00 + , 0x01, 0x04, 0x8e, 0x00, 0x70, 0xf4, 0x40, 0x64, 0x20, 0x47, 0xad, 0x30, 0xc1, 0xee, 0xdc, 0x62 + , 0x86, 0xdd, 0x89, 0x03, 0x2b, 0xb1, 0x46, 0x8b, 0x20, 0xc2, 0x00, 0x71, 0x80, 0x0a, 0xa8, 0xfc + , 0x07, 0x97, 0x28, 0x48, 0xc7, 0x19, 0x40, 0x6e, 0x91, 0x80, 0x5e, 0xad, 0xc2, 0xc8, 0x04, 0x10 + , 0x40, 0x90, 0x56, 0x10, 0x23, 0xe2, 0x74, 0x71, 0xf0, 0x79, 0xca, 0xf0, 0xfb, 0xb7, 0xa0, 0xea + , 0x20, 0x87, 0xc0, 0x43, 0x1a, 0xa8, 0xa3, 0x79, 0x80, 0x10, 0x60, 0x42, 0xbe, 0x43, 0x05, 0x92 + , 0x8c, 0x61, 0xfb, 0xb9, 0xe1, 0xd7, 0x35, 0x41, 0xaa, 0x5a, 0x60, 0xb8, 0x03, 0x04, 0x10, 0x38 + , 0x02, 0x40, 0x0d, 0x51, 0x58, 0xe8, 0x83, 0xf7, 0xba, 0xc2, 0xee, 0xbe, 0x81, 0xc4, 0x03, 0x14 + , 0x30, 0xc2, 0xca, 0xad, 0x81, 0xf6, 0xe0, 0xa0, 0x06, 0x4c, 0xe0, 0xd3, 0x9b, 0x18, 0x11, 0xc1 + , 0x06, 0x0a, 0x43, 0x56, 0x48, 0xb9, 0xc3, 0xcc, 0x0c, 0x3a, 0x24, 0x19, 0x7a, 0x79, 0x19, 0x48 + , 0x02, 0x98, 0x98, 0x01, 0x02, 0x08, 0x1a, 0x9a, 0x90, 0xf4, 0xcf, 0x06, 0x3e, 0x54, 0x02, 0x84 + , 0xd8, 0x59, 0x99, 0x21, 0x07, 0x0f, 0xc1, 0xaf, 0xe3, 0x82, 0x34, 0x8f, 0x98, 0x07, 0xdd, 0x55 + , 0x80, 0x83, 0x0d, 0x30, 0x22, 0x1f, 0xe0, 0x01, 0x4d, 0xf7, 0x90, 0xd0, 0x65, 0x06, 0x5f, 0x92 + , 0xc5, 0x0e, 0xbd, 0xc6, 0x83, 0x99, 0x15, 0xa8, 0x0a, 0xa8, 0x1e, 0x20, 0x80, 0xa0, 0xa1, 0x09 + , 0xcc, 0x28, 0xe0, 0x20, 0x07, 0xef, 0x32, 0x06, 0xdf, 0x68, 0x00, 0x3d, 0x6c, 0x1f, 0x7a, 0x0b + , 0x20, 0xbc, 0xd4, 0x62, 0xa2, 0xd1, 0x55, 0x2a, 0xc3, 0x06, 0xb0, 0x80, 0x23, 0x80, 0x05, 0x1e + , 0xfc, 0xa0, 0x23, 0xcc, 0x58, 0x21, 0xe5, 0x3e, 0xf8, 0xc0, 0x08, 0x50, 0xe2, 0x86, 0x1c, 0xe8 + , 0xc1, 0x02, 0x3e, 0x5e, 0x14, 0x20, 0x80, 0x10, 0x39, 0x00, 0x52, 0xff, 0x02, 0x63, 0x08, 0x08 + , 0x81, 0x80, 0x05, 0xae, 0x0f, 0x9a, 0x5f, 0x58, 0xc1, 0x87, 0xa0, 0x81, 0xf0, 0x68, 0x63, 0x14 + , 0x17, 0x60, 0x84, 0x1e, 0xdf, 0x07, 0xbb, 0xa7, 0x00, 0x76, 0x4c, 0x3e, 0xf8, 0xec, 0x2c, 0x56 + , 0xc8, 0x11, 0x42, 0xa0, 0x04, 0xce, 0x06, 0xa9, 0x87, 0x41, 0x11, 0x00, 0x10, 0x40, 0xd0, 0x08 + , 0x00, 0xf5, 0x10, 0xa0, 0x47, 0x1d, 0x40, 0xef, 0x54, 0x81, 0x9c, 0x7c, 0x06, 0x12, 0x04, 0xdf + , 0x7d, 0xc3, 0x0a, 0xa9, 0x42, 0xa0, 0xb9, 0x60, 0x34, 0x13, 0x60, 0x07, 0x90, 0xa3, 0xf1, 0x21 + , 0xa7, 0xb2, 0x43, 0xc3, 0x1d, 0x56, 0xe4, 0x83, 0x0e, 0x6e, 0x02, 0x5f, 0x11, 0xc7, 0x0a, 0x3a + , 0x45, 0x0b, 0x58, 0x15, 0x40, 0x8f, 0xd1, 0x02, 0x08, 0x20, 0x44, 0x50, 0x82, 0x4f, 0x5b, 0x01 + , 0x1f, 0x77, 0x06, 0xba, 0x60, 0x0e, 0x74, 0xe4, 0x13, 0xec, 0xa6, 0x15, 0x48, 0x5e, 0x60, 0x05 + , 0x1f, 0x42, 0x07, 0xad, 0x0d, 0x06, 0xce, 0x8f, 0x83, 0x1a, 0xc0, 0xcf, 0x0e, 0x42, 0xbd, 0x32 + , 0x0b, 0x7c, 0x95, 0x22, 0x27, 0xe4, 0xc4, 0x14, 0x76, 0xc8, 0xad, 0x8a, 0xf0, 0x23, 0xa6, 0x01 + , 0x02, 0x08, 0x39, 0x02, 0xa0, 0xf7, 0xfd, 0x41, 0x2e, 0x56, 0xe4, 0x00, 0xdd, 0xda, 0x04, 0xbd + , 0x71, 0x0b, 0x7a, 0xe7, 0x28, 0x88, 0x64, 0x86, 0x5c, 0xcc, 0xcb, 0x34, 0xa8, 0x2f, 0x49, 0x1e + , 0x18, 0x00, 0x2d, 0x7e, 0x60, 0x07, 0x07, 0x41, 0x5a, 0x33, 0xf0, 0x1b, 0xb3, 0xc0, 0xc7, 0x37 + , 0x71, 0xb0, 0x71, 0x80, 0x0f, 0x94, 0x43, 0xba, 0x38, 0x14, 0x20, 0x80, 0x10, 0x11, 0x00, 0xaa + , 0x73, 0xc1, 0xa7, 0xfd, 0x01, 0x63, 0x00, 0x7c, 0xcc, 0x10, 0x27, 0xec, 0xf8, 0x1b, 0x70, 0xbe + , 0x80, 0x34, 0x60, 0x61, 0xf5, 0x02, 0x33, 0x89, 0x67, 0x84, 0x8f, 0x04, 0x00, 0x6f, 0xf7, 0xb0 + , 0xb2, 0x42, 0x1b, 0x9b, 0xb0, 0x23, 0x14, 0x41, 0x81, 0x08, 0xbe, 0x01, 0x0b, 0x7c, 0x76, 0x13 + , 0x1b, 0x1b, 0xa4, 0x42, 0x85, 0xe8, 0x02, 0x08, 0x20, 0x44, 0x04, 0x00, 0xcb, 0x2f, 0xc8, 0x05 + , 0x73, 0xe0, 0x5b, 0x46, 0x39, 0x39, 0x20, 0x47, 0xdc, 0x80, 0x0e, 0x3c, 0x83, 0xd6, 0x1b, 0xb0 + , 0x38, 0x00, 0xd9, 0x01, 0x1e, 0xa8, 0x1e, 0x20, 0x8f, 0x0e, 0x52, 0xc0, 0xc8, 0x82, 0x28, 0x76 + , 0x58, 0xc0, 0x37, 0xc4, 0x41, 0xd3, 0x2f, 0x90, 0xe6, 0xe0, 0x84, 0x5d, 0x19, 0xca, 0x06, 0x2e + , 0x87, 0xd8, 0x58, 0xe1, 0x23, 0xcb, 0x00, 0x01, 0x84, 0x52, 0x9d, 0xb2, 0x82, 0x0e, 0xb9, 0x84 + , 0x96, 0x3f, 0xa0, 0x83, 0x9e, 0xb8, 0x38, 0x21, 0x47, 0xce, 0x41, 0x2e, 0xdd, 0x85, 0x46, 0x27 + , 0xf8, 0x1e, 0x34, 0xf0, 0x11, 0xb1, 0xa3, 0x99, 0x00, 0x01, 0x90, 0x92, 0x3f, 0xa4, 0xe8, 0x81 + , 0x26, 0x7c, 0x76, 0xf0, 0xf1, 0x4d, 0x90, 0x23, 0x9b, 0xc0, 0x47, 0xc8, 0x81, 0x02, 0x12, 0xf9 + , 0xce, 0x19, 0x80, 0x00, 0x42, 0x89, 0x00, 0x70, 0x19, 0xc4, 0x0a, 0x8e, 0x2e, 0x48, 0x04, 0x70 + , 0x71, 0x80, 0x63, 0x80, 0x1d, 0x12, 0x9d, 0xa0, 0xe3, 0x86, 0xd8, 0xa1, 0xb7, 0x1f, 0xc3, 0x5a + , 0x51, 0xa3, 0x00, 0x02, 0xc0, 0xa1, 0x0f, 0xbf, 0x9e, 0x0f, 0x72, 0x37, 0x1f, 0xa8, 0x42, 0x05 + , 0xa6, 0x78, 0x60, 0xb0, 0x83, 0x2f, 0x07, 0x85, 0x64, 0x01, 0x0e, 0x48, 0x2a, 0x86, 0x6b, 0x04 + , 0x08, 0x20, 0x94, 0x08, 0x60, 0x62, 0x64, 0x04, 0xdf, 0xa9, 0x05, 0xaa, 0x31, 0x40, 0xc1, 0x0f + , 0xbe, 0x5c, 0x14, 0xda, 0x7a, 0x05, 0x9a, 0xc3, 0x06, 0x0f, 0x7e, 0x36, 0x78, 0x5d, 0x40, 0x77 + , 0x9f, 0x0e, 0x46, 0x00, 0x6d, 0xf9, 0x80, 0xd3, 0x3c, 0xa4, 0xe0, 0xe1, 0x80, 0x84, 0x22, 0x38 + , 0x22, 0xc0, 0x37, 0xb4, 0x72, 0x81, 0xef, 0xcd, 0xe5, 0x04, 0x0a, 0x02, 0xa3, 0x08, 0xb9, 0x23 + , 0x05, 0x10, 0x40, 0xe8, 0x2d, 0x7a, 0x16, 0xf0, 0x59, 0x5b, 0xa0, 0x4b, 0x44, 0xa1, 0x37, 0xbc + , 0x72, 0x83, 0x8b, 0x24, 0x76, 0xf0, 0xf5, 0xba, 0x1c, 0x88, 0x92, 0x0d, 0x54, 0x10, 0xb1, 0x01 + , 0xab, 0x6d, 0xfa, 0xfa, 0x74, 0x90, 0x02, 0x48, 0x03, 0x91, 0x15, 0x7a, 0x5a, 0x1f, 0xa4, 0x2f + , 0x05, 0xbe, 0xae, 0x1b, 0xd4, 0xf2, 0xe4, 0x00, 0x5f, 0x90, 0xcb, 0x0d, 0x39, 0x39, 0x8e, 0x1d + , 0x7c, 0x96, 0x2e, 0xb2, 0x5e, 0x80, 0x00, 0xc2, 0x88, 0x00, 0x66, 0x66, 0x50, 0xa5, 0x01, 0xae + , 0xb1, 0x81, 0xe1, 0xcf, 0x0b, 0xba, 0xda, 0x95, 0x1b, 0x1c, 0x05, 0x10, 0x13, 0xc1, 0x14, 0xe4 + , 0xfa, 0x3f, 0x36, 0x68, 0x73, 0x97, 0x8e, 0x3e, 0x1d, 0x8c, 0x00, 0x16, 0xfa, 0xac, 0x90, 0x12 + , 0x9a, 0x1d, 0x1c, 0xec, 0x90, 0x9b, 0xd2, 0x81, 0x80, 0x07, 0x72, 0x4f, 0x2e, 0x17, 0x27, 0xb8 + , 0x6f, 0xc5, 0x01, 0x1a, 0x0a, 0x42, 0x0d, 0x31, 0x80, 0x00, 0xc2, 0xd2, 0xa7, 0x05, 0x9f, 0x79 + , 0x0c, 0x29, 0x83, 0xb8, 0x21, 0x97, 0xec, 0x42, 0x62, 0x92, 0x13, 0x1a, 0x09, 0xe0, 0xac, 0xc0 + , 0x0e, 0x1e, 0xd4, 0x60, 0x03, 0xd9, 0x3c, 0x92, 0x27, 0x09, 0x80, 0x8d, 0x19, 0xf0, 0x81, 0xf5 + , 0x6c, 0x90, 0x31, 0x06, 0x68, 0xb8, 0x73, 0xb0, 0x43, 0x2e, 0xed, 0x06, 0x06, 0x1b, 0x0f, 0x30 + , 0xfd, 0x72, 0x83, 0x02, 0x92, 0x0b, 0x74, 0xfd, 0x24, 0xf8, 0xe4, 0x4a, 0x54, 0x00, 0x10, 0x40 + , 0x58, 0xd2, 0x2f, 0x2b, 0xf8, 0xf6, 0x75, 0xf0, 0x55, 0xd3, 0x5c, 0xc0, 0xf0, 0xe7, 0xe5, 0xe1 + , 0xf9, 0x02, 0xba, 0x80, 0xf6, 0xc7, 0x8f, 0x9f, 0x1c, 0xe0, 0x6b, 0x16, 0x39, 0xa0, 0x27, 0x66 + , 0x21, 0x5d, 0x69, 0xf6, 0xfb, 0x17, 0xfa, 0x51, 0x68, 0x23, 0x04, 0x40, 0x5b, 0x9c, 0xa0, 0x24 + , 0xcb, 0x06, 0x09, 0x7e, 0xd0, 0x81, 0xb9, 0xec, 0x90, 0xea, 0x96, 0x83, 0x1b, 0x7c, 0x43, 0x31 + , 0x0f, 0x38, 0x17, 0x70, 0x82, 0xd3, 0x2f, 0x2b, 0xc6, 0xb1, 0x95, 0x00, 0x01, 0x84, 0x25, 0x02 + , 0x80, 0x15, 0x04, 0xc8, 0x34, 0x60, 0x16, 0x00, 0x6a, 0xfc, 0xc6, 0xcd, 0xc3, 0xcb, 0xcb, 0x0b + , 0x3e, 0xa4, 0x9e, 0xf3, 0x27, 0x07, 0xe4, 0x00, 0x16, 0xd8, 0x11, 0x14, 0x88, 0x5b, 0x67, 0xff + , 0x8d, 0xc8, 0x03, 0x24, 0xc0, 0x57, 0x82, 0x42, 0x86, 0x0f, 0xd8, 0x40, 0x57, 0x9f, 0xb3, 0x43 + , 0x12, 0x3e, 0x27, 0xa4, 0x19, 0x09, 0x4c, 0xc1, 0xbc, 0x20, 0xc0, 0x03, 0x29, 0x82, 0x80, 0xc1 + , 0x09, 0x94, 0xc7, 0xec, 0x3b, 0x01, 0x04, 0x10, 0xf6, 0x12, 0x1c, 0x58, 0xb6, 0x00, 0x8d, 0xe3 + , 0x04, 0x97, 0x41, 0xc0, 0x38, 0x84, 0x44, 0xc1, 0x2f, 0xf8, 0xf5, 0x8f, 0xe0, 0x03, 0x3f, 0x90 + , 0x4f, 0x6e, 0x02, 0xed, 0x2a, 0xf8, 0xf9, 0xe3, 0xff, 0x48, 0xda, 0xc3, 0x0a, 0xea, 0xb7, 0x82 + , 0xc6, 0x8e, 0xc1, 0x77, 0x72, 0x43, 0x2a, 0x5c, 0xc8, 0xf8, 0x01, 0xa4, 0xc5, 0xcf, 0xc9, 0xc9 + , 0x03, 0x0e, 0x37, 0x20, 0x01, 0xb9, 0xa5, 0x1e, 0x9c, 0xfc, 0xb1, 0xb4, 0x59, 0x00, 0x02, 0x08 + , 0x7b, 0x04, 0x00, 0xdb, 0x49, 0xa0, 0x52, 0x08, 0x94, 0x89, 0xb8, 0x78, 0xbf, 0xf3, 0xc0, 0xaf + , 0x26, 0x87, 0x9e, 0x1c, 0xf4, 0x0b, 0x7a, 0x4e, 0xe0, 0x1f, 0xd8, 0xf6, 0x57, 0xc8, 0xee, 0xa6 + , 0x5f, 0x23, 0xa9, 0x20, 0x82, 0xdc, 0x02, 0x0a, 0x0a, 0x7b, 0x36, 0x58, 0x81, 0xcf, 0x01, 0xef + , 0xf0, 0x82, 0x1a, 0xfd, 0x7c, 0xbc, 0x7c, 0xc0, 0x08, 0x00, 0xb5, 0x61, 0x40, 0x11, 0xc0, 0x09 + , 0x4e, 0xfe, 0x58, 0x06, 0x0f, 0x00, 0x02, 0x08, 0x67, 0x1b, 0x06, 0xd8, 0xca, 0x01, 0x6a, 0xfb + , 0xf9, 0x13, 0x74, 0xb5, 0xfd, 0x77, 0xde, 0xef, 0xbc, 0x90, 0xa3, 0x47, 0x51, 0x8e, 0x4c, 0x84 + , 0x1e, 0x64, 0xf0, 0xef, 0x0f, 0xec, 0x86, 0x3f, 0xf0, 0x99, 0x5b, 0xb4, 0xf4, 0xf5, 0x60, 0x01 + , 0xe0, 0x92, 0x87, 0x0d, 0x92, 0xf8, 0xd9, 0xc1, 0x41, 0xce, 0x05, 0xed, 0x37, 0x81, 0x8a, 0x1a + , 0x20, 0xe6, 0xe3, 0xe7, 0xe7, 0xe3, 0xe7, 0xe3, 0x01, 0xe5, 0x00, 0x48, 0x03, 0x14, 0xe7, 0x7d + , 0xf4, 0x00, 0x01, 0x84, 0xaf, 0x11, 0x09, 0x89, 0x03, 0x60, 0x09, 0xf6, 0xf3, 0x07, 0xf4, 0x8a + , 0x86, 0xef, 0xdf, 0xbf, 0xff, 0xf9, 0x0d, 0x3b, 0x6d, 0x02, 0x71, 0x13, 0x27, 0x78, 0x17, 0x26 + , 0x64, 0x67, 0xda, 0xff, 0xff, 0x7f, 0x87, 0xfb, 0x69, 0x66, 0xa0, 0xb9, 0x5b, 0x70, 0xab, 0x07 + , 0xd2, 0x36, 0x04, 0x0f, 0xb2, 0x41, 0x82, 0x9d, 0x13, 0x3c, 0x7c, 0xc3, 0xc5, 0xcb, 0xc7, 0xc3 + , 0xcf, 0x07, 0x4c, 0xfe, 0x40, 0x0c, 0x0c, 0x7f, 0x1e, 0xa0, 0x14, 0xb0, 0x61, 0x8f, 0xcb, 0x34 + , 0x80, 0x00, 0xc2, 0x17, 0x01, 0xc0, 0xb6, 0x2d, 0x30, 0x53, 0x71, 0xff, 0xe2, 0xfa, 0xc5, 0xc3 + , 0x0b, 0x3d, 0xb9, 0x15, 0x7c, 0x62, 0x34, 0xfc, 0x18, 0x1b, 0xc4, 0x09, 0x12, 0xd0, 0x6d, 0x7f + , 0x20, 0xe2, 0x17, 0x78, 0x0b, 0x1a, 0x0d, 0x3c, 0x3e, 0x28, 0x00, 0x33, 0x13, 0x33, 0x78, 0x6c + , 0x12, 0x56, 0xe1, 0x72, 0x42, 0xd2, 0x3e, 0x24, 0xec, 0x41, 0x7d, 0x57, 0x2e, 0x6e, 0x4e, 0x7e + , 0x7e, 0x01, 0x7e, 0x7e, 0x50, 0x14, 0x70, 0x73, 0xf3, 0x82, 0xe4, 0x80, 0xcd, 0x7f, 0x1c, 0xb7 + , 0x37, 0x00, 0x01, 0x40, 0x00, 0x11, 0xe8, 0x46, 0x81, 0xa3, 0xf8, 0xf7, 0x2f, 0x1e, 0xd8, 0x29 + , 0x42, 0xe0, 0xf3, 0x48, 0xff, 0xc2, 0xaf, 0x34, 0x06, 0x6f, 0x7b, 0x05, 0x1f, 0x6b, 0x00, 0xdf + , 0x4c, 0x0c, 0xde, 0x69, 0xf3, 0xeb, 0xff, 0xb0, 0x3c, 0xd5, 0x86, 0x89, 0x99, 0x09, 0x52, 0xf2 + , 0x70, 0x40, 0x2b, 0x5d, 0x48, 0xd8, 0x73, 0x40, 0xfa, 0x4c, 0xe0, 0x12, 0x88, 0x8b, 0x5f, 0x40 + , 0x10, 0x14, 0xf8, 0xa0, 0x1c, 0x00, 0x6a, 0x01, 0x81, 0xab, 0x5f, 0x7c, 0x37, 0xba, 0x01, 0x04 + , 0x10, 0x81, 0x08, 0x60, 0x66, 0x62, 0x02, 0x9a, 0x0f, 0x3e, 0xa2, 0xfa, 0x17, 0xe4, 0x34, 0x27 + , 0xc8, 0x6d, 0xc0, 0xd0, 0xba, 0x17, 0x76, 0x8c, 0xc4, 0xdf, 0xff, 0xb0, 0x7d, 0xb1, 0xb0, 0x8b + , 0x81, 0xff, 0x0f, 0xbb, 0x7b, 0x7c, 0x80, 0xcd, 0x1e, 0xc8, 0x48, 0x0f, 0xb8, 0xb1, 0x8f, 0x28 + , 0x75, 0xb8, 0x78, 0x20, 0xdd, 0x55, 0x4e, 0x60, 0x83, 0x85, 0x8f, 0x0f, 0x98, 0xf8, 0x05, 0x04 + , 0xf8, 0x80, 0x39, 0x80, 0x0f, 0xd8, 0xfe, 0x01, 0x5f, 0x1e, 0xc0, 0x8e, 0x7f, 0x06, 0x17, 0x20 + , 0x80, 0x08, 0x0f, 0x24, 0x80, 0x1a, 0xb9, 0x7f, 0x39, 0x79, 0xc0, 0xa7, 0x6e, 0x41, 0x4f, 0xec + , 0x06, 0x9f, 0x29, 0x04, 0x4c, 0xfc, 0xff, 0x61, 0x97, 0xbc, 0xfe, 0x05, 0xef, 0xe4, 0xfe, 0x0f + , 0xdd, 0x48, 0x0c, 0x46, 0x8c, 0x8c, 0xbf, 0x7f, 0xfd, 0x84, 0x9c, 0xca, 0x35, 0x0c, 0x00, 0x74 + , 0xb6, 0x8a, 0x9d, 0x0d, 0xda, 0xc4, 0xe1, 0x84, 0x24, 0x77, 0x70, 0x33, 0x9d, 0x93, 0x1b, 0x02 + , 0x80, 0x21, 0x2e, 0x28, 0x28, 0x20, 0x08, 0x2e, 0x7e, 0x78, 0x80, 0xf5, 0x00, 0xb8, 0xfa, 0x05 + , 0x66, 0x17, 0xfc, 0x26, 0x03, 0x04, 0x10, 0x51, 0x23, 0x39, 0xc0, 0x52, 0xec, 0xdf, 0x9f, 0x3f + , 0xc8, 0xc7, 0x9f, 0x81, 0xcf, 0xe3, 0xfa, 0x0d, 0xbe, 0xe6, 0x15, 0x7a, 0xe5, 0x25, 0xf4, 0xa2 + , 0x39, 0xe8, 0xde, 0x4a, 0xf0, 0x5e, 0x28, 0x10, 0xff, 0xd7, 0x30, 0xe8, 0xa0, 0x81, 0x43, 0x1f + , 0x52, 0xea, 0xb3, 0x43, 0x1a, 0xf9, 0xc0, 0xc0, 0x07, 0x5f, 0x0b, 0x00, 0x09, 0x78, 0xc8, 0x15 + , 0x01, 0x3c, 0x82, 0x20, 0x00, 0x0c, 0x7e, 0x01, 0x60, 0x3e, 0x00, 0x8f, 0x3f, 0x70, 0x01, 0x35 + , 0x10, 0x34, 0x1c, 0x20, 0x80, 0x88, 0x8a, 0x00, 0x60, 0x26, 0x02, 0xe6, 0x39, 0xee, 0xbf, 0x90 + , 0x03, 0xe9, 0x20, 0x17, 0x61, 0xff, 0xfe, 0xf3, 0xf7, 0x37, 0xfc, 0xc0, 0x03, 0xc8, 0x4e, 0x64 + , 0x86, 0xff, 0x88, 0xcd, 0xc4, 0xe0, 0x1d, 0x50, 0xa0, 0xed, 0x09, 0xc0, 0x4c, 0x33, 0xa4, 0xe3 + , 0x00, 0x34, 0x55, 0x0e, 0x1e, 0xd8, 0x07, 0xcf, 0xea, 0x42, 0xd2, 0x3d, 0x38, 0xe8, 0x81, 0x45 + , 0x0f, 0x0f, 0x24, 0xe1, 0x83, 0x68, 0x21, 0x41, 0x10, 0x14, 0xe0, 0x17, 0x04, 0x96, 0x41, 0xbc + , 0xe0, 0xd6, 0x0f, 0x30, 0xa6, 0x08, 0xde, 0x63, 0x08, 0x04, 0x00, 0x01, 0x44, 0xec, 0x58, 0x26 + , 0x30, 0x03, 0x02, 0xed, 0x86, 0x1e, 0x81, 0x03, 0x6a, 0xfb, 0x43, 0x9a, 0x9f, 0x7f, 0x61, 0xc9 + , 0x1e, 0x96, 0xfe, 0x21, 0x3b, 0xc9, 0x60, 0xdb, 0x42, 0x20, 0x4b, 0xe5, 0x81, 0x45, 0x17, 0x30 + , 0xd3, 0x50, 0x12, 0x0a, 0x03, 0x05, 0x20, 0x63, 0xfc, 0xec, 0x90, 0x72, 0x9f, 0x13, 0x5a, 0xf6 + , 0xc0, 0x13, 0x3e, 0x0f, 0x37, 0x64, 0xa4, 0x81, 0x57, 0x40, 0x50, 0x48, 0x48, 0x58, 0x48, 0x48 + , 0x00, 0x1a, 0xfa, 0xc0, 0x38, 0x01, 0xe6, 0x10, 0x62, 0x6e, 0xf2, 0x04, 0x02, 0x80, 0x00, 0x22 + , 0x61, 0x30, 0x19, 0x58, 0xf3, 0x83, 0x8f, 0x5e, 0x41, 0xb4, 0x3e, 0x11, 0xcd, 0x4f, 0xf8, 0x31 + , 0x1e, 0x90, 0x6d, 0x80, 0xc8, 0x7b, 0x44, 0x20, 0xbb, 0x0b, 0x98, 0x40, 0xc3, 0x47, 0x43, 0x68 + , 0xac, 0x02, 0xe8, 0x64, 0x16, 0x36, 0xc8, 0x22, 0x1d, 0x76, 0xc8, 0xa0, 0x00, 0x27, 0x64, 0x78 + , 0x92, 0x13, 0x14, 0xbc, 0xdc, 0xe0, 0x31, 0x36, 0xf0, 0x48, 0x27, 0xb0, 0xe4, 0x11, 0x10, 0x16 + , 0x16, 0x02, 0x15, 0x3e, 0x02, 0xe0, 0xc2, 0x87, 0x87, 0x97, 0x07, 0x54, 0xf8, 0x10, 0x28, 0xfa + , 0xe1, 0x00, 0x20, 0x80, 0x48, 0x1b, 0xcd, 0x07, 0x16, 0x7f, 0xff, 0xa1, 0x67, 0x10, 0x81, 0xae + , 0x99, 0x06, 0x9d, 0xe0, 0x04, 0xa9, 0x7b, 0xa1, 0x75, 0x2d, 0x23, 0x24, 0x03, 0x80, 0x17, 0x51 + , 0x23, 0xf6, 0x78, 0x40, 0x77, 0x2a, 0x30, 0x32, 0x83, 0x4f, 0xa3, 0x1b, 0x02, 0xc5, 0x11, 0xe8 + , 0x46, 0x42, 0xc8, 0xfc, 0x0a, 0x64, 0x4a, 0x11, 0x3c, 0xc6, 0x00, 0x2a, 0x7d, 0x80, 0xe5, 0x0e + , 0x78, 0x84, 0x98, 0x1b, 0x34, 0x46, 0x0c, 0xec, 0xe7, 0x72, 0x03, 0x4b, 0x7d, 0x70, 0xe2, 0x17 + , 0x12, 0x00, 0xb5, 0x3e, 0x41, 0x6d, 0x7f, 0x1e, 0xf0, 0xe8, 0x3d, 0xf1, 0x76, 0x01, 0x04, 0x10 + , 0x69, 0x11, 0x00, 0x0c, 0x55, 0xa0, 0x4b, 0xfe, 0xa2, 0x9e, 0xc2, 0xf2, 0x1f, 0xba, 0xb3, 0x95 + , 0x01, 0xb2, 0xb7, 0x95, 0x11, 0xb6, 0x99, 0x00, 0xb1, 0xd3, 0x89, 0x19, 0xb6, 0x4f, 0x81, 0x99 + , 0x11, 0x7c, 0x62, 0xe6, 0xe0, 0xcd, 0x0a, 0xe0, 0xf1, 0x7d, 0xf0, 0xdc, 0x2e, 0x68, 0x76, 0x85 + , 0x03, 0xda, 0xec, 0xe1, 0x00, 0x97, 0x3d, 0xdc, 0xa0, 0xf0, 0x87, 0xd4, 0xbd, 0xbc, 0xe0, 0xf0 + , 0x17, 0x10, 0x00, 0xa6, 0x7d, 0x60, 0xea, 0x17, 0x12, 0x04, 0xb7, 0x7e, 0x80, 0x6d, 0x7f, 0xa0 + , 0x28, 0xb0, 0x8e, 0x26, 0x69, 0x82, 0x04, 0x20, 0x80, 0x48, 0x9e, 0xcf, 0x02, 0x06, 0x25, 0x30 + , 0x29, 0x30, 0xfc, 0x83, 0x16, 0x3b, 0xe0, 0x43, 0x0e, 0x18, 0x60, 0x9b, 0x58, 0x11, 0xbb, 0x72 + , 0x90, 0x02, 0x9f, 0x89, 0x85, 0x09, 0xb4, 0x5a, 0x92, 0x85, 0x99, 0xf9, 0xc7, 0x2f, 0x16, 0x66 + , 0xa6, 0x5f, 0xbf, 0x98, 0x98, 0x20, 0xdd, 0x38, 0x52, 0xad, 0xa6, 0x35, 0x80, 0xae, 0x2b, 0x81 + , 0x4d, 0xea, 0x42, 0x26, 0xb7, 0x20, 0x6d, 0x1e, 0x0e, 0x2e, 0x4e, 0xe8, 0x7d, 0x48, 0xdc, 0x90 + , 0xe1, 0x35, 0x50, 0x9b, 0x07, 0x1c, 0xf8, 0xc0, 0xe0, 0x07, 0x25, 0x7f, 0x48, 0xcf, 0x0b, 0x18 + , 0x51, 0xa4, 0xae, 0x55, 0x00, 0x08, 0x20, 0x72, 0x26, 0x14, 0x59, 0x98, 0x59, 0x80, 0x2e, 0x81 + , 0xa6, 0xe1, 0xff, 0x90, 0xed, 0x05, 0xd0, 0x7b, 0xfd, 0x18, 0x11, 0x25, 0x0e, 0x74, 0x6f, 0x0d + , 0x78, 0xa9, 0x24, 0x2b, 0x64, 0xcd, 0x06, 0x90, 0xf5, 0x13, 0xc8, 0xfd, 0xc5, 0x0c, 0x1b, 0xcd + , 0xfe, 0x33, 0x48, 0x4a, 0x24, 0xe8, 0xde, 0x15, 0xe8, 0x6a, 0x2a, 0xc8, 0x32, 0x10, 0xd8, 0x00 + , 0x27, 0x6c, 0x79, 0x02, 0x17, 0xa4, 0xf0, 0xe1, 0x02, 0x95, 0xfc, 0x90, 0xb4, 0x2f, 0x04, 0x49 + , 0xfb, 0xe0, 0xae, 0x2f, 0x2f, 0xb0, 0xdb, 0x05, 0x0c, 0x7d, 0xd2, 0x27, 0x68, 0x01, 0x02, 0x88 + , 0xcc, 0x19, 0x5d, 0xa0, 0x73, 0xb9, 0xa1, 0x57, 0x15, 0x43, 0xb7, 0xd4, 0x33, 0xc2, 0x36, 0xa3 + , 0xbd, 0x83, 0x06, 0x3d, 0x33, 0x33, 0xfc, 0x8e, 0x39, 0xf0, 0x42, 0x30, 0xe8, 0x75, 0x97, 0x3f + , 0x59, 0x7e, 0xb2, 0xb2, 0xfc, 0xfc, 0xf9, 0x9b, 0x85, 0x05, 0x74, 0x9a, 0x32, 0xf8, 0x00, 0x47 + , 0xd0, 0x19, 0x69, 0x03, 0x73, 0x14, 0x14, 0xb0, 0xa6, 0x85, 0xee, 0xcd, 0x82, 0x2e, 0xe5, 0x61 + , 0x45, 0x8c, 0xf3, 0x40, 0x46, 0x39, 0x39, 0x39, 0x11, 0xeb, 0x43, 0x20, 0xed, 0x1f, 0x1e, 0x70 + , 0xb8, 0x83, 0x8a, 0x7d, 0x60, 0xe8, 0x43, 0x5a, 0xfd, 0xe0, 0xb6, 0x10, 0x37, 0x79, 0xd3, 0xe3 + , 0x00, 0x01, 0x44, 0xfe, 0x94, 0x3a, 0xd0, 0xcd, 0x40, 0x5b, 0x19, 0x20, 0x7b, 0xfc, 0x40, 0x11 + , 0x00, 0x49, 0xef, 0xd0, 0x30, 0x47, 0xec, 0x79, 0x82, 0xae, 0xd0, 0x66, 0x86, 0x6c, 0x4c, 0x00 + , 0x11, 0x3f, 0x81, 0x1e, 0x85, 0xdc, 0x36, 0xcf, 0xf2, 0x9b, 0x15, 0x94, 0x13, 0x58, 0x20, 0x47 + , 0x59, 0x03, 0x5b, 0xb7, 0xf4, 0x3a, 0x91, 0x05, 0xb4, 0x8e, 0x13, 0xbc, 0x17, 0x0e, 0xb4, 0x20 + , 0x19, 0xb6, 0x9c, 0x0a, 0xdc, 0xde, 0x67, 0x87, 0xad, 0x02, 0x01, 0x35, 0x7c, 0x10, 0xa3, 0x6c + , 0xa0, 0xf0, 0xe7, 0x04, 0x56, 0xbb, 0xc0, 0x90, 0x17, 0x14, 0x80, 0xa4, 0x7b, 0xd0, 0x90, 0x03 + , 0x30, 0xf0, 0x81, 0x51, 0xc2, 0x45, 0x6e, 0xe8, 0x03, 0x01, 0x40, 0x00, 0x51, 0xb4, 0xa6, 0x01 + , 0x68, 0x2b, 0x30, 0xea, 0xa1, 0x7b, 0x60, 0x21, 0xd7, 0x1a, 0xb3, 0x30, 0x43, 0x97, 0xf1, 0xb2 + , 0x81, 0xf7, 0x39, 0xb1, 0x42, 0x20, 0x2b, 0x2b, 0x7c, 0x7d, 0xe9, 0x77, 0x50, 0x1e, 0xff, 0xf9 + , 0x03, 0xc8, 0x02, 0x76, 0xd1, 0x58, 0x21, 0x97, 0xa0, 0x41, 0x0f, 0x2b, 0x65, 0xf9, 0x03, 0x9b + , 0xdd, 0xfc, 0xf7, 0x9f, 0x36, 0x19, 0x02, 0xbc, 0x7d, 0x14, 0x9c, 0x4c, 0x58, 0xc0, 0x77, 0x90 + , 0x83, 0x17, 0x37, 0x41, 0x52, 0x3e, 0x64, 0x74, 0x9f, 0x0d, 0xbc, 0x8c, 0x10, 0xd2, 0xf2, 0xe1 + , 0x82, 0x0c, 0xf6, 0x40, 0x46, 0xfa, 0xb9, 0xb9, 0xf9, 0x78, 0xf9, 0x40, 0xc1, 0x0e, 0xc4, 0xe0 + , 0xf6, 0x3e, 0x3f, 0x1f, 0xbc, 0xc9, 0xcf, 0x49, 0xc9, 0xd2, 0x10, 0x80, 0x00, 0xa2, 0x74, 0x51 + , 0x09, 0xd0, 0x2b, 0x5c, 0xdc, 0x5c, 0xf0, 0xba, 0x17, 0x9a, 0xdc, 0x59, 0x59, 0xd8, 0xc1, 0x49 + , 0xea, 0xc3, 0x87, 0x0f, 0x90, 0x28, 0x80, 0x2e, 0x6b, 0xfc, 0x0e, 0x9a, 0x40, 0xfd, 0xf1, 0xf3 + , 0x27, 0x1b, 0xdb, 0x0f, 0x20, 0x84, 0x5c, 0x4d, 0xf3, 0x9b, 0xed, 0x17, 0xbc, 0x4a, 0x80, 0x0d + , 0x71, 0x43, 0x46, 0xf8, 0x20, 0xe3, 0x4c, 0x54, 0x38, 0xa8, 0x0e, 0xb1, 0x5d, 0x17, 0x71, 0xfb + , 0x2f, 0xa2, 0xd0, 0x67, 0x85, 0xb7, 0xf7, 0xc1, 0xeb, 0x71, 0xd8, 0xe1, 0x73, 0x5b, 0xb0, 0xe4 + , 0x0f, 0x24, 0x40, 0xe9, 0x9d, 0x1f, 0x1c, 0xf2, 0x7c, 0xe0, 0x74, 0x0f, 0x6a, 0xef, 0x83, 0xa7 + , 0xba, 0xb8, 0xb8, 0x88, 0xe9, 0xee, 0xe2, 0x01, 0x00, 0x01, 0x58, 0xbb, 0x62, 0x2d, 0x00, 0x41 + , 0x10, 0x38, 0x50, 0x5a, 0x53, 0xff, 0xff, 0x99, 0x4c, 0xe5, 0x23, 0xdf, 0x0b, 0x0e, 0xc2, 0x96 + , 0xa6, 0x9a, 0x5c, 0x01, 0x15, 0x79, 0x78, 0x77, 0xfc, 0x80, 0xea, 0x51, 0xaf, 0xd4, 0x48, 0x02 + , 0xdd, 0xfe, 0x26, 0x34, 0x05, 0x4e, 0x49, 0x7d, 0x62, 0xe6, 0xe4, 0x19, 0xf8, 0xfb, 0x56, 0xf6 + , 0xa3, 0xcd, 0xa5, 0x55, 0xdd, 0x88, 0x0a, 0xb5, 0x7c, 0x09, 0x51, 0xeb, 0xd3, 0x67, 0x33, 0x49 + , 0x97, 0x87, 0x5e, 0x6f, 0x47, 0xa7, 0xb5, 0xa3, 0xdb, 0x61, 0x82, 0x6a, 0x10, 0xfe, 0x7a, 0xcf + , 0x54, 0x21, 0x0a, 0x93, 0x02, 0x17, 0x04, 0x0a, 0x68, 0x5e, 0xd0, 0x31, 0xfb, 0x97, 0xc2, 0xaa + , 0x09, 0x18, 0xc2, 0xa0, 0xa5, 0x20, 0xfe, 0xe3, 0x67, 0xd7, 0x56, 0x2d, 0x38, 0x37, 0x6f, 0xf0 + , 0xdb, 0xa9, 0xb7, 0xd8, 0x7b, 0x0d, 0x6a, 0xb8, 0xcd, 0x75, 0xf9, 0x4e, 0x59, 0xbc, 0x04, 0x10 + , 0x75, 0x96, 0x55, 0x01, 0xdd, 0x01, 0x4c, 0x0b, 0xd0, 0x04, 0x06, 0xbb, 0xd8, 0x15, 0x36, 0x57 + , 0x0d, 0x9a, 0xb5, 0xf8, 0xf8, 0xf1, 0x33, 0x28, 0xe4, 0xbf, 0x43, 0x72, 0x39, 0xfb, 0x4f, 0x8e + , 0x9f, 0x3f, 0x7e, 0x70, 0x40, 0x2e, 0xe5, 0x83, 0xc5, 0xc0, 0xaf, 0xdf, 0x90, 0x73, 0xc3, 0x21 + , 0xd7, 0x74, 0x40, 0xe7, 0xda, 0xc0, 0xd3, 0xfd, 0x90, 0x33, 0x64, 0x41, 0x03, 0xae, 0x90, 0x51 + , 0x6f, 0xa0, 0x85, 0xff, 0xe0, 0x27, 0xaa, 0x31, 0x40, 0x4f, 0xe1, 0x61, 0x80, 0x32, 0x20, 0x07 + , 0x1f, 0x31, 0x42, 0x77, 0xf7, 0x23, 0x6d, 0x55, 0x87, 0xee, 0x72, 0x83, 0xec, 0xb8, 0x42, 0x5a + , 0x42, 0x0e, 0xd9, 0x35, 0x01, 0x1e, 0xe4, 0xe7, 0x80, 0xe6, 0x00, 0x4e, 0xd8, 0x68, 0x33, 0x1f + , 0x78, 0x68, 0x9f, 0x1f, 0x32, 0xc0, 0xcf, 0xc7, 0x07, 0x1e, 0xe4, 0x01, 0xa5, 0x7c, 0x60, 0x9f + , 0x98, 0x83, 0xe8, 0xbe, 0x2e, 0x7e, 0x00, 0x10, 0x40, 0xd4, 0x5c, 0xd7, 0x06, 0x0c, 0x70, 0x48 + , 0x35, 0x0c, 0xee, 0xcb, 0x40, 0x4b, 0x55, 0x78, 0x72, 0xfa, 0xf4, 0x09, 0x74, 0x27, 0x2e, 0xfb + , 0x77, 0x60, 0xef, 0x06, 0x74, 0x25, 0xe8, 0x0f, 0x0e, 0xd8, 0xa5, 0xa0, 0xe0, 0xd5, 0x16, 0xbf + , 0xe1, 0x17, 0xae, 0x80, 0xe7, 0xf9, 0x7f, 0xff, 0xfe, 0x83, 0x74, 0x74, 0x35, 0x38, 0x12, 0xfe + , 0xc2, 0x4e, 0xf0, 0x05, 0x1f, 0x1f, 0x0b, 0x3b, 0x94, 0x10, 0x3e, 0x02, 0x02, 0x3d, 0xcc, 0x85 + , 0x09, 0x7e, 0x34, 0x09, 0x68, 0x63, 0x2d, 0xf8, 0x84, 0x12, 0xc4, 0x76, 0x51, 0xd8, 0xbe, 0x2d + , 0x56, 0x16, 0x78, 0xc9, 0xc3, 0x06, 0x5d, 0x47, 0x08, 0x9e, 0x5c, 0x87, 0xcf, 0xae, 0x73, 0x72 + , 0x00, 0x9b, 0x95, 0xa0, 0x00, 0xe7, 0x03, 0xcf, 0x2d, 0x82, 0xa7, 0xd7, 0x41, 0x3d, 0x5f, 0x1e + , 0x6e, 0x48, 0xbd, 0x4c, 0xe4, 0x38, 0x0f, 0x31, 0x00, 0x20, 0x00, 0x6b, 0x67, 0x94, 0x02, 0x30 + , 0x0c, 0xc2, 0xd0, 0xbf, 0xb5, 0x65, 0xbb, 0xff, 0x45, 0x45, 0xe6, 0xba, 0x51, 0x46, 0x13, 0x1d + , 0xc2, 0x7e, 0x7b, 0x85, 0x22, 0x55, 0x7c, 0x31, 0x59, 0x2c, 0x2c, 0xc4, 0x1d, 0x93, 0x4f, 0x9e + , 0x8e, 0xee, 0x2a, 0x1b, 0x1a, 0xb6, 0x58, 0xb2, 0x8b, 0x88, 0xaa, 0x9a, 0x9d, 0xd5, 0xfa, 0xd5 + , 0x90, 0x6a, 0x03, 0xd4, 0x3f, 0x83, 0x0d, 0x9e, 0x19, 0xd4, 0xd4, 0xef, 0x8f, 0xb7, 0xb1, 0x25 + , 0x8c, 0xb0, 0xbf, 0x1e, 0x79, 0xf3, 0xfa, 0xf3, 0xd1, 0x0c, 0x4b, 0xa3, 0x48, 0x1a, 0x4f, 0x4e + , 0x01, 0x3e, 0x96, 0xf1, 0xf1, 0xb7, 0xf4, 0xf5, 0xa3, 0xfe, 0x29, 0x27, 0x2c, 0xc5, 0x41, 0x57 + , 0xa1, 0x96, 0xca, 0x91, 0x16, 0xb1, 0xd6, 0xe1, 0x6c, 0x1d, 0x02, 0xe7, 0xb6, 0xf6, 0x44, 0xee + , 0x15, 0x40, 0xd4, 0x5f, 0xd9, 0x09, 0x74, 0x1f, 0xd0, 0xa9, 0xe0, 0x28, 0x00, 0xaf, 0x53, 0x05 + , 0xe5, 0x6b, 0x76, 0x0e, 0xe8, 0x38, 0x22, 0xa8, 0x29, 0x0d, 0x8c, 0x00, 0x48, 0x34, 0xfc, 0xfc + , 0xc9, 0x09, 0x2c, 0x86, 0x7e, 0x71, 0xc2, 0x4a, 0x21, 0xd8, 0xa5, 0x59, 0xa0, 0xb9, 0x86, 0x5f + , 0x88, 0x63, 0xc4, 0x41, 0xb3, 0x9e, 0x48, 0xe7, 0xb7, 0x83, 0x4f, 0x76, 0x84, 0x54, 0x05, 0xb0 + , 0x56, 0x2b, 0xb8, 0xe0, 0x87, 0x9c, 0x7a, 0xc1, 0xc4, 0x08, 0x3b, 0x1c, 0x06, 0x3a, 0xf8, 0x81 + , 0x52, 0xeb, 0x42, 0x9b, 0x08, 0xf0, 0xd5, 0xfb, 0x6c, 0x6c, 0xd0, 0x4d, 0xb9, 0xe0, 0x9d, 0x2b + , 0x5c, 0x5c, 0xa0, 0x55, 0x3c, 0xbc, 0xd0, 0x51, 0x4e, 0xc8, 0x50, 0x1b, 0x2f, 0x64, 0x64, 0x1f + , 0x92, 0x89, 0x71, 0xad, 0x6c, 0xa0, 0x04, 0x00, 0x04, 0x10, 0xad, 0x96, 0xd6, 0x82, 0xb7, 0x21 + , 0x30, 0xc3, 0xca, 0x58, 0x70, 0x87, 0x1e, 0x3a, 0x73, 0xca, 0xfd, 0xe5, 0xeb, 0x37, 0x1e, 0xf0 + , 0x72, 0x47, 0xf0, 0x6a, 0xa3, 0xaf, 0xb0, 0x8b, 0x85, 0x60, 0x77, 0x54, 0x22, 0xb7, 0x88, 0xa0 + , 0xcb, 0x2e, 0x10, 0x07, 0xb9, 0xff, 0x07, 0x1f, 0x79, 0xcd, 0x80, 0x38, 0xc7, 0x1a, 0x71, 0x28 + , 0x21, 0xe4, 0x68, 0x24, 0x06, 0xf8, 0xa9, 0x5f, 0x90, 0x1c, 0xc0, 0x02, 0xdb, 0x33, 0x0a, 0xdf + , 0x87, 0xcb, 0x8a, 0x68, 0xfb, 0x40, 0x00, 0x30, 0xf5, 0xc3, 0x86, 0x98, 0xa1, 0x23, 0xfc, 0x90 + , 0xa1, 0x7e, 0x48, 0xdb, 0x1f, 0x34, 0xaf, 0x02, 0x5a, 0x56, 0xce, 0xce, 0x4c, 0x9b, 0x0d, 0xd2 + , 0x00, 0x01, 0xc4, 0x48, 0xeb, 0xd3, 0x28, 0xc1, 0xb7, 0xf3, 0xfd, 0x82, 0xde, 0x8d, 0x08, 0xb9 + , 0xa5, 0xfe, 0x2b, 0xe4, 0x86, 0x63, 0x08, 0x0b, 0xbc, 0xe4, 0x0b, 0xb4, 0xea, 0xe5, 0x3b, 0x2c + , 0x0a, 0x7e, 0x41, 0xee, 0x7f, 0x82, 0x1f, 0xf4, 0x0e, 0xbd, 0xb9, 0x06, 0x36, 0xfd, 0x09, 0x3f + , 0x0a, 0x98, 0x01, 0x56, 0x09, 0xff, 0x87, 0x1e, 0x3b, 0x08, 0x3b, 0x51, 0x07, 0x51, 0xfe, 0xc0 + , 0xce, 0x88, 0x61, 0x81, 0x77, 0xc8, 0x61, 0x3b, 0x47, 0xd9, 0x40, 0x7b, 0x81, 0xc0, 0x83, 0xcc + , 0xd0, 0xe9, 0x74, 0x2e, 0xd8, 0x3c, 0x0b, 0x78, 0xd4, 0x07, 0x3a, 0xe3, 0x0b, 0x5e, 0x5f, 0x0b + , 0xda, 0x32, 0x4d, 0xbb, 0xf0, 0x01, 0x08, 0x20, 0x9a, 0x47, 0x00, 0x04, 0x80, 0x2f, 0x70, 0x02 + , 0xdf, 0x10, 0xf7, 0x1d, 0x72, 0x4d, 0x28, 0xe8, 0x5e, 0x39, 0xf0, 0x1d, 0xa3, 0x60, 0x0e, 0xf4 + , 0xa6, 0x7a, 0xf0, 0x1d, 0xa2, 0x3f, 0x7f, 0x42, 0x57, 0xdd, 0x41, 0x66, 0xde, 0x20, 0xf8, 0xcf + , 0x3f, 0xa4, 0x6a, 0x00, 0xf9, 0xe4, 0x5f, 0xd8, 0xd1, 0x8e, 0x90, 0xb3, 0x20, 0xa1, 0xc7, 0x7b + , 0x81, 0x4b, 0x20, 0xc8, 0x71, 0x30, 0xb0, 0xd3, 0x2e, 0x20, 0x5b, 0xa5, 0x59, 0xa0, 0xeb, 0xc8 + , 0xd9, 0x21, 0x2b, 0xd8, 0x38, 0x61, 0x00, 0xb6, 0xa8, 0x0a, 0xd6, 0xf8, 0xe7, 0xe4, 0x80, 0x6c + , 0x16, 0xa5, 0x45, 0x99, 0x83, 0x06, 0x00, 0x02, 0xf0, 0x76, 0x06, 0x29, 0x00, 0x80, 0x20, 0x10 + , 0x94, 0xa0, 0xff, 0x3f, 0x57, 0x8d, 0xc2, 0x50, 0x57, 0xfb, 0x41, 0x9d, 0xba, 0x27, 0x62, 0xab + , 0xee, 0x7c, 0x7a, 0x00, 0x3f, 0x66, 0xc1, 0x29, 0x53, 0x01, 0x2a, 0x11, 0xc8, 0xd0, 0x40, 0xb7 + , 0x0a, 0x2b, 0x03, 0x99, 0x0e, 0x7e, 0x71, 0xf0, 0xbf, 0x97, 0xfa, 0xd0, 0xcb, 0x86, 0xff, 0xfe + , 0xa9, 0x14, 0x64, 0xd5, 0x01, 0xb5, 0x0e, 0x7f, 0xca, 0x3e, 0x10, 0x8d, 0xe7, 0x7f, 0xd7, 0x52 + , 0xa0, 0x1b, 0x96, 0x60, 0xc7, 0x0a, 0xf5, 0xa6, 0x7f, 0x76, 0x53, 0xe9, 0xa9, 0x61, 0x5a, 0x5c + , 0x53, 0x06, 0x8a, 0xfa, 0x68, 0xfe, 0x31, 0x04, 0xb8, 0x02, 0x88, 0x8e, 0x11, 0x00, 0x06, 0xc0 + , 0x60, 0x83, 0xb6, 0xfa, 0xc1, 0x57, 0x6a, 0x41, 0x82, 0xfb, 0x27, 0x74, 0xc5, 0xd7, 0x0f, 0xf0 + , 0x9d, 0xc5, 0x3f, 0x7f, 0xc0, 0x2e, 0xed, 0xfe, 0x0d, 0xbe, 0x4f, 0xee, 0x17, 0xe4, 0xd6, 0x21 + , 0x58, 0x7d, 0x00, 0x5f, 0x80, 0xf4, 0x0f, 0x6a, 0x1e, 0x68, 0xfa, 0x1f, 0xd6, 0xfc, 0x81, 0xf6 + , 0x00, 0x60, 0x07, 0x5d, 0x30, 0x43, 0x0e, 0x5c, 0x00, 0x36, 0xf9, 0x61, 0x5b, 0x7b, 0xa0, 0x85 + , 0x3e, 0x78, 0x23, 0x28, 0x74, 0x55, 0x2d, 0xa4, 0x06, 0x86, 0x1d, 0x22, 0x00, 0xaa, 0xa0, 0xe9 + , 0xb9, 0xff, 0x13, 0x20, 0x80, 0xe8, 0x1d, 0x01, 0x70, 0xf0, 0x17, 0x7c, 0x71, 0x1f, 0xa4, 0xe9 + , 0xf3, 0x13, 0x52, 0x42, 0x41, 0xaf, 0x66, 0x87, 0x62, 0xe8, 0x95, 0xb0, 0xd0, 0x65, 0xc0, 0xd0 + , 0x7b, 0x85, 0xfe, 0xc0, 0xd6, 0xc1, 0xfc, 0x83, 0x1d, 0x73, 0xcd, 0x08, 0x5e, 0x02, 0x03, 0xad + , 0x84, 0x11, 0x65, 0x3f, 0xe2, 0xfc, 0x29, 0xc8, 0x26, 0x73, 0x48, 0xa2, 0x06, 0x9f, 0xc1, 0x00 + , 0x86, 0x6c, 0x88, 0x1c, 0x01, 0xdb, 0x0c, 0xcd, 0x32, 0x20, 0xfb, 0x3e, 0x01, 0x02, 0x68, 0xc0 + , 0x22, 0x00, 0x02, 0x80, 0xc1, 0x08, 0xb9, 0xeb, 0x0c, 0xda, 0xfa, 0xf9, 0x85, 0xc0, 0x7f, 0xa0 + , 0x0b, 0x61, 0x20, 0x37, 0x58, 0x42, 0xae, 0x16, 0x82, 0x5e, 0xf3, 0x81, 0x58, 0x87, 0x01, 0x39 + , 0x88, 0x19, 0x94, 0x0b, 0xd0, 0x9a, 0xff, 0xa8, 0x9d, 0x2f, 0x50, 0xa5, 0x0b, 0xed, 0x1c, 0xb2 + , 0xa2, 0x01, 0x70, 0x5b, 0x6d, 0x00, 0x8f, 0x62, 0x03, 0x08, 0xa0, 0x01, 0x8e, 0x00, 0x38, 0x00 + , 0x3a, 0xe3, 0x0f, 0xa2, 0xa0, 0x81, 0xdd, 0x60, 0x09, 0x5f, 0xff, 0xf8, 0x07, 0x7c, 0xbd, 0x0d + , 0xec, 0x7e, 0x8f, 0xff, 0x90, 0x8a, 0x00, 0x7a, 0x3a, 0x3c, 0xbc, 0x17, 0x8c, 0xd4, 0x04, 0x02 + , 0x9d, 0x58, 0x02, 0x1e, 0x1a, 0x44, 0x8e, 0x06, 0x0c, 0x30, 0x18, 0x8e, 0x7d, 0x01, 0x08, 0xa0 + , 0xc1, 0x12, 0x01, 0xc8, 0x00, 0x76, 0x75, 0x19, 0xb8, 0x13, 0x06, 0xbd, 0xdf, 0x09, 0x72, 0x0d + , 0x11, 0xb4, 0x06, 0x86, 0xb4, 0x83, 0x90, 0x2b, 0x61, 0x06, 0x58, 0x04, 0x30, 0xc0, 0x8e, 0x9f + , 0x85, 0x8f, 0x7e, 0xb2, 0xc0, 0xe6, 0x87, 0x20, 0x1b, 0xfc, 0x07, 0xdb, 0xf6, 0x66, 0x80, 0x00 + , 0x1a, 0x8c, 0x11, 0x80, 0x0c, 0x40, 0xc1, 0x0c, 0xbb, 0x17, 0x0d, 0x72, 0xa5, 0x0d, 0x7c, 0x35 + , 0x00, 0xe4, 0x18, 0x78, 0xd0, 0x19, 0xcc, 0xd0, 0x59, 0x69, 0xd8, 0x89, 0xcb, 0x88, 0x13, 0x98 + , 0xa1, 0x43, 0x42, 0x83, 0xf9, 0xd4, 0x6b, 0x80, 0x00, 0x03, 0x00, 0x36, 0x48, 0x61, 0x8b, 0x2d + , 0x54, 0xbb, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, 0x0a }; + +} +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreStableHeaders.h b/school/informatik/verkerhssimulation/src/ogre/OgreStableHeaders.h new file mode 100644 index 00000000..c582c1e6 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreStableHeaders.h @@ -0,0 +1,80 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +/* Stable headers which will be used for precompilation if the compiler + supports it. Add entries here when headers are unlikely to change. + NB: a change to any of these headers will result in a full rebuild, + so don't add things to this lightly. +*/ + +#ifndef __OgreStableHeaders__ +#define __OgreStableHeaders__ + +#include "OgrePlatform.h" + +#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_APPLE +#include "OgreArchive.h" +#include "OgreAxisAlignedBox.h" +#include "OgreBitwise.h" +#include "OgreCamera.h" +#include "OgreColourValue.h" +#include "OgreCommon.h" +#include "OgreDataStream.h" +#include "OgreException.h" +#include "OgreFileSystem.h" +#include "OgreLog.h" +#include "OgreMath.h" +#include "OgreMatrix3.h" +#include "OgreMatrix4.h" +#include "OgreMovableObject.h" +#include "OgreNode.h" +#include "OgrePlane.h" +#include "OgrePrerequisites.h" +#include "OgreQuaternion.h" +#include "OgreResource.h" +#include "OgreSerializer.h" +#include "OgreSharedPtr.h" +#include "OgreSimpleRenderable.h" +#include "OgreSimpleSpline.h" +#include "OgreSingleton.h" +#include "OgreSphere.h" +#include "OgreStdHeaders.h" +#include "OgreString.h" +#include "OgreStringConverter.h" +#include "OgreStringInterface.h" +#include "OgreStringVector.h" +#include "OgreUserDefinedObject.h" +#include "OgreVector2.h" +#include "OgreVector3.h" +#include "OgreVector4.h" +#include "OgreWireBoundingBox.h" +#include "OgreZip.h" +#endif + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreStaticFaceGroup.h b/school/informatik/verkerhssimulation/src/ogre/OgreStaticFaceGroup.h new file mode 100644 index 00000000..570445c8 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreStaticFaceGroup.h @@ -0,0 +1,134 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __StaticFaceGroup_H__ +#define __StaticFaceGroup_H__ + +#include "OgrePrerequisites.h" + +#include "OgrePlane.h" +#include "OgrePatchSurface.h" + +namespace Ogre { + + /** A type of face group, ie face list of procedural etc */ + enum FaceGroupType { + FGT_FACE_LIST, + FGT_PATCH, + FGT_UNKNOWN + }; + + /** Collectes a group of static ie immovable faces together which have common + properties like the material they use, the plane they lie on. + @remarks + Whilst for discrete geometry (i.e. movable objects) groups of faces are + held in the SubMesh class, for immovable objects like scenery there + needs to ba little more flexibility in the grouping since the group is + likely to be a small part of a huge set of geometry. In addition, because + the faces are unmoving certain optimisations can be performed, e.g. + precalculating a world-coordinate bounding box and normal. + @par + Exactly how this class is used depends on the format of the large + static geometry used in the level. An example would be the use of this + class in the BspNode class for indoor levels. + For flexibility and efficiency, it is not assumed that this class holds + details of the vertices itself, or in fact that it holds the vertex indices + itself. Everything is manipulated via pointers so if you want this + class to point into a block of geometry data it can. + */ + struct StaticFaceGroup { + // Type of face group. + FaceGroupType fType; + + /// Is this a sky surface? + bool isSky; + + /** Index into a buffer containing vertex definitions. Because we're + dealing with subsets of large levels this is likely to be part-way + through a huge vertex buffer. */ + int vertexStart; + + /** The range of vertices in the buffer this facegroup references. + This is really for copying purposes only, so that we know which + subset of vertices to copy from our large-level buffer into the rendering buffer. + */ + int numVertices; + + /** Index into a buffer containing vertex indices. This buffer + may be individual to this group or shared for memory allocation + efficiency.The vertex indexes are relative the the mVertexStart pointer, + not to the start of the large-level buffer, allowing simple reindexing + when copying data into rendering buffers. + This is only applicable to FGT_FACE_LIST face group types. + */ + int elementStart; + + /** The number of vertex indices. + This is only applicable to FGT_FACE_LIST face group types. + */ + int numElements; + + /** Handle to material used by this group. + Note the use of the material handle rather than the material + name - this is for efficiency since there will be many of these. + */ + int materialHandle; + + Plane plane; + + /// Patch surface (only applicable when fType = FGT_PATCH) + PatchSurface* patchSurf; + + + _OgreExport friend std::ostream& operator<<(std::ostream& o, const StaticFaceGroup& s) + { + o << "StaticFaceGroup("; + if (s.fType == FGT_FACE_LIST) + { + o << "faceList, numVertices=" << s.numVertices << ", vertexStart=" << s.vertexStart; + o << ", numElements=" << s.numElements << ", elementStart=" << s.elementStart; + o << ", normal=" << s.plane.normal; + } + else if (s.fType == FGT_PATCH) + { + o << "bezierPatch, numVertices=" << s.numVertices << ", vertexStart=" << s.vertexStart; + // TODO + } + + o << ", materialHandle=" << s.materialHandle; + o << ")"; + + return o; + } + + + }; + +} // namespace + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreStaticGeometry.h b/school/informatik/verkerhssimulation/src/ogre/OgreStaticGeometry.h new file mode 100644 index 00000000..9d64dc69 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreStaticGeometry.h @@ -0,0 +1,748 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __StaticGeometry_H__ +#define __StaticGeometry_H__ + +#include "OgrePrerequisites.h" +#include "OgreMovableObject.h" +#include "OgreRenderable.h" + +namespace Ogre { + + /** Pre-transforms and batches up meshes for efficient use as static + geometry in a scene. + @remarks + Modern graphics cards (GPUs) prefer to receive geometry in large + batches. It is orders of magnitude faster to render 10 batches + of 10,000 triangles than it is to render 10,000 batches of 10 + triangles, even though both result in the same number of on-screen + triangles. + @par + Therefore it is important when you are rendering a lot of geometry to + batch things up into as few rendering calls as possible. This + class allows you to build a batched object from a series of entities + in order to benefit from this behaviour. + Batching has implications of it's own though: + @li Batched geometry cannot be subdivided; that means that the whole + group will be displayed, or none of it will. This obivously has + culling issues. + @li A single world transform must apply to the entire batch. Therefore + once you have batched things, you can't move them around relative to + each other. That's why this class is most useful when dealing with + static geometry (hence the name). In addition, geometry is + effectively duplicated, so if you add 3 entities based on the same + mesh in different positions, they will use 3 times the geometry + space than the movable version (which re-uses the same geometry). + So you trade memory and flexibility of movement for pure speed when + using this class. + @li A single material must apply for each batch. In fact this class + allows you to use multiple materials, but you should be aware that + internally this means that there is one batch per material. + Therefore you won't gain as much benefit from the batching if you + use many different materials; try to keep the number down. + @par + In order to retain some sort of culling, this class will batch up + meshes in localised regions. The size and shape of these blocks is + controlled by the SceneManager which contructs this object, since it + makes sense to batch things up in the most appropriate way given the + existing partitioning of the scene. + @par + The LOD settings of both the Mesh and the Materials used in + constructing this static geometry will be respected. This means that + if you use meshes/materials which have LOD, batches in the distance + will have a lower polygon count or material detail to those in the + foreground. Since each mesh might have different LOD distances, during + build the furthest distance at each LOD level from all meshes + in that region is used. This means all the LOD levels change at the + same time, but at the furthest distance of any of them (so quality is + not degraded). Be aware that using Mesh LOD in this class will + further increase the memory required. Only generated LOD + is supported for meshes. + @par + There are 2 ways you can add geometry to this class; you can add + Entity objects directly with predetermined positions, scales and + orientations, or you can add an entire SceneNode and it's subtree, + including all the objects attached to it. Once you've added everthing + you need to, you have to call build() the fix the geometry in place. + @note + This class is not a replacement for world geometry (@see + SceneManager::setWorldGeometry). The single most efficient way to + render large amounts of static geometry is to use a SceneManager which + is specialised for dealing with that particular world structure. + However, this class does provide you with a good 'halfway house' + between generalised movable geometry (Entity) which works with all + SceneManagers but isn't efficient when using very large numbers, and + highly specialised world geometry which is extremely fast but not + generic and typically requires custom world editors. + @par + You should not construct instances of this class directly; instead, cal + SceneManager::createStaticGeometry, which gives the SceneManager the + option of providing you with a specialised version of this class if it + wishes, and also handles the memory management for you like other + classes. + @note + Warning: this class only works with triangle lists at the moment, + do not pass it triangle strips, fans or lines / points. + */ + class _OgreExport StaticGeometry + { + public: + /** Struct holding geometry optimised per SubMesh / lod level, ready + for copying to instances. + @remarks + Since we're going to be duplicating geometry lots of times, it's + far more important that we don't have redundant vertex data. If a + SubMesh uses shared geometry, or we're looking at a lower LOD, not + all the vertices are being referenced by faces on that submesh. + Therefore to duplicate them, potentially hundreds or even thousands + of times, would be extremely wasteful. Therefore, if a SubMesh at + a given LOD has wastage, we create an optimised version of it's + geometry which is ready for copying with no wastage. + */ + class _OgrePrivate OptimisedSubMeshGeometry + { + public: + OptimisedSubMeshGeometry() :vertexData(0), indexData(0) {} + ~OptimisedSubMeshGeometry() + { + delete vertexData; + delete indexData; + } + VertexData *vertexData; + IndexData *indexData; + }; + typedef std::list OptimisedSubMeshGeometryList; + /// Saved link between SubMesh at a LOD and vertex/index data + /// May point to original or optimised geometry + struct SubMeshLodGeometryLink + { + VertexData* vertexData; + IndexData* indexData; + }; + typedef std::vector SubMeshLodGeometryLinkList; + typedef std::map SubMeshGeometryLookup; + /// Structure recording a queued submesh for the build + struct QueuedSubMesh + { + SubMesh* submesh; + /// Link to LOD list of geometry, potentially optimised + SubMeshLodGeometryLinkList* geometryLodList; + String materialName; + Vector3 position; + Quaternion orientation; + Vector3 scale; + /// Pre-transformed world AABB + AxisAlignedBox worldBounds; + }; + typedef std::vector QueuedSubMeshList; + /// Structure recording a queued geometry for low level builds + struct QueuedGeometry + { + SubMeshLodGeometryLink* geometry; + Vector3 position; + Quaternion orientation; + Vector3 scale; + }; + typedef std::vector QueuedGeometryList; + + // forward declarations + class LODBucket; + class MaterialBucket; + class Region; + + /** A GeometryBucket is a the lowest level bucket where geometry with + the same vertex & index format is stored. It also acts as the + renderable. + */ + class _OgreExport GeometryBucket : public Renderable + { + protected: + /// Geometry which has been queued up pre-build (not for deallocation) + QueuedGeometryList mQueuedGeometry; + /// Pointer to parent bucket + MaterialBucket* mParent; + /// String identifying the vertex / index format + String mFormatString; + /// Vertex information, includes current number of vertices + /// committed to be a part of this bucket + VertexData* mVertexData; + /// Index information, includes index type which limits the max + /// number of vertices which are allowed in one bucket + IndexData* mIndexData; + /// Size of indexes + HardwareIndexBuffer::IndexType mIndexType; + /// Maximum vertex indexable + size_t mMaxVertexIndex; + + template + void copyIndexes(const T* src, T* dst, size_t count, size_t indexOffset) + { + if (indexOffset == 0) + { + memcpy(dst, src, sizeof(T) * count); + } + else + { + while(count--) + { + *dst++ = static_cast(*src++ + indexOffset); + } + } + } + public: + GeometryBucket(MaterialBucket* parent, const String& formatString, + const VertexData* vData, const IndexData* iData); + virtual ~GeometryBucket(); + MaterialBucket* getParent(void) { return mParent; } + /// Get the vertex data for this geometry + const VertexData* getVertexData(void) const { return mVertexData; } + /// Get the index data for this geometry + const IndexData* getIndexData(void) const { return mIndexData; } + /// @copydoc Renderable::getMaterial + const MaterialPtr& getMaterial(void) const; + Technique* getTechnique(void) const; + void getRenderOperation(RenderOperation& op); + void getWorldTransforms(Matrix4* xform) const; + const Quaternion& getWorldOrientation(void) const; + const Vector3& getWorldPosition(void) const; + Real getSquaredViewDepth(const Camera* cam) const; + const LightList& getLights(void) const; + bool getCastsShadows(void) const; + + /** Try to assign geometry to this bucket. + @returns false if there is no room left in this bucket + */ + bool assign(QueuedGeometry* qsm); + /// Build + void build(bool stencilShadows); + /// Dump contents for diagnostics + void dump(std::ofstream& of) const; + }; + /** A MaterialBucket is a collection of smaller buckets with the same + Material (and implicitly the same LOD). */ + class _OgreExport MaterialBucket + { + public: + /// list of Geometry Buckets in this region + typedef std::vector GeometryBucketList; + protected: + /// Pointer to parent LODBucket + LODBucket* mParent; + /// Material being used + String mMaterialName; + /// Pointer to material being used + MaterialPtr mMaterial; + /// Active technique + Technique* mTechnique; + + /// list of Geometry Buckets in this region + GeometryBucketList mGeometryBucketList; + // index to current Geometry Buckets for a given geometry format + typedef std::map CurrentGeometryMap; + CurrentGeometryMap mCurrentGeometryMap; + /// Get a packed string identifying the geometry format + String getGeometryFormatString(SubMeshLodGeometryLink* geom); + + public: + MaterialBucket(LODBucket* parent, const String& materialName); + virtual ~MaterialBucket(); + LODBucket* getParent(void) { return mParent; } + /// Get the material name + const String& getMaterialName(void) const { return mMaterialName; } + /// Assign geometry to this bucket + void assign(QueuedGeometry* qsm); + /// Build + void build(bool stencilShadows); + /// Add children to the render queue + void addRenderables(RenderQueue* queue, uint8 group, + Real camSquaredDist); + /// Get the material for this bucket + const MaterialPtr& getMaterial(void) const { return mMaterial; } + /// Iterator over geometry + typedef VectorIterator GeometryIterator; + /// Get an iterator over the contained geometry + GeometryIterator getGeometryIterator(void); + /// Get the current Technique + Technique* getCurrentTechnique(void) const { return mTechnique; } + /// Dump contents for diagnostics + void dump(std::ofstream& of) const; + }; + /** A LODBucket is a collection of smaller buckets with the same LOD. + @remarks + LOD refers to Mesh LOD here. Material LOD can change separately + at the next bucket down from this. + */ + class _OgreExport LODBucket + { + public: + /// Lookup of Material Buckets in this region + typedef std::map MaterialBucketMap; + protected: + /// Pointer to parent region + Region* mParent; + /// LOD level (0 == full LOD) + unsigned short mLod; + /// distance at which this LOD starts to apply (squared) + Real mSquaredDistance; + /// Lookup of Material Buckets in this region + MaterialBucketMap mMaterialBucketMap; + /// Geometry queued for a single LOD (deallocated here) + QueuedGeometryList mQueuedGeometryList; + public: + LODBucket(Region* parent, unsigned short lod, Real lodDist); + virtual ~LODBucket(); + Region* getParent(void) { return mParent; } + /// Get the lod index + ushort getLod(void) const { return mLod; } + /// Get the lod squared distance + Real getSquaredDistance(void) const { return mSquaredDistance; } + /// Assign a queued submesh to this bucket, using specified mesh LOD + void assign(QueuedSubMesh* qsm, ushort atLod); + /// Build + void build(bool stencilShadows); + /// Add children to the render queue + void addRenderables(RenderQueue* queue, uint8 group, + Real camSquaredDistance); + /// Iterator over the materials in this LOD + typedef MapIterator MaterialIterator; + /// Get an iterator over the materials in this LOD + MaterialIterator getMaterialIterator(void); + /// Dump contents for diagnostics + void dump(std::ofstream& of) const; + + }; + /** The details of a topological region which is the highest level of + partitioning for this class. + @remarks + The size & shape of regions entirely depends on the SceneManager + specific implementation. It is a MovableObject since it will be + attached to a node based on the local centre - in practice it + won't actually move (although in theory it could). + */ + class _OgreExport Region : public MovableObject + { + public: + /// list of LOD Buckets in this region + typedef std::vector LODBucketList; + protected: + /** Nested class to allow region shadows. */ + class _OgreExport RegionShadowRenderable : public ShadowRenderable + { + protected: + Region* mParent; + // Shared link to position buffer + HardwareVertexBufferSharedPtr mPositionBuffer; + // Shared link to w-coord buffer (optional) + HardwareVertexBufferSharedPtr mWBuffer; + + public: + RegionShadowRenderable(Region* parent, + HardwareIndexBufferSharedPtr* indexBuffer, const VertexData* vertexData, + bool createSeparateLightCap, bool isLightCap = false); + ~RegionShadowRenderable(); + /// Overridden from ShadowRenderable + void getWorldTransforms(Matrix4* xform) const; + /// Overridden from ShadowRenderable + const Quaternion& getWorldOrientation(void) const; + /// Overridden from ShadowRenderable + const Vector3& getWorldPosition(void) const; + HardwareVertexBufferSharedPtr getPositionBuffer(void) { return mPositionBuffer; } + HardwareVertexBufferSharedPtr getWBuffer(void) { return mWBuffer; } + + }; + /// Parent static geometry + StaticGeometry* mParent; + /// Scene manager link + SceneManager* mSceneMgr; + /// Scene node + SceneNode* mNode; + /// Local list of queued meshes (not used for deallocation) + QueuedSubMeshList mQueuedSubMeshes; + /// Unique identifier for the region + uint32 mRegionID; + /// Center of the region + Vector3 mCentre; + /// LOD distances (squared) as built up - use the max at each level + std::vector mLodSquaredDistances; + /// Local AABB relative to region centre + AxisAlignedBox mAABB; + /// Local bounding radius + Real mBoundingRadius; + /// The current lod level, as determined from the last camera + ushort mCurrentLod; + /// Current camera distance, passed on to do material lod later + Real mCamDistanceSquared; + /// List of LOD buckets + LODBucketList mLodBucketList; + /// List of lights for this region + mutable LightList mLightList; + /// The last frame that this light list was updated in + mutable ulong mLightListUpdated; + /// Edge list, used if stencil shadow casting is enabled + EdgeData* mEdgeList; + /// List of shadow renderables + ShadowRenderableList mShadowRenderables; + /// Is a vertex program in use somewhere in this region? + bool mVertexProgramInUse; + + + + public: + Region(StaticGeometry* parent, const String& name, SceneManager* mgr, + uint32 regionID, const Vector3& centre); + virtual ~Region(); + // more fields can be added in subclasses + StaticGeometry* getParent(void) const { return mParent;} + /// Assign a queued mesh to this region, read for final build + void assign(QueuedSubMesh* qmesh); + /// Build this region + void build(bool stencilShadows); + /// Get the region ID of this region + uint32 getID(void) const { return mRegionID; } + /// Get the centre point of the region + const Vector3& getCentre(void) const { return mCentre; } + const String& getMovableType(void) const; + void _notifyCurrentCamera(Camera* cam); + const AxisAlignedBox& getBoundingBox(void) const; + Real getBoundingRadius(void) const; + void _updateRenderQueue(RenderQueue* queue); + bool isVisible(void) const; + uint32 getTypeFlags(void) const; + + typedef VectorIterator LODIterator; + /// Get an iterator over the LODs in this region + LODIterator getLODIterator(void); + /// @copydoc ShadowCaster::getShadowVolumeRenderableIterator + ShadowRenderableListIterator getShadowVolumeRenderableIterator( + ShadowTechnique shadowTechnique, const Light* light, + HardwareIndexBufferSharedPtr* indexBuffer, + bool extrudeVertices, Real extrusionDistance, unsigned long flags = 0 ); + /// Overridden from MovableObject + EdgeData* getEdgeList(void); + /** Overridden member from ShadowCaster. */ + bool hasEdgeList(void); + + /// Dump contents for diagnostics + void dump(std::ofstream& of) const; + + }; + /** Indexed region map based on packed x/y/z region index, 10 bits for + each axis. + @remarks + Regions are indexed 0-1023 in all axes, where for example region + 0 in the x axis begins at mOrigin.x + (mRegionDimensions.x * -512), + and region 1023 ends at mOrigin + (mRegionDimensions.x * 512). + */ + typedef std::map RegionMap; + protected: + // General state & settings + SceneManager* mOwner; + String mName; + bool mBuilt; + Real mUpperDistance; + Real mSquaredUpperDistance; + bool mCastShadows; + Vector3 mRegionDimensions; + Vector3 mHalfRegionDimensions; + Vector3 mOrigin; + bool mVisible; + /// The render queue to use when rendering this object + uint8 mRenderQueueID; + /// Flags whether the RenderQueue's default should be used. + bool mRenderQueueIDSet; + + QueuedSubMeshList mQueuedSubMeshes; + + /// List of geometry which has been optimised for SubMesh use + /// This is the primary storage used for cleaning up later + OptimisedSubMeshGeometryList mOptimisedSubMeshGeometryList; + + /** Cached links from SubMeshes to (potentially optimised) geometry + This is not used for deletion since the lookup may reference + original vertex data + */ + SubMeshGeometryLookup mSubMeshGeometryLookup; + + /// Map of regions + RegionMap mRegionMap; + + /** Virtual method for getting a region most suitable for the + passed in bounds. Can be overridden by subclasses. + */ + virtual Region* getRegion(const AxisAlignedBox& bounds, bool autoCreate); + /** Get the region within which a point lies */ + virtual Region* getRegion(const Vector3& point, bool autoCreate); + /** Get the region using indexes */ + virtual Region* getRegion(ushort x, ushort y, ushort z, bool autoCreate); + /** Get the region using a packed index, returns null if it doesn't exist. */ + virtual Region* getRegion(uint32 index); + /** Get the region indexes for a point. + */ + virtual void getRegionIndexes(const Vector3& point, + ushort& x, ushort& y, ushort& z); + /** Pack 3 indexes into a single index value + */ + virtual uint32 packIndex(ushort x, ushort y, ushort z); + /** Get the volume intersection for an indexed region with some bounds. + */ + virtual Real getVolumeIntersection(const AxisAlignedBox& box, + ushort x, ushort y, ushort z); + /** Get the bounds of an indexed region. + */ + virtual AxisAlignedBox getRegionBounds(ushort x, ushort y, ushort z); + /** Get the centre of an indexed region. + */ + virtual Vector3 getRegionCentre(ushort x, ushort y, ushort z); + /** Calculate world bounds from a set of vertex data. */ + virtual AxisAlignedBox calculateBounds(VertexData* vertexData, + const Vector3& position, const Quaternion& orientation, + const Vector3& scale); + /** Look up or calculate the geometry data to use for this SubMesh */ + SubMeshLodGeometryLinkList* determineGeometry(SubMesh* sm); + /** Split some shared geometry into dedicated geometry. */ + void splitGeometry(VertexData* vd, IndexData* id, + SubMeshLodGeometryLink* targetGeomLink); + + typedef std::map IndexRemap; + /** Method for figuring out which vertices are used by an index buffer + and calculating a remap lookup for a vertex buffer just containing + those vertices. + */ + template + void buildIndexRemap(T* pBuffer, size_t numIndexes, IndexRemap& remap) + { + remap.clear(); + for (size_t i = 0; i < numIndexes; ++i) + { + // use insert since duplicates are silently discarded + remap.insert(IndexRemap::value_type(*pBuffer++, remap.size())); + // this will have mapped oldindex -> new index IF oldindex + // wasn't already there + } + } + /** Method for altering indexes based on a remap. */ + template + void remapIndexes(T* src, T* dst, const IndexRemap& remap, + size_t numIndexes) + { + for (size_t i = 0; i < numIndexes; ++i) + { + // look up original and map to target + IndexRemap::const_iterator ix = remap.find(*src++); + assert(ix != remap.end()); + *dst++ = static_cast(ix->second); + } + } + + public: + /// Constructor; do not use directly (@see SceneManager::createStaticGeometry) + StaticGeometry(SceneManager* owner, const String& name); + /// Destructor + virtual ~StaticGeometry(); + + /// Get the name of this object + const String& getName(void) const { return mName; } + /** Adds an Entity to the static geometry. + @remarks + This method takes an existing Entity and adds its details to the + list of elements to include when building. Note that the Entity + itself is not copied or referenced in this method; an Entity is + passed simply so that you can change the materials of attached + SubEntity objects if you want. You can add the same Entity + instance multiple times with different material settings + completely safely, and destroy the Entity before destroying + this StaticGeometry if you like. The Entity passed in is simply + used as a definition. + @note Must be called before 'build'. + @param ent The Entity to use as a definition (the Mesh and Materials + referenced will be recorded for the build call). + @param position The world position at which to add this Entity + @param orientation The world orientation at which to add this Entity + @param scale The scale at which to add this entity + */ + virtual void addEntity(Entity* ent, const Vector3& position, + const Quaternion& orientation = Quaternion::IDENTITY, + const Vector3& scale = Vector3::UNIT_SCALE); + + /** Adds all the Entity objects attached to a SceneNode and all it's + children to the static geometry. + @remarks + This method performs just like addEntity, except it adds all the + entities attached to an entire sub-tree to the geometry. + The position / orientation / scale parameters are taken from the + node structure instead of being specified manually. + @note + The SceneNode you pass in will not be automatically detached from + it's parent, so if you have this node already attached to the scene + graph, you will need to remove it if you wish to avoid the overhead + of rendering both the original objects and their new static + versions! We don't do this for you incase you are preparing this + in advance and so don't want the originals detached yet. + @note Must be called before 'build'. + @param node Pointer to the node to use to provide a set of Entity + templates + */ + virtual void addSceneNode(const SceneNode* node); + + /** Build the geometry. + @remarks + Based on all the entities which have been added, and the batching + options which have been set, this method constructs the batched + geometry structures required. The batches are added to the scene + and will be rendered unless you specifically hide them. + @note + Once you have called this method, you can no longer add any more + entities. + */ + virtual void build(void); + + /** Destroys all the built geometry state (reverse of build). + @remarks + You can call build() again after this and it will pick up all the + same entities / nodes you queued last time. + */ + virtual void destroy(void); + + /** Clears any of the entities / nodes added to this geometry and + destroys anything which has already been built. + */ + virtual void reset(void); + + /** Sets the distance at which batches are no longer rendered. + @remarks + This lets you turn off batches at a given distance. This can be + useful for things like detail meshes (grass, foliage etc) and could + be combined with a shader which fades the geometry out beforehand + to lessen the effect. + @param dist Distance beyond which the batches will not be rendered + (the default is 0, which means batches are always rendered). + */ + virtual void setRenderingDistance(Real dist) { + mUpperDistance = dist; + mSquaredUpperDistance = mUpperDistance * mUpperDistance; + } + + /** Gets the distance at which batches are no longer rendered. */ + virtual Real getRenderingDistance(void) const { return mUpperDistance; } + + /** Gets the squared distance at which batches are no longer rendered. */ + virtual Real getSquaredRenderingDistance(void) const + { return mSquaredUpperDistance; } + + /** Hides or shows all the batches. */ + virtual void setVisible(bool visible); + + /** Are the batches visible? */ + virtual bool isVisible(void) const { return mVisible; } + + /** Sets whether this geometry should cast shadows. + @remarks + No matter what the settings on the original entities, + the StaticGeometry class defaults to not casting shadows. + This is because, being static, unless you have moving lights + you'd be better to use precalculated shadows of some sort. + However, if you need them, you can enable them using this + method. If the SceneManager is set up to use stencil shadows, + edge lists will be copied from the underlying meshes on build. + It is essential that all meshes support stencil shadows in this + case. + @note If you intend to use stencil shadows, you must set this to + true before calling 'build' as well as making sure you set the + scene's shadow type (that should always be the first thing you do + anyway). You can turn shadows off temporarily but they can never + be turned on if they were not at the time of the build. + */ + virtual void setCastShadows(bool castShadows); + /// Will the geometry from this object cast shadows? + virtual bool getCastShadows(void) { return mCastShadows; } + + /** Sets the size of a single region of geometry. + @remarks + This method allows you to configure the physical world size of + each region, so you can balance culling against batch size. Entities + will be fitted within the batch they most closely fit, and the + eventual bounds of each batch may well be slightly larger than this + if they overlap a little. The default is Vector3(1000, 1000, 1000). + @note Must be called before 'build'. + @param size Vector3 expressing the 3D size of each region. + */ + virtual void setRegionDimensions(const Vector3& size) { + mRegionDimensions = size; + mHalfRegionDimensions = size * 0.5; + } + /** Gets the size of a single batch of geometry. */ + virtual const Vector3& getRegionDimensions(void) const { return mRegionDimensions; } + /** Sets the origin of the geometry. + @remarks + This method allows you to configure the world centre of the geometry, + thus the place which all regions surround. You probably don't need + to mess with this unless you have a seriously large world, since the + default set up can handle an area 1024 * mRegionDimensions, and + the sparseness of population is no issue when it comes to rendering. + The default is Vector3(0,0,0). + @note Must be called before 'build'. + @param size Vector3 expressing the 3D origin of the geometry. + */ + virtual void setOrigin(const Vector3& origin) { mOrigin = origin; } + /** Gets the origin of this geometry. */ + virtual const Vector3& getOrigin(void) const { return mOrigin; } + + /** Sets the render queue group this object will be rendered through. + @remarks + Render queues are grouped to allow you to more tightly control the ordering + of rendered objects. If you do not call this method, all objects default + to the default queue (RenderQueue::getDefaultQueueGroup), which is fine for + most objects. You may want to alter this if you want to perform more complex + rendering. + @par + See RenderQueue for more details. + @param queueID Enumerated value of the queue group to use. + */ + virtual void setRenderQueueGroup(uint8 queueID); + + /** Gets the queue group for this entity, see setRenderQueueGroup for full details. */ + virtual uint8 getRenderQueueGroup(void) const; + + /// Iterator for iterating over contained regions + typedef MapIterator RegionIterator; + /// Get an iterator over the regions in this geometry + RegionIterator getRegionIterator(void); + + /** Dump the contents of this StaticGeometry to a file for diagnostic + purposes. + */ + virtual void dump(const String& filename) const; + + + }; + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreStdHeaders.h b/school/informatik/verkerhssimulation/src/ogre/OgreStdHeaders.h new file mode 100644 index 00000000..2bcf9ec7 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreStdHeaders.h @@ -0,0 +1,102 @@ +#ifndef __StdHeaders_H__ +#define __StdHeaders_H__ + +#ifdef __BORLANDC__ + #define __STD_ALGORITHM +#endif + +#if defined ( OGRE_GCC_VISIBILITY ) +/* Until libstdc++ for gcc 4.2 is released, we have to declare all + * symbols in libstdc++.so externally visible, otherwise we end up + * with them marked as hidden by -fvisible=hidden. + * + * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20218 + */ +# pragma GCC visibility push(default) +#endif + +#include +#include +#include +#include +#include +#include +#include + +// STL containers +#include +#include +#include +#include +#include +#include +#include +#include + +// Note - not in the original STL, but exists in SGI STL and STLport +#if (OGRE_COMPILER == OGRE_COMPILER_GNUC) && !defined(STLPORT) +# include +# include +#else +# include +# include +#endif + +// STL algorithms & functions +#include +#include +#include + +// C++ Stream stuff +#include +#include +#include +#include + +#ifdef __BORLANDC__ +namespace Ogre +{ + using namespace std; +} +#endif + +extern "C" { + +# include +# include + +} + +#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 +# undef min +# undef max +# if defined( __MINGW32__ ) +# include +# endif +#endif + +#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX +extern "C" { + +# include +# include + +} +#endif + +#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE +extern "C" { +# include +# include +# include +} +#endif + +#if OGRE_THREAD_SUPPORT +# include +#endif + +#if defined ( OGRE_GCC_VISIBILITY ) +# pragma GCC visibility pop +#endif +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreString.h b/school/informatik/verkerhssimulation/src/ogre/OgreString.h new file mode 100644 index 00000000..f71ab70c --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreString.h @@ -0,0 +1,165 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _String_H__ +#define _String_H__ + +#include "OgrePrerequisites.h" + +// If we're using the GCC 3.1 C++ Std lib +#if OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 310 && !defined(STLPORT) + +#include +namespace __gnu_cxx +{ + template <> struct hash< Ogre::_StringBase > + { + size_t operator()( const Ogre::_StringBase _stringBase ) const + { + /* This is the PRO-STL way, but it seems to cause problems with VC7.1 + and in some other cases (although I can't recreate it) + hash H; + return H(_stringBase.c_str()); + */ + /** This is our custom way */ + register size_t ret = 0; + for( Ogre::_StringBase::const_iterator it = _stringBase.begin(); it != _stringBase.end(); ++it ) + ret = 5 * ret + *it; + + return ret; + } + }; +} + +#endif + +namespace Ogre { + + /** Utility class for manipulating Strings. */ + class _OgreExport StringUtil + { + public: + typedef std::ostringstream StrStreamType; + + /** Removes any whitespace characters, be it standard space or + TABs and so on. + @remarks + The user may specify wether they want to trim only the + beginning or the end of the String ( the default action is + to trim both). + */ + static void trim( String& str, bool left = true, bool right = true ); + + /** Returns a StringVector that contains all the substrings delimited + by the characters in the passed delims argument. + @param + delims A list of delimiter characters to split by + @param + maxSplits The maximum number of splits to perform (0 for unlimited splits). If this + parameters is > 0, the splitting process will stop after this many splits, left to right. + */ + static std::vector< String > split( const String& str, const String& delims = "\t\n ", unsigned int maxSplits = 0); + + /** Upper-cases all the characters in the string. + */ + static void toLowerCase( String& str ); + + /** Lower-cases all the characters in the string. + */ + static void toUpperCase( String& str ); + + + /** Returns whether the string begins with the pattern passed in. + @param pattern The pattern to compare with. + @param lowerCase If true, the end of the string will be lower cased before + comparison, pattern should also be in lower case. + */ + static bool startsWith(const String& str, const String& pattern, bool lowerCase = true); + + /** Returns whether the string ends with the pattern passed in. + @param pattern The pattern to compare with. + @param lowerCase If true, the end of the string will be lower cased before + comparison, pattern should also be in lower case. + */ + static bool endsWith(const String& str, const String& pattern, bool lowerCase = true); + + /** Method for standardising paths - use forward slashes only, end with slash. + */ + static String standardisePath( const String &init); + + /** Method for splitting a fully qualified filename into the base name + and path. + @remarks + Path is standardised as in standardisePath + */ + static void splitFilename(const String& qualifiedName, + String& outBasename, String& outPath); + + /** Method for splitting a fully qualified filename into the base name, + extension and path. + @remarks + Path is standardised as in standardisePath + */ + static void splitFullFilename(const Ogre::String& qualifiedName, + Ogre::String& outBasename, Ogre::String& outExtention, + Ogre::String& outPath); + + /** Method for splitting a filename into the base name + and extension. + */ + static void splitBaseFilename(const Ogre::String& fullName, + Ogre::String& outBasename, Ogre::String& outExtention); + + + /** Simple pattern-matching routine allowing a wildcard pattern. + @param str String to test + @param pattern Pattern to match against; can include simple '*' wildcards + @param caseSensitive Whether the match is case sensitive or not + */ + static bool match(const String& str, const String& pattern, bool caseSensitive = true); + + + + + + /// Constant blank string, useful for returning by ref where local does not exist + static const String BLANK; + }; + + +#if OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 310 && !defined(STLPORT) + typedef ::__gnu_cxx::hash< _StringBase > _StringHash; +#elif !defined( _STLP_HASH_FUN_H ) + typedef stdext::hash_compare< _StringBase, std::less< _StringBase > > _StringHash; +#else + typedef std::hash< _StringBase > _StringHash; +#endif + +} // namespace Ogre + +#endif // _String_H__ diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreStringConverter.h b/school/informatik/verkerhssimulation/src/ogre/OgreStringConverter.h new file mode 100644 index 00000000..b5d3770d --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreStringConverter.h @@ -0,0 +1,246 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __StringConverter_H__ +#define __StringConverter_H__ + +#include "OgrePrerequisites.h" +#include "OgreMath.h" +#include "OgreString.h" +#include "OgreStringVector.h" + +namespace Ogre { + + /** Class for converting the core Ogre data types to/from Strings. + @remarks + The code for converting values to and from strings is here as a separate + class to avoid coupling String to other datatypes (and vice-versa) which reduces + compilation dependency: important given how often the core types are used. + @par + This class is mainly used for parsing settings in text files. External applications + can also use it to interface with classes which use the StringInterface template + class. + @par + The String formats of each of the major types is listed with the methods. The basic types + like int and Real just use the underlying C runtime library atof and atoi family methods, + however custom types like Vector3, ColourValue and Matrix4 are also supported by this class + using custom formats. + @author + Steve Streeting + */ + class _OgreExport StringConverter + { + public: + + /** Converts a Real to a String. */ + static String toString(Real val, unsigned short precision = 6, + unsigned short width = 0, char fill = ' ', + std::ios::fmtflags flags = std::ios::fmtflags(0) ); + /** Converts a Radian to a String. */ + static String toString(Radian val, unsigned short precision = 6, + unsigned short width = 0, char fill = ' ', + std::ios::fmtflags flags = std::ios::fmtflags(0) ) + { + return toString(val.valueAngleUnits(), precision, width, fill, flags); + } + /** Converts a Degree to a String. */ + static String toString(Degree val, unsigned short precision = 6, + unsigned short width = 0, char fill = ' ', + std::ios::fmtflags flags = std::ios::fmtflags(0) ) + { + return toString(val.valueAngleUnits(), precision, width, fill, flags); + } + /** Converts an int to a String. */ + static String toString(int val, unsigned short width = 0, + char fill = ' ', + std::ios::fmtflags flags = std::ios::fmtflags(0) ); +#if OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_64 || OGRE_PLATFORM == OGRE_PLATFORM_APPLE + /** Converts an unsigned int to a String. */ + static String toString(unsigned int val, + unsigned short width = 0, char fill = ' ', + std::ios::fmtflags flags = std::ios::fmtflags(0) ); + /** Converts a size_t to a String. */ + static String toString(size_t val, + unsigned short width = 0, char fill = ' ', + std::ios::fmtflags flags = std::ios::fmtflags(0) ); + #if OGRE_COMPILER == OGRE_COMPILER_MSVC + /** Converts an unsigned long to a String. */ + static String toString(unsigned long val, + unsigned short width = 0, char fill = ' ', + std::ios::fmtflags flags = std::ios::fmtflags(0) ); + + #endif +#else + /** Converts a size_t to a String. */ + static String toString(size_t val, + unsigned short width = 0, char fill = ' ', + std::ios::fmtflags flags = std::ios::fmtflags(0) ); + /** Converts an unsigned long to a String. */ + static String toString(unsigned long val, + unsigned short width = 0, char fill = ' ', + std::ios::fmtflags flags = std::ios::fmtflags(0) ); +#endif + /** Converts a long to a String. */ + static String toString(long val, + unsigned short width = 0, char fill = ' ', + std::ios::fmtflags flags = std::ios::fmtflags(0) ); + /** Converts a boolean to a String. + @param yesNo If set to true, result is 'yes' or 'no' instead of 'true' or 'false' + */ + static String toString(bool val, bool yesNo = false); + /** Converts a Vector2 to a String. + @remarks + Format is "x y" (i.e. 2x Real values, space delimited) + */ + static String toString(const Vector2& val); + /** Converts a Vector3 to a String. + @remarks + Format is "x y z" (i.e. 3x Real values, space delimited) + */ + static String toString(const Vector3& val); + /** Converts a Vector4 to a String. + @remarks + Format is "x y z w" (i.e. 4x Real values, space delimited) + */ + static String toString(const Vector4& val); + /** Converts a Matrix3 to a String. + @remarks + Format is "00 01 02 10 11 12 20 21 22" where '01' means row 0 column 1 etc. + */ + static String toString(const Matrix3& val); + /** Converts a Matrix4 to a String. + @remarks + Format is "00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33" where + '01' means row 0 column 1 etc. + */ + static String toString(const Matrix4& val); + /** Converts a Quaternion to a String. + @remarks + Format is "w x y z" (i.e. 4x Real values, space delimited) + */ + static String toString(const Quaternion& val); + /** Converts a ColourValue to a String. + @remarks + Format is "r g b a" (i.e. 4x Real values, space delimited). + */ + static String toString(const ColourValue& val); + /** Converts a StringVector to a string. + @remarks + Strings must not contain spaces since space is used as a delimeter in + the output. + */ + static String toString(const StringVector& val); + + /** Converts a String to a Real. + @returns + 0.0 if the value could not be parsed, otherwise the Real version of the String. + */ + static Real parseReal(const String& val); + /** Converts a String to a Angle. + @returns + 0.0 if the value could not be parsed, otherwise the Angle version of the String. + */ + static inline Radian parseAngle(const String& val) { + return Angle(parseReal(val)); + } + /** Converts a String to a whole number. + @returns + 0.0 if the value could not be parsed, otherwise the numeric version of the String. + */ + static int parseInt(const String& val); + /** Converts a String to a whole number. + @returns + 0.0 if the value could not be parsed, otherwise the numeric version of the String. + */ + static unsigned int parseUnsignedInt(const String& val); + /** Converts a String to a whole number. + @returns + 0.0 if the value could not be parsed, otherwise the numeric version of the String. + */ + static long parseLong(const String& val); + /** Converts a String to a whole number. + @returns + 0.0 if the value could not be parsed, otherwise the numeric version of the String. + */ + static unsigned long parseUnsignedLong(const String& val); + /** Converts a String to a boolean. + @remarks + Returns true if case-insensitive match of the start of the string + matches "true", "yes" or "1", false otherwise. + */ + static bool parseBool(const String& val); + /** Parses a Vector3 out of a String. + @remarks + Format is "x y z" ie. 3 Real components, space delimited. Failure to parse returns + Vector3::ZERO. + */ + static Vector3 parseVector3(const String& val); + /** Parses a Matrix3 out of a String. + @remarks + Format is "00 01 02 10 11 12 20 21 22" where '01' means row 0 column 1 etc. + Failure to parse returns Matrix3::IDENTITY. + */ + static Matrix3 parseMatrix3(const String& val); + /** Parses a Matrix4 out of a String. + @remarks + Format is "00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33" where + '01' means row 0 column 1 etc. Failure to parse returns Matrix4::IDENTITY. + */ + static Matrix4 parseMatrix4(const String& val); + /** Parses a Quaternion out of a String. + @remarks + Format is "w x y z" (i.e. 4x Real values, space delimited). + Failure to parse returns Quaternion::IDENTITY. + + */ + static Quaternion parseQuaternion(const String& val); + /** Parses a ColourValue out of a String. + @remarks + Format is "r g b a" (i.e. 4x Real values, space delimited), or "r g b" which implies + an alpha value of 1.0 (opaque). Failure to parse returns ColourValue::Black. + */ + static ColourValue parseColourValue(const String& val); + + /** Pareses a StringVector from a string. + @remarks + Strings must not contain spaces since space is used as a delimeter in + the output. + */ + static StringVector parseStringVector(const String& val); + /** Checks the String is a valid number value. */ + static bool isNumber(const String& val); + }; + + +} + + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreStringInterface.h b/school/informatik/verkerhssimulation/src/ogre/OgreStringInterface.h new file mode 100644 index 00000000..146659ce --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreStringInterface.h @@ -0,0 +1,332 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __StringInterface_H__ +#define __StringInterface_H__ + +#include "OgrePrerequisites.h" +#include "OgreString.h" +#include "OgreCommon.h" + +namespace Ogre { + + + /// List of parameter types available + enum ParameterType + { + PT_BOOL, + PT_REAL, + PT_INT, + PT_UNSIGNED_INT, + PT_SHORT, + PT_UNSIGNED_SHORT, + PT_LONG, + PT_UNSIGNED_LONG, + PT_STRING, + PT_VECTOR3, + PT_MATRIX3, + PT_MATRIX4, + PT_QUATERNION, + PT_COLOURVALUE + }; + + /// Definition of a parameter supported by a StringInterface class, for introspection + class _OgreExport ParameterDef + { + public: + String name; + String description; + ParameterType paramType; + ParameterDef(const String& newName, const String& newDescription, ParameterType newType) + : name(newName), description(newDescription), paramType(newType) {} + }; + typedef std::vector ParameterList; + + /** Abstract class which is command object which gets/sets parameters.*/ + class _OgreExport ParamCommand + { + public: + virtual String doGet(const void* target) const = 0; + virtual void doSet(void* target, const String& val) = 0; + + virtual ~ParamCommand() { } + }; + typedef std::map ParamCommandMap; + + /** Class to hold a dictionary of parameters for a single class. */ + class _OgreExport ParamDictionary + { + friend class StringInterface; + protected: + /// Definitions of parameters + ParameterList mParamDefs; + + /// Command objects to get/set + ParamCommandMap mParamCommands; + + /** Retrieves the parameter command object for a named parameter. */ + ParamCommand* getParamCommand(const String& name) + { + ParamCommandMap::iterator i = mParamCommands.find(name); + if (i != mParamCommands.end()) + { + return i->second; + } + else + { + return 0; + } + } + + const ParamCommand* getParamCommand(const String& name) const + { + ParamCommandMap::const_iterator i = mParamCommands.find(name); + if (i != mParamCommands.end()) + { + return i->second; + } + else + { + return 0; + } + } + public: + ParamDictionary() {} + /** Method for adding a parameter definition for this class. + @param paramDef A ParameterDef object defining the parameter + @param paramCmd Pointer to a ParamCommand subclass to handle the getting / setting of this parameter. + NB this class will not destroy this on shutdown, please ensure you do + + */ + void addParameter(const ParameterDef& paramDef, ParamCommand* paramCmd) + { + mParamDefs.push_back(paramDef); + mParamCommands[paramDef.name] = paramCmd; + } + /** Retrieves a list of parameters valid for this object. + @returns + A reference to a static list of ParameterDef objects. + + */ + const ParameterList& getParameters(void) const + { + return mParamDefs; + } + + + + }; + typedef std::map ParamDictionaryMap; + + /** Class defining the common interface which classes can use to + present a reflection-style, self-defining parameter set to callers. + @remarks + This class also holds a static map of class name to parameter dictionaries + for each subclass to use. See ParamDictionary for details. + @remarks + In order to use this class, each subclass must call createParamDictionary in their constructors + which will create a parameter dictionary for the class if it does not exist yet. + */ + class _OgreExport StringInterface + { + protected: + + /// Dictionary of parameters + static ParamDictionaryMap msDictionary; + + /// Class name for this instance to be used as a lookup (must be initialised by subclasses) + String mParamDictName; + + /** Internal method for creating a parameter dictionary for the class, if it does not already exist. + @remarks + This method will check to see if a parameter dictionary exist for this class yet, + and if not will create one. NB you must supply the name of the class (RTTI is not + used or performance). + @param + className the name of the class using the dictionary + @returns + true if a new dictionary was created, false if it was already there + */ + bool createParamDictionary(const String& className) + { + mParamDictName = className; + if (msDictionary.find(className) == msDictionary.end()) + { + msDictionary[className] = ParamDictionary(); + return true; + } + return false; + + } + + public: + + /** Virtual desctructor, see Effective C++ */ + virtual ~StringInterface() {} + + /** Retrieves the parameter dictionary for this class. + @remarks + Only valid to call this after createParamDictionary. + @returns + Pointer to ParamDictionary shared by all instances of this class + which you can add parameters to, retrieve parameters etc. + */ + ParamDictionary* getParamDictionary(void) + { + ParamDictionaryMap::iterator i = msDictionary.find(mParamDictName); + if (i != msDictionary.end()) + { + return &(i->second); + } + else + { + return 0; + } + } + + const ParamDictionary* getParamDictionary(void) const + { + ParamDictionaryMap::const_iterator i = msDictionary.find(mParamDictName); + if (i != msDictionary.end()) + { + return &(i->second); + } + else + { + return 0; + } + } + + /** Retrieves a list of parameters valid for this object. + @returns + A reference to a static list of ParameterDef objects. + + */ + const ParameterList& getParameters(void) const; + + /** Generic parameter setting method. + @remarks + Call this method with the name of a parameter and a string version of the value + to set. The implementor will convert the string to a native type internally. + If in doubt, check the parameter definition in the list returned from + StringInterface::getParameters. + @param + name The name of the parameter to set + @param + value String value. Must be in the right format for the type specified in the parameter definition. + See the StringConverter class for more information. + @returns + true if set was successful, false otherwise (NB no exceptions thrown - tolerant method) + */ + virtual bool setParameter(const String& name, const String& value); + /** Generic multiple parameter setting method. + @remarks + Call this method with a list of name / value pairs + to set. The implementor will convert the string to a native type internally. + If in doubt, check the parameter definition in the list returned from + StringInterface::getParameters. + @param + paramList Name/value pair list + */ + virtual void setParameterList(const NameValuePairList& paramList); + /** Generic parameter retrieval method. + @remarks + Call this method with the name of a parameter to retrieve a string-format value of + the parameter in question. If in doubt, check the parameter definition in the + list returned from getParameters for the type of this parameter. If you + like you can use StringConverter to convert this string back into a native type. + @param + name The name of the parameter to get + @returns + String value of parameter, blank if not found + */ + virtual String getParameter(const String& name) const + { + // Get dictionary + const ParamDictionary* dict = getParamDictionary(); + + if (dict) + { + // Look up command object + const ParamCommand* cmd = dict->getParamCommand(name); + + if (cmd) + { + return cmd->doGet(this); + } + } + + // Fallback + return ""; + } + /** Method for copying this object's parameters to another object. + @remarks + This method takes the values of all the object's parameters and tries to set the + same values on the destination object. This provides a completely type independent + way to copy parameters to other objects. Note that because of the String manipulation + involved, this should not be regarded as an efficient process and should be saved for + times outside of the rendering loop. + @par + Any unrecognised parameters will be ignored as with setParameter method. + @param dest Pointer to object to have it's parameters set the same as this object. + + */ + virtual void copyParametersTo(StringInterface* dest) const + { + // Get dictionary + const ParamDictionary* dict = getParamDictionary(); + + if (dict) + { + // Iterate through own parameters + ParameterList::const_iterator i; + + for (i = dict->mParamDefs.begin(); + i != dict->mParamDefs.end(); ++i) + { + dest->setParameter(i->name, getParameter(i->name)); + } + } + + + } + + /** Cleans up the static 'msDictionary' required to reset Ogre, + otherwise the containers are left with invalid pointers, which will lead to a crash + as soon as one of the ResourceManager implementers (e.g. MaterialManager) initializes.*/ + static void cleanupDictionary () ; + + }; + + + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreStringVector.h b/school/informatik/verkerhssimulation/src/ogre/OgreStringVector.h new file mode 100644 index 00000000..60cee155 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreStringVector.h @@ -0,0 +1,45 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _StringVector_H__ +#define _StringVector_H__ + +#include "OgrePrerequisites.h" + +#include "OgreString.h" +#include "OgreSharedPtr.h" + + +namespace Ogre { + + typedef std::vector StringVector; + typedef SharedPtr StringVectorPtr; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreSubEntity.h b/school/informatik/verkerhssimulation/src/ogre/OgreSubEntity.h new file mode 100644 index 00000000..1ea72d3a --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreSubEntity.h @@ -0,0 +1,230 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __SubEntity_H__ +#define __SubEntity_H__ + +#include "OgrePrerequisites.h" + +#include "OgreString.h" +#include "OgreRenderable.h" +#include "OgreHardwareBufferManager.h" + +namespace Ogre { + + /** Utility class which defines the sub-parts of an Entity. + @remarks + Just as meshes are split into submeshes, an Entity is made up of + potentially multiple SubMeshes. These are mainly here to provide the + link between the Material which the SubEntity uses (which may be the + default Material for the SubMesh or may have been changed for this + object) and the SubMesh data. + @par + The SubEntity also allows the application some flexibility in the + material properties for this section of a particular instance of this + Mesh, e.g. tinting the windows on a car model. + @par + SubEntity instances are never created manually. They are created at + the same time as their parent Entity by the SceneManager method + createEntity. + */ + class _OgreExport SubEntity: public Renderable + { + // Note no virtual functions for efficiency + friend class Entity; + friend class SceneManager; + protected: + /** Private constructor - don't allow creation by anybody else. + */ + SubEntity(Entity* parent, SubMesh* subMeshBasis); + + /** Private destructor. + */ + virtual ~SubEntity(); + + /// Pointer to parent. + Entity* mParentEntity; + + /// Name of Material in use by this SubEntity. + String mMaterialName; + + /// Cached pointer to material. + MaterialPtr mpMaterial; + + // Pointer to the SubMesh defining geometry. + SubMesh* mSubMesh; + + /// Is this SubEntity visible? + bool mVisible; + + /// The LOD number of the material to use, calculated by Entity::_notifyCurrentCamera + unsigned short mMaterialLodIndex; + + /// blend buffer details for dedicated geometry + VertexData* mSkelAnimVertexData; + /// Quick lookup of buffers + TempBlendedBufferInfo mTempSkelAnimInfo; + /// Temp buffer details for software Vertex anim geometry + TempBlendedBufferInfo mTempVertexAnimInfo; + /// Vertex data details for software Vertex anim of shared geometry + VertexData* mSoftwareVertexAnimVertexData; + /// Vertex data details for hardware Vertex anim of shared geometry + /// - separate since we need to s/w anim for shadows whilst still altering + /// the vertex data for hardware morphing (pos2 binding) + VertexData* mHardwareVertexAnimVertexData; + /// Have we applied any vertex animation to geometry? + bool mVertexAnimationAppliedThisFrame; + /// Number of hardware blended poses supported by material + ushort mHardwarePoseCount; + /// Cached distance to last camera for getSquaredViewDepth + mutable Real mCachedCameraDist; + /// The camera for which the cached distance is valid + mutable const Camera *mCachedCamera; + + /** Internal method for preparing this Entity for use in animation. */ + void prepareTempBlendBuffers(void); + + public: + /** Gets the name of the Material in use by this instance. + */ + const String& getMaterialName() const; + + /** Sets the name of the Material to be used. + @remarks + By default a SubEntity uses the default Material that the SubMesh + uses. This call can alter that so that the Material is different + for this instance. + */ + void setMaterialName( const String& name ); + + /** Tells this SubEntity whether to be visible or not. */ + virtual void setVisible(bool visible); + + /** Returns whether or not this SubEntity is supposed to be visible. */ + virtual bool isVisible(void) const; + + /** Accessor method to read mesh data. + */ + SubMesh* getSubMesh(void); + + /** Accessor to get parent Entity */ + Entity* getParent(void) const { return mParentEntity; } + + /** Overridden - see Renderable. + */ + const MaterialPtr& getMaterial(void) const; + + /** Overridden - see Renderable. + */ + Technique* getTechnique(void) const; + + /** Overridden - see Renderable. + */ + void getRenderOperation(RenderOperation& op); + + /** Overridden - see Renderable. + */ + void getWorldTransforms(Matrix4* xform) const; + /** @copydoc Renderable::getWorldOrientation */ + const Quaternion& getWorldOrientation(void) const; + /** @copydoc Renderable::getWorldPosition */ + const Vector3& getWorldPosition(void) const; + /** Overridden - see Renderable. + */ + bool getNormaliseNormals(void) const; + /** Overridden - see Renderable. + */ + unsigned short getNumWorldTransforms(void) const; + /** Overridden, see Renderable */ + Real getSquaredViewDepth(const Camera* cam) const; + /** @copydoc Renderable::getLights */ + const LightList& getLights(void) const; + /** @copydoc Renderable::getCastsShadows */ + bool getCastsShadows(void) const; + /** Advanced method to get the temporarily blended vertex information + for entities which are software skinned. + @remarks + Internal engine will eliminate software animation if possible, this + information is unreliable unless added request for software animation + via Entity::addSoftwareAnimationRequest. + @note + The positions/normals of the returned vertex data is in object space. + */ + VertexData* _getSkelAnimVertexData(void); + /** Advanced method to get the temporarily blended software morph vertex information + @remarks + Internal engine will eliminate software animation if possible, this + information is unreliable unless added request for software animation + via Entity::addSoftwareAnimationRequest. + @note + The positions/normals of the returned vertex data is in object space. + */ + VertexData* _getSoftwareVertexAnimVertexData(void); + /** Advanced method to get the hardware morph vertex information + @note + The positions/normals of the returned vertex data is in object space. + */ + VertexData* _getHardwareVertexAnimVertexData(void); + /** Advanced method to get the temp buffer information for software + skeletal animation. + */ + TempBlendedBufferInfo* _getSkelAnimTempBufferInfo(void); + /** Advanced method to get the temp buffer information for software + morph animation. + */ + TempBlendedBufferInfo* _getVertexAnimTempBufferInfo(void); + /// Retrieve the VertexData which should be used for GPU binding + VertexData* getVertexDataForBinding(void); + + /** Mark all vertex data as so far unanimated. + */ + void _markBuffersUnusedForAnimation(void); + /** Mark all vertex data as animated. + */ + void _markBuffersUsedForAnimation(void); + /** Are buffers already marked as vertex animated? */ + bool _getBuffersMarkedForAnimation(void) const { return mVertexAnimationAppliedThisFrame; } + /** Internal method to copy original vertex data to the morph structures + should there be no active animation in use. + */ + void _restoreBuffersForUnusedAnimation(bool hardwareAnimation); + + /** Overridden from Renderble to provide some custom behaviour. */ + void _updateCustomGpuParameter( + const GpuProgramParameters::AutoConstantEntry& constantEntry, + GpuProgramParameters* params) const; + + /** Invalidate the camera distance cache */ + void _invalidateCameraCache () + { mCachedCamera = 0; } + }; + +} + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreSubMesh.h b/school/informatik/verkerhssimulation/src/ogre/OgreSubMesh.h new file mode 100644 index 00000000..7204879b --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreSubMesh.h @@ -0,0 +1,267 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __SubMesh_H_ +#define __SubMesh_H_ + +#include "OgrePrerequisites.h" + +#include "OgreVertexIndexData.h" +#include "OgreMaterial.h" +#include "OgreRenderOperation.h" +#include "OgreVertexBoneAssignment.h" +#include "OgreProgressiveMesh.h" +#include "OgreAnimationTrack.h" + +namespace Ogre { + + /** Defines a part of a complete mesh. + @remarks + Meshes which make up the definition of a discrete 3D object + are made up of potentially multiple parts. This is because + different parts of the mesh may use different materials or + use different vertex formats, such that a rendering state + change is required between them. + @par + Like the Mesh class, instatiations of 3D objects in the scene + share the SubMesh instances, and have the option of overriding + their material differences on a per-object basis if required. + See the SubEntity class for more information. + */ + class _OgreExport SubMesh + { + friend class Mesh; + friend class MeshSerializerImpl; + friend class MeshSerializerImpl_v1_2; + friend class MeshSerializerImpl_v1_1; + public: + SubMesh(); + ~SubMesh(); + + + /// Indicates if this submesh shares vertex data with other meshes or whether it has it's own vertices. + bool useSharedVertices; + + /// The render operation type used to render this submesh + RenderOperation::OperationType operationType; + + /** Dedicated vertex data (only valid if useSharedVertices = false). + @remarks + This data is completely owned by this submesh. + @par + The use of shared or non-shared buffers is determined when + model data is converted to the OGRE .mesh format. + */ + VertexData *vertexData; + + /// Face index data + IndexData *indexData; + + /** Dedicated index map for translate blend index to bone index (only valid if useSharedVertices = false). + @remarks + This data is completely owned by this submesh. + @par + We collect actually used bones of all bone assignments, and build the + blend index in 'packed' form, then the range of the blend index in vertex + data VES_BLEND_INDICES element is continuous, with no gaps. Thus, by + minimising the world matrix array constants passing to GPU, we can support + more bones for a mesh when hardware skinning is used. The hardware skinning + support limit is applied to each set of vertex data in the mesh, in other words, the + hardware skinning support limit is applied only to the actually used bones of each + SubMeshes, not all bones across the entire Mesh. + @par + Because the blend index is different to the bone index, therefore, we use + the index map to translate the blend index to bone index. + @par + The use of shared or non-shared index map is determined when + model data is converted to the OGRE .mesh format. + */ + typedef std::vector IndexMap; + IndexMap blendIndexToBoneIndexMap; + + ProgressiveMesh::LODFaceList mLodFaceList; + + /** A list of extreme points on the submesh (optional). + @remarks + These points are some arbitrary points on the mesh that are used + by engine to better sort submeshes by depth. This doesn't matter + much for non-transparent submeshes, as Z-buffer takes care of invisible + surface culling anyway, but is pretty useful for semi-transparent + submeshes because the order in which transparent submeshes must be + rendered cannot be always correctly deduced from entity position. + @par + These points are intelligently chosen from the points that make up + the submesh, the criteria for choosing them should be that these points + somewhat characterize the submesh outline, e.g. they should not be + close to each other, and they should be on the outer hull of the submesh. + They can be stored in the .mesh file, or generated at runtime + (see generateExtremes ()). + @par + If this array is empty, submesh sorting is done like in older versions - + by comparing the positions of the owning entity. + */ + std::vector extremityPoints; + + /// Reference to parent Mesh (not a smart pointer so child does not keep parent alive). + Mesh* parent; + + /// Sets the name of the Material which this SubMesh will use + void setMaterialName(const String& matName); + const String& getMaterialName(void) const; + + /** Returns true if a material has been assigned to the submesh, otherwise returns false. + */ + bool isMatInitialised(void) const; + + /** Returns a RenderOperation structure required to render this mesh. + @param + rend Reference to a RenderOperation structure to populate. + @param + lodIndex The index of the LOD to use. + */ + void _getRenderOperation(RenderOperation& rend, ushort lodIndex = 0); + + /** Assigns a vertex to a bone with a given weight, for skeletal animation. + @remarks + This method is only valid after calling setSkeletonName. + Since this is a one-off process there exists only 'addBoneAssignment' and + 'clearBoneAssignments' methods, no 'editBoneAssignment'. You should not need + to modify bone assignments during rendering (only the positions of bones) and OGRE + reserves the right to do some internal data reformatting of this information, depending + on render system requirements. + @par + This method is for assigning weights to the dedicated geometry of the SubMesh. To assign + weights to the shared Mesh geometry, see the equivalent methods on Mesh. + */ + void addBoneAssignment(const VertexBoneAssignment& vertBoneAssign); + + /** Removes all bone assignments for this mesh. + @par + This method is for assigning weights to the dedicated geometry of the SubMesh. To assign + weights to the shared Mesh geometry, see the equivalent methods on Mesh. + */ + void clearBoneAssignments(void); + + /// Multimap of verex bone assignments (orders by vertex index) + typedef std::multimap VertexBoneAssignmentList; + typedef MapIterator BoneAssignmentIterator; + + /** Gets an iterator for access all bone assignments. + @remarks + Only valid if this SubMesh has dedicated geometry. + */ + BoneAssignmentIterator getBoneAssignmentIterator(void); + + /** Must be called once to compile bone assignments into geometry buffer. */ + void _compileBoneAssignments(void); + + typedef ConstMapIterator AliasTextureIterator; + /** Gets an constant iterator to access all texture alias names assigned to this submesh. + + */ + AliasTextureIterator getAliasTextureIterator(void) const; + /** Adds the alias or replaces an existing one and associates the texture name to it. + @remarks + The submesh uses the texture alias to replace textures used in the material applied + to the submesh. + @param + aliasName is the name of the alias. + @param + textureName is the name of the texture to be associated with the alias + + */ + void addTextureAlias(const String& aliasName, const String& textureName); + /** Remove a specific texture alias name from the sub mesh + @param + aliasName is the name of the alias to be removed. If it is not found + then it is ignored. + */ + void removeTextureAlias(const String& aliasName); + /** removes all texture aliases from the sub mesh + */ + void removeAllTextureAliases(void); + /** returns true if the sub mesh has texture aliases + */ + bool hasTextureAliases(void) const { return !mTextureAliases.empty(); } + /** Gets the number of texture aliases assigned to the sub mesh. + */ + size_t getTextureAliasCount(void) const { return mTextureAliases.size(); } + + /** The current material used by the submesh is copied into a new material + and the submesh's texture aliases are applied if the current texture alias + names match those found in the original material. + @remarks + The submesh's texture aliases must be setup prior to calling this method. + If a new material has to be created, the subMesh autogenerates the new name. + The new name is the old name + "_" + number. + @return + True if texture aliases were applied and a new material was created. + */ + bool updateMaterialUsingTextureAliases(void); + + /** Get the type of any vertex animation used by dedicated geometry. + */ + VertexAnimationType getVertexAnimationType(void) const; + + /** Generate the submesh extremes (@see extremityPoints). + @param count + Number of extreme points to compute for the submesh. + */ + void generateExtremes(size_t count); + + protected: + + /// Name of the material this SubMesh uses. + String mMaterialName; + + /// Is there a material yet? + bool mMatInitialised; + + /// paired list of texture aliases and texture names + AliasTextureNamePairList mTextureAliases; + + VertexBoneAssignmentList mBoneAssignments; + + /// Flag indicating that bone assignments need to be recompiled + bool mBoneAssignmentsOutOfDate; + + /// Type of vertex animation for dedicated vertex data (populated by Mesh) + mutable VertexAnimationType mVertexAnimationType; + + + /// Internal method for removing LOD data + void removeLodLevels(void); + + + + }; + +} // namespace + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreTagPoint.h b/school/informatik/verkerhssimulation/src/ogre/OgreTagPoint.h new file mode 100644 index 00000000..7d42fedc --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreTagPoint.h @@ -0,0 +1,116 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __TagPoint_H_ +#define __TagPoint_H_ + +#include "OgrePrerequisites.h" + +#include "OgreBone.h" +#include "OgreMatrix4.h" + +namespace Ogre { + + + + /** A tagged point on a skeleton, which can be used to attach entities to on specific + other entities. + @remarks + A Skeleton, like a Mesh, is shared between Entity objects and simply updated as required + when it comes to rendering. However there are times when you want to attach another object + to an animated entity, and make sure that attachment follows the parent entity's animation + (for example, a character holding a gun in his / her hand). This class simply identifies + attachment points on a skeleton which can be used to attach child objects. + @par + The child objects themselves are not physically attached to this class; as it's name suggests + this class just 'tags' the area. The actual child objects are attached to the Entity using the + skeleton which has this tag point. Use the Entity::attachMovableObjectToBone method to attach + the objects, which creates a new TagPoint on demand. + */ + class _OgreExport TagPoint : public Bone + { + + public: + TagPoint(unsigned short handle, Skeleton* creator); + virtual ~TagPoint(); + + Entity *getParentEntity(void) const; + MovableObject* getChildObject(void) const; + + void setParentEntity(Entity *pEntity); + void setChildObject(MovableObject *pObject); + + /** Tells the TagPoint whether it should inherit orientation from it's parent entity. + @param inherit If true, this TagPoint's orientation will be affected by + its parent entity's orientation. If false, it will not be affected. + */ + void setInheritParentEntityOrientation(bool inherit); + + /** Returns true if this TagPoint is affected by orientation applied to the parent entity. + */ + bool getInheritParentEntityOrientation(void) const; + + /** Tells the TagPoint whether it should inherit scaling factors from it's parent entity. + @param inherit If true, this TagPoint's scaling factors will be affected by + its parent entity's scaling factors. If false, it will not be affected. + */ + void setInheritParentEntityScale(bool inherit); + + /** Returns true if this TagPoint is affected by scaling factors applied to the parent entity. + */ + bool getInheritParentEntityScale(void) const; + + /** Gets the transform of parent entity. */ + const Matrix4& getParentEntityTransform(void) const; + + /** Gets the transform of this node just for the skeleton (not entity) */ + const Matrix4& _getFullLocalTransform(void) const; + + /** @copydoc Node::needUpdate */ + void needUpdate(bool forceParentUpdate = false); + + /** Overridden from Node in order to include parent Entity transform. */ + void updateFromParentImpl(void) const; + /** @copydoc Renderable::getLights */ + const LightList& getLights(void) const; + + + + private: + Entity *mParentEntity; + MovableObject *mChildObject; + mutable Matrix4 mFullLocalTransform; + bool mInheritParentEntityOrientation; + bool mInheritParentEntityScale; + }; + + +} //namespace + + +#endif//__TagPoint_H_ diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreTechnique.h b/school/informatik/verkerhssimulation/src/ogre/OgreTechnique.h new file mode 100644 index 00000000..127c9e81 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreTechnique.h @@ -0,0 +1,488 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Technique_H__ +#define __Technique_H__ + +#include "OgrePrerequisites.h" +#include "OgreIteratorWrappers.h" +#include "OgreBlendMode.h" +#include "OgreCommon.h" +#include "OgrePass.h" + +namespace Ogre { + /** Class representing an approach to rendering this particular Material. + @remarks + Ogre will attempt to use the best technique supported by the active hardware, + unless you specifically request a lower detail technique (say for distant + rendering). + */ + class _OgreExport Technique + { + protected: + // illumination pass state type + enum IlluminationPassesState + { + IPS_COMPILE_DISABLED = -1, + IPS_NOT_COMPILED = 0, + IPS_COMPILED = 1 + }; + + typedef std::vector Passes; + /// List of primary passes + Passes mPasses; + /// List of derived passes, categorised into IlluminationStage (ordered) + IlluminationPassList mIlluminationPasses; + Material* mParent; // raw pointer since we don't want child to stop parent's destruction + bool mIsSupported; + IlluminationPassesState mIlluminationPassesCompilationPhase; + /// LOD level + unsigned short mLodIndex; + /** Scheme index, derived from scheme name but the names are held on + MaterialManager, for speed an index is used here. + */ + unsigned short mSchemeIndex; + String mName; // optional name for the technique + + /// Internal method for clearing illumination pass list + void clearIlluminationPasses(void); + public: + /// Constructor + Technique(Material* parent); + /// Copy constructor + Technique(Material* parent, const Technique& oth); + ~Technique(); + /** Indicates if this technique is supported by the current graphics card. + @remarks + This will only be correct after the Technique has been compiled, which is + usually done from Material::compile. + */ + bool isSupported(void) const; + /** Internal compilation method; see Material::compile. + @returns Any information explaining problems with the compile. + */ + String _compile(bool autoManageTextureUnits); + /** Internal method for splitting the passes into illumination passes. */ + void _compileIlluminationPasses(void); + + + /** Creates a new Pass for this Technique. + @remarks + A Pass is a single rendering pass, ie a single draw of the given material. + Note that if you create a pass without a fragment program, during compilation of the + material the pass may be split into multiple passes if the graphics card cannot + handle the number of texture units requested. For passes with fragment programs, however, + the number of passes you create will never be altered, so you have to make sure + that you create an alternative fallback Technique for if a card does not have + enough facilities for what you're asking for. + */ + Pass* createPass(void); + /** Retrieves the Pass with the given index. */ + Pass* getPass(unsigned short index); + /** Retrieves the Pass matching name. + Returns 0 if name match is not found. + */ + Pass* getPass(const String& name); + /** Retrieves the number of passes. */ + unsigned short getNumPasses(void) const; + /** Removes the Pass with the given index. */ + void removePass(unsigned short index); + /** Removes all Passes from this Technique. */ + void removeAllPasses(void); + /** Move a pass from source index to destination index. + If successful then returns true. + */ + bool movePass(const unsigned short sourceIndex, const unsigned short destinationIndex); + typedef VectorIterator PassIterator; + /** Gets an iterator over the passes in this Technique. */ + const PassIterator getPassIterator(void); + typedef VectorIterator IlluminationPassIterator; + /** Gets an iterator over the illumination-stage categorised passes. */ + const IlluminationPassIterator getIlluminationPassIterator(void); + /// Gets the parent Material + Material* getParent(void) const { return mParent; } + + /** Overloaded operator to copy on Technique to another. */ + Technique& operator=(const Technique& rhs); + + /// Gets the resource group of the ultimate parent Material + const String& getResourceGroup(void) const; + + /** Returns true if this Technique involves transparency. + @remarks + This basically boils down to whether the first pass + has a scene blending factor. Even if the other passes + do not, the base colour, including parts of the original + scene, may be used for blending, therefore we have to treat + the whole Technique as transparent. + */ + bool isTransparent(void) const; + + /** Internal load method, derived from call to Material::load. */ + void _load(void); + /** Internal unload method, derived from call to Material::unload. */ + void _unload(void); + + // Is this loaded? + bool isLoaded(void) const; + + /** Tells the technique that it needs recompilation. */ + void _notifyNeedsRecompile(void); + + + // ------------------------------------------------------------------------------- + // The following methods are to make migration from previous versions simpler + // and to make code easier to write when dealing with simple materials + // They set the properties which have been moved to Pass for all Techniques and all Passes + + /** Sets the point size properties for every Pass in this Technique. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setPointSize + */ + void setPointSize(Real ps); + + /** Sets the ambient colour reflectance properties for every Pass in every Technique. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setAmbient + */ + void setAmbient(Real red, Real green, Real blue); + + /** Sets the ambient colour reflectance properties for every Pass in every Technique. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setAmbient + */ + void setAmbient(const ColourValue& ambient); + + /** Sets the diffuse colour reflectance properties of every Pass in every Technique. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setDiffuse + */ + void setDiffuse(Real red, Real green, Real blue, Real alpha); + + /** Sets the diffuse colour reflectance properties of every Pass in every Technique. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setDiffuse + */ + void setDiffuse(const ColourValue& diffuse); + + /** Sets the specular colour reflectance properties of every Pass in every Technique. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setSpecular + */ + void setSpecular(Real red, Real green, Real blue, Real alpha); + + /** Sets the specular colour reflectance properties of every Pass in every Technique. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setSpecular + */ + void setSpecular(const ColourValue& specular); + + /** Sets the shininess properties of every Pass in every Technique. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setShininess + */ + void setShininess(Real val); + + /** Sets the amount of self-illumination of every Pass in every Technique. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setSelfIllumination + */ + void setSelfIllumination(Real red, Real green, Real blue); + + /** Sets the amount of self-illumination of every Pass in every Technique. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setSelfIllumination + */ + void setSelfIllumination(const ColourValue& selfIllum); + + /** Sets whether or not each Pass renders with depth-buffer checking on or not. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setDepthCheckEnabled + */ + void setDepthCheckEnabled(bool enabled); + + /** Sets whether or not each Pass renders with depth-buffer writing on or not. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setDepthWriteEnabled + */ + void setDepthWriteEnabled(bool enabled); + + /** Sets the function used to compare depth values when depth checking is on. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setDepthFunction + */ + void setDepthFunction( CompareFunction func ); + + /** Sets whether or not colour buffer writing is enabled for each Pass. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setColourWriteEnabled + */ + void setColourWriteEnabled(bool enabled); + + /** Sets the culling mode for each pass based on the 'vertex winding'. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setCullingMode + */ + void setCullingMode( CullingMode mode ); + + /** Sets the manual culling mode, performed by CPU rather than hardware. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setManualCullingMode + */ + void setManualCullingMode( ManualCullingMode mode ); + + /** Sets whether or not dynamic lighting is enabled for every Pass. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setLightingEnabled + */ + void setLightingEnabled(bool enabled); + + /** Sets the type of light shading required + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setShadingMode + */ + void setShadingMode( ShadeOptions mode ); + + /** Sets the fogging mode applied to each pass. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setFog + */ + void setFog( + bool overrideScene, + FogMode mode = FOG_NONE, + const ColourValue& colour = ColourValue::White, + Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 ); + + /** Sets the depth bias to be used for each Pass. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setDepthBias + */ + void setDepthBias(float constantBias, float slopeScaleBias); + + /** Set texture filtering for every texture unit in every Pass + @note + This property actually exists on the TextureUnitState class + For simplicity, this method allows you to set these properties for + every current TeextureUnitState, If you need more precision, retrieve the + Pass and TextureUnitState instances and set the property there. + @see TextureUnitState::setTextureFiltering + */ + void setTextureFiltering(TextureFilterOptions filterType); + /** Sets the anisotropy level to be used for all textures. + @note + This property has been moved to the TextureUnitState class, which is accessible via the + Technique and Pass. For simplicity, this method allows you to set these properties for + every current TeextureUnitState, If you need more precision, retrieve the Technique, + Pass and TextureUnitState instances and set the property there. + @see TextureUnitState::setTextureAnisotropy + */ + void setTextureAnisotropy(unsigned int maxAniso); + + /** Sets the kind of blending every pass has with the existing contents of the scene. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setSceneBlending + */ + void setSceneBlending( const SceneBlendType sbt ); + + /** Allows very fine control of blending every Pass with the existing contents of the scene. + @note + This property actually exists on the Pass class. For simplicity, this method allows + you to set these properties for every current Pass within this Technique. If + you need more precision, retrieve the Pass instance and set the + property there. + @see Pass::setSceneBlending + */ + void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor); + + /** Assigns a level-of-detail (LOD) index to this Technique. + @remarks + As noted previously, as well as providing fallback support for various + graphics cards, multiple Technique objects can also be used to implement + material LOD, where the detail of the material diminishes with distance to + save rendering power. + @par + By default, all Techniques have a LOD index of 0, which means they are the highest + level of detail. Increasing LOD indexes are lower levels of detail. You can + assign more than one Technique to the same LOD index, meaning that the best + Technique that is supported at that LOD index is used. + @par + You should not leave gaps in the LOD sequence; Ogre will allow you to do this + and will continue to function as if the LODs were sequential, but it will + confuse matters. + */ + void setLodIndex(unsigned short index); + /** Gets the level-of-detail index assigned to this Technique. */ + unsigned short getLodIndex(void) const { return mLodIndex; } + + /** Set the 'scheme name' for this technique. + @remarks + Material schemes are used to control top-level switching from one + set of techniques to another. For example, you might use this to + define 'high', 'medium' and 'low' complexity levels on materials + to allow a user to pick a performance / quality ratio. Another + possibility is that you have a fully HDR-enabled pipeline for top + machines, rendering all objects using unclamped shaders, and a + simpler pipeline for others; this can be implemented using + schemes. + @par + Every technique belongs to a scheme - if you don't specify one, the + Technique belongs to the scheme called 'Default', which is also the + scheme used to render by default. The active scheme is set one of + two ways - either by calling Viewport::setMaterialScheme, or + by manually calling MaterialManager::setActiveScheme. + */ + void setSchemeName(const String& schemeName); + /** Returns the scheme to which this technique is assigned. + @see Technique::setSchemeName + */ + const String& getSchemeName(void) const; + + /// Internal method for getting the scheme index + unsigned short _getSchemeIndex(void) const; + + /** Is depth writing going to occur on this technique? */ + bool isDepthWriteEnabled(void) const; + + /** Is depth checking going to occur on this technique? */ + bool isDepthCheckEnabled(void) const; + + /** Exists colour writing disabled pass on this technique? */ + bool hasColourWriteDisabled(void) const; + + /** Set the name of the technique. + @remarks + The use of technique name is optional. Its usefull in material scripts where a material could inherit + from another material and only want to modify a particalar technique. + */ + void setName(const String& name); + /// Gets the name of the technique + const String& getName(void) const { return mName; } + + /** Applies texture names to Texture Unit State with matching texture name aliases. + All passes, and Texture Unit States within the technique are checked. + If matching texture aliases are found then true is returned. + + @param + aliasList is a map container of texture alias, texture name pairs + @param + apply set true to apply the texture aliases else just test to see if texture alias matches are found. + @return + True if matching texture aliases were found in the Technique. + */ + bool applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply = true) const; + + + }; + + +} +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreTextAreaOverlayElement.h b/school/informatik/verkerhssimulation/src/ogre/OgreTextAreaOverlayElement.h new file mode 100644 index 00000000..6bdf940d --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreTextAreaOverlayElement.h @@ -0,0 +1,247 @@ +/*------------------------------------------------------------------------- +This source file is a part of OGRE +(Object-oriented Graphics Rendering Engine) + +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License (LGPL) as +published by the Free Software Foundation; either version 2.1 of the +License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or go to +http://www.gnu.org/copyleft/lesser.txt +-------------------------------------------------------------------------*/ + +#ifndef _TextAreaOverlayElement_H__ +#define _TextAreaOverlayElement_H__ + +#include "OgreOverlayElement.h" +#include "OgreFont.h" + +namespace Ogre +{ + /** This class implements an overlay element which contains simple unformatted text. + */ + class _OgreExport TextAreaOverlayElement : public OverlayElement + { + public: + enum Alignment + { + Left, + Right, + Center + }; + + public: + /** Constructor. */ + TextAreaOverlayElement(const String& name); + virtual ~TextAreaOverlayElement(); + + virtual void initialise(void); + virtual void setCaption(const DisplayString& text); + + void setCharHeight( Real height ); + Real getCharHeight() const; + + void setSpaceWidth( Real width ); + Real getSpaceWidth() const; + + void setFontName( const String& font ); + const String& getFontName() const; + + /** See OverlayElement. */ + virtual const String& getTypeName(void) const; + /** See Renderable. */ + void getRenderOperation(RenderOperation& op); + /** Overridden from OverlayElement */ + void setMaterialName(const String& matName); + + /** Sets the colour of the text. + @remarks + This method establishes a constant colour for + the entire text. Also see setColourBottom and + setColourTop which allow you to set a colour gradient. + */ + void setColour(const ColourValue& col); + + /** Gets the colour of the text. */ + const ColourValue& getColour(void) const; + /** Sets the colour of the bottom of the letters. + @remarks + By setting a separate top and bottom colour, you + can create a text area which has a graduated colour + effect to it. + */ + void setColourBottom(const ColourValue& col); + /** Gets the colour of the bottom of the letters. */ + const ColourValue& getColourBottom(void) const; + /** Sets the colour of the top of the letters. + @remarks + By setting a separate top and bottom colour, you + can create a text area which has a graduated colour + effect to it. + */ + void setColourTop(const ColourValue& col); + /** Gets the colour of the top of the letters. */ + const ColourValue& getColourTop(void) const; + + inline void setAlignment( Alignment a ) + { + mAlignment = a; + mGeomPositionsOutOfDate = true; + } + inline Alignment getAlignment() const + { + return mAlignment; + } + + /** Overridden from OverlayElement */ + void setMetricsMode(GuiMetricsMode gmm); + + /** Overridden from OverlayElement */ + void _update(void); + + //----------------------------------------------------------------------------------------- + /** Command object for setting the caption. + @see ParamCommand + */ + class _OgrePrivate CmdCaption : public ParamCommand + { + public: + String doGet( const void* target ) const; + void doSet( void* target, const String& val ); + }; + //----------------------------------------------------------------------------------------- + /** Command object for setting the char height. + @see ParamCommand + */ + class _OgrePrivate CmdCharHeight : public ParamCommand + { + public: + String doGet( const void* target ) const; + void doSet( void* target, const String& val ); + }; + //----------------------------------------------------------------------------------------- + /** Command object for setting the width of a space. + @see ParamCommand + */ + class _OgrePrivate CmdSpaceWidth : public ParamCommand + { + public: + String doGet( const void* target ) const; + void doSet( void* target, const String& val ); + }; + //----------------------------------------------------------------------------------------- + /** Command object for setting the caption. + @see ParamCommand + */ + class _OgrePrivate CmdFontName : public ParamCommand + { + public: + String doGet( const void* target ) const; + void doSet( void* target, const String& val ); + }; + //----------------------------------------------------------------------------------------- + /** Command object for setting the top colour. + @see ParamCommand + */ + class _OgrePrivate CmdColourTop : public ParamCommand + { + public: + String doGet( const void* target ) const; + void doSet( void* target, const String& val ); + }; + //----------------------------------------------------------------------------------------- + /** Command object for setting the bottom colour. + @see ParamCommand + */ + class _OgrePrivate CmdColourBottom : public ParamCommand + { + public: + String doGet( const void* target ) const; + void doSet( void* target, const String& val ); + }; + //----------------------------------------------------------------------------------------- + /** Command object for setting the constant colour. + @see ParamCommand + */ + class _OgrePrivate CmdColour : public ParamCommand + { + public: + String doGet( const void* target ) const; + void doSet( void* target, const String& val ); + }; + //----------------------------------------------------------------------------------------- + /** Command object for setting the alignment. + @see ParamCommand + */ + class _OgrePrivate CmdAlignment : public ParamCommand + { + public: + String doGet( const void* target ) const; + void doSet( void* target, const String& val ); + }; + + protected: + /// The text alignment + Alignment mAlignment; + + /// Flag indicating if this panel should be visual or just group things + bool mTransparent; + + /// Render operation + RenderOperation mRenderOp; + + /// Method for setting up base parameters for this class + void addBaseParameters(void); + + static String msTypeName; + + // Command objects + static CmdCharHeight msCmdCharHeight; + static CmdSpaceWidth msCmdSpaceWidth; + static CmdFontName msCmdFontName; + static CmdColour msCmdColour; + static CmdColourTop msCmdColourTop; + static CmdColourBottom msCmdColourBottom; + static CmdAlignment msCmdAlignment; + + + FontPtr mpFont; + Real mCharHeight; + ushort mPixelCharHeight; + Real mSpaceWidth; + ushort mPixelSpaceWidth; + size_t mAllocSize; + Real mViewportAspectCoef; + + /// Colours to use for the vertices + ColourValue mColourBottom; + ColourValue mColourTop; + bool mColoursChanged; + + + /// Internal method to allocate memory, only reallocates when necessary + void checkMemoryAllocation( size_t numChars ); + /// Inherited function + virtual void updatePositionGeometry(); + /// Inherited function + virtual void updateTextureGeometry(); + /// Updates vertex colours + virtual void updateColours(void); + }; +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreTexture.h b/school/informatik/verkerhssimulation/src/ogre/OgreTexture.h new file mode 100644 index 00000000..57dcab6a --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreTexture.h @@ -0,0 +1,416 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _Texture_H__ +#define _Texture_H__ + +#include "OgrePrerequisites.h" +#include "OgreHardwareBuffer.h" +#include "OgreResource.h" +#include "OgreImage.h" + +namespace Ogre { + + /** Enum identifying the texture usage + */ + enum TextureUsage + { + /// @copydoc HardwareBuffer::Usage + TU_STATIC = HardwareBuffer::HBU_STATIC, + TU_DYNAMIC = HardwareBuffer::HBU_DYNAMIC, + TU_WRITE_ONLY = HardwareBuffer::HBU_WRITE_ONLY, + TU_STATIC_WRITE_ONLY = HardwareBuffer::HBU_STATIC_WRITE_ONLY, + TU_DYNAMIC_WRITE_ONLY = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, + TU_DYNAMIC_WRITE_ONLY_DISCARDABLE = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE, + /// mipmaps will be automatically generated for this texture + TU_AUTOMIPMAP = 0x100, + /// this texture will be a render target, ie. used as a target for render to texture + /// setting this flag will ignore all other texture usages except TU_AUTOMIPMAP + TU_RENDERTARGET = 0x200, + /// default to automatic mipmap generation static textures + TU_DEFAULT = TU_AUTOMIPMAP | TU_STATIC_WRITE_ONLY + + }; + + /** Enum identifying the texture type + */ + enum TextureType + { + /// 1D texture, used in combination with 1D texture coordinates + TEX_TYPE_1D = 1, + /// 2D texture, used in combination with 2D texture coordinates (default) + TEX_TYPE_2D = 2, + /// 3D volume texture, used in combination with 3D texture coordinates + TEX_TYPE_3D = 3, + /// 3D cube map, used in combination with 3D texture coordinates + TEX_TYPE_CUBE_MAP = 4 + }; + + /** Enum identifying special mipmap numbers + */ + enum TextureMipmap + { + /// Generate mipmaps up to 1x1 + MIP_UNLIMITED = 0x7FFFFFFF, + /// Use TextureManager default + MIP_DEFAULT = -1 + }; + + // Forward declaration + class TexturePtr; + + /** Abstract class representing a Texture resource. + @remarks + The actual concrete subclass which will exist for a texture + is dependent on the rendering system in use (Direct3D, OpenGL etc). + This class represents the commonalities, and is the one 'used' + by programmers even though the real implementation could be + different in reality. Texture objects are created through + the 'create' method of the TextureManager concrete subclass. + */ + class _OgreExport Texture : public Resource + { + public: + Texture(ResourceManager* creator, const String& name, ResourceHandle handle, + const String& group, bool isManual = false, ManualResourceLoader* loader = 0); + + /** Sets the type of texture; can only be changed before load() + */ + virtual void setTextureType(TextureType ttype ) { mTextureType = ttype; } + + /** Gets the type of texture + */ + virtual TextureType getTextureType(void) const { return mTextureType; } + + /** Gets the number of mipmaps to be used for this texture. + */ + virtual size_t getNumMipmaps(void) const {return mNumMipmaps;} + + /** Sets the number of mipmaps to be used for this texture. + @note + Must be set before calling any 'load' method. + */ + virtual void setNumMipmaps(size_t num) {mNumRequestedMipmaps = mNumMipmaps = num;} + + /** Are mipmaps hardware generated? + @remarks + Will only be accurate after texture load, or createInternalResources + */ + virtual bool getMipmapsHardwareGenerated(void) const { return mMipmapsHardwareGenerated; } + + /** Returns the gamma adjustment factor applied to this texture. + */ + virtual float getGamma(void) const { return mGamma; } + + /** Sets the gamma adjustment factor applied to this texture. + @note + Must be called before any 'load' method. + */ + virtual void setGamma(float g) { mGamma = g; } + + /** Returns the height of the texture. + */ + virtual size_t getHeight(void) const { return mHeight; } + + /** Returns the width of the texture. + */ + virtual size_t getWidth(void) const { return mWidth; } + + /** Returns the depth of the texture (only applicable for 3D textures). + */ + virtual size_t getDepth(void) const { return mDepth; } + + /** Returns the height of the original input texture (may differ due to hardware requirements). + */ + virtual size_t getSrcHeight(void) const { return mSrcHeight; } + + /** Returns the width of the original input texture (may differ due to hardware requirements). + */ + virtual size_t getSrcWidth(void) const { return mSrcWidth; } + + /** Returns the original depth of the input texture (only applicable for 3D textures). + */ + virtual size_t getSrcDepth(void) const { return mSrcDepth; } + + /** Set the height of the texture; can only do this before load(); + */ + virtual void setHeight(size_t h) { mHeight = mSrcHeight = h; } + + /** Set the width of the texture; can only do this before load(); + */ + virtual void setWidth(size_t w) { mWidth = mSrcWidth = w; } + + /** Set the depth of the texture (only applicable for 3D textures); + ; can only do this before load(); + */ + virtual void setDepth(size_t d) { mDepth = mSrcDepth = d; } + + /** Returns the TextureUsage indentifier for this Texture + */ + virtual int getUsage() const + { + return mUsage; + } + + /** Sets the TextureUsage indentifier for this Texture; only useful before load() + + @param u is a combination of TU_STATIC, TU_DYNAMIC, TU_WRITE_ONLY + TU_AUTOMIPMAP and TU_RENDERTARGET (see TextureUsage enum). You are + strongly advised to use HBU_STATIC_WRITE_ONLY wherever possible, if you need to + update regularly, consider HBU_DYNAMIC_WRITE_ONLY. + */ + virtual void setUsage(int u) { mUsage = u; } + + /** Creates the internal texture resources for this texture. + @remarks + This method creates the internal texture resources (pixel buffers, + texture surfaces etc) required to begin using this texture. You do + not need to call this method directly unless you are manually creating + a texture, in which case something must call it, after having set the + size and format of the texture (e.g. the ManualResourceLoader might + be the best one to call it). If you are not defining a manual texture, + or if you use one of the self-contained load...() methods, then it will be + called for you. + */ + virtual void createInternalResources(void); + + /** Frees internal texture resources for this texture. + */ + virtual void freeInternalResources(void); + + /** Copies (and maybe scales to fit) the contents of this texture to + another texture. */ + virtual void copyToTexture( TexturePtr& target ); + + /** Loads the data from an image. + @note Important: only call this from outside the load() routine of a + Resource. Don't call it within (including ManualResourceLoader) - use + _loadImages() instead. This method is designed to be external, + performs locking and checks the load status before loading. + */ + virtual void loadImage( const Image &img ); + + /** Loads the data from a raw stream. + @note Important: only call this from outside the load() routine of a + Resource. Don't call it within (including ManualResourceLoader) - use + _loadImages() instead. This method is designed to be external, + performs locking and checks the load status before loading. + @param stream Data stream containing the raw pixel data + @param uWidth Width of the image + @param uHeight Height of the image + @param eFormat The format of the pixel data + */ + virtual void loadRawData( DataStreamPtr& stream, + ushort uWidth, ushort uHeight, PixelFormat eFormat); + + /** Internal method to load the texture from a set of images. + @note Do NOT call this method unless you are inside the load() routine + already, e.g. a ManualResourceLoader. It is not threadsafe and does + not check or update resource loading status. + */ + virtual void _loadImages( const ConstImagePtrList& images ); + + /** Returns the pixel format for the texture surface. */ + virtual PixelFormat getFormat() const + { + return mFormat; + } + + /** Returns the desired pixel format for the texture surface. */ + virtual PixelFormat getDesiredFormat(void) const + { + return mDesiredFormat; + } + + /** Returns the pixel format of the original input texture (may differ due to + hardware requirements and pixel format convertion). + */ + virtual PixelFormat getSrcFormat(void) const + { + return mSrcFormat; + } + + /** Sets the pixel format for the texture surface; can only be set before load(). */ + virtual void setFormat(PixelFormat pf); + + /** Returns true if the texture has an alpha layer. */ + virtual bool hasAlpha(void) const; + + /** Sets desired bit depth for integer pixel format textures. + @note + Available values: 0, 16 and 32, where 0 (the default) means keep original format + as it is. This value is number of bits for the pixel. + */ + virtual void setDesiredIntegerBitDepth(ushort bits); + + /** gets desired bit depth for integer pixel format textures. + */ + virtual ushort getDesiredIntegerBitDepth(void) const; + + /** Sets desired bit depth for float pixel format textures. + @note + Available values: 0, 16 and 32, where 0 (the default) means keep original format + as it is. This value is number of bits for a channel of the pixel. + */ + virtual void setDesiredFloatBitDepth(ushort bits); + + /** gets desired bit depth for float pixel format textures. + */ + virtual ushort getDesiredFloatBitDepth(void) const; + + /** Sets desired bit depth for integer and float pixel format. + */ + virtual void setDesiredBitDepths(ushort integerBits, ushort floatBits); + + /** Sets whether luminace pixel format will treated as alpha format when load this texture. + */ + virtual void setTreatLuminanceAsAlpha(bool asAlpha); + + /** Gets whether luminace pixel format will treated as alpha format when load this texture. + */ + virtual bool getTreatLuminanceAsAlpha(void) const; + + /** Return the number of faces this texture has. This will be 6 for a cubemap + texture and 1 for a 1D, 2D or 3D one. + */ + virtual size_t getNumFaces() const; + + /** Return hardware pixel buffer for a surface. This buffer can then + be used to copy data from and to a particular level of the texture. + @param face Face number, in case of a cubemap texture. Must be 0 + for other types of textures. + For cubemaps, this is one of + +X (0), -X (1), +Y (2), -Y (3), +Z (4), -Z (5) + @param mipmap Mipmap level. This goes from 0 for the first, largest + mipmap level to getNumMipmaps()-1 for the smallest. + @returns A shared pointer to a hardware pixel buffer + @remarks The buffer is invalidated when the resource is unloaded or destroyed. + Do not use it after the lifetime of the containing texture. + */ + virtual HardwarePixelBufferSharedPtr getBuffer(size_t face=0, size_t mipmap=0) = 0; + + protected: + size_t mHeight; + size_t mWidth; + size_t mDepth; + + size_t mNumRequestedMipmaps; + size_t mNumMipmaps; + bool mMipmapsHardwareGenerated; + float mGamma; + + TextureType mTextureType; + PixelFormat mFormat; + int mUsage; // Bit field, so this can't be TextureUsage + + PixelFormat mSrcFormat; + size_t mSrcWidth, mSrcHeight, mSrcDepth; + + PixelFormat mDesiredFormat; + unsigned short mDesiredIntegerBitDepth; + unsigned short mDesiredFloatBitDepth; + bool mTreatLuminanceAsAlpha; + + bool mInternalResourcesCreated; + + /// @copydoc Resource::calculateSize + size_t calculateSize(void) const; + + + /** Implementation of creating internal texture resources + */ + virtual void createInternalResourcesImpl(void) = 0; + + /** Implementation of freeing internal texture resources + */ + virtual void freeInternalResourcesImpl(void) = 0; + + /** Default implementation of unload which calls freeInternalResources */ + void unloadImpl(void); + + }; + + /** Specialisation of SharedPtr to allow SharedPtr to be assigned to TexturePtr + @note Has to be a subclass since we need operator=. + We could templatise this instead of repeating per Resource subclass, + except to do so requires a form VC6 does not support i.e. + ResourceSubclassPtr : public SharedPtr + */ + class _OgreExport TexturePtr : public SharedPtr + { + public: + TexturePtr() : SharedPtr() {} + explicit TexturePtr(Texture* rep) : SharedPtr(rep) {} + TexturePtr(const TexturePtr& r) : SharedPtr(r) {} + TexturePtr(const ResourcePtr& r) : SharedPtr() + { + // lock & copy other mutex pointer + OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME) + { + OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME) + OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME) + pRep = static_cast(r.getPointer()); + pUseCount = r.useCountPointer(); + if (pUseCount) + { + ++(*pUseCount); + } + } + } + + /// Operator used to convert a ResourcePtr to a TexturePtr + TexturePtr& operator=(const ResourcePtr& r) + { + if (pRep == static_cast(r.getPointer())) + return *this; + release(); + // lock & copy other mutex pointer + OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME) + { + OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME) + OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME) + pRep = static_cast(r.getPointer()); + pUseCount = r.useCountPointer(); + if (pUseCount) + { + ++(*pUseCount); + } + } + else + { + // RHS must be a null pointer + assert(r.isNull() && "RHS must be null if it has no mutex!"); + setNull(); + } + return *this; + } + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreTextureManager.h b/school/informatik/verkerhssimulation/src/ogre/OgreTextureManager.h new file mode 100644 index 00000000..9cabe9b8 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreTextureManager.h @@ -0,0 +1,398 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _TextureManager_H__ +#define _TextureManager_H__ + + +#include "OgrePrerequisites.h" + +#include "OgreResourceManager.h" +#include "OgreTexture.h" +#include "OgreSingleton.h" + + +namespace Ogre { + + /** Class for loading & managing textures. + @remarks + Note that this class is abstract - the particular + RenderSystem that is in use at the time will create + a concrete subclass of this. Note that the concrete + class will be available via the abstract singleton + obtained from TextureManager::getSingleton(), but + you should not assume that it is available until you + have a) initialised Ogre (after selecting a RenderSystem + and calling initialise from the Root object), and b) + created at least one window - this may be done at the + same time as part a if you allow Ogre to autocreate one. + */ + class _OgreExport TextureManager : public ResourceManager, public Singleton + { + public: + + TextureManager(void); + virtual ~TextureManager(); + + /** Loads a texture from a file. + @param + name The file to load, or a String identifier in some cases + @param + group The name of the resource group to assign the texture to + @param + texType The type of texture to load/create, defaults to normal 2D textures + @param + numMipmaps The number of pre-filtered mipmaps to generate. If left to MIP_DEFAULT then + the TextureManager's default number of mipmaps will be used (see setDefaultNumMipmaps()) + If set to MIP_UNLIMITED mipmaps will be generated until the lowest possible + level, 1x1x1. + @param + gamma The gamma adjustment factor to apply to this texture (brightening/darkening) + @param + isAlpha Only applicable to greyscale images. If true, specifies that + the image should be loaded into an alpha texture rather than a + single channel colour texture - useful for fixed-function systems. + @param + desiredFormat The format you would like to have used instead of + the format being based on the contents of the texture + */ + virtual TexturePtr load( + const String& name, const String& group, + TextureType texType = TEX_TYPE_2D, int numMipmaps = MIP_DEFAULT, + Real gamma = 1.0f, bool isAlpha = false, + PixelFormat desiredFormat = PF_UNKNOWN); + + /** Loads a texture from an Image object. + @note + The texture will create as manual texture without loader. + @param + name The name to give the resulting texture + @param + group The name of the resource group to assign the texture to + @param + img The Image object which contains the data to load + @param + texType The type of texture to load/create, defaults to normal 2D textures + @param + numMipmaps The number of pre-filtered mipmaps to generate. If left to MIP_DEFAULT then + the TextureManager's default number of mipmaps will be used (see setDefaultNumMipmaps()) + If set to MIP_UNLIMITED mipmaps will be generated until the lowest possible + level, 1x1x1. + @param + gamma The gamma adjustment factor to apply to this texture (brightening/darkening) + @param + isAlpha Only applicable to greyscale images. If true, specifies that + the image should be loaded into an alpha texture rather than a + single channel colour texture - useful for fixed-function systems. + @param + desiredFormat The format you would like to have used instead of + the format being based on the contents of the texture + */ + virtual TexturePtr loadImage( + const String &name, const String& group, const Image &img, + TextureType texType = TEX_TYPE_2D, + int iNumMipmaps = MIP_DEFAULT, Real gamma = 1.0f, bool isAlpha = false, + PixelFormat desiredFormat = PF_UNKNOWN); + + /** Loads a texture from a raw data stream. + @note + The texture will create as manual texture without loader. + @param + name The name to give the resulting texture + @param + group The name of the resource group to assign the texture to + @param + stream Incoming data stream + @param + width, height The dimensions of the texture + @param + format The format of the data being passed in; the manager reserves + the right to create a different format for the texture if the + original format is not available in this context. + @param + texType The type of texture to load/create, defaults to normal 2D textures + @param + numMipmaps The number of pre-filtered mipmaps to generate. If left to MIP_DEFAULT then + the TextureManager's default number of mipmaps will be used (see setDefaultNumMipmaps()) + If set to MIP_UNLIMITED mipmaps will be generated until the lowest possible + level, 1x1x1. + @param + gamma The gamma adjustment factor to apply to this texture (brightening/darkening) + */ + virtual TexturePtr loadRawData(const String &name, const String& group, + DataStreamPtr& stream, ushort uWidth, ushort uHeight, + PixelFormat format, TextureType texType = TEX_TYPE_2D, + int iNumMipmaps = MIP_DEFAULT, Real gamma = 1.0f); + + /** Create a manual texture with specified width, height and depth (not loaded from a file). + @param + name The name to give the resulting texture + @param + group The name of the resource group to assign the texture to + @param + texType The type of texture to load/create, defaults to normal 2D textures + @param + width, height, depth The dimensions of the texture + @param + numMipmaps The number of pre-filtered mipmaps to generate. If left to MIP_DEFAULT then + the TextureManager's default number of mipmaps will be used (see setDefaultNumMipmaps()) + If set to MIP_UNLIMITED mipmaps will be generated until the lowest possible + level, 1x1x1. + @param + format The internal format you wish to request; the manager reserves + the right to create a different format if the one you select is + not available in this context. + @param + usage The kind of usage this texture is intended for. It + is a combination of TU_STATIC, TU_DYNAMIC, TU_WRITE_ONLY, + TU_AUTOMIPMAP and TU_RENDERTARGET (see TextureUsage enum). You are + strongly advised to use HBU_STATIC_WRITE_ONLY wherever possible, if you need to + update regularly, consider HBU_DYNAMIC_WRITE_ONLY. + @param + loader If you intend the contents of the manual texture to be + regularly updated, to the extent that you don't need to recover + the contents if the texture content is lost somehow, you can leave + this parameter as 0. However, if you intend to populate the + texture only once, then you should implement ManualResourceLoader + and pass a pointer to it in this parameter; this means that if the + manual texture ever needs to be reloaded, the ManualResourceLoader + will be called to do it. + */ + virtual TexturePtr createManual(const String & name, const String& group, + TextureType texType, uint width, uint height, uint depth, + int num_mips, PixelFormat format, int usage = TU_DEFAULT, ManualResourceLoader* loader = 0 ); + + /** Create a manual texture with a depth of 1 (not loaded from a file). + @param + name The name to give the resulting texture + @param + group The name of the resource group to assign the texture to + @param + texType The type of texture to load/create, defaults to normal 2D textures + @param + width, height The dimensions of the texture + @param + numMipmaps The number of pre-filtered mipmaps to generate. If left to MIP_DEFAULT then + the TextureManager's default number of mipmaps will be used (see setDefaultNumMipmaps()). + If set to MIP_UNLIMITED mipmaps will be generated until the lowest possible + level, 1x1x1. + @param + format The internal format you wish to request; the manager reserves + the right to create a different format if the one you select is + not available in this context. + @param + usage The kind of usage this texture is intended for. It + is a combination of TU_STATIC, TU_DYNAMIC, TU_WRITE_ONLY, + TU_AUTOMIPMAP and TU_RENDERTARGET (see TextureUsage enum). You are + strongly advised to use HBU_STATIC_WRITE_ONLY wherever possible, if you need to + update regularly, consider HBU_DYNAMIC_WRITE_ONLY. + @param + loader If you intend the contents of the manual texture to be + regularly updated, to the extent that you don't need to recover + the contents if the texture content is lost somehow, you can leave + this parameter as 0. However, if you intend to populate the + texture only once, then you should implement ManualResourceLoader + and pass a pointer to it in this parameter; this means that if the + manual texture ever needs to be reloaded, the ManualResourceLoader + will be called to do it. + */ + TexturePtr createManual(const String & name, const String& group, + TextureType texType, uint width, uint height, int num_mips, + PixelFormat format, int usage = TU_DEFAULT, ManualResourceLoader* loader = 0 ) + { + return createManual(name, group, texType, width, height, 1, + num_mips, format, usage, loader); + } + + /** Sets preferred bit depth for integer pixel format textures. + @param + bits Number of bits. Available values: 0, 16 and 32, where 0 (the default) means keep + original format as it is. This value is number of bits for the pixel. + @param + reloadTextures If true (the default), will reloading all reloadable textures. + */ + virtual void setPreferredIntegerBitDepth(ushort bits, bool reloadTextures = true); + + /** gets preferred bit depth for integer pixel format textures. + */ + virtual ushort getPreferredIntegerBitDepth(void) const; + + /** Sets preferred bit depth for float pixel format textures. + @param + bits Number of bits. Available values: 0, 16 and 32, where 0 (the default) means keep + original format as it is. This value is number of bits for a channel of the pixel. + @param + reloadTextures If true (the default), will reloading all reloadable textures. + */ + virtual void setPreferredFloatBitDepth(ushort bits, bool reloadTextures = true); + + /** gets preferred bit depth for float pixel format textures. + */ + virtual ushort getPreferredFloatBitDepth(void) const; + + /** Sets preferred bit depth for integer and float pixel format. + @param + integerBits Number of bits. Available values: 0, 16 and 32, where 0 (the default) means keep + original format as it is. This value is number of bits for the pixel. + @param + floatBits Number of bits. Available values: 0, 16 and 32, where 0 (the default) means keep + original format as it is. This value is number of bits for a channel of the pixel. + @param + reloadTextures If true (the default), will reloading all reloadable textures. + */ + virtual void setPreferredBitDepths(ushort integerBits, ushort floatBits, bool reloadTextures = true); + + /** Returns whether this render system can natively support the precise texture + format requested with the given usage options. + @remarks + You can still create textures with this format even if this method returns + false; the texture format will just be altered to one which the device does + support. + @note + Sometimes the device may just slightly change the format, such as reordering the + channels or packing the channels differently, without it making and qualitative + differences to the texture. If you want to just detect whether the quality of a + given texture will be reduced, use isEquivalentFormatSupport instead. + @param format The pixel format requested + @param usage The kind of usage this texture is intended for, a combination of + the TextureUsage flags. + @returns true if the format is natively supported, false if a fallback would be used. + */ + virtual bool isFormatSupported(TextureType ttype, PixelFormat format, int usage); + + /** Returns whether this render system can support the texture format requested + with the given usage options, or another format with no quality reduction. + */ + virtual bool isEquivalentFormatSupported(TextureType ttype, PixelFormat format, int usage); + + /** Gets the format which will be natively used for a requested format given the + contraints of the current device. + */ + virtual PixelFormat getNativeFormat(TextureType ttype, PixelFormat format, int usage) = 0; + + /** Returns whether this render system has hardware filtering supported for the + texture format requested with the given usage options. + @remarks + Not all texture format are supports filtering by the hardware, i.e. some + cards support floating point format, but it doesn't supports filtering on + the floating point texture at all, or only a subset floating point formats + have flitering supported. + @par + In the case you want to write shader to work with floating point texture, and + you want to produce better visual quality, it's necessary to flitering the + texture manually in shader (potential requires four or more texture fetch + instructions, plus several arithmetic instructions) if filtering doesn't + supported by hardware. But in case on the hardware that supports floating + point filtering natively, it had better to adopt this capability for + performance (because only one texture fetch instruction are required) and + doesn't loss visual quality. + @par + This method allow you queries hardware texture filtering capability to deciding + which verion of the shader to be used. Note it's up to you to write multi-version + shaders for support various hardware, internal engine can't do that for you + automatically. + @note + Under GL, texture filtering are always supported by driver, but if it's not + supported by hardware natively, software simulation will be used, and you + will end up with very slow speed (less than 0.1 fps for example). To slove + this performance problem, you must disable filtering manually (by use + filtering none in the material script's texture_unit section, or + call TextureUnitState::setTextureFiltering with TFO_NONE if populate + material in code). + @param ttype The texture type requested + @param format The pixel format requested + @param usage The kind of usage this texture is intended for, a combination of + the TextureUsage flags. + @param preciseFormatOnly Whether precise or fallback format mode is used to detecting. + In case the pixel format doesn't supported by device, false will be returned + if in precise mode, and natively used pixel format will be actually use to + check if in fallback mode. + @returns true if the texture filtering is supported. + */ + virtual bool isHardwareFilteringSupported(TextureType ttype, PixelFormat format, int usage, + bool preciseFormatOnly = false) = 0; + + /** Sets the default number of mipmaps to be used for loaded textures, for when textures are + loaded automatically (e.g. by Material class) or when 'load' is called with the default + parameters by the application. + If set to MIP_UNLIMITED mipmaps will be generated until the lowest possible + level, 1x1x1. + @note + The default value is 0. + */ + virtual void setDefaultNumMipmaps(size_t num); + + /** Gets the default number of mipmaps to be used for loaded textures. + */ + virtual size_t getDefaultNumMipmaps() + { + return mDefaultNumMipmaps; + } + + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static TextureManager& getSingleton(void); + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static TextureManager* getSingletonPtr(void); + + protected: + + ushort mPreferredIntegerBitDepth; + ushort mPreferredFloatBitDepth; + size_t mDefaultNumMipmaps; + }; +}// Namespace + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreTextureUnitState.h b/school/informatik/verkerhssimulation/src/ogre/OgreTextureUnitState.h new file mode 100644 index 00000000..9722bc12 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreTextureUnitState.h @@ -0,0 +1,1177 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __TextureUnitState_H__ +#define __TextureUnitState_H__ + +#include "OgrePrerequisites.h" +#include "OgreCommon.h" +#include "OgreBlendMode.h" +#include "OgreMatrix4.h" +#include "OgreIteratorWrappers.h" +#include "OgreString.h" +#include "OgreTexture.h" + +namespace Ogre { + /** Class representing the state of a single texture unit during a Pass of a + Technique, of a Material. + @remarks + Texture units are pipelines for retrieving texture data for rendering onto + your objects in the world. Using them is common to both the fixed-function and + the programmable (vertex and fragment program) pipeline, but some of the + settings will only have an effect in the fixed-function pipeline (for example, + setting a texture rotation will have no effect if you use the programmable + pipeline, because this is overridden by the fragment program). The effect + of each setting as regards the 2 pipelines is commented in each setting. + @par + When I use the term 'fixed-function pipeline' I mean traditional rendering + where you do not use vertex or fragment programs (shaders). Programmable + pipeline means that for this pass you are using vertex or fragment programs. + */ + class _OgreExport TextureUnitState + { + friend class RenderSystem; + public: + /** Definition of the broad types of texture effect you can apply to a texture unit. + @note + Note that these have no effect when using the programmable pipeline, since their + effect is overridden by the vertex / fragment programs. + */ + enum TextureEffectType + { + /// Generate all texture coords based on angle between camera and vertex + ET_ENVIRONMENT_MAP, + /// Generate texture coords based on a frustum + ET_PROJECTIVE_TEXTURE, + /// Constant u/v scrolling effect + ET_UVSCROLL, + /// Constant u scrolling effect + ET_USCROLL, + /// Constant u/v scrolling effect + ET_VSCROLL, + /// Constant rotation + ET_ROTATE, + /// More complex transform + ET_TRANSFORM + + }; + + /** Enumeration to specify type of envmap. + @note + Note that these have no effect when using the programmable pipeline, since their + effect is overridden by the vertex / fragment programs. + */ + enum EnvMapType + { + /// Envmap based on vector from camera to vertex position, good for planar geometry + ENV_PLANAR, + /// Envmap based on dot of vector from camera to vertex and vertex normal, good for curves + ENV_CURVED, + /// Envmap entended to supply reflection vectors for cube mapping + ENV_REFLECTION, + /// Envmap entended to supply normal vectors for cube mapping + ENV_NORMAL + }; + + /** Useful enumeration when dealing with procedural transforms. + @note + Note that these have no effect when using the programmable pipeline, since their + effect is overridden by the vertex / fragment programs. + */ + enum TextureTransformType + { + TT_TRANSLATE_U, + TT_TRANSLATE_V, + TT_SCALE_U, + TT_SCALE_V, + TT_ROTATE + }; + + /** Texture addressing modes - default is TAM_WRAP. + @note + These settings are relevant in both the fixed-function and the + programmable pipeline. + */ + enum TextureAddressingMode + { + /// Texture wraps at values over 1.0 + TAM_WRAP, + /// Texture mirrors (flips) at joins over 1.0 + TAM_MIRROR, + /// Texture clamps at 1.0 + TAM_CLAMP, + /// Texture coordinates outside the range [0.0, 1.0] are set to the border colour + TAM_BORDER + }; + + /** Texture addressing mode for each texture coordinate. */ + struct UVWAddressingMode + { + TextureAddressingMode u, v, w; + }; + + /** Enum identifying the frame indexes for faces of a cube map (not the composite 3D type. + */ + enum TextureCubeFace + { + CUBE_FRONT = 0, + CUBE_BACK = 1, + CUBE_LEFT = 2, + CUBE_RIGHT = 3, + CUBE_UP = 4, + CUBE_DOWN = 5 + }; + + /** Internal structure defining a texture effect. + */ + struct TextureEffect { + TextureEffectType type; + int subtype; + Real arg1, arg2; + WaveformType waveType; + Real base; + Real frequency; + Real phase; + Real amplitude; + Controller* controller; + const Frustum* frustum; + }; + + /** Texture effects in a multimap paired array + */ + typedef std::multimap EffectMap; + + /** Default constructor. + */ + TextureUnitState(Pass* parent); + + TextureUnitState(Pass* parent, const TextureUnitState& oth ); + + TextureUnitState & operator = ( const TextureUnitState& oth ); + + /** Default destructor. + */ + ~TextureUnitState(); + + /** Name-based constructor. + @param + name The basic name of the texture e.g. brickwall.jpg, stonefloor.png + @param + texCoordSet The index of the texture coordinate set to use. + */ + TextureUnitState( Pass* parent, const String& texName, unsigned int texCoordSet = 0); + + /** Get the name of current texture image for this layer. + @remarks + This will either always be a single name for this layer, + or will be the name of the current frame for an animated + or otherwise multi-frame texture. + @note + Applies to both fixed-function and programmable pipeline. + */ + const String& getTextureName(void) const; + + /** Sets this texture layer to use a single texture, given the + name of the texture to use on this layer. + @note + Applies to both fixed-function and programmable pipeline. + */ + void setTextureName( const String& name, TextureType ttype = TEX_TYPE_2D); + + /** Sets this texture layer to use a combination of 6 texture maps, each one relating to a face of a cube. + @remarks + Cubic textures are made up of 6 separate texture images. Each one of these is an orthoganal view of the + world with a FOV of 90 degrees and an aspect ratio of 1:1. You can generate these from 3D Studio by + rendering a scene to a reflection map of a transparent cube and saving the output files. + @par + Cubic maps can be used either for skyboxes (complete wrap-around skies, like space) or as environment + maps to simulate reflections. The system deals with these 2 scenarios in different ways: +
    +
  1. +

    + for cubic environment maps, the 6 textures are combined into a single 'cubic' texture map which + is then addressed using 3D texture coordinates. This is required because you don't know what + face of the box you're going to need to address when you render an object, and typically you + need to reflect more than one face on the one object, so all 6 textures are needed to be + 'active' at once. Cubic environment maps are enabled by calling this method with the forUVW + parameter set to true, and then calling setEnvironmentMap(true). +

    +

    + Note that not all cards support cubic environment mapping. +

    +
  2. +
  3. +

    + for skyboxes, the 6 textures are kept separate and used independently for each face of the skybox. + This is done because not all cards support 3D cubic maps and skyboxes do not need to use 3D + texture coordinates so it is simpler to render each face of the box with 2D coordinates, changing + texture between faces. +

    +

    + Skyboxes are created by calling SceneManager::setSkyBox. +

    +
  4. + + @note + Applies to both fixed-function and programmable pipeline. + @param + name The basic name of the texture e.g. brickwall.jpg, stonefloor.png. There must be 6 versions + of this texture with the suffixes _fr, _bk, _up, _dn, _lf, and _rt (before the extension) which + make up the 6 sides of the box. The textures must all be the same size and be powers of 2 in width & height. + If you can't make your texture names conform to this, use the alternative method of the same name which takes + an array of texture names instead. + @param + forUVW Set to true if you want a single 3D texture addressable with 3D texture coordinates rather than + 6 separate textures. Useful for cubic environment mapping. + */ + void setCubicTextureName( const String& name, bool forUVW = false ); + + /** Sets this texture layer to use a combination of 6 texture maps, each one relating to a face of a cube. + @remarks + Cubic textures are made up of 6 separate texture images. Each one of these is an orthoganal view of the + world with a FOV of 90 degrees and an aspect ratio of 1:1. You can generate these from 3D Studio by + rendering a scene to a reflection map of a transparent cube and saving the output files. + @par + Cubic maps can be used either for skyboxes (complete wrap-around skies, like space) or as environment + maps to simulate reflections. The system deals with these 2 scenarios in different ways: +
      +
    1. +

      + for cubic environment maps, the 6 textures are combined into a single 'cubic' texture map which + is then addressed using 3D texture coordinates. This is required because you don't know what + face of the box you're going to need to address when you render an object, and typically you + need to reflect more than one face on the one object, so all 6 textures are needed to be + 'active' at once. Cubic environment maps are enabled by calling this method with the forUVW + parameter set to true, and then calling setEnvironmentMap(true). +

      +

      + Note that not all cards support cubic environment mapping. +

      +
    2. +
    3. +

      + for skyboxes, the 6 textures are kept separate and used independently for each face of the skybox. + This is done because not all cards support 3D cubic maps and skyboxes do not need to use 3D + texture coordinates so it is simpler to render each face of the box with 2D coordinates, changing + texture between faces. +

      +

      + Skyboxes are created by calling SceneManager::setSkyBox. +

      +
    4. + + @note + Applies to both fixed-function and programmable pipeline. + @param + name The basic name of the texture e.g. brickwall.jpg, stonefloor.png. There must be 6 versions + of this texture with the suffixes _fr, _bk, _up, _dn, _lf, and _rt (before the extension) which + make up the 6 sides of the box. The textures must all be the same size and be powers of 2 in width & height. + If you can't make your texture names conform to this, use the alternative method of the same name which takes + an array of texture names instead. + @param + forUVW Set to true if you want a single 3D texture addressable with 3D texture coordinates rather than + 6 separate textures. Useful for cubic environment mapping. + */ + void setCubicTextureName( const String* const names, bool forUVW = false ); + + /** Sets the names of the texture images for an animated texture. + @remarks + Animated textures are just a series of images making up the frames of the animation. All the images + must be the same size, and their names must have a frame number appended before the extension, e.g. + if you specify a name of "wall.jpg" with 3 frames, the image names must be "wall_0.jpg", "wall_1.jpg" + and "wall_2.jpg". + @par + You can change the active frame on a texture layer by calling the setCurrentFrame method. + @note + If you can't make your texture images conform to the naming standard layed out here, you + can call the alternative setAnimatedTextureName method which takes an array of names instead. + @note + Applies to both fixed-function and programmable pipeline. + @param + name The base name of the textures to use e.g. wall.jpg for frames wall_0.jpg, wall_1.jpg etc. + @param + numFrames The number of frames in the sequence. + @param + duration The length of time it takes to display the whole animation sequence, in seconds. + If 0, no automatic transition occurs. + */ + void setAnimatedTextureName( const String& name, unsigned int numFrames, Real duration = 0 ); + + /** Sets the names of the texture images for an animated texture. + @remarks + This an alternative method to the one where you specify a single name and let the system derive + the names of each frame, incase your images can't conform to this naming standard. + @par + Animated textures are just a series of images making up the frames of the animation. All the images + must be the same size, and you must provide their names as an array in the first parameter. + You can change the active frame on a texture layer by calling the setCurrentFrame method. + @note + If you can make your texture images conform to a naming standard of basicName_frame.ext, you + can call the alternative setAnimatedTextureName method which just takes a base name instead. + @note + Applies to both fixed-function and programmable pipeline. + @param + names Pointer to array of names of the textures to use, in frame order. + @param + numFrames The number of frames in the sequence. + @param + duration The length of time it takes to display the whole animation sequence, in seconds. + If 0, no automatic transition occurs. + */ + void setAnimatedTextureName( const String* const names, unsigned int numFrames, Real duration = 0 ); + + /** Returns the width and height of the texture in the given frame. + */ + std::pair< size_t, size_t > getTextureDimensions( unsigned int frame = 0 ) const; + + /** Changes the active frame in an animated or multi-image texture. + @remarks + An animated texture (or a cubic texture where the images are not combined for 3D use) is made up of + a number of frames. This method sets the active frame. + @note + Applies to both fixed-function and programmable pipeline. + */ + void setCurrentFrame( unsigned int frameNumber ); + + /** Gets the active frame in an animated or multi-image texture layer. + @note + Applies to both fixed-function and programmable pipeline. + */ + unsigned int getCurrentFrame(void) const; + + /** Gets the name of the texture associated with a frame number. + Throws an exception if frameNumber exceeds the number of stored frames. + @note + Applies to both fixed-function and programmable pipeline. + */ + const String& getFrameTextureName(unsigned int frameNumber) const; + + /** Sets the name of the texture associated with a frame. + @param name The name of the texture + @param frameNumber The frame the texture name is to be placed in + @note + Throws an exception if frameNumber exceeds the number of stored frames. + Applies to both fixed-function and programmable pipeline. + */ + void setFrameTextureName(const String& name, unsigned int frameNumber); + + /** Add a Texture name to the end of the frame container. + @param name The name of the texture + @note + Applies to both fixed-function and programmable pipeline. + */ + void addFrameTextureName(const String& name); + /** deletes a specific texture frame. The texture used is not deleted but the + texture will no longer be used by the Texture Unit. An exception is raised + if the frame number exceeds the number of actual frames. + @param frameNumber The frame number of the texture to be deleted. + @note + Applies to both fixed-function and programmable pipeline. + */ + void deleteFrameTextureName(const size_t frameNumber); + /** Gets the number of frames for a texture. + @note + Applies to both fixed-function and programmable pipeline. + */ + unsigned int getNumFrames(void) const; + + + /** The type of unit to bind the texture settings to. */ + enum BindingType + { + /** Regular fragment processing unit - the default. */ + BT_FRAGMENT = 0, + /** Vertex processing unit - indicates this unit will be used for + a vertex texture fetch. + */ + BT_VERTEX = 1 + }; + /** Enum identifying the type of content this texture unit contains. + */ + enum ContentType + { + /// Normal texture identified by name + CONTENT_NAMED = 0, + /// A shadow texture, automatically bound by engine + CONTENT_SHADOW = 1 + }; + + /** Sets the type of unit these texture settings should be bound to. + @remarks + Some render systems, when implementing vertex texture fetch, separate + the binding of textures for use in the vertex program versus those + used in fragment programs. This setting allows you to target the + vertex processing unit with a texture binding, in those cases. For + rendersystems which have a unified binding for the vertex and fragment + units, this setting makes no difference. + */ + void setBindingType(BindingType bt); + + /** Gets the type of unit these texture settings should be bound to. + */ + BindingType getBindingType(void) const; + + /** Set the type of content this TextureUnitState references. + @remarks + The default is to reference a standard named texture, but this unit + can also reference automated content like a shadow texture. + */ + void setContentType(ContentType ct); + /** Get the type of content this TextureUnitState references. */ + ContentType getContentType(void) const; + + /** Returns true if this texture unit is either a series of 6 2D textures, each + in it's own frame, or is a full 3D cube map. You can tell which by checking + getTextureType. + @note + Applies to both fixed-function and programmable pipeline. + */ + bool isCubic(void) const; + + /** Returns true if this texture layer uses a composite 3D cubic texture. + @note + Applies to both fixed-function and programmable pipeline. + */ + bool is3D(void) const; + + /** Returns the type of this texture. + @note + Applies to both fixed-function and programmable pipeline. + */ + TextureType getTextureType(void) const; + + /** Sets the desired pixel format when load the texture. + */ + void setDesiredFormat(PixelFormat desiredFormat); + + /** Gets the desired pixel format when load the texture. + */ + PixelFormat getDesiredFormat(void) const; + + /** Sets how many mipmaps have been requested for the texture. + */ + void setNumMipmaps(int numMipmaps); + + /** Gets how many mipmaps have been requested for the texture. + */ + int getNumMipmaps(void) const; + + /** Sets whether this texture is requested to be loaded as alpha if single channel + */ + void setIsAlpha(bool isAlpha); + + /** Gets whether this texture is requested to be loaded as alpha if single channel + */ + bool getIsAlpha(void) const; + + /** Gets the index of the set of texture co-ords this layer uses. + @note + Applies to both fixed-function and programmable pipeline. + */ + unsigned int getTextureCoordSet(void) const; + + /** Sets the index of the set of texture co-ords this layer uses. + @note + Default is 0 for all layers. Only change this if you have provided multiple texture co-ords per + vertex. + @note + Applies to both fixed-function and programmable pipeline. + */ + void setTextureCoordSet(unsigned int set); + + /** Sets a matrix used to transform any texture coordinates on this layer. + @remarks + Texture coordinates can be modified on a texture layer to create effects like scrolling + textures. A texture transform can either be applied to a layer which takes the source coordinates + from a fixed set in the geometry, or to one which generates them dynamically (e.g. environment mapping). + @par + It's obviously a bit impractical to create scrolling effects by calling this method manually since you + would have to call it every framw with a slight alteration each time, which is tedious. Instead + you can use the ControllerManager class to create a Controller object which will manage the + effect over time for you. See the ControllerManager::createTextureScroller and it's sibling methods for details.
      + In addition, if you want to set the individual texture transformations rather than concatenating them + yourself, use setTextureScroll, setTextureScale and setTextureRotate. + @note + Has no effect in the programmable pipeline. + */ + void setTextureTransform(const Matrix4& xform); + + /** Gets the current texture transformation matrix. + @remarks + Causes a reclaculation of the matrix if any parameters have been changed via + setTextureScroll, setTextureScale and setTextureRotate. + @note + Has no effect in the programmable pipeline. + */ + const Matrix4& getTextureTransform(void) const; + + /** Sets the translation offset of the texture, ie scrolls the texture. + @remarks + This method sets the translation element of the texture transformation, and is easier to use than setTextureTransform if + you are combining translation, scaling and rotation in your texture transformation. Again if you want + to animate these values you need to use a Controller + @note + Has no effect in the programmable pipeline. + @param u The amount the texture should be moved horizontally (u direction). + @param v The amount the texture should be moved vertically (v direction). + @see + ControllerManager, Controller + */ + void setTextureScroll(Real u, Real v); + + /** As setTextureScroll, but sets only U value. + @note + Has no effect in the programmable pipeline. + */ + void setTextureUScroll(Real value); + // get texture uscroll value + Real getTextureUScroll(void) const; + + /** As setTextureScroll, but sets only V value. + @note + Has no effect in the programmable pipeline. + */ + void setTextureVScroll(Real value); + // get texture vscroll value + Real getTextureVScroll(void) const; + + /** As setTextureScale, but sets only U value. + @note + Has no effect in the programmable pipeline. + */ + void setTextureUScale(Real value); + // get texture uscale value + Real getTextureUScale(void) const; + + /** As setTextureScale, but sets only V value. + @note + Has no effect in the programmable pipeline. + */ + void setTextureVScale(Real value); + // get texture vscale value + Real getTextureVScale(void) const; + + /** Sets the scaling factor applied to texture coordinates. + @remarks + This method sets the scale element of the texture transformation, and is easier to use than + setTextureTransform if you are combining translation, scaling and rotation in your texture transformation. Again if you want + to animate these values you need to use a Controller (see ControllerManager and it's methods for + more information). + @note + Has no effect in the programmable pipeline. + @param + uScale The value by which the texture is to be scaled horizontally. + @param + vScale The value by which the texture is to be scaled vertically. + */ + void setTextureScale(Real uScale, Real vScale); + + /** Sets the anticlockwise rotation factor applied to texture coordinates. + @remarks + This sets a fixed rotation angle - if you wish to animate this, see the + ControllerManager::createTextureRotater method. + @note + Has no effect in the programmable pipeline. + @param + angle The angle of rotation (anticlockwise). + */ + void setTextureRotate(const Radian& angle); +#ifndef OGRE_FORCE_ANGLE_TYPES + inline void setTextureRotate(Real angle) { + setTextureRotate ( Degree(angle) ); + } +#endif//OGRE_FORCE_ANGLE_TYPES + // get texture rotation effects angle value + const Radian& getTextureRotate(void) const; + + /** Gets the texture addressing mode for a given coordinate, + i.e. what happens at uv values above 1.0. + @note + The default is TAM_WRAP i.e. the texture repeats over values of 1.0. + */ + const UVWAddressingMode& getTextureAddressingMode(void) const; + + /** Sets the texture addressing mode, i.e. what happens at uv values above 1.0. + @note + The default is TAM_WRAP i.e. the texture repeats over values of 1.0. + @note This is a shortcut method which sets the addressing mode for all + coordinates at once; you can also call the more specific method + to set the addressing mode per coordinate. + @note + This applies for both the fixed-function and programmable pipelines. + */ + void setTextureAddressingMode( TextureAddressingMode tam); + + /** Sets the texture addressing mode, i.e. what happens at uv values above 1.0. + @note + The default is TAM_WRAP i.e. the texture repeats over values of 1.0. + @note + This applies for both the fixed-function and programmable pipelines. + */ + void setTextureAddressingMode( TextureAddressingMode u, + TextureAddressingMode v, TextureAddressingMode w); + + /** Sets the texture addressing mode, i.e. what happens at uv values above 1.0. + @note + The default is TAM_WRAP i.e. the texture repeats over values of 1.0. + @note + This applies for both the fixed-function and programmable pipelines. + */ + void setTextureAddressingMode( const UVWAddressingMode& uvw); + + /** Sets the texture border colour. + @note + The default is ColourValue::Black, and this value only used when addressing mode + is TAM_BORDER. + @note + This applies for both the fixed-function and programmable pipelines. + */ + void setTextureBorderColour(const ColourValue& colour); + + /** Sets the texture border colour. + @note + The default is ColourValue::Black, and this value only used when addressing mode + is TAM_BORDER. + */ + const ColourValue& getTextureBorderColour(void) const; + + /** Setting advanced blending options. + @remarks + This is an extended version of the TextureUnitState::setColourOperation method which allows + extremely detailed control over the blending applied between this and earlier layers. + See the IMPORTANT note below about the issues between mulitpass and multitexturing that + using this method can create. + @par + Texture colour operations determine how the final colour of the surface appears when + rendered. Texture units are used to combine colour values from various sources (ie. the + diffuse colour of the surface from lighting calculations, combined with the colour of + the texture). This method allows you to specify the 'operation' to be used, ie. the + calculation such as adds or multiplies, and which values to use as arguments, such as + a fixed value or a value from a previous calculation. + @par + The defaults for each layer are: +
        +
      • op = LBX_MODULATE
      • +
      • source1 = LBS_TEXTURE
      • +
      • source2 = LBS_CURRENT
      • +
      + ie. each layer takes the colour results of the previous layer, and multiplies them + with the new texture being applied. Bear in mind that colours are RGB values from + 0.0 - 1.0 so multiplying them together will result in values in the same range, + 'tinted' by the multiply. Note however that a straight multiply normally has the + effect of darkening the textures - for this reason there are brightening operations + like LBO_MODULATE_X2. See the LayerBlendOperation and LayerBlendSource enumerated + types for full details. + @note + Because of the limitations on some underlying APIs (Direct3D included) + the LBS_TEXTURE argument can only be used as the first argument, not the second. + @par + The final 3 parameters are only required if you decide to pass values manually + into the operation, i.e. you want one or more of the inputs to the colour calculation + to come from a fixed value that you supply. Hence you only need to fill these in if + you supply LBS_MANUAL to the corresponding source, or use the LBX_BLEND_MANUAL + operation. + @warning + Ogre tries to use multitexturing hardware to blend texture layers + together. However, if it runs out of texturing units (e.g. 2 of a GeForce2, 4 on a + GeForce3) it has to fall back on multipass rendering, i.e. rendering the same object + multiple times with different textures. This is both less efficient and there is a smaller + range of blending operations which can be performed. For this reason, if you use this method + you MUST also call TextureUnitState::setColourOpMultipassFallback to specify which effect you + want to fall back on if sufficient hardware is not available. + @note + This has no effect in the programmable pipeline. + @param + If you wish to avoid having to do this, use the simpler TextureUnitState::setColourOperation method + which allows less flexible blending options but sets up the multipass fallback automatically, + since it only allows operations which have direct multipass equivalents. + @param + op The operation to be used, e.g. modulate (multiply), add, subtract + @param + source1 The source of the first colour to the operation e.g. texture colour + @param + source2 The source of the second colour to the operation e.g. current surface colour + @param + arg1 Manually supplied colour value (only required if source1 = LBS_MANUAL) + @param + arg2 Manually supplied colour value (only required if source2 = LBS_MANUAL) + @param + manualBlend Manually supplied 'blend' value - only required for operations + which require manual blend e.g. LBX_BLEND_MANUAL + */ + void setColourOperationEx( + LayerBlendOperationEx op, + LayerBlendSource source1 = LBS_TEXTURE, + LayerBlendSource source2 = LBS_CURRENT, + + const ColourValue& arg1 = ColourValue::White, + const ColourValue& arg2 = ColourValue::White, + + Real manualBlend = 0.0); + + /** Determines how this texture layer is combined with the one below it (or the diffuse colour of + the geometry if this is layer 0). + @remarks + This method is the simplest way to blend tetxure layers, because it requires only one parameter, + gives you the most common blending types, and automatically sets up 2 blending methods: one for + if single-pass multitexturing hardware is available, and another for if it is not and the blending must + be achieved through multiple rendering passes. It is, however, quite limited and does not expose + the more flexible multitexturing operations, simply because these can't be automatically supported in + multipass fallback mode. If want to use the fancier options, use TextureUnitState::setColourOperationEx, + but you'll either have to be sure that enough multitexturing units will be available, or you should + explicitly set a fallback using TextureUnitState::setColourOpMultipassFallback. + @note + The default method is LBO_MODULATE for all layers. + @note + This option has no effect in the programmable pipeline. + @param + op One of the LayerBlendOperation enumerated blending types. + */ + void setColourOperation( const LayerBlendOperation op); + + /** Sets the multipass fallback operation for this layer, if you used TextureUnitState::setColourOperationEx + and not enough multitexturing hardware is available. + @remarks + Because some effects exposed using TextureUnitState::setColourOperationEx are only supported under + multitexturing hardware, if the hardware is lacking the system must fallback on multipass rendering, + which unfortunately doesn't support as many effects. This method is for you to specify the fallback + operation which most suits you. + @par + You'll notice that the interface is the same as the Material::setSceneBlending method; this is + because multipass rendering IS effectively scene blending, since each layer is rendered on top + of the last using the same mechanism as making an object transparent, it's just being rendered + in the same place repeatedly to get the multitexture effect. + @par + If you use the simpler (and hence less flexible) TextureUnitState::setColourOperation method you + don't need to call this as the system sets up the fallback for you. + @note + This option has no effect in the programmable pipeline, because there is no multipass fallback + and multitexture blending is handled by the fragment shader. + */ + void setColourOpMultipassFallback( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor); + + /** Get multitexturing colour blending mode. + */ + const LayerBlendModeEx& getColourBlendMode(void) const; + + /** Get multitexturing alpha blending mode. + */ + const LayerBlendModeEx& getAlphaBlendMode(void) const; + + /** Get the multipass fallback for colour blending operation source factor. + */ + SceneBlendFactor getColourBlendFallbackSrc(void) const; + + /** Get the multipass fallback for colour blending operation destination factor. + */ + SceneBlendFactor getColourBlendFallbackDest(void) const; + + /** Sets the alpha operation to be applied to this texture. + @remarks + This works in exactly the same way as setColourOperation, except + that the effect is applied to the level of alpha (i.e. transparency) + of the texture rather than its colour. When the alpha of a texel (a pixel + on a texture) is 1.0, it is opaque, wheras it is fully transparent if the + alpha is 0.0. Please refer to the setColourOperation method for more info. + @param + op The operation to be used, e.g. modulate (multiply), add, subtract + @param + source1 The source of the first alpha value to the operation e.g. texture alpha + @param + source2 The source of the second alpha value to the operation e.g. current surface alpha + @param + arg1 Manually supplied alpha value (only required if source1 = LBS_MANUAL) + @param + arg2 Manually supplied alpha value (only required if source2 = LBS_MANUAL) + @param + manualBlend Manually supplied 'blend' value - only required for operations + which require manual blend e.g. LBX_BLEND_MANUAL + @see + setColourOperation + @note + This option has no effect in the programmable pipeline. + */ + void setAlphaOperation(LayerBlendOperationEx op, + LayerBlendSource source1 = LBS_TEXTURE, + LayerBlendSource source2 = LBS_CURRENT, + Real arg1 = 1.0, + Real arg2 = 1.0, + Real manualBlend = 0.0); + + /** Generic method for setting up texture effects. + @remarks + Allows you to specify effects directly by using the TextureEffectType enumeration. The + arguments that go with it depend on the effect type. Only one effect of + each type can be applied to a texture layer. + @par + This method is used internally by Ogre but it is better generally for applications to use the + more intuitive specialised methods such as setEnvironmentMap and setScroll. + @note + This option has no effect in the programmable pipeline. + */ + void addEffect(TextureEffect& effect); + + /** Turns on/off texture coordinate effect that makes this layer an environment map. + @remarks + Environment maps make an object look reflective by using the object's vertex normals relative + to the camera view to generate texture coordinates. + @par + The vectors generated can either be used to address a single 2D texture which + is a 'fish-eye' lens view of a scene, or a 3D cubic environment map which requires 6 textures + for each side of the inside of a cube. The type depends on what texture you set up - if you use the + setTextureName method then a 2D fisheye lens texture is required, whereas if you used setCubicTextureName + then a cubic environemnt map will be used. + @par + This effect works best if the object has lots of gradually changing normals. The texture also + has to be designed for this effect - see the example spheremap.png included with the sample + application for a 2D environment map; a cubic map can be generated by rendering 6 views of a + scene to each of the cube faces with orthoganal views. + @note + Enabling this disables any other texture coordinate generation effects. + However it can be combined with texture coordinate modification functions, which then operate on the + generated coordinates rather than static model texture coordinates. + @param + enable True to enable, false to disable + @param + planar If set to true, instead of being based on normals the environment effect is based on + vertex positions. This is good for planar surfaces. + @note + This option has no effect in the programmable pipeline. + */ + void setEnvironmentMap(bool enable, EnvMapType envMapType = ENV_CURVED); + + /** Sets up an animated scroll for the texture layer. + @note + Useful for creating constant scrolling effects on a texture layer (for varying scrolls, see setTransformAnimation). + @param + uSpeed The number of horizontal loops per second (+ve=moving right, -ve = moving left) + @param + vSpeed The number of vertical loops per second (+ve=moving up, -ve= moving down) + @note + This option has no effect in the programmable pipeline. + */ + void setScrollAnimation(Real uSpeed, Real vSpeed); + + /** Sets up an animated texture rotation for this layer. + @note + Useful for constant rotations (for varying rotations, see setTransformAnimation). + @param + speed The number of complete anticlockwise revolutions per second (use -ve for clockwise) + @note + This option has no effect in the programmable pipeline. + */ + void setRotateAnimation(Real speed); + + /** Sets up a general time-relative texture modification effect. + @note + This can be called multiple times for different values of ttype, but only the latest effect + applies if called multiple time for the same ttype. + @param + ttype The type of transform, either translate (scroll), scale (stretch) or rotate (spin) + @param + waveType The shape of the wave, see WaveformType enum for details + @param + base The base value for the function (range of output = {base, base + amplitude}) + @param + frequency The speed of the wave in cycles per second + @param + phase The offset of the start of the wave, e.g. 0.5 to start half-way through the wave + @param + amplitude Scales the output so that instead of lying within 0..1 it lies within 0..1*amplitude for exaggerated effects + @note + This option has no effect in the programmable pipeline. + */ + void setTransformAnimation( const TextureTransformType ttype, + const WaveformType waveType, Real base = 0, Real frequency = 1, Real phase = 0, Real amplitude = 1 ); + + + /** Enables or disables projective texturing on this texture unit. + @remarks + Projective texturing allows you to generate texture coordinates + based on a Frustum, which gives the impression that a texture is + being projected onto the surface. Note that once you have called + this method, the texture unit continues to monitor the Frustum you + passed in and the projection will change if you can alter it. It also + means that you must ensure that the Frustum object you pass a pointer + to remains in existence for as long as this TextureUnitState does. + @par + This effect cannot be combined with other texture generation effects, + such as environment mapping. It also has no effect on passes which + have a vertex program enabled - projective texturing has to be done + in the vertex program instead. + @param enabled Whether to enable / disable + @param projectionSettings The Frustum which will be used to derive the + projection parameters. + */ + void setProjectiveTexturing(bool enabled, const Frustum* projectionSettings = 0); + + /** Removes all effects applied to this texture layer. + */ + void removeAllEffects(void); + + /** Removes a single effect applied to this texture layer. + @note + Because you can only have 1 effect of each type (e.g. 1 texture coordinate generation) applied + to a layer, only the effect type is required. + */ + void removeEffect( const TextureEffectType type ); + + /** Determines if this texture layer is currently blank. + @note + This can happen if a texture fails to load or some other non-fatal error. Worth checking after + setting texture name. + */ + bool isBlank(void) const; + + /** Sets this texture layer to be blank. + */ + void setBlank(void); + + /** Tests if the texture associated with this unit has failed to load. + */ + bool isTextureLoadFailing() const { return mTextureLoadFailed; } + + /** Tells the unit to retry loading the texture if it had failed to load. + */ + void retryTextureLoad() { mTextureLoadFailed = false; } + + // get texture effects in a multimap paired array + const EffectMap& getEffects(void) const; + // get the animated-texture animation duration + Real getAnimationDuration(void) const; + + /** Set the texture filtering for this unit, using the simplified interface. + @remarks + You also have the option of specifying the minification, magnification + and mip filter individually if you want more control over filtering + options. See the alternative setTextureFiltering methods for details. + @note + This option applies in both the fixed function and the programmable pipeline. + @param filterType The high-level filter type to use. + */ + void setTextureFiltering(TextureFilterOptions filterType); + /** Set a single filtering option on this texture unit. + @params ftype The filtering type to set + @params opts The filtering option to set + */ + void setTextureFiltering(FilterType ftype, FilterOptions opts); + /** Set a the detailed filtering options on this texture unit. + @params minFilter The filtering to use when reducing the size of the texture. + Can be FO_POINT, FO_LINEAR or FO_ANISOTROPIC + @params magFilter The filtering to use when increasing the size of the texture + Can be FO_POINT, FO_LINEAR or FO_ANISOTROPIC + @params mipFilter The filtering to use between mip levels + Can be FO_NONE (turns off mipmapping), FO_POINT or FO_LINEAR (trilinear filtering) + */ + void setTextureFiltering(FilterOptions minFilter, FilterOptions magFilter, FilterOptions mipFilter); + // get the texture filtering for the given type + FilterOptions getTextureFiltering(FilterType ftpye) const; + + /** Sets the anisotropy level to be used for this texture level. + @par maxAniso The maximal anisotropy level, should be between 2 and the maximum supported by hardware (1 is the default, ie. no anisotrophy). + @note + This option applies in both the fixed function and the programmable pipeline. + */ + void setTextureAnisotropy(unsigned int maxAniso); + // get this layer texture anisotropy level + unsigned int getTextureAnisotropy() const; + + /** Sets the bias value applied to the mipmap calculation. + @remarks + You can alter the mipmap calculation by biasing the result with a + single floating point value. After the mip level has been calculated, + this bias value is added to the result to give the final mip level. + Lower mip levels are larger (higher detail), so a negative bias will + force the larger mip levels to be used, and a positive bias + will cause smaller mip levels to be used. The bias values are in + mip levels, so a -1 bias will force mip levels one larger than by the + default calculation. + @param bias The bias value as described above, can be positive or negative. + */ + void setTextureMipmapBias(float bias) { mMipmapBias = bias; } + /** Gets the bias value applied to the mipmap calculation. + @see TextureUnitState::setTextureMipmapBias + */ + float getTextureMipmapBias(void) const { return mMipmapBias; } + + /// Gets the parent Pass object + Pass* getParent(void) const { return mParent; } + + /** Internal method for loading this object as part of Material::load */ + void _load(void); + /** Internal method for unloading this object as part of Material::unload */ + void _unload(void); + /// Returns whether this unit has texture coordinate generation that depends on the camera + bool hasViewRelativeTextureCoordinateGeneration(void) const; + + // Is this loaded? + bool isLoaded(void) const; + /** Tells the class that it needs recompilation. */ + void _notifyNeedsRecompile(void); + + /** Set the name of the Texture Unit State + @remarks + The name of the Texture Unit State is optional. Its usefull in material scripts where a material could inherit + from another material and only want to modify a particalar Texture Unit State. + */ + void setName(const String& name); + /// get the name of the Texture Unit State + const String& getName(void) const { return mName; } + + /** Set the alias name used for texture frame names + @param name can be any sequence of characters and does not have to be unique + */ + void setTextureNameAlias(const String& name); + /** gets the Texture Name Alias of the Texture Unit. + */ + const String& getTextureNameAlias(void) const { return mTextureNameAlias;} + + /** Applies texture names to Texture Unit State with matching texture name aliases. + If no matching aliases are found then the TUS state does not change. + @remarks + Cubic, 1d, 2d, and 3d textures are determined from current state of the Texture Unit. + Assumes animated frames are sequentially numbered in the name. + If matching texture aliases are found then true is returned. + + @param + aliasList is a map container of texture alias, texture name pairs + @param + apply set true to apply the texture aliases else just test to see if texture alias matches are found. + @return + True if matching texture aliases were found in the Texture Unit State. + */ + bool applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply = true); + + /** Notify this object that its parent has changed */ + void _notifyParent(Pass* parent); + + /** Get the texture pointer for the current frame. */ + const TexturePtr& _getTexturePtr(void) const; + /** Get the texture pointer for a given frame. */ + const TexturePtr& _getTexturePtr(size_t frame) const; + + /** Set the texture pointer for the current frame (internal use only!). */ + void _setTexturePtr(const TexturePtr& texptr); + /** Set the texture pointer for a given frame (internal use only!). */ + void _setTexturePtr(const TexturePtr& texptr, size_t frame); + + /** Gets the animation controller (as created because of setAnimatedTexture) + if it exists. + */ + Controller* _getAnimController() const { return mAnimController; } +protected: + // State + /// The current animation frame. + unsigned int mCurrentFrame; + + /// Duration of animation in seconds + Real mAnimDuration; + bool mCubic; // is this a series of 6 2D textures to make up a cube? + + TextureType mTextureType; + PixelFormat mDesiredFormat; + int mTextureSrcMipmaps; // Request number of mipmaps + + unsigned int mTextureCoordSetIndex; + UVWAddressingMode mAddressMode; + ColourValue mBorderColour; + + LayerBlendModeEx mColourBlendMode; + SceneBlendFactor mColourBlendFallbackSrc; + SceneBlendFactor mColourBlendFallbackDest; + + LayerBlendModeEx mAlphaBlendMode; + mutable bool mTextureLoadFailed; + bool mIsAlpha; + + mutable bool mRecalcTexMatrix; + Real mUMod, mVMod; + Real mUScale, mVScale; + Radian mRotate; + mutable Matrix4 mTexModMatrix; + + /// Texture filtering - minification + FilterOptions mMinFilter; + /// Texture filtering - magnification + FilterOptions mMagFilter; + /// Texture filtering - mipmapping + FilterOptions mMipFilter; + ///Texture anisotropy + unsigned int mMaxAniso; + /// Mipmap bias (always float, not Real) + float mMipmapBias; + + bool mIsDefaultAniso; + bool mIsDefaultFiltering; + /// Binding type (fragment or vertex pipeline) + BindingType mBindingType; + /// Content type of texture (normal loaded texture, auto-texture) + ContentType mContentType; + + //----------------------------------------------------------------------------- + // Complex members (those that can't be copied using memcpy) are at the end to + // allow for fast copying of the basic members. + // + std::vector mFrames; + mutable std::vector mFramePtrs; + String mName; // optional name for the TUS + String mTextureNameAlias; // optional alias for texture frames + EffectMap mEffects; + //----------------------------------------------------------------------------- + + //----------------------------------------------------------------------------- + // Pointer members (those that can't be copied using memcpy), and MUST + // preserving even if assign from others + // + Pass* mParent; + Controller* mAnimController; + //----------------------------------------------------------------------------- + + + /** Internal method for calculating texture matrix. + */ + void recalcTextureMatrix(void) const; + + /** Internal method for creating animation controller. + */ + void createAnimController(void); + + /** Internal method for creating texture effect controller. + */ + void createEffectController(TextureEffect& effect); + + /** Internal method for ensuring the texture for a given frame is loaded. */ + void ensureLoaded(size_t frame) const; + + + }; + + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreTimer.h b/school/informatik/verkerhssimulation/src/ogre/OgreTimer.h new file mode 100644 index 00000000..00eba9ca --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreTimer.h @@ -0,0 +1,44 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __OgreCommonTimer_H__ +#define __OgreCommonTimer_H__ + +#include "OgrePrerequisites.h" +#include "OgrePlatform.h" + +//Bring in the specific platform's header file +#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 +# include "WIN32/OgreTimerImp.h" +#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX +# include "GLX/OgreTimerImp.h" +#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE +# include "OSX/OgreTimerImp.h" +#endif + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreUTFString.h b/school/informatik/verkerhssimulation/src/ogre/OgreUTFString.h new file mode 100644 index 00000000..ebe0deca --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreUTFString.h @@ -0,0 +1,2406 @@ +// Modified from OpenGUI under lenient license +// Original copyright details and licensing below: +// OpenGUI (http://opengui.sourceforge.net) +// This source code is released under the BSD License + +// Permission is given to the Ogre project to use the contents of file within its +// source and binary applications, as well as any derivative works, in accordance +// with the terms of any license under which Ogre is or will be distributed. +// +// Ogre may relicense its copy of this file, as well as any OpenGUI released updates +// to this file, under any terms that it deems fit, and is not required to maintain +// the original BSD licensing terms of this file, however OpenGUI retains the right +// to present its copy of this file under the terms of any license under which +// OpenGUI is distributed. +// +// Ogre is not required to release to OpenGUI any future changes that it makes to +// this file, and understands and agrees that any such changes that are released +// back to OpenGUI will become available under the terms of any license under which +// OpenGUI is distributed. +// +// For brevity, this permission text may be removed from this file if desired. +// The original record kept within the SourceForge (http://sourceforge.net/) tracker +// is sufficient. +// +// - Eric Shorkey (zero/zeroskill) [January 20th, 2007] + +#ifndef __OGRE_UTFSTRING_H__ +#define __OGRE_UTFSTRING_H__ + + +#include "OgrePrerequisites.h" + +#if OGRE_UNICODE_SUPPORT + +// these are explained later +#include +#include +#include + +// Workaround for VC7: +// when build with /MD or /MDd, VC7 have both std::basic_string and +// basic_string<__wchar_t> instantiated in msvcprt[d].lib/MSVCP71[D].dll, but the header +// files tells compiler that only one of them is over there (based on /Zc:wchar_t compile +// option). And since this file used both of them, causing compiler instantiating another +// one in user object code, which lead to duplicate symbols with msvcprt.lib/MSVCP71[D].dll. +// +#if OGRE_COMPILER == OGRE_COMPILER_MSVC && (1300 <= OGRE_COMP_VER && OGRE_COMP_VER <= 1310) + +# if defined(_DLL_CPPLIB) + +namespace std +{ + template class _CRTIMP2 basic_string, + allocator >; + + template class _CRTIMP2 basic_string<__wchar_t, char_traits<__wchar_t>, + allocator<__wchar_t> >; +} + +# endif // defined(_DLL_CPPLIB) + +#endif // OGRE_COMPILER == OGRE_COMPILER_MSVC && OGRE_COMP_VER == 1300 + + +namespace Ogre { + + /* READ THIS NOTICE BEFORE USING IN YOUR OWN APPLICATIONS + =NOTICE= + This class is not a complete Unicode solution. It purposefully does not + provide certain functionality, such as proper lexical sorting for + Unicode values. It does provide comparison operators for the sole purpose + of using UTFString as an index with std::map and other operator< sorted + containers, but it should NOT be relied upon for meaningful lexical + operations, such as alphabetical sorts. If you need this type of + functionality, look into using ICU instead (http://icu.sourceforge.net/). + + =REQUIREMENTS= + There are a few requirements for proper operation. They are fairly small, + and shouldn't restrict usage on any reasonable target. + * Compiler must support unsigned 16-bit integer types + * Compiler must support signed 32-bit integer types + * wchar_t must be either UTF-16 or UTF-32 encoding, and specified as such + using the WCHAR_UTF16 macro as outlined below. + * You must include , , and . Probably more, but + these are the most obvious. + + =REQUIRED PREPROCESSOR MACROS= + This class requires two preprocessor macros to be defined in order to + work as advertised. + INT32 - must be mapped to a signed 32 bit integer (ex. #define INT32 int) + UINT16 - must be mapped to an unsigned 16 bit integer (ex. #define UINT32 unsigned short) + + Additionally, a third macro should be defined to control the evaluation of wchar_t: + WCHAR_UTF16 - should be defined when wchar_t represents UTF-16 code points, + such as in Windows. Otherwise it is assumed that wchar_t is a 32-bit + integer representing UTF-32 code points. + */ + + // THIS IS A VERY BRIEF AUTO DETECTION. YOU MAY NEED TO TWEAK THIS +#ifdef __STDC_ISO_10646__ +// for any compiler that provides this, wchar_t is guaranteed to hold any Unicode value with a single code point (32-bit or larger) +// so we can safely skip the rest of the testing +#else // #ifdef __STDC_ISO_10646__ +#if defined( __WIN32__ ) || defined( _WIN32 ) +#define WCHAR_UTF16 // All currently known Windows platforms utilize UTF-16 encoding in wchar_t +#else // #if defined( __WIN32__ ) || defined( _WIN32 ) +#if WCHAR_MAX <= 0xFFFF // this is a last resort fall back test; WCHAR_MAX is defined in +#define WCHAR_UTF16 // best we can tell, wchar_t is not larger than 16-bit +#endif // #if WCHAR_MAX <= 0xFFFF +#endif // #if defined( __WIN32__ ) || defined( _WIN32 ) +#endif // #ifdef __STDC_ISO_10646__ + + +// OGRE_IS_NATIVE_WCHAR_T means that wchar_t isn't a typedef of +// uint16 or uint32. +#if OGRE_COMPILER == OGRE_COMPILER_MSVC + +// Don't define wchar_t related functions since it'll duplicate +// with UTFString::code_point related functions when compile +// without /Zc:wchar_t, because in this case both of them are +// a typedef of uint16. +# if defined(_NATIVE_WCHAR_T_DEFINED) +# define OGRE_IS_NATIVE_WCHAR_T 1 +# else +# define OGRE_IS_NATIVE_WCHAR_T 0 +# endif + +#else // OGRE_COMPILER != OGRE_COMPILER_MSVC + +// Assumed wchar_t is natively for other compilers +# define OGRE_IS_NATIVE_WCHAR_T 1 + +#endif // OGRE_COMPILER == OGRE_COMPILER_MSVC + + //! A UTF-16 string with implicit conversion to/from std::string and std::wstring + /*! This class provides a complete 1 to 1 map of most std::string functions (at least to my + knowledge). Implicit conversions allow this string class to work with all common C++ string + formats, with specialty functions defined where implicit conversion would cause potential + problems or is otherwise unavailable. + + Some additional functionality is present to assist in working with characters using the + 32-bit UTF-32 encoding. (Which is guaranteed to fit any Unicode character into a single + code point.) \b Note: Reverse iterators do not have this functionality due to the + ambiguity that surrounds working with UTF-16 in reverse. (Such as, where should an + iterator point to represent the beginning of a surrogate pair?) + + + \par Supported Input Types + The supported string types for input, and their assumed encoding schemes, are: + - std::string (UTF-8) + - char* (UTF-8) + - std::wstring (autodetected UTF-16 / UTF-32 based on compiler) + - wchar_t* (autodetected UTF-16 / UTF-32 based on compiler) + + + \see + - For additional information on UTF-16 encoding: http://en.wikipedia.org/wiki/UTF-16 + - For additional information on UTF-8 encoding: http://en.wikipedia.org/wiki/UTF-8 + - For additional information on UTF-32 encoding: http://en.wikipedia.org/wiki/UTF-32 + */ + class UTFString { + // constants used in UTF-8 conversions + static const unsigned char _lead1 = 0xC0; //110xxxxx + static const unsigned char _lead1_mask = 0x1F; //00011111 + static const unsigned char _lead2 = 0xE0; //1110xxxx + static const unsigned char _lead2_mask = 0x0F; //00001111 + static const unsigned char _lead3 = 0xF0; //11110xxx + static const unsigned char _lead3_mask = 0x07; //00000111 + static const unsigned char _lead4 = 0xF8; //111110xx + static const unsigned char _lead4_mask = 0x03; //00000011 + static const unsigned char _lead5 = 0xFC; //1111110x + static const unsigned char _lead5_mask = 0x01; //00000001 + static const unsigned char _cont = 0x80; //10xxxxxx + static const unsigned char _cont_mask = 0x3F; //00111111 + + public: + //! size type used to indicate string size and character positions within the string + typedef size_t size_type; + //! the usual constant representing: not found, no limit, etc + static const size_type npos = ~0; + + //! a single 32-bit Unicode character + typedef uint32 unicode_char; + + //! a single UTF-16 code point + typedef uint16 code_point; + + //! value type typedef for use in iterators + typedef code_point value_type; + + typedef std::basic_string dstring; // data string + + //! string type used for returning UTF-32 formatted data + typedef std::basic_string utf32string; + + //! This exception is used when invalid data streams are encountered + class invalid_data: public std::runtime_error { /* i don't know why the beautifier is freaking out on this line */ + public: + //! constructor takes a string message that can be later retrieved by the what() function + explicit invalid_data( const std::string& _Message ): std::runtime_error( _Message ) { + /* The thing is, Bob, it's not that I'm lazy, it's that I just don't care. */ + } + }; + + //######################################################################### + //! base iterator class for UTFString + class _base_iterator: public std::iterator { /* i don't know why the beautifier is freaking out on this line */ + friend class UTFString; + protected: + _base_iterator() { + mString = 0; + } + + void _seekFwd( size_type c ) { + mIter += c; + } + void _seekRev( size_type c ) { + mIter -= c; + } + void _become( const _base_iterator& i ) { + mIter = i.mIter; + mString = i.mString; + } + bool _test_begin() const { + return mIter == mString->mData.begin(); + } + bool _test_end() const { + return mIter == mString->mData.end(); + } + size_type _get_index() const { + return mIter - mString->mData.begin(); + } + void _jump_to( size_type index ) { + mIter = mString->mData.begin() + index; + } + + unicode_char _getCharacter() const { + size_type current_index = _get_index(); + return mString->getChar( current_index ); + } + int _setCharacter( unicode_char uc ) { + size_type current_index = _get_index(); + int change = mString->setChar( current_index, uc ); + _jump_to( current_index ); + return change; + } + + void _moveNext() { + _seekFwd( 1 ); // move 1 code point forward + if ( _test_end() ) return; // exit if we hit the end + if ( _utf16_surrogate_follow( mIter[0] ) ) { + // landing on a follow code point means we might be part of a bigger character + // so we test for that + code_point lead_half = 0; + //NB: we can't possibly be at the beginning here, so no need to test + lead_half = mIter[-1]; // check the previous code point to see if we're part of a surrogate pair + if ( _utf16_surrogate_lead( lead_half ) ) { + _seekFwd( 1 ); // if so, then advance 1 more code point + } + } + } + void _movePrev() { + _seekRev( 1 ); // move 1 code point backwards + if ( _test_begin() ) return; // exit if we hit the beginning + if ( _utf16_surrogate_follow( mIter[0] ) ) { + // landing on a follow code point means we might be part of a bigger character + // so we test for that + code_point lead_half = 0; + lead_half = mIter[-1]; // check the previous character to see if we're part of a surrogate pair + if ( _utf16_surrogate_lead( lead_half ) ) { + _seekRev( 1 ); // if so, then rewind 1 more code point + } + } + } + + dstring::iterator mIter; + UTFString* mString; + }; + + //######################################################################### + // FORWARD ITERATORS + //######################################################################### + class _const_fwd_iterator; // forward declaration + + //! forward iterator for UTFString + class _fwd_iterator: public _base_iterator { /* i don't know why the beautifier is freaking out on this line */ + friend class _const_fwd_iterator; + public: + _fwd_iterator() {} + _fwd_iterator( const _fwd_iterator& i ) { + _become( i ); + } + + //! pre-increment + _fwd_iterator& operator++() { + _seekFwd( 1 ); + return *this; + } + //! post-increment + _fwd_iterator operator++( int ) { + _fwd_iterator tmp( *this ); + _seekFwd( 1 ); + return tmp; + } + + //! pre-decrement + _fwd_iterator& operator--() { + _seekRev( 1 ); + return *this; + } + //! post-decrement + _fwd_iterator operator--( int ) { + _fwd_iterator tmp( *this ); + _seekRev( 1 ); + return tmp; + } + + //! addition operator + _fwd_iterator operator+( size_type n ) { + _fwd_iterator tmp( *this ); + tmp._seekFwd( n ); + return tmp; + } + //! addition operator + _fwd_iterator operator+( difference_type n ) { + _fwd_iterator tmp( *this ); + if ( n < 0 ) + tmp._seekRev( -n ); + else + tmp._seekFwd( n ); + return tmp; + } + //! subtraction operator + _fwd_iterator operator-( size_type n ) { + _fwd_iterator tmp( *this ); + tmp._seekRev( n ); + return tmp; + } + //! subtraction operator + _fwd_iterator operator-( difference_type n ) { + _fwd_iterator tmp( *this ); + if ( n < 0 ) + tmp._seekFwd( -n ); + else + tmp._seekRev( n ); + return tmp; + } + + //! addition assignment operator + _fwd_iterator& operator+=( size_type n ) { + _seekFwd( n ); + return *this; + } + //! addition assignment operator + _fwd_iterator& operator+=( difference_type n ) { + if ( n < 0 ) + _seekRev( -n ); + else + _seekFwd( n ); + return *this; + } + //! subtraction assignment operator + _fwd_iterator& operator-=( size_type n ) { + _seekRev( n ); + return *this; + } + //! subtraction assignment operator + _fwd_iterator& operator-=( difference_type n ) { + if ( n < 0 ) + _seekFwd( -n ); + else + _seekRev( n ); + return *this; + } + + //! dereference operator + value_type& operator*() const { + return *mIter; + } + + //! dereference at offset operator + value_type& operator[]( size_type n ) const { + _fwd_iterator tmp( *this ); + tmp += n; + return *tmp; + } + //! dereference at offset operator + value_type& operator[]( difference_type n ) const { + _fwd_iterator tmp( *this ); + tmp += n; + return *tmp; + } + + //! advances to the next Unicode character, honoring surrogate pairs in the UTF-16 stream + _fwd_iterator& moveNext() { + _moveNext(); + return *this; + } + //! rewinds to the previous Unicode character, honoring surrogate pairs in the UTF-16 stream + _fwd_iterator& movePrev() { + _movePrev(); + return *this; + } + //! Returns the Unicode value of the character at the current position (decodes surrogate pairs if needed) + unicode_char getCharacter() const { + return _getCharacter(); + } + //! Sets the Unicode value of the character at the current position (adding a surrogate pair if needed); returns the amount of string length change caused by the operation + int setCharacter( unicode_char uc ) { + return _setCharacter( uc ); + } + }; + + + + //######################################################################### + //! const forward iterator for UTFString + class _const_fwd_iterator: public _base_iterator { /* i don't know why the beautifier is freaking out on this line */ + public: + _const_fwd_iterator() {} + _const_fwd_iterator( const _const_fwd_iterator& i ) { + _become( i ); + } + _const_fwd_iterator( const _fwd_iterator& i ) { + _become( i ); + } + + //! pre-increment + _const_fwd_iterator& operator++() { + _seekFwd( 1 ); + return *this; + } + //! post-increment + _const_fwd_iterator operator++( int ) { + _const_fwd_iterator tmp( *this ); + _seekFwd( 1 ); + return tmp; + } + + //! pre-decrement + _const_fwd_iterator& operator--() { + _seekRev( 1 ); + return *this; + } + //! post-decrement + _const_fwd_iterator operator--( int ) { + _const_fwd_iterator tmp( *this ); + _seekRev( 1 ); + return tmp; + } + + //! addition operator + _const_fwd_iterator operator+( size_type n ) { + _const_fwd_iterator tmp( *this ); + tmp._seekFwd( n ); + return tmp; + } + //! addition operator + _const_fwd_iterator operator+( difference_type n ) { + _const_fwd_iterator tmp( *this ); + if ( n < 0 ) + tmp._seekRev( -n ); + else + tmp._seekFwd( n ); + return tmp; + } + //! subtraction operator + _const_fwd_iterator operator-( size_type n ) { + _const_fwd_iterator tmp( *this ); + tmp._seekRev( n ); + return tmp; + } + //! subtraction operator + _const_fwd_iterator operator-( difference_type n ) { + _const_fwd_iterator tmp( *this ); + if ( n < 0 ) + tmp._seekFwd( -n ); + else + tmp._seekRev( n ); + return tmp; + } + + //! addition assignment operator + _const_fwd_iterator& operator+=( size_type n ) { + _seekFwd( n ); + return *this; + } + //! addition assignment operator + _const_fwd_iterator& operator+=( difference_type n ) { + if ( n < 0 ) + _seekRev( -n ); + else + _seekFwd( n ); + return *this; + } + //! subtraction assignment operator + _const_fwd_iterator& operator-=( size_type n ) { + _seekRev( n ); + return *this; + } + //! subtraction assignment operator + _const_fwd_iterator& operator-=( difference_type n ) { + if ( n < 0 ) + _seekFwd( -n ); + else + _seekRev( n ); + return *this; + } + + //! dereference operator + const value_type& operator*() const { + return *mIter; + } + + //! dereference at offset operator + const value_type& operator[]( size_type n ) const { + _const_fwd_iterator tmp( *this ); + tmp += n; + return *tmp; + } + //! dereference at offset operator + const value_type& operator[]( difference_type n ) const { + _const_fwd_iterator tmp( *this ); + tmp += n; + return *tmp; + } + + //! advances to the next Unicode character, honoring surrogate pairs in the UTF-16 stream + _const_fwd_iterator& moveNext() { + _moveNext(); + return *this; + } + //! rewinds to the previous Unicode character, honoring surrogate pairs in the UTF-16 stream + _const_fwd_iterator& movePrev() { + _movePrev(); + return *this; + } + //! Returns the Unicode value of the character at the current position (decodes surrogate pairs if needed) + unicode_char getCharacter() const { + return _getCharacter(); + } + + //! difference operator + friend size_type operator-( const _const_fwd_iterator& left, const _const_fwd_iterator& right ); + //! equality operator + friend bool operator==( const _const_fwd_iterator& left, const _const_fwd_iterator& right ); + //! inequality operator + friend bool operator!=( const _const_fwd_iterator& left, const _const_fwd_iterator& right ); + //! less than + friend bool operator<( const _const_fwd_iterator& left, const _const_fwd_iterator& right ); + //! less than or equal + friend bool operator<=( const _const_fwd_iterator& left, const _const_fwd_iterator& right ); + //! greater than + friend bool operator>( const _const_fwd_iterator& left, const _const_fwd_iterator& right ); + //! greater than or equal + friend bool operator>=( const _const_fwd_iterator& left, const _const_fwd_iterator& right ); + + }; + + //######################################################################### + // REVERSE ITERATORS + //######################################################################### + class _const_rev_iterator; // forward declaration + //! forward iterator for UTFString + class _rev_iterator: public _base_iterator { /* i don't know why the beautifier is freaking out on this line */ + friend class _const_rev_iterator; + public: + _rev_iterator() {} + _rev_iterator( const _rev_iterator& i ) { + _become( i ); + } + + //! pre-increment + _rev_iterator& operator++() { + _seekRev( 1 ); + return *this; + } + //! post-increment + _rev_iterator operator++( int ) { + _rev_iterator tmp( *this ); + _seekRev( 1 ); + return tmp; + } + + //! pre-decrement + _rev_iterator& operator--() { + _seekFwd( 1 ); + return *this; + } + //! post-decrement + _rev_iterator operator--( int ) { + _rev_iterator tmp( *this ); + _seekFwd( 1 ); + return tmp; + } + + //! addition operator + _rev_iterator operator+( size_type n ) { + _rev_iterator tmp( *this ); + tmp._seekRev( n ); + return tmp; + } + //! addition operator + _rev_iterator operator+( difference_type n ) { + _rev_iterator tmp( *this ); + if ( n < 0 ) + tmp._seekFwd( -n ); + else + tmp._seekRev( n ); + return tmp; + } + //! subtraction operator + _rev_iterator operator-( size_type n ) { + _rev_iterator tmp( *this ); + tmp._seekFwd( n ); + return tmp; + } + //! subtraction operator + _rev_iterator operator-( difference_type n ) { + _rev_iterator tmp( *this ); + if ( n < 0 ) + tmp._seekRev( -n ); + else + tmp._seekFwd( n ); + return tmp; + } + + //! addition assignment operator + _rev_iterator& operator+=( size_type n ) { + _seekRev( n ); + return *this; + } + //! addition assignment operator + _rev_iterator& operator+=( difference_type n ) { + if ( n < 0 ) + _seekFwd( -n ); + else + _seekRev( n ); + return *this; + } + //! subtraction assignment operator + _rev_iterator& operator-=( size_type n ) { + _seekFwd( n ); + return *this; + } + //! subtraction assignment operator + _rev_iterator& operator-=( difference_type n ) { + if ( n < 0 ) + _seekRev( -n ); + else + _seekFwd( n ); + return *this; + } + + //! dereference operator + value_type& operator*() const { + return mIter[-1]; + } + + //! dereference at offset operator + value_type& operator[]( size_type n ) const { + _rev_iterator tmp( *this ); + tmp -= n; + return *tmp; + } + //! dereference at offset operator + value_type& operator[]( difference_type n ) const { + _rev_iterator tmp( *this ); + tmp -= n; + return *tmp; + } + }; + //######################################################################### + //! const reverse iterator for UTFString + class _const_rev_iterator: public _base_iterator { /* i don't know why the beautifier is freaking out on this line */ + public: + _const_rev_iterator() {} + _const_rev_iterator( const _const_rev_iterator& i ) { + _become( i ); + } + _const_rev_iterator( const _rev_iterator& i ) { + _become( i ); + } + //! pre-increment + _const_rev_iterator& operator++() { + _seekRev( 1 ); + return *this; + } + //! post-increment + _const_rev_iterator operator++( int ) { + _const_rev_iterator tmp( *this ); + _seekRev( 1 ); + return tmp; + } + + //! pre-decrement + _const_rev_iterator& operator--() { + _seekFwd( 1 ); + return *this; + } + //! post-decrement + _const_rev_iterator operator--( int ) { + _const_rev_iterator tmp( *this ); + _seekFwd( 1 ); + return tmp; + } + + //! addition operator + _const_rev_iterator operator+( size_type n ) { + _const_rev_iterator tmp( *this ); + tmp._seekRev( n ); + return tmp; + } + //! addition operator + _const_rev_iterator operator+( difference_type n ) { + _const_rev_iterator tmp( *this ); + if ( n < 0 ) + tmp._seekFwd( -n ); + else + tmp._seekRev( n ); + return tmp; + } + //! subtraction operator + _const_rev_iterator operator-( size_type n ) { + _const_rev_iterator tmp( *this ); + tmp._seekFwd( n ); + return tmp; + } + //! subtraction operator + _const_rev_iterator operator-( difference_type n ) { + _const_rev_iterator tmp( *this ); + if ( n < 0 ) + tmp._seekRev( -n ); + else + tmp._seekFwd( n ); + return tmp; + } + + //! addition assignment operator + _const_rev_iterator& operator+=( size_type n ) { + _seekRev( n ); + return *this; + } + //! addition assignment operator + _const_rev_iterator& operator+=( difference_type n ) { + if ( n < 0 ) + _seekFwd( -n ); + else + _seekRev( n ); + return *this; + } + //! subtraction assignment operator + _const_rev_iterator& operator-=( size_type n ) { + _seekFwd( n ); + return *this; + } + //! subtraction assignment operator + _const_rev_iterator& operator-=( difference_type n ) { + if ( n < 0 ) + _seekRev( -n ); + else + _seekFwd( n ); + return *this; + } + + //! dereference operator + const value_type& operator*() const { + return mIter[-1]; + } + + //! dereference at offset operator + const value_type& operator[]( size_type n ) const { + _const_rev_iterator tmp( *this ); + tmp -= n; + return *tmp; + } + //! dereference at offset operator + const value_type& operator[]( difference_type n ) const { + _const_rev_iterator tmp( *this ); + tmp -= n; + return *tmp; + } + + //! difference operator + friend size_type operator-( const _const_rev_iterator& left, const _const_rev_iterator& right ); + //! equality operator + friend bool operator==( const _const_rev_iterator& left, const _const_rev_iterator& right ); + //! inequality operator + friend bool operator!=( const _const_rev_iterator& left, const _const_rev_iterator& right ); + //! less than + friend bool operator<( const _const_rev_iterator& left, const _const_rev_iterator& right ); + //! less than or equal + friend bool operator<=( const _const_rev_iterator& left, const _const_rev_iterator& right ); + //! greater than + friend bool operator>( const _const_rev_iterator& left, const _const_rev_iterator& right ); + //! greater than or equal + friend bool operator>=( const _const_rev_iterator& left, const _const_rev_iterator& right ); + }; + //######################################################################### + + typedef _fwd_iterator iterator; //!< iterator + typedef _rev_iterator reverse_iterator; //!< reverse iterator + typedef _const_fwd_iterator const_iterator; //!< const iterator + typedef _const_rev_iterator const_reverse_iterator; //!< const reverse iterator + + + //!\name Constructors/Destructor + //@{ + //! default constructor, creates an empty string + UTFString() { + _init(); + } + //! copy constructor + UTFString( const UTFString& copy ) { + _init(); + mData = copy.mData; + } + //! \a length copies of \a ch + UTFString( size_type length, const code_point& ch ) { + _init(); + assign( length, ch ); + } + //! duplicate of nul-terminated sequence \a str + UTFString( const code_point* str ) { + _init(); + assign( str ); + } + //! duplicate of \a str, \a length code points long + UTFString( const code_point* str, size_type length ) { + _init(); + assign( str, length ); + } + //! substring of \a str starting at \a index and \a length code points long + UTFString( const UTFString& str, size_type index, size_type length ) { + _init(); + assign( str, index, length ); + } +#if OGRE_IS_NATIVE_WCHAR_T + //! duplicate of nul-terminated \c wchar_t array + UTFString( const wchar_t* w_str ) { + _init(); + assign( w_str ); + } + //! duplicate of \a w_str, \a length characters long + UTFString( const wchar_t* w_str, size_type length ) { + _init(); + assign( w_str, length ); + } +#endif + //! duplicate of \a wstr + UTFString( const std::wstring& wstr ) { + _init(); + assign( wstr ); + } + //! duplicate of nul-terminated C-string \a c_str (UTF-8 encoding) + UTFString( const char* c_str ) { + _init(); + assign( c_str ); + } + //! duplicate of \a c_str, \a length characters long (UTF-8 encoding) + UTFString( const char* c_str, size_type length ) { + _init(); + assign( c_str, length ); + } + //! duplicate of \a str (UTF-8 encoding) + UTFString( const std::string& str ) { + _init(); + assign( str ); + } + //! destructor + ~UTFString() { + _cleanBuffer(); + } + //@} + + ////////////////////////////////////////////////////////////////////////// + + //!\name Utility functions + //@{ + //! Returns the number of code points in the current string + size_type size() const { + return mData.size(); + } + //! Returns the number of code points in the current string + size_type length() const { + return size(); + } + //! Returns the number of Unicode characters in the string + /*! Executes in linear time. */ + size_type length_Characters() const { + const_iterator i = begin(), ie = end(); + size_type c = 0; + while ( i != ie ) { + i.moveNext(); + ++c; + } + return c; + } + //! returns the maximum number of UTF-16 code points that the string can hold + size_type max_size() const { + return mData.max_size(); + } + //! sets the capacity of the string to at least \a size code points + void reserve( size_type size ) { + mData.reserve( size ); + } + //! changes the size of the string to \a size, filling in any new area with \a val + void resize( size_type num, const code_point& val = 0 ) { + mData.resize( num, val ); + } + //! exchanges the elements of the current string with those of \a from + void swap( UTFString& from ) { + mData.swap( from.mData ); + } + //! returns \c true if the string has no elements, \c false otherwise + bool empty() const { + return mData.empty(); + } + //! returns a pointer to the first character in the current string + const code_point* c_str() const { + return mData.c_str(); + } + //! returns a pointer to the first character in the current string + const code_point* data() const { + return c_str(); + } + //! returns the number of elements that the string can hold before it will need to allocate more space + size_type capacity() const { + return mData.capacity(); + } + //! deletes all of the elements in the string + void clear() { + mData.clear(); + } + //! returns a substring of the current string, starting at \a index, and \a num characters long. + /*! If \a num is omitted, it will default to \c UTFString::npos, and the substr() function will simply return the remainder of the string starting at \a index. */ + UTFString substr( size_type index, size_type num = npos ) const { + // this could avoid the extra copy if we used a private specialty constructor + dstring data = mData.substr( index, num ); + UTFString tmp; + tmp.mData.swap( data ); + return tmp; + } + //! appends \a val to the end of the string + void push_back( unicode_char val ) { + code_point cp[2]; + size_t c = _utf32_to_utf16( val, cp ); + if ( c > 0 ) push_back( cp[0] ); + if ( c > 1 ) push_back( cp[1] ); + } +#if OGRE_IS_NATIVE_WCHAR_T + //! appends \a val to the end of the string + void push_back( wchar_t val ) { + // we do this because the Unicode method still preserves UTF-16 code points + mData.push_back( static_cast( val ) ); + } +#endif + //! appends \a val to the end of the string + /*! This can be used to push surrogate pair code points, you'll just need to push them + one after the other. */ + void push_back( code_point val ) { + mData.push_back( val ); + } + //! appends \a val to the end of the string + /*! Limited to characters under the 127 value barrier. */ + void push_back( char val ) { + mData.push_back( static_cast( val ) ); + } + //! returns \c true if the given Unicode character \a ch is in this string + bool inString( unicode_char ch ) const { + const_iterator i, ie = end(); + for ( i = begin(); i != ie; i.moveNext() ) { + if ( i.getCharacter() == ch ) + return true; + } + return false; + } + //@} + + ////////////////////////////////////////////////////////////////////////// + + //!\name Stream variations + //@{ + //! returns the current string in UTF-8 form within a std::string + const std::string& asUTF8() const { + _load_buffer_UTF8(); + return *m_buffer.mStrBuffer; + } + //! returns the current string in UTF-8 form as a nul-terminated char array + const char* asUTF8_c_str() const { + _load_buffer_UTF8(); + return m_buffer.mStrBuffer->c_str(); + } + //! returns the current string in UTF-32 form within a utf32string + const utf32string& asUTF32() const { + _load_buffer_UTF32(); + return *m_buffer.mUTF32StrBuffer; + } + //! returns the current string in UTF-32 form as a nul-terminated unicode_char array + const unicode_char* asUTF32_c_str() const { + _load_buffer_UTF32(); + return m_buffer.mUTF32StrBuffer->c_str(); + } + //! returns the current string in the native form of std::wstring + const std::wstring& asWStr() const { + _load_buffer_WStr(); + return *m_buffer.mWStrBuffer; + } + //! returns the current string in the native form of a nul-terminated wchar_t array + const wchar_t* asWStr_c_str() const { + _load_buffer_WStr(); + return m_buffer.mWStrBuffer->c_str(); + } + //@} + + ////////////////////////////////////////////////////////////////////////// + + //!\name Single Character Access + //@{ + //! returns a reference to the element in the string at index \c loc + code_point& at( size_type loc ) { + return mData.at( loc ); + } + //! returns a reference to the element in the string at index \c loc + const code_point& at( size_type loc ) const { + return mData.at( loc ); + } + //! returns the data point \a loc evaluated as a UTF-32 value + /*! This function will will only properly decode surrogate pairs when \a loc points to the index + of a lead code point that is followed by a trailing code point. Evaluating the trailing code point + itself, or pointing to a code point that is a sentinel value (part of a broken pair) will return + the value of just that code point (not a valid Unicode value, but useful as a sentinel value). */ + unicode_char getChar( size_type loc ) const { + const code_point* ptr = c_str(); + unicode_char uc; + size_t l = _utf16_char_length( ptr[loc] ); + code_point cp[2] = { /* blame the code beautifier */ + 0, 0 + }; + cp[0] = ptr[loc]; + + if ( l == 2 && ( loc + 1 ) < mData.length() ) { + cp[1] = ptr[loc+1]; + } + _utf16_to_utf32( cp, uc ); + return uc; + } + //! sets the value of the character at \a loc to the Unicode value \a ch (UTF-32) + /*! Providing sentinel values (values between U+D800-U+DFFF) are accepted, but you should be aware + that you can also unwittingly create a valid surrogate pair if you don't pay attention to what you + are doing. \note This operation may also lengthen the string if a surrogate pair is needed to + represent the value given, but one is not available to replace; or alternatively shorten the string + if an existing surrogate pair is replaced with a character that is representable without a surrogate + pair. The return value will signify any lengthening or shortening performed, returning 0 if no change + was made, -1 if the string was shortened, or 1 if the string was lengthened. Any single call can + only change the string length by + or - 1. */ + int setChar( size_type loc, unicode_char ch ) { + code_point cp[2] = { /* blame the code beautifier */ + 0, 0 + }; + size_t l = _utf32_to_utf16( ch, cp ); + unicode_char existingChar = getChar( loc ); + size_t existingSize = _utf16_char_length( existingChar ); + size_t newSize = _utf16_char_length( ch ); + + if ( newSize > existingSize ) { + at( loc ) = cp[0]; + insert( loc + 1, 1, cp[1] ); + return 1; + } + if ( newSize < existingSize ) { + erase( loc, 1 ); + at( loc ) = cp[0]; + return -1; + } + + // newSize == existingSize + at( loc ) = cp[0]; + if ( l == 2 ) at( loc + 1 ) = cp[1]; + return 0; + } + //@} + + ////////////////////////////////////////////////////////////////////////// + + //!\name iterator acquisition + //@{ + //! returns an iterator to the first element of the string + iterator begin() { + iterator i; + i.mIter = mData.begin(); + i.mString = this; + return i; + } + //! returns an iterator to the first element of the string + const_iterator begin() const { + const_iterator i; + i.mIter = const_cast( this )->mData.begin(); + i.mString = const_cast( this ); + return i; + } + //! returns an iterator just past the end of the string + iterator end() { + iterator i; + i.mIter = mData.end(); + i.mString = this; + return i; + } + //! returns an iterator just past the end of the string + const_iterator end() const { + const_iterator i; + i.mIter = const_cast( this )->mData.end(); + i.mString = const_cast( this ); + return i; + } + //! returns a reverse iterator to the last element of the string + reverse_iterator rbegin() { + reverse_iterator i; + i.mIter = mData.end(); + i.mString = this; + return i; + } + //! returns a reverse iterator to the last element of the string + const_reverse_iterator rbegin() const { + const_reverse_iterator i; + i.mIter = const_cast( this )->mData.end(); + i.mString = const_cast( this ); + return i; + } + //! returns a reverse iterator just past the beginning of the string + reverse_iterator rend() { + reverse_iterator i; + i.mIter = mData.begin(); + i.mString = this; + return i; + } + //! returns a reverse iterator just past the beginning of the string + const_reverse_iterator rend() const { + const_reverse_iterator i; + i.mIter = const_cast( this )->mData.begin(); + i.mString = const_cast( this ); + return i; + } + //@} + + ////////////////////////////////////////////////////////////////////////// + + //!\name assign + //@{ + //! gives the current string the values from \a start to \a end + UTFString& assign( iterator start, iterator end ) { + mData.assign( start.mIter, end.mIter ); + return *this; + } + //! assign \a str to the current string + UTFString& assign( const UTFString& str ) { + mData.assign( str.mData ); + return *this; + } + //! assign the nul-terminated \a str to the current string + UTFString& assign( const code_point* str ) { + mData.assign( str ); + return *this; + } + //! assign the first \a num characters of \a str to the current string + UTFString& assign( const code_point* str, size_type num ) { + mData.assign( str, num ); + return *this; + } + //! assign \a len entries from \a str to the current string, starting at \a index + UTFString& assign( const UTFString& str, size_type index, size_type len ) { + mData.assign( str.mData, index, len ); + return *this; + } + //! assign \a num copies of \a ch to the current string + UTFString& assign( size_type num, const code_point& ch ) { + mData.assign( num, ch ); + return *this; + } + //! assign \a wstr to the current string (\a wstr is treated as a UTF-16 stream) + UTFString& assign( const std::wstring& wstr ) { + mData.clear(); + mData.reserve( wstr.length() ); // best guess bulk allocate +#ifdef WCHAR_UTF16 // if we're already working in UTF-16, this is easy + code_point tmp; + std::wstring::const_iterator i, ie = wstr.end(); + for ( i = wstr.begin(); i != ie; i++ ) { + tmp = static_cast( *i ); + mData.push_back( tmp ); + } +#else // otherwise we do it the safe way (which is still 100% safe to pass UTF-16 through, just slower) + code_point cp[3] = {0, 0, 0}; + unicode_char tmp; + std::wstring::const_iterator i, ie = wstr.end(); + for ( i = wstr.begin(); i != ie; i++ ) { + tmp = static_cast( *i ); + size_t l = _utf32_to_utf16( tmp, cp ); + if ( l > 0 ) mData.push_back( cp[0] ); + if ( l > 1 ) mData.push_back( cp[1] ); + } +#endif + return *this; + } +#if OGRE_IS_NATIVE_WCHAR_T + //! assign \a w_str to the current string + UTFString& assign( const wchar_t* w_str ) { + std::wstring tmp; + tmp.assign( w_str ); + return assign( tmp ); + } + //! assign the first \a num characters of \a w_str to the current string + UTFString& assign( const wchar_t* w_str, size_type num ) { + std::wstring tmp; + tmp.assign( w_str, num ); + return assign( tmp ); + } +#endif + //! assign \a str to the current string (\a str is treated as a UTF-8 stream) + UTFString& assign( const std::string& str ) { + size_type len = _verifyUTF8( str ); + clear(); // empty our contents, if there are any + reserve( len ); // best guess bulk capacity growth + + // This is a 3 step process, converting each byte in the UTF-8 stream to UTF-32, + // then converting it to UTF-16, then finally appending the data buffer + + unicode_char uc; // temporary Unicode character buffer + unsigned char utf8buf[7]; // temporary UTF-8 buffer + utf8buf[6] = 0; + size_t utf8len; // UTF-8 length + code_point utf16buff[3]; // temporary UTF-16 buffer + utf16buff[2] = 0; + size_t utf16len; // UTF-16 length + + std::string::const_iterator i, ie = str.end(); + for ( i = str.begin(); i != ie; i++ ) { + utf8len = _utf8_char_length( static_cast( *i ) ); // estimate bytes to load + for ( size_t j = 0; j < utf8len; j++ ) { // load the needed UTF-8 bytes + utf8buf[j] = ( static_cast( *( i + j ) ) ); // we don't increment 'i' here just in case the estimate is wrong (shouldn't happen, but we're being careful) + } + utf8buf[utf8len] = 0; // nul terminate so we throw an exception before running off the end of the buffer + utf8len = _utf8_to_utf32( utf8buf, uc ); // do the UTF-8 -> UTF-32 conversion + i += utf8len - 1; // we subtract 1 for the increment of the 'for' loop + + utf16len = _utf32_to_utf16( uc, utf16buff ); // UTF-32 -> UTF-16 conversion + append( utf16buff, utf16len ); // append the characters to the string + } + return *this; + } + //! assign \a c_str to the current string (\a c_str is treated as a UTF-8 stream) + UTFString& assign( const char* c_str ) { + std::string tmp( c_str ); + return assign( tmp ); + } + //! assign the first \a num characters of \a c_str to the current string (\a c_str is treated as a UTF-8 stream) + UTFString& assign( const char* c_str, size_type num ) { + std::string tmp; + tmp.assign( c_str, num ); + return assign( tmp ); + } + //@} + + ////////////////////////////////////////////////////////////////////////// + + //!\name append + //@{ + //! appends \a str on to the end of the current string + UTFString& append( const UTFString& str ) { + mData.append( str.mData ); + return *this; + } + //! appends \a str on to the end of the current string + UTFString& append( const code_point* str ) { + mData.append( str ); + return *this; + } + //! appends a substring of \a str starting at \a index that is \a len characters long on to the end of the current string + UTFString& append( const UTFString& str, size_type index, size_type len ) { + mData.append( str.mData, index, len ); + return *this; + } + //! appends \a num characters of \a str on to the end of the current string + UTFString& append( const code_point* str, size_type num ) { + mData.append( str, num ); + return *this; + } + //! appends \a num repetitions of \a ch on to the end of the current string + UTFString& append( size_type num, code_point ch ) { + mData.append( num, ch ); + return *this; + } + //! appends the sequence denoted by \a start and \a end on to the end of the current string + UTFString& append( iterator start, iterator end ) { + mData.append( start.mIter, end.mIter ); + return *this; + } +#if OGRE_IS_NATIVE_WCHAR_T + //! appends \a num characters of \a str on to the end of the current string + UTFString& append( const wchar_t* w_str, size_type num ) { + std::wstring tmp( w_str, num ); + return append( tmp ); + } + //! appends \a num repetitions of \a ch on to the end of the current string + UTFString& append( size_type num, wchar_t ch ) { + return append( num, static_cast( ch ) ); + } +#endif + //! appends \a num characters of \a str on to the end of the current string (UTF-8 encoding) + UTFString& append( const char* c_str, size_type num ) { + UTFString tmp( c_str, num ); + append( tmp ); + return *this; + } + //! appends \a num repetitions of \a ch on to the end of the current string (Unicode values less than 128) + UTFString& append( size_type num, char ch ) { + append( num, static_cast( ch ) ); + return *this; + } + //! appends \a num repetitions of \a ch on to the end of the current string (Full Unicode spectrum) + UTFString& append( size_type num, unicode_char ch ) { + code_point cp[2] = {0, 0}; + if ( _utf32_to_utf16( ch, cp ) == 2 ) { + for ( size_type i = 0; i < num; i++ ) { + append( 1, cp[0] ); + append( 1, cp[1] ); + } + } else { + for ( size_type i = 0; i < num; i++ ) { + append( 1, cp[0] ); + } + } + return *this; + } + //@} + + ////////////////////////////////////////////////////////////////////////// + + //!\name insert + //@{ + //! inserts \a ch before the code point denoted by \a i + iterator insert( iterator i, const code_point& ch ) { + iterator ret; + ret.mIter = mData.insert( i.mIter, ch ); + ret.mString = this; + return ret; + } + //! inserts \a str into the current string, at location \a index + UTFString& insert( size_type index, const UTFString& str ) { + mData.insert( index, str.mData ); + return *this; + } + //! inserts \a str into the current string, at location \a index + UTFString& insert( size_type index, const code_point* str ) { + mData.insert( index, str ); + return *this; + } + //! inserts a substring of \a str (starting at \a index2 and \a num code points long) into the current string, at location \a index1 + UTFString& insert( size_type index1, const UTFString& str, size_type index2, size_type num ) { + mData.insert( index1, str.mData, index2, num ); + return *this; + } + //! inserts the code points denoted by \a start and \a end into the current string, before the code point specified by \a i + void insert( iterator i, iterator start, iterator end ) { + mData.insert( i.mIter, start.mIter, end.mIter ); + } + //! inserts \a num code points of \a str into the current string, at location \a index + UTFString& insert( size_type index, const code_point* str, size_type num ) { + mData.insert( index, str, num ); + return *this; + } +#if OGRE_IS_NATIVE_WCHAR_T + //! inserts \a num code points of \a str into the current string, at location \a index + UTFString& insert( size_type index, const wchar_t* w_str, size_type num ) { + UTFString tmp( w_str, num ); + insert( index, tmp ); + return *this; + } +#endif + //! inserts \a num code points of \a str into the current string, at location \a index + UTFString& insert( size_type index, const char* c_str, size_type num ) { + UTFString tmp( c_str, num ); + insert( index, tmp ); + return *this; + } + //! inserts \a num copies of \a ch into the current string, at location \a index + UTFString& insert( size_type index, size_type num, code_point ch ) { + mData.insert( index, num, ch ); + return *this; + } +#if OGRE_IS_NATIVE_WCHAR_T + //! inserts \a num copies of \a ch into the current string, at location \a index + UTFString& insert( size_type index, size_type num, wchar_t ch ) { + insert( index, num, static_cast( ch ) ); + return *this; + } +#endif + //! inserts \a num copies of \a ch into the current string, at location \a index + UTFString& insert( size_type index, size_type num, char ch ) { + insert( index, num, static_cast( ch ) ); + return *this; + } + //! inserts \a num copies of \a ch into the current string, at location \a index + UTFString& insert( size_type index, size_type num, unicode_char ch ) { + code_point cp[3] = {0, 0, 0}; + size_t l = _utf32_to_utf16( ch, cp ); + if ( l == 1 ) { + return insert( index, num, cp[0] ); + } + for ( size_type c = 0; c < num; c++ ) { + // insert in reverse order to preserve ordering after insert + insert( index, 1, cp[1] ); + insert( index, 1, cp[0] ); + } + return *this; + } + //! inserts \a num copies of \a ch into the current string, before the code point denoted by \a i + void insert( iterator i, size_type num, const code_point& ch ) { + mData.insert( i.mIter, num, ch ); + } +#if OGRE_IS_NATIVE_WCHAR_T + //! inserts \a num copies of \a ch into the current string, before the code point denoted by \a i + void insert( iterator i, size_type num, const wchar_t& ch ) { + insert( i, num, static_cast( ch ) ); + } +#endif + //! inserts \a num copies of \a ch into the current string, before the code point denoted by \a i + void insert( iterator i, size_type num, const char& ch ) { + insert( i, num, static_cast( ch ) ); + } + //! inserts \a num copies of \a ch into the current string, before the code point denoted by \a i + void insert( iterator i, size_type num, const unicode_char& ch ) { + code_point cp[3] = {0, 0, 0}; + size_t l = _utf32_to_utf16( ch, cp ); + if ( l == 1 ) { + insert( i, num, cp[0] ); + } else { + for ( size_type c = 0; c < num; c++ ) { + // insert in reverse order to preserve ordering after insert + insert( i, 1, cp[1] ); + insert( i, 1, cp[0] ); + } + } + } + //@} + + ////////////////////////////////////////////////////////////////////////// + + //!\name erase + //@{ + //! removes the code point pointed to by \a loc, returning an iterator to the next character + iterator erase( iterator loc ) { + iterator ret; + ret.mIter = mData.erase( loc.mIter ); + ret.mString = this; + return ret; + } + //! removes the code points between \a start and \a end (including the one at \a start but not the one at \a end), returning an iterator to the code point after the last code point removed + iterator erase( iterator start, iterator end ) { + iterator ret; + ret.mIter = mData.erase( start.mIter, end.mIter ); + ret.mString = this; + return ret; + } + //! removes \a num code points from the current string, starting at \a index + UTFString& erase( size_type index = 0, size_type num = npos ) { + if ( num == npos ) + mData.erase( index ); + else + mData.erase( index, num ); + return *this; + } + //@} + + ////////////////////////////////////////////////////////////////////////// + + //!\name replace + //@{ + //! replaces up to \a num1 code points of the current string (starting at \a index1) with \a str + UTFString& replace( size_type index1, size_type num1, const UTFString& str ) { + mData.replace( index1, num1, str.mData, 0, npos ); + return *this; + } + //! replaces up to \a num1 code points of the current string (starting at \a index1) with up to \a num2 code points from \a str + UTFString& replace( size_type index1, size_type num1, const UTFString& str, size_type num2 ) { + mData.replace( index1, num1, str.mData, 0, num2 ); + return *this; + } + //! replaces up to \a num1 code points of the current string (starting at \a index1) with up to \a num2 code points from \a str beginning at \a index2 + UTFString& replace( size_type index1, size_type num1, const UTFString& str, size_type index2, size_type num2 ) { + mData.replace( index1, num1, str.mData, index2, num2 ); + return *this; + } + //! replaces code points in the current string from \a start to \a end with \a num code points from \a str + UTFString& replace( iterator start, iterator end, const UTFString& str, size_type num = npos ) { + _const_fwd_iterator st(start); //Work around for gcc, allow it to find correct overload + + size_type index1 = begin() - st; + size_type num1 = end - st; + return replace( index1, num1, str, 0, num ); + } + //! replaces up to \a num1 code points in the current string (beginning at \a index) with \c num2 copies of \c ch + UTFString& replace( size_type index, size_type num1, size_type num2, code_point ch ) { + mData.replace( index, num1, num2, ch ); + return *this; + } + //! replaces the code points in the current string from \a start to \a end with \a num copies of \a ch + UTFString& replace( iterator start, iterator end, size_type num, code_point ch ) { + _const_fwd_iterator st(start); //Work around for gcc, allow it to find correct overload + + size_type index1 = begin() - st; + size_type num1 = end - st; + return replace( index1, num1, num, ch ); + } + //@} + + ////////////////////////////////////////////////////////////////////////// + + //!\name compare + //@{ + //! compare \a str to the current string + int compare( const UTFString& str ) const { + return mData.compare( str.mData ); + } + //! compare \a str to the current string + int compare( const code_point* str ) const { + return mData.compare( str ); + } + //! compare \a str to a substring of the current string, starting at \a index for \a length characters + int compare( size_type index, size_type length, const UTFString& str ) const { + return mData.compare( index, length, str.mData ); + } + //! compare a substring of \a str to a substring of the current string, where \a index2 and \a length2 refer to \a str and \a index and \a length refer to the current string + int compare( size_type index, size_type length, const UTFString& str, size_type index2, size_type length2 ) const { + return mData.compare( index, length, str.mData, index2, length2 ); + } + //! compare a substring of \a str to a substring of the current string, where the substring of \a str begins at zero and is \a length2 characters long, and the substring of the current string begins at \a index and is \a length characters long + int compare( size_type index, size_type length, const code_point* str, size_type length2 ) const { + return mData.compare( index, length, str, length2 ); + } +#if OGRE_IS_NATIVE_WCHAR_T + //! compare a substring of \a str to a substring of the current string, where the substring of \a str begins at zero and is \a length2 elements long, and the substring of the current string begins at \a index and is \a length characters long + int compare( size_type index, size_type length, const wchar_t* w_str, size_type length2 ) const { + UTFString tmp( w_str, length2 ); + return compare( index, length, tmp ); + } +#endif + //! compare a substring of \a str to a substring of the current string, where the substring of \a str begins at zero and is \a length2 UTF-8 code points long, and the substring of the current string begins at \a index and is \a length characters long + int compare( size_type index, size_type length, const char* c_str, size_type length2 ) const { + UTFString tmp( c_str, length2 ); + return compare( index, length, tmp ); + } + //@} + + ////////////////////////////////////////////////////////////////////////// + + //!\name find & rfind + //@{ + //! returns the index of the first occurrence of \a str within the current string, starting at \a index; returns \c UTFString::npos if nothing is found + /*! \a str is a UTF-16 encoded string, but through implicit casting can also be a UTF-8 encoded string (const char* or std::string) */ + size_type find( const UTFString& str, size_type index = 0 ) const { + return mData.find( str.c_str(), index ); + } + //! returns the index of the first occurrence of \a str within the current string and within \a length code points, starting at \a index; returns \c UTFString::npos if nothing is found + /*! \a cp_str is a UTF-16 encoded string */ + size_type find( const code_point* cp_str, size_type index, size_type length ) const { + UTFString tmp( cp_str ); + return mData.find( tmp.c_str(), index, length ); + } + //! returns the index of the first occurrence of \a str within the current string and within \a length code points, starting at \a index; returns \c UTFString::npos if nothing is found + /*! \a cp_str is a UTF-8 encoded string */ + size_type find( const char* c_str, size_type index, size_type length ) const { + UTFString tmp( c_str ); + return mData.find( tmp.c_str(), index, length ); + } +#if OGRE_IS_NATIVE_WCHAR_T + //! returns the index of the first occurrence of \a str within the current string and within \a length code points, starting at \a index; returns \c UTFString::npos if nothing is found + /*! \a cp_str is a UTF-16 encoded string */ + size_type find( const wchar_t* w_str, size_type index, size_type length ) const { + UTFString tmp( w_str ); + return mData.find( tmp.c_str(), index, length ); + } +#endif + //! returns the index of the first occurrence \a ch within the current string, starting at \a index; returns \c UTFString::npos if nothing is found + /*! \a ch is only capable of representing Unicode values up to U+007F (127) */ + size_type find( char ch, size_type index = 0 ) const { + return find( static_cast( ch ), index ); + } + //! returns the index of the first occurrence \a ch within the current string, starting at \a index; returns \c UTFString::npos if nothing is found + /*! \a ch is only capable of representing Unicode values up to U+FFFF (65535) */ + size_type find( code_point ch, size_type index = 0 ) const { + return mData.find( ch, index ); + } +#if OGRE_IS_NATIVE_WCHAR_T + //! returns the index of the first occurrence \a ch within the current string, starting at \a index; returns \c UTFString::npos if nothing is found + /*! \a ch is only capable of representing Unicode values up to U+FFFF (65535) */ + size_type find( wchar_t ch, size_type index = 0 ) const { + return find( static_cast( ch ), index ); + } +#endif + //! returns the index of the first occurrence \a ch within the current string, starting at \a index; returns \c UTFString::npos if nothing is found + /*! \a ch can fully represent any Unicode character */ + size_type find( unicode_char ch, size_type index = 0 ) const { + code_point cp[3] = {0, 0, 0}; + size_t l = _utf32_to_utf16( ch, cp ); + return find( UTFString( cp, l ), index ); + } + + //! returns the location of the first occurrence of \a str in the current string, doing a reverse search from \a index; returns \c UTFString::npos if nothing is found + size_type rfind( const UTFString& str, size_type index = 0 ) const { + return mData.rfind( str.c_str(), index ); + } + //! returns the location of the first occurrence of \a str in the current string, doing a reverse search from \a index, searching at most \a num characters; returns \c UTFString::npos if nothing is found + size_type rfind( const code_point* cp_str, size_type index, size_type num ) const { + UTFString tmp( cp_str ); + return mData.rfind( tmp.c_str(), index, num ); + } + //! returns the location of the first occurrence of \a str in the current string, doing a reverse search from \a index, searching at most \a num characters; returns \c UTFString::npos if nothing is found + size_type rfind( const char* c_str, size_type index, size_type num ) const { + UTFString tmp( c_str ); + return mData.rfind( tmp.c_str(), index, num ); + } +#if OGRE_IS_NATIVE_WCHAR_T + //! returns the location of the first occurrence of \a str in the current string, doing a reverse search from \a index, searching at most \a num characters; returns \c UTFString::npos if nothing is found + size_type rfind( const wchar_t* w_str, size_type index, size_type num ) const { + UTFString tmp( w_str ); + return mData.rfind( tmp.c_str(), index, num ); + } +#endif + //! returns the location of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UTFString::npos if nothing is found + size_type rfind( char ch, size_type index = 0 ) const { + return rfind( static_cast( ch ), index ); + } + //! returns the location of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UTFString::npos if nothing is found + size_type rfind( code_point ch, size_type index ) const { + return mData.rfind( ch, index ); + } +#if OGRE_IS_NATIVE_WCHAR_T + //! returns the location of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UTFString::npos if nothing is found + size_type rfind( wchar_t ch, size_type index = 0 ) const { + return rfind( static_cast( ch ), index ); + } +#endif + //! returns the location of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UTFString::npos if nothing is found + size_type rfind( unicode_char ch, size_type index = 0 ) const { + code_point cp[3] = {0, 0, 0}; + size_t l = _utf32_to_utf16( ch, cp ); + return rfind( UTFString( cp, l ), index ); + } + //@} + + ////////////////////////////////////////////////////////////////////////// + + //!\name find_first/last_(not)_of + //@{ + //! Returns the index of the first character within the current string that matches \b any character in \a str, beginning the search at \a index and searching at most \a num characters; returns \c UTFString::npos if nothing is found + size_type find_first_of( const UTFString &str, size_type index = 0, size_type num = npos ) const { + size_type i = 0; + const size_type len = length(); + while ( i < num && ( index + i ) < len ) { + unicode_char ch = getChar( index + i ); + if ( str.inString( ch ) ) + return index + i; + i += _utf16_char_length( ch ); // increment by the Unicode character length + } + return npos; + } + //! returns the index of the first occurrence of \a ch in the current string, starting the search at \a index; returns \c UTFString::npos if nothing is found + size_type find_first_of( code_point ch, size_type index = 0 ) const { + UTFString tmp; + tmp.assign( 1, ch ); + return find_first_of( tmp, index ); + } + //! returns the index of the first occurrence of \a ch in the current string, starting the search at \a index; returns \c UTFString::npos if nothing is found + size_type find_first_of( char ch, size_type index = 0 ) const { + return find_first_of( static_cast( ch ), index ); + } +#if OGRE_IS_NATIVE_WCHAR_T + //! returns the index of the first occurrence of \a ch in the current string, starting the search at \a index; returns \c UTFString::npos if nothing is found + size_type find_first_of( wchar_t ch, size_type index = 0 ) const { + return find_first_of( static_cast( ch ), index ); + } +#endif + //! returns the index of the first occurrence of \a ch in the current string, starting the search at \a index; returns \c UTFString::npos if nothing is found + size_type find_first_of( unicode_char ch, size_type index = 0 ) const { + code_point cp[3] = {0, 0, 0}; + size_t l = _utf32_to_utf16( ch, cp ); + return find_first_of( UTFString( cp, l ), index ); + } + + //! returns the index of the first character within the current string that does not match any character in \a str, beginning the search at \a index and searching at most \a num characters; returns \c UTFString::npos if nothing is found + size_type find_first_not_of( const UTFString& str, size_type index = 0, size_type num = npos ) const { + size_type i = 0; + const size_type len = length(); + while ( i < num && ( index + i ) < len ) { + unicode_char ch = getChar( index + i ); + if ( !str.inString( ch ) ) + return index + i; + i += _utf16_char_length( ch ); // increment by the Unicode character length + } + return npos; + } + //! returns the index of the first character within the current string that does not match \a ch, starting the search at \a index; returns \c UTFString::npos if nothing is found + size_type find_first_not_of( code_point ch, size_type index = 0 ) const { + UTFString tmp; + tmp.assign( 1, ch ); + return find_first_not_of( tmp, index ); + } + //! returns the index of the first character within the current string that does not match \a ch, starting the search at \a index; returns \c UTFString::npos if nothing is found + size_type find_first_not_of( char ch, size_type index = 0 ) const { + return find_first_not_of( static_cast( ch ), index ); + } +#if OGRE_IS_NATIVE_WCHAR_T + //! returns the index of the first character within the current string that does not match \a ch, starting the search at \a index; returns \c UTFString::npos if nothing is found + size_type find_first_not_of( wchar_t ch, size_type index = 0 ) const { + return find_first_not_of( static_cast( ch ), index ); + } +#endif + //! returns the index of the first character within the current string that does not match \a ch, starting the search at \a index; returns \c UTFString::npos if nothing is found + size_type find_first_not_of( unicode_char ch, size_type index = 0 ) const { + code_point cp[3] = {0, 0, 0}; + size_t l = _utf32_to_utf16( ch, cp ); + return find_first_not_of( UTFString( cp, l ), index ); + } + + //! returns the index of the first character within the current string that matches any character in \a str, doing a reverse search from \a index and searching at most \a num characters; returns \c UTFString::npos if nothing is found + size_type find_last_of( const UTFString& str, size_type index = npos, size_type num = npos ) const { + size_type i = 0; + const size_type len = length(); + if ( index > len ) index = len - 1; + + while ( i < num && ( index - i ) != npos ) { + size_type j = index - i; + // careful to step full Unicode characters + if ( j != 0 && _utf16_surrogate_follow( at( j ) ) && _utf16_surrogate_lead( at( j - 1 ) ) ) { + j = index - ++i; + } + // and back to the usual dull test + unicode_char ch = getChar( j ); + if ( str.inString( ch ) ) + return j; + i++; + } + return npos; + } + //! returns the index of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UTFString::npos if nothing is found + size_type find_last_of( code_point ch, size_type index = npos ) const { + UTFString tmp; + tmp.assign( 1, ch ); + return find_last_of( tmp, index ); + } + //! returns the index of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UTFString::npos if nothing is found + size_type find_last_of( char ch, size_type index = npos ) const { + return find_last_of( static_cast( ch ), index ); + } +#if OGRE_IS_NATIVE_WCHAR_T + //! returns the index of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UTFString::npos if nothing is found + size_type find_last_of( wchar_t ch, size_type index = npos ) const { + return find_last_of( static_cast( ch ), index ); + } +#endif + //! returns the index of the first occurrence of \a ch in the current string, doing a reverse search from \a index; returns \c UTFString::npos if nothing is found + size_type find_last_of( unicode_char ch, size_type index = npos ) const { + code_point cp[3] = {0, 0, 0}; + size_t l = _utf32_to_utf16( ch, cp ); + return find_last_of( UTFString( cp, l ), index ); + } + + //! returns the index of the last character within the current string that does not match any character in \a str, doing a reverse search from \a index; returns \c UTFString::npos if nothing is found + size_type find_last_not_of( const UTFString& str, size_type index = npos, size_type num = npos ) const { + size_type i = 0; + const size_type len = length(); + if ( index > len ) index = len - 1; + + while ( i < num && ( index - i ) != npos ) { + size_type j = index - i; + // careful to step full Unicode characters + if ( j != 0 && _utf16_surrogate_follow( at( j ) ) && _utf16_surrogate_lead( at( j - 1 ) ) ) { + j = index - ++i; + } + // and back to the usual dull test + unicode_char ch = getChar( j ); + if ( !str.inString( ch ) ) + return j; + i++; + } + return npos; + } + //! returns the index of the last occurrence of a character that does not match \a ch in the current string, doing a reverse search from \a index; returns \c UTFString::npos if nothing is found + size_type find_last_not_of( code_point ch, size_type index = npos ) const { + UTFString tmp; + tmp.assign( 1, ch ); + return find_last_not_of( tmp, index ); + } + //! returns the index of the last occurrence of a character that does not match \a ch in the current string, doing a reverse search from \a index; returns \c UTFString::npos if nothing is found + size_type find_last_not_of( char ch, size_type index = npos ) const { + return find_last_not_of( static_cast( ch ), index ); + } +#if OGRE_IS_NATIVE_WCHAR_T + //! returns the index of the last occurrence of a character that does not match \a ch in the current string, doing a reverse search from \a index; returns \c UTFString::npos if nothing is found + size_type find_last_not_of( wchar_t ch, size_type index = npos ) const { + return find_last_not_of( static_cast( ch ), index ); + } +#endif + //! returns the index of the last occurrence of a character that does not match \a ch in the current string, doing a reverse search from \a index; returns \c UTFString::npos if nothing is found + size_type find_last_not_of( unicode_char ch, size_type index = npos ) const { + code_point cp[3] = {0, 0, 0}; + size_t l = _utf32_to_utf16( ch, cp ); + return find_last_not_of( UTFString( cp, l ), index ); + } + //@} + + ////////////////////////////////////////////////////////////////////////// + + //!\name Operators + //@{ + //! less than operator + bool operator<( const UTFString& right ) const { + return compare( right ) < 0; + } + //! less than or equal operator + bool operator<=( const UTFString& right ) const { + return compare( right ) <= 0; + } + //! greater than operator + bool operator>( const UTFString& right ) const { + return compare( right ) > 0; + } + //! greater than or equal operator + bool operator>=( const UTFString& right ) const { + return compare( right ) >= 0; + } + //! equality operator + bool operator==( const UTFString& right ) const { + return compare( right ) == 0; + } + //! inequality operator + bool operator!=( const UTFString& right ) const { + return !operator==( right ); + } + //! assignment operator, implicitly casts all compatible types + UTFString& operator=( const UTFString& s ) { + return assign( s ); + } + //! assignment operator + UTFString& operator=( code_point ch ) { + clear(); + return append( 1, ch ); + } + //! assignment operator + UTFString& operator=( char ch ) { + clear(); + return append( 1, ch ); + } +#if OGRE_IS_NATIVE_WCHAR_T + //! assignment operator + UTFString& operator=( wchar_t ch ) { + clear(); + return append( 1, ch ); + } +#endif + //! assignment operator + UTFString& operator=( unicode_char ch ) { + clear(); + return append( 1, ch ); + } + //! code point dereference operator + code_point& operator[]( size_type index ) { + return at( index ); + } + //! code point dereference operator + const code_point& operator[]( size_type index ) const { + return at( index ); + } + //@} + + ////////////////////////////////////////////////////////////////////////// + + //!\name Implicit Cast Operators + //@{ + //! implicit cast to std::string + operator std::string() const { + return std::string( asUTF8() ); + } + //! implicit cast to std::wstring + operator std::wstring() const { + return std::wstring( asWStr() ); + } + //@} + + ////////////////////////////////////////////////////////////////////////// + + //!\name UTF-16 character encoding/decoding + //@{ + //! returns \c true if \a cp does not match the signature for the lead of follow code point of a surrogate pair in a UTF-16 sequence + static bool _utf16_independent_char( code_point cp ) { + if ( 0xD800 <= cp && cp <= 0xDFFF ) // tests if the cp is within the surrogate pair range + return false; // it matches a surrogate pair signature + return true; // everything else is a standalone code point + } + //! returns \c true if \a cp matches the signature of a surrogate pair lead character + static bool _utf16_surrogate_lead( code_point cp ) { + if ( 0xD800 <= cp && cp <= 0xDBFF ) // tests if the cp is within the 2nd word of a surrogate pair + return true; // it is a 1st word + return false; // it isn't + } + //! returns \c true if \a cp matches the signature of a surrogate pair following character + static bool _utf16_surrogate_follow( code_point cp ) { + if ( 0xDC00 <= cp && cp <= 0xDFFF ) // tests if the cp is within the 2nd word of a surrogate pair + return true; // it is a 2nd word + return false; // everything else isn't + } + //! estimates the number of UTF-16 code points in the sequence starting with \a cp + static size_t _utf16_char_length( code_point cp ) { + if ( 0xD800 <= cp && cp <= 0xDBFF ) // test if cp is the beginning of a surrogate pair + return 2; // if it is, then we are 2 words long + return 1; // otherwise we are only 1 word long + } + //! returns the number of UTF-16 code points needed to represent the given UTF-32 character \a cp + static size_t _utf16_char_length( unicode_char uc ) { + if ( uc > 0xFFFF ) // test if uc is greater than the single word maximum + return 2; // if so, we need a surrogate pair + return 1; // otherwise we can stuff it into a single word + } + //! converts the given UTF-16 character buffer \a in_cp to a single UTF-32 Unicode character \a out_uc, returns the number of code points used to create the output character (2 for surrogate pairs, otherwise 1) + /*! This function does it's best to prevent error conditions, verifying complete + surrogate pairs before applying the algorithm. In the event that half of a pair + is found it will happily generate a value in the 0xD800 - 0xDFFF range, which is + normally an invalid Unicode value but we preserve them for use as sentinel values. */ + static size_t _utf16_to_utf32( const code_point in_cp[2], unicode_char& out_uc ) { + const code_point& cp1 = in_cp[0]; + const code_point& cp2 = in_cp[1]; + bool wordPair = false; + + // does it look like a surrogate pair? + if ( 0xD800 <= cp1 && cp1 <= 0xDBFF ) { + // looks like one, but does the other half match the algorithm as well? + if ( 0xDC00 <= cp2 && cp2 <= 0xDFFF ) + wordPair = true; // yep! + } + + if ( !wordPair ) { // if we aren't a 100% authentic surrogate pair, then just copy the value + out_uc = cp1; + return 1; + } + + unsigned short cU = cp1, cL = cp2; // copy upper and lower words of surrogate pair to writable buffers + cU -= 0xD800; // remove the encoding markers + cL -= 0xDC00; + + out_uc = ( cU & 0x03FF ) << 10; // grab the 10 upper bits and set them in their proper location + out_uc |= ( cL & 0x03FF ); // combine in the lower 10 bits + out_uc += 0x10000; // add back in the value offset + + return 2; // this whole operation takes to words, so that's what we'll return + } + //! writes the given UTF-32 \a uc_in to the buffer location \a out_cp using UTF-16 encoding, returns the number of code points used to encode the input (always 1 or 2) + /*! This function, like its counterpart, will happily create invalid UTF-16 surrogate pairs. These + invalid entries will be created for any value of \c in_uc that falls in the range U+D800 - U+DFFF. + These are generally useful as sentinel values to represent various program specific conditions. + \note This function will also pass through any single UTF-16 code point without modification, + making it a safe method of ensuring a stream that is unknown UTF-32 or UTF-16 is truly UTF-16.*/ + static size_t _utf32_to_utf16( const unicode_char& in_uc, code_point out_cp[2] ) { + if ( in_uc <= 0xFFFF ) { // we blindly preserve sentinel values because our decoder understands them + out_cp[0] = in_uc; + return 1; + } + unicode_char uc = in_uc; // copy to writable buffer + unsigned short tmp; // single code point buffer + uc -= 0x10000; // subtract value offset + + //process upper word + tmp = ( uc >> 10 ) & 0x03FF; // grab the upper 10 bits + tmp += 0xD800; // add encoding offset + out_cp[0] = tmp; // write + + // process lower word + tmp = uc & 0x03FF; // grab the lower 10 bits + tmp += 0xDC00; // add encoding offset + out_cp[1] = tmp; // write + + return 2; // return used word count (2 for surrogate pairs) + } + //@} + + ////////////////////////////////////////////////////////////////////////// + + //!\name UTF-8 character encoding/decoding + //@{ + //! returns \c true if \a cp is the beginning of a UTF-8 sequence + static bool _utf8_start_char( unsigned char cp ) { + return ( cp & ~_cont_mask ) != _cont; + } + //! estimates the number of UTF-8 code points in the sequence starting with \a cp + static size_t _utf8_char_length( unsigned char cp ) { + if ( !( cp & 0x80 ) ) return 1; + if (( cp & ~_lead1_mask ) == _lead1 ) return 2; + if (( cp & ~_lead2_mask ) == _lead2 ) return 3; + if (( cp & ~_lead3_mask ) == _lead3 ) return 4; + if (( cp & ~_lead4_mask ) == _lead4 ) return 5; + if (( cp & ~_lead5_mask ) == _lead5 ) return 6; + throw invalid_data( "invalid UTF-8 sequence header value" ); + } + //! returns the number of UTF-8 code points needed to represent the given UTF-32 character \a cp + static size_t _utf8_char_length( unicode_char uc ) { + /* + 7 bit: U-00000000 - U-0000007F: 0xxxxxxx + 11 bit: U-00000080 - U-000007FF: 110xxxxx 10xxxxxx + 16 bit: U-00000800 - U-0000FFFF: 1110xxxx 10xxxxxx 10xxxxxx + 21 bit: U-00010000 - U-001FFFFF: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + 26 bit: U-00200000 - U-03FFFFFF: 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx + 31 bit: U-04000000 - U-7FFFFFFF: 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx + */ + if ( !( uc & ~0x0000007F ) ) return 1; + if ( !( uc & ~0x000007FF ) ) return 2; + if ( !( uc & ~0x0000FFFF ) ) return 3; + if ( !( uc & ~0x001FFFFF ) ) return 4; + if ( !( uc & ~0x03FFFFFF ) ) return 5; + if ( !( uc & ~0x7FFFFFFF ) ) return 6; + throw invalid_data( "invalid UTF-32 value" ); + } + + //! converts the given UTF-8 character buffer to a single UTF-32 Unicode character, returns the number of bytes used to create the output character (maximum of 6) + static size_t _utf8_to_utf32( const unsigned char in_cp[6], unicode_char& out_uc ) { + size_t len = _utf8_char_length( in_cp[0] ); + if ( len == 1 ) { // if we are only 1 byte long, then just grab it and exit + out_uc = in_cp[0]; + return 1; + } + + unicode_char c = 0; // temporary buffer + size_t i = 0; + switch ( len ) { // load header byte + case 6: + c = in_cp[i] & _lead5_mask; + break; + case 5: + c = in_cp[i] & _lead4_mask; + break; + case 4: + c = in_cp[i] & _lead3_mask; + break; + case 3: + c = in_cp[i] & _lead2_mask; + break; + case 2: + c = in_cp[i] & _lead1_mask; + break; + } + + for ( ++i; i < len; i++ ) { // load each continuation byte + if (( in_cp[i] & ~_cont_mask ) != _cont ) + throw invalid_data( "bad UTF-8 continuation byte" ); + c <<= 6; + c |= ( in_cp[i] & _cont_mask ); + } + + out_uc = c; // write the final value and return the used byte length + return len; + } + //! writes the given UTF-32 \a uc_in to the buffer location \a out_cp using UTF-8 encoding, returns the number of bytes used to encode the input + static size_t _utf32_to_utf8( const unicode_char& in_uc, unsigned char out_cp[6] ) { + size_t len = _utf8_char_length( in_uc ); // predict byte length of sequence + unicode_char c = in_uc; // copy to temp buffer + + //stuff all of the lower bits + for ( size_t i = len - 1; i > 0; i-- ) { + out_cp[i] = (( c ) & _cont_mask ) | _cont; + c >>= 6; + } + + //now write the header byte + switch ( len ) { + case 6: + out_cp[0] = (( c ) & _lead5_mask ) | _lead5; + break; + case 5: + out_cp[0] = (( c ) & _lead4_mask ) | _lead4; + break; + case 4: + out_cp[0] = (( c ) & _lead3_mask ) | _lead3; + break; + case 3: + out_cp[0] = (( c ) & _lead2_mask ) | _lead2; + break; + case 2: + out_cp[0] = (( c ) & _lead1_mask ) | _lead1; + break; + case 1: + default: + out_cp[0] = ( c ) & 0x7F; + break; + } + + // return the byte length of the sequence + return len; + } + + //! verifies a UTF-8 stream, returning the total number of Unicode characters found + static size_type _verifyUTF8( const unsigned char* c_str ) { + std::string tmp( reinterpret_cast( c_str ) ); + return _verifyUTF8( tmp ); + } + //! verifies a UTF-8 stream, returning the total number of Unicode characters found + static size_type _verifyUTF8( const std::string& str ) { + std::string::const_iterator i, ie = str.end(); + i = str.begin(); + size_type length = 0; + + while ( i != ie ) { + // characters pass until we find an extended sequence + if (( *i ) & 0x80 ) { + unsigned char c = ( *i ); + size_t contBytes = 0; + + // get continuation byte count and test for overlong sequences + if (( c & ~_lead1_mask ) == _lead1 ) { // 1 additional byte + if ( c == _lead1 ) throw invalid_data( "overlong UTF-8 sequence" ); + contBytes = 1; + + } else if (( c & ~_lead2_mask ) == _lead2 ) { // 2 additional bytes + contBytes = 2; + if ( c == _lead2 ) { // possible overlong UTF-8 sequence + c = ( *( i + 1 ) ); // look ahead to next byte in sequence + if (( c & _lead2 ) == _cont ) throw invalid_data( "overlong UTF-8 sequence" ); + } + + } else if (( c & ~_lead3_mask ) == _lead3 ) { // 3 additional bytes + contBytes = 3; + if ( c == _lead3 ) { // possible overlong UTF-8 sequence + c = ( *( i + 1 ) ); // look ahead to next byte in sequence + if (( c & _lead3 ) == _cont ) throw invalid_data( "overlong UTF-8 sequence" ); + } + + } else if (( c & ~_lead4_mask ) == _lead4 ) { // 4 additional bytes + contBytes = 4; + if ( c == _lead4 ) { // possible overlong UTF-8 sequence + c = ( *( i + 1 ) ); // look ahead to next byte in sequence + if (( c & _lead4 ) == _cont ) throw invalid_data( "overlong UTF-8 sequence" ); + } + + } else if (( c & ~_lead5_mask ) == _lead5 ) { // 5 additional bytes + contBytes = 5; + if ( c == _lead5 ) { // possible overlong UTF-8 sequence + c = ( *( i + 1 ) ); // look ahead to next byte in sequence + if (( c & _lead5 ) == _cont ) throw invalid_data( "overlong UTF-8 sequence" ); + } + } + + // check remaining continuation bytes for + while ( contBytes-- ) { + c = ( *( ++i ) ); // get next byte in sequence + if (( c & ~_cont_mask ) != _cont ) + throw invalid_data( "bad UTF-8 continuation byte" ); + } + } + length++; + i++; + } + return length; + } + //@} + + private: + //template friend class _iterator; + dstring mData; + + //! buffer data type identifier + enum BufferType { + bt_none, + bt_string, + bt_wstring, + bt_utf32string + }; + + //! common constructor operations + void _init() { + m_buffer.mVoidBuffer = 0; + m_bufferType = bt_none; + m_bufferSize = 0; + } + + /////////////////////////////////////////////////////////////////////// + // Scratch buffer + //! auto cleans the scratch buffer using the proper delete for the stored type + void _cleanBuffer() const { + if ( m_buffer.mVoidBuffer != 0 ) { + switch ( m_bufferType ) { + case bt_string: + delete m_buffer.mStrBuffer; + break; + case bt_wstring: + delete m_buffer.mWStrBuffer; + break; + case bt_utf32string: + delete m_buffer.mUTF32StrBuffer; + break; + case bt_none: // under the worse of circumstances, this is all we can do, and hope it works out + default: + //delete m_buffer.mVoidBuffer; + // delete void* is undefined, don't do that + assert("This should never happen - mVoidBuffer should never contain something if we " + "don't know the type"); + break; + } + m_buffer.mVoidBuffer = 0; + m_bufferSize = 0; + } + } + + //! create a std::string in the scratch buffer area + void _getBufferStr() const { + if ( m_bufferType != bt_string ) { + _cleanBuffer(); + m_buffer.mStrBuffer = new std::string(); + m_bufferType = bt_string; + } + m_buffer.mStrBuffer->clear(); + } + //! create a std::wstring in the scratch buffer area + void _getBufferWStr() const { + if ( m_bufferType != bt_wstring ) { + _cleanBuffer(); + m_buffer.mWStrBuffer = new std::wstring(); + m_bufferType = bt_wstring; + } + m_buffer.mWStrBuffer->clear(); + } + //! create a utf32string in the scratch buffer area + void _getBufferUTF32Str() const { + if ( m_bufferType != bt_utf32string ) { + _cleanBuffer(); + m_buffer.mUTF32StrBuffer = new utf32string(); + m_bufferType = bt_utf32string; + } + m_buffer.mUTF32StrBuffer->clear(); + } + + void _load_buffer_UTF8() const { + _getBufferStr(); + std::string& buffer = ( *m_buffer.mStrBuffer ); + buffer.reserve( length() ); + + unsigned char utf8buf[6]; + char* charbuf = ( char* )utf8buf; + unicode_char c; + size_t len; + + const_iterator i, ie = end(); + for ( i = begin(); i != ie; i.moveNext() ) { + c = i.getCharacter(); + len = _utf32_to_utf8( c, utf8buf ); + size_t j = 0; + while ( j < len ) + buffer.push_back( charbuf[j++] ); + } + } + void _load_buffer_WStr() const { + _getBufferWStr(); + std::wstring& buffer = ( *m_buffer.mWStrBuffer ); + buffer.reserve( length() ); // may over reserve, but should be close enough +#ifdef WCHAR_UTF16 // wchar_t matches UTF-16 + const_iterator i, ie = end(); + for ( i = begin(); i != ie; ++i ) { + buffer.push_back(( wchar_t )( *i ) ); + } +#else // wchar_t fits UTF-32 + unicode_char c; + const_iterator i, ie = end(); + for ( i = begin(); i != ie; i.moveNext() ) { + c = i.getCharacter(); + buffer.push_back(( wchar_t )c ); + } +#endif + } + void _load_buffer_UTF32() const { + _getBufferUTF32Str(); + utf32string& buffer = ( *m_buffer.mUTF32StrBuffer ); + buffer.reserve( length() ); // may over reserve, but should be close enough + + unicode_char c; + + const_iterator i, ie = end(); + for ( i = begin(); i != ie; i.moveNext() ) { + c = i.getCharacter(); + buffer.push_back( c ); + } + } + + mutable BufferType m_bufferType; // identifies the data type held in m_buffer + mutable size_t m_bufferSize; // size of the CString buffer + + // multi-purpose buffer used everywhere we need a throw-away buffer + union { + mutable void* mVoidBuffer; + mutable std::string* mStrBuffer; + mutable std::wstring* mWStrBuffer; + mutable utf32string* mUTF32StrBuffer; + } + m_buffer; + }; + + //! string addition operator \relates UTFString + inline UTFString operator+( const UTFString& s1, const UTFString& s2 ) { + return UTFString( s1 ).append( s2 ); + } + //! string addition operator \relates UTFString + inline UTFString operator+( const UTFString& s1, UTFString::code_point c ) { + return UTFString( s1 ).append( 1, c ); + } + //! string addition operator \relates UTFString + inline UTFString operator+( const UTFString& s1, UTFString::unicode_char c ) { + return UTFString( s1 ).append( 1, c ); + } + //! string addition operator \relates UTFString + inline UTFString operator+( const UTFString& s1, char c ) { + return UTFString( s1 ).append( 1, c ); + } +#if OGRE_IS_NATIVE_WCHAR_T + //! string addition operator \relates UTFString + inline UTFString operator+( const UTFString& s1, wchar_t c ) { + return UTFString( s1 ).append( 1, c ); + } +#endif + //! string addition operator \relates UTFString + inline UTFString operator+( UTFString::code_point c, const UTFString& s2 ) { + return UTFString().append( 1, c ).append( s2 ); + } + //! string addition operator \relates UTFString + inline UTFString operator+( UTFString::unicode_char c, const UTFString& s2 ) { + return UTFString().append( 1, c ).append( s2 ); + } + //! string addition operator \relates UTFString + inline UTFString operator+( char c, const UTFString& s2 ) { + return UTFString().append( 1, c ).append( s2 ); + } +#if OGRE_IS_NATIVE_WCHAR_T + //! string addition operator \relates UTFString + inline UTFString operator+( wchar_t c, const UTFString& s2 ) { + return UTFString().append( 1, c ).append( s2 ); + } +#endif + + // (const) forward iterator common operators + inline UTFString::size_type operator-( const UTFString::_const_fwd_iterator& left, const UTFString::_const_fwd_iterator& right ) { + return ( left.mIter - right.mIter ); + } + inline bool operator==( const UTFString::_const_fwd_iterator& left, const UTFString::_const_fwd_iterator& right ) { + return left.mIter == right.mIter; + } + inline bool operator!=( const UTFString::_const_fwd_iterator& left, const UTFString::_const_fwd_iterator& right ) { + return left.mIter != right.mIter; + } + inline bool operator<( const UTFString::_const_fwd_iterator& left, const UTFString::_const_fwd_iterator& right ) { + return left.mIter < right.mIter; + } + inline bool operator<=( const UTFString::_const_fwd_iterator& left, const UTFString::_const_fwd_iterator& right ) { + return left.mIter <= right.mIter; + } + inline bool operator>( const UTFString::_const_fwd_iterator& left, const UTFString::_const_fwd_iterator& right ) { + return left.mIter > right.mIter; + } + inline bool operator>=( const UTFString::_const_fwd_iterator& left, const UTFString::_const_fwd_iterator& right ) { + return left.mIter >= right.mIter; + } + + // (const) reverse iterator common operators + // NB: many of these operations are evaluated in reverse because this is a reverse iterator wrapping a forward iterator + inline UTFString::size_type operator-( const UTFString::_const_rev_iterator& left, const UTFString::_const_rev_iterator& right ) { + return ( right.mIter - left.mIter ); + } + inline bool operator==( const UTFString::_const_rev_iterator& left, const UTFString::_const_rev_iterator& right ) { + return left.mIter == right.mIter; + } + inline bool operator!=( const UTFString::_const_rev_iterator& left, const UTFString::_const_rev_iterator& right ) { + return left.mIter != right.mIter; + } + inline bool operator<( const UTFString::_const_rev_iterator& left, const UTFString::_const_rev_iterator& right ) { + return right.mIter < left.mIter; + } + inline bool operator<=( const UTFString::_const_rev_iterator& left, const UTFString::_const_rev_iterator& right ) { + return right.mIter <= left.mIter; + } + inline bool operator>( const UTFString::_const_rev_iterator& left, const UTFString::_const_rev_iterator& right ) { + return right.mIter > left.mIter; + } + inline bool operator>=( const UTFString::_const_rev_iterator& left, const UTFString::_const_rev_iterator& right ) { + return right.mIter >= left.mIter; + } + + //! std::ostream write operator \relates UTFString + inline std::ostream& operator << ( std::ostream& os, const UTFString& s ) { + return os << s.asUTF8(); + } + + //! std::wostream write operator \relates UTFString + inline std::wostream& operator << ( std::wostream& os, const UTFString& s ) { + return os << s.asWStr(); + } + + + +} // namespace Ogre{ + +#endif // OGRE_UNICODE_SUPPORT + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreUnifiedHighLevelGpuProgram.h b/school/informatik/verkerhssimulation/src/ogre/OgreUnifiedHighLevelGpuProgram.h new file mode 100644 index 00000000..8508fcc7 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreUnifiedHighLevelGpuProgram.h @@ -0,0 +1,168 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __UnifiedHighLevelGpuProgram_H__ +#define __UnifiedHighLevelGpuProgram_H__ + +#include "OgrePrerequisites.h" +#include "OgreHighLevelGpuProgram.h" +#include "OgreHighLevelGpuProgramManager.h" + +namespace Ogre { + + /** Specialisation of HighLevelGpuProgram which just delegates its implementation + to one other high level program, allowing a single program definition + to represent one supported program from a number of options + @remarks + Whilst you can use Technique to implement several ways to render an object + depending on hardware support, if the only reason to need multiple paths is + because of the high-level shader language supported, this can be + cumbersome. For example you might want to implement the same shader + in HLSL and GLSL for portability but apart from the implementation detail, + the shaders do the same thing and take the same parameters. If the materials + in question are complex, duplicating the techniques just to switch language + is not optimal, so instead you can define high-level programs with a + syntax of 'unified', and list the actual implementations in order of + preference via repeated use of the 'delegate' parameter, which just points + at another program name. The first one which has a supported syntax + will be used. + */ + class _OgreExport UnifiedHighLevelGpuProgram : public HighLevelGpuProgram + { + public: + /// Command object for setting delegate (can set more than once) + class CmdDelegate : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + protected: + static CmdDelegate msCmdDelegate; + + /// Ordered list of potential delegates + StringVector mDelegateNames; + /// The chosen delegate + mutable HighLevelGpuProgramPtr mChosenDelegate; + + /// Choose the delegate to use + void chooseDelegate() const; + + void createLowLevelImpl(void); + void unloadHighLevelImpl(void); + void buildConstantDefinitions() const; + void loadFromSource(void); + + public: + /** Constructor, should be used only by factory classes. */ + UnifiedHighLevelGpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle, + const String& group, bool isManual = false, ManualResourceLoader* loader = 0); + ~UnifiedHighLevelGpuProgram(); + + + /** Adds a new delegate program to the list. + @remarks + Delegates are tested in order so earlier ones are preferred. + */ + void addDelegateProgram(const String& name); + + /// Remove all delegate programs + void clearDelegatePrograms(); + + /// Get the chosen delegate + const HighLevelGpuProgramPtr& _getDelegate() const; + + /** @copydoc GpuProgram::getLanguage */ + const String& getLanguage(void) const; + + /** Creates a new parameters object compatible with this program definition. + @remarks + Unlike low-level assembly programs, parameters objects are specific to the + program and therefore must be created from it rather than by the + HighLevelGpuProgramManager. This method creates a new instance of a parameters + object containing the definition of the parameters this program understands. + */ + GpuProgramParametersSharedPtr createParameters(void); + /** @copydoc GpuProgram::getBindingDelegate */ + GpuProgram* _getBindingDelegate(void); + + // All the following methods must delegate to the implementation + + /** @copydoc GpuProgram::isSupported */ + bool isSupported(void) const; + + /** @copydoc GpuProgram::isSkeletalAnimationIncluded */ + bool isSkeletalAnimationIncluded(void) const; + + bool isMorphAnimationIncluded(void) const; + + bool isPoseAnimationIncluded(void) const; + + bool isVertexTextureFetchRequired(void) const; + GpuProgramParametersSharedPtr getDefaultParameters(void); + bool hasDefaultParameters(void) const; + bool getPassSurfaceAndLightStates(void) const; + bool hasCompileError(void) const; + void resetCompileError(void); + + void load(bool backgroundThread = false); + void reload(void); + bool isReloadable(void) const; + bool isLoaded(void) const; + LoadingState isLoading() const; + LoadingState getLoadingState() const; + void unload(void); + size_t getSize(void) const; + void touch(void); + bool isBackgroundLoaded(void) const; + void setBackgroundLoaded(bool bl); + void escalateLoading(); + void addListener(Listener* lis); + void removeListener(Listener* lis); + + }; + + /** Factory class for Unified programs. */ + class UnifiedHighLevelGpuProgramFactory : public HighLevelGpuProgramFactory + { + public: + UnifiedHighLevelGpuProgramFactory(); + ~UnifiedHighLevelGpuProgramFactory(); + /// Get the name of the language this factory creates programs for + const String& getLanguage(void) const; + HighLevelGpuProgram* create(ResourceManager* creator, + const String& name, ResourceHandle handle, + const String& group, bool isManual, ManualResourceLoader* loader); + void destroy(HighLevelGpuProgram* prog); + + }; + + +} +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreUserDefinedObject.h b/school/informatik/verkerhssimulation/src/ogre/OgreUserDefinedObject.h new file mode 100644 index 00000000..58d51490 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreUserDefinedObject.h @@ -0,0 +1,93 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __UserDefinedObject_H__ +#define __UserDefinedObject_H__ + +#include "OgrePrerequisites.h" + +namespace Ogre { + + + /** This class is designed to be subclassed by OGRE users, to allow them to + associate their own application objects with MovableObject instances + in the engine. + @remarks + It's always been suggested that an OGRE application would likley comprise + a number of game objects which would keep pointers to OGRE objects in order + to maintain the link. However, in some cases it would be very useful to be able to + navigate directly from an OGRE instance back to a custom application object. + This abstract class exists for this purpose; MovableObjects hold a pointer to + a UserDefinedObject instance, which application writers subclass in order to + include their own attributes. Your game objects themselves may be subclasses of this + class, or your subclasses may merely be a link between them. + @par + Because OGRE never uses instances of this object itself, there is very little + definition to this class; the application is expected to add all the detail it wants. + However, as a hint, and for debugging purposes, this class does define a 'type id', + which it is recommended you use to differentiate between your subclasses, + if you have more than one type. + */ + class _OgreExport UserDefinedObject + { + public: + /** Standard constructor. */ + UserDefinedObject(); + virtual ~UserDefinedObject() {} + + /** Return a number identifying the type of user defined object. + @remarks + Can be used to differentiate between different types of object which you attach to + OGRE MovableObject instances. Recommend you override this in your classes if you + use more than one type of object. + @par + Alternatively, you can override the getTypeName method and use that instead; + that version is a litle more friendly and easier to scope, but obviously + slightly less efficient. You choose which you prefer. + */ + virtual long getTypeID(void) const; + + /** Return a string identifying the type of user defined object. + @remarks + Can be used to differentiate between different types of object which you attach to + OGRE MovableObject instances. Recommend you override this in your classes if you + use more than one type of object. + @par + Alternatively, you can override the getTypeID method and use that instead; + that version is a litle more efficient, but obviously + slightly less easy to read. You choose which you prefer. + */ + virtual const String& getTypeName(void) const; + + }; + + + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreVector2.h b/school/informatik/verkerhssimulation/src/ogre/OgreVector2.h new file mode 100644 index 00000000..eec56773 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreVector2.h @@ -0,0 +1,532 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Vector2_H__ +#define __Vector2_H__ + + +#include "OgrePrerequisites.h" +#include "OgreMath.h" + +namespace Ogre +{ + + /** Standard 2-dimensional vector. + @remarks + A direction in 2D space represented as distances along the 2 + orthoganal axes (x, y). Note that positions, directions and + scaling factors can be represented by a vector, depending on how + you interpret the values. + */ + class _OgreExport Vector2 + { + public: + Real x, y; + + public: + inline Vector2() + { + } + + inline Vector2(const Real fX, const Real fY ) + : x( fX ), y( fY ) + { + } + + inline explicit Vector2( const Real scaler ) + : x( scaler), y( scaler ) + { + } + + inline explicit Vector2( const Real afCoordinate[2] ) + : x( afCoordinate[0] ), + y( afCoordinate[1] ) + { + } + + inline explicit Vector2( const int afCoordinate[2] ) + { + x = (Real)afCoordinate[0]; + y = (Real)afCoordinate[1]; + } + + inline explicit Vector2( Real* const r ) + : x( r[0] ), y( r[1] ) + { + } + + inline Vector2( const Vector2& rkVector ) + : x( rkVector.x ), y( rkVector.y ) + { + } + + inline Real operator [] ( const size_t i ) const + { + assert( i < 2 ); + + return *(&x+i); + } + + inline Real& operator [] ( const size_t i ) + { + assert( i < 2 ); + + return *(&x+i); + } + + /// Pointer accessor for direct copying + inline Real* ptr() + { + return &x; + } + /// Pointer accessor for direct copying + inline const Real* ptr() const + { + return &x; + } + + /** Assigns the value of the other vector. + @param + rkVector The other vector + */ + inline Vector2& operator = ( const Vector2& rkVector ) + { + x = rkVector.x; + y = rkVector.y; + + return *this; + } + + inline Vector2& operator = ( const Real fScalar) + { + x = fScalar; + y = fScalar; + + return *this; + } + + inline bool operator == ( const Vector2& rkVector ) const + { + return ( x == rkVector.x && y == rkVector.y ); + } + + inline bool operator != ( const Vector2& rkVector ) const + { + return ( x != rkVector.x || y != rkVector.y ); + } + + // arithmetic operations + inline Vector2 operator + ( const Vector2& rkVector ) const + { + return Vector2( + x + rkVector.x, + y + rkVector.y); + } + + inline Vector2 operator - ( const Vector2& rkVector ) const + { + return Vector2( + x - rkVector.x, + y - rkVector.y); + } + + inline Vector2 operator * ( const Real fScalar ) const + { + return Vector2( + x * fScalar, + y * fScalar); + } + + inline Vector2 operator * ( const Vector2& rhs) const + { + return Vector2( + x * rhs.x, + y * rhs.y); + } + + inline Vector2 operator / ( const Real fScalar ) const + { + assert( fScalar != 0.0 ); + + Real fInv = 1.0 / fScalar; + + return Vector2( + x * fInv, + y * fInv); + } + + inline Vector2 operator / ( const Vector2& rhs) const + { + return Vector2( + x / rhs.x, + y / rhs.y); + } + + inline const Vector2& operator + () const + { + return *this; + } + + inline Vector2 operator - () const + { + return Vector2(-x, -y); + } + + // overloaded operators to help Vector2 + inline friend Vector2 operator * ( const Real fScalar, const Vector2& rkVector ) + { + return Vector2( + fScalar * rkVector.x, + fScalar * rkVector.y); + } + + inline friend Vector2 operator / ( const Real fScalar, const Vector2& rkVector ) + { + return Vector2( + fScalar / rkVector.x, + fScalar / rkVector.y); + } + + inline friend Vector2 operator + (const Vector2& lhs, const Real rhs) + { + return Vector2( + lhs.x + rhs, + lhs.y + rhs); + } + + inline friend Vector2 operator + (const Real lhs, const Vector2& rhs) + { + return Vector2( + lhs + rhs.x, + lhs + rhs.y); + } + + inline friend Vector2 operator - (const Vector2& lhs, const Real rhs) + { + return Vector2( + lhs.x - rhs, + lhs.y - rhs); + } + + inline friend Vector2 operator - (const Real lhs, const Vector2& rhs) + { + return Vector2( + lhs - rhs.x, + lhs - rhs.y); + } + // arithmetic updates + inline Vector2& operator += ( const Vector2& rkVector ) + { + x += rkVector.x; + y += rkVector.y; + + return *this; + } + + inline Vector2& operator += ( const Real fScaler ) + { + x += fScaler; + y += fScaler; + + return *this; + } + + inline Vector2& operator -= ( const Vector2& rkVector ) + { + x -= rkVector.x; + y -= rkVector.y; + + return *this; + } + + inline Vector2& operator -= ( const Real fScaler ) + { + x -= fScaler; + y -= fScaler; + + return *this; + } + + inline Vector2& operator *= ( const Real fScalar ) + { + x *= fScalar; + y *= fScalar; + + return *this; + } + + inline Vector2& operator *= ( const Vector2& rkVector ) + { + x *= rkVector.x; + y *= rkVector.y; + + return *this; + } + + inline Vector2& operator /= ( const Real fScalar ) + { + assert( fScalar != 0.0 ); + + Real fInv = 1.0 / fScalar; + + x *= fInv; + y *= fInv; + + return *this; + } + + inline Vector2& operator /= ( const Vector2& rkVector ) + { + x /= rkVector.x; + y /= rkVector.y; + + return *this; + } + + /** Returns the length (magnitude) of the vector. + @warning + This operation requires a square root and is expensive in + terms of CPU operations. If you don't need to know the exact + length (e.g. for just comparing lengths) use squaredLength() + instead. + */ + inline Real length () const + { + return Math::Sqrt( x * x + y * y ); + } + + /** Returns the square of the length(magnitude) of the vector. + @remarks + This method is for efficiency - calculating the actual + length of a vector requires a square root, which is expensive + in terms of the operations required. This method returns the + square of the length of the vector, i.e. the same as the + length but before the square root is taken. Use this if you + want to find the longest / shortest vector without incurring + the square root. + */ + inline Real squaredLength () const + { + return x * x + y * y; + } + + /** Calculates the dot (scalar) product of this vector with another. + @remarks + The dot product can be used to calculate the angle between 2 + vectors. If both are unit vectors, the dot product is the + cosine of the angle; otherwise the dot product must be + divided by the product of the lengths of both vectors to get + the cosine of the angle. This result can further be used to + calculate the distance of a point from a plane. + @param + vec Vector with which to calculate the dot product (together + with this one). + @returns + A float representing the dot product value. + */ + inline Real dotProduct(const Vector2& vec) const + { + return x * vec.x + y * vec.y; + } + + /** Normalises the vector. + @remarks + This method normalises the vector such that it's + length / magnitude is 1. The result is called a unit vector. + @note + This function will not crash for zero-sized vectors, but there + will be no changes made to their components. + @returns The previous length of the vector. + */ + inline Real normalise() + { + Real fLength = Math::Sqrt( x * x + y * y); + + // Will also work for zero-sized vectors, but will change nothing + if ( fLength > 1e-08 ) + { + Real fInvLength = 1.0 / fLength; + x *= fInvLength; + y *= fInvLength; + } + + return fLength; + } + + + + /** Returns a vector at a point half way between this and the passed + in vector. + */ + inline Vector2 midPoint( const Vector2& vec ) const + { + return Vector2( + ( x + vec.x ) * 0.5, + ( y + vec.y ) * 0.5 ); + } + + /** Returns true if the vector's scalar components are all greater + that the ones of the vector it is compared against. + */ + inline bool operator < ( const Vector2& rhs ) const + { + if( x < rhs.x && y < rhs.y ) + return true; + return false; + } + + /** Returns true if the vector's scalar components are all smaller + that the ones of the vector it is compared against. + */ + inline bool operator > ( const Vector2& rhs ) const + { + if( x > rhs.x && y > rhs.y ) + return true; + return false; + } + + /** Sets this vector's components to the minimum of its own and the + ones of the passed in vector. + @remarks + 'Minimum' in this case means the combination of the lowest + value of x, y and z from both vectors. Lowest is taken just + numerically, not magnitude, so -1 < 0. + */ + inline void makeFloor( const Vector2& cmp ) + { + if( cmp.x < x ) x = cmp.x; + if( cmp.y < y ) y = cmp.y; + } + + /** Sets this vector's components to the maximum of its own and the + ones of the passed in vector. + @remarks + 'Maximum' in this case means the combination of the highest + value of x, y and z from both vectors. Highest is taken just + numerically, not magnitude, so 1 > -3. + */ + inline void makeCeil( const Vector2& cmp ) + { + if( cmp.x > x ) x = cmp.x; + if( cmp.y > y ) y = cmp.y; + } + + /** Generates a vector perpendicular to this vector (eg an 'up' vector). + @remarks + This method will return a vector which is perpendicular to this + vector. There are an infinite number of possibilities but this + method will guarantee to generate one of them. If you need more + control you should use the Quaternion class. + */ + inline Vector2 perpendicular(void) const + { + return Vector2 (-y, x); + } + /** Calculates the 2 dimensional cross-product of 2 vectors, which results + in a single floating point value which is 2 times the area of the triangle. + */ + inline Real crossProduct( const Vector2& rkVector ) const + { + return x * rkVector.y - y * rkVector.x; + } + /** Generates a new random vector which deviates from this vector by a + given angle in a random direction. + @remarks + This method assumes that the random number generator has already + been seeded appropriately. + @param + angle The angle at which to deviate in radians + @param + up Any vector perpendicular to this one (which could generated + by cross-product of this vector and any other non-colinear + vector). If you choose not to provide this the function will + derive one on it's own, however if you provide one yourself the + function will be faster (this allows you to reuse up vectors if + you call this method more than once) + @returns + A random vector which deviates from this vector by angle. This + vector will not be normalised, normalise it if you wish + afterwards. + */ + inline Vector2 randomDeviant( + Real angle) const + { + + angle *= Math::UnitRandom() * Math::TWO_PI; + Real cosa = cos(angle); + Real sina = sin(angle); + return Vector2(cosa * x - sina * y, + sina * x + cosa * y); + } + + /** Returns true if this vector is zero length. */ + inline bool isZeroLength(void) const + { + Real sqlen = (x * x) + (y * y); + return (sqlen < (1e-06 * 1e-06)); + + } + + /** As normalise, except that this vector is unaffected and the + normalised vector is returned as a copy. */ + inline Vector2 normalisedCopy(void) const + { + Vector2 ret = *this; + ret.normalise(); + return ret; + } + + /** Calculates a reflection vector to the plane with the given normal . + @remarks NB assumes 'this' is pointing AWAY FROM the plane, invert if it is not. + */ + inline Vector2 reflect(const Vector2& normal) const + { + return Vector2( *this - ( 2 * this->dotProduct(normal) * normal ) ); + } + + // special points + static const Vector2 ZERO; + static const Vector2 UNIT_X; + static const Vector2 UNIT_Y; + static const Vector2 NEGATIVE_UNIT_X; + static const Vector2 NEGATIVE_UNIT_Y; + static const Vector2 UNIT_SCALE; + + /** Function for writing to a stream. + */ + inline _OgreExport friend std::ostream& operator << + ( std::ostream& o, const Vector2& v ) + { + o << "Vector2(" << v.x << ", " << v.y << ")"; + return o; + } + + }; + +} +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreVector3.h b/school/informatik/verkerhssimulation/src/ogre/OgreVector3.h new file mode 100644 index 00000000..7849d477 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreVector3.h @@ -0,0 +1,769 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Vector3_H__ +#define __Vector3_H__ + +#include "OgrePrerequisites.h" +#include "OgreMath.h" +#include "OgreQuaternion.h" + +namespace Ogre +{ + + /** Standard 3-dimensional vector. + @remarks + A direction in 3D space represented as distances along the 3 + orthoganal axes (x, y, z). Note that positions, directions and + scaling factors can be represented by a vector, depending on how + you interpret the values. + */ + class _OgreExport Vector3 + { + public: + Real x, y, z; + + public: + inline Vector3() + { + } + + inline Vector3( const Real fX, const Real fY, const Real fZ ) + : x( fX ), y( fY ), z( fZ ) + { + } + + inline explicit Vector3( const Real afCoordinate[3] ) + : x( afCoordinate[0] ), + y( afCoordinate[1] ), + z( afCoordinate[2] ) + { + } + + inline explicit Vector3( const int afCoordinate[3] ) + { + x = (Real)afCoordinate[0]; + y = (Real)afCoordinate[1]; + z = (Real)afCoordinate[2]; + } + + inline explicit Vector3( Real* const r ) + : x( r[0] ), y( r[1] ), z( r[2] ) + { + } + + inline explicit Vector3( const Real scaler ) + : x( scaler ) + , y( scaler ) + , z( scaler ) + { + } + + + inline Vector3( const Vector3& rkVector ) + : x( rkVector.x ), y( rkVector.y ), z( rkVector.z ) + { + } + + inline Real operator [] ( const size_t i ) const + { + assert( i < 3 ); + + return *(&x+i); + } + + inline Real& operator [] ( const size_t i ) + { + assert( i < 3 ); + + return *(&x+i); + } + /// Pointer accessor for direct copying + inline Real* ptr() + { + return &x; + } + /// Pointer accessor for direct copying + inline const Real* ptr() const + { + return &x; + } + + /** Assigns the value of the other vector. + @param + rkVector The other vector + */ + inline Vector3& operator = ( const Vector3& rkVector ) + { + x = rkVector.x; + y = rkVector.y; + z = rkVector.z; + + return *this; + } + + inline Vector3& operator = ( const Real fScaler ) + { + x = fScaler; + y = fScaler; + z = fScaler; + + return *this; + } + + inline bool operator == ( const Vector3& rkVector ) const + { + return ( x == rkVector.x && y == rkVector.y && z == rkVector.z ); + } + + inline bool operator != ( const Vector3& rkVector ) const + { + return ( x != rkVector.x || y != rkVector.y || z != rkVector.z ); + } + + // arithmetic operations + inline Vector3 operator + ( const Vector3& rkVector ) const + { + return Vector3( + x + rkVector.x, + y + rkVector.y, + z + rkVector.z); + } + + inline Vector3 operator - ( const Vector3& rkVector ) const + { + return Vector3( + x - rkVector.x, + y - rkVector.y, + z - rkVector.z); + } + + inline Vector3 operator * ( const Real fScalar ) const + { + return Vector3( + x * fScalar, + y * fScalar, + z * fScalar); + } + + inline Vector3 operator * ( const Vector3& rhs) const + { + return Vector3( + x * rhs.x, + y * rhs.y, + z * rhs.z); + } + + inline Vector3 operator / ( const Real fScalar ) const + { + assert( fScalar != 0.0 ); + + Real fInv = 1.0 / fScalar; + + return Vector3( + x * fInv, + y * fInv, + z * fInv); + } + + inline Vector3 operator / ( const Vector3& rhs) const + { + return Vector3( + x / rhs.x, + y / rhs.y, + z / rhs.z); + } + + inline const Vector3& operator + () const + { + return *this; + } + + inline Vector3 operator - () const + { + return Vector3(-x, -y, -z); + } + + // overloaded operators to help Vector3 + inline friend Vector3 operator * ( const Real fScalar, const Vector3& rkVector ) + { + return Vector3( + fScalar * rkVector.x, + fScalar * rkVector.y, + fScalar * rkVector.z); + } + + inline friend Vector3 operator / ( const Real fScalar, const Vector3& rkVector ) + { + return Vector3( + fScalar / rkVector.x, + fScalar / rkVector.y, + fScalar / rkVector.z); + } + + inline friend Vector3 operator + (const Vector3& lhs, const Real rhs) + { + return Vector3( + lhs.x + rhs, + lhs.y + rhs, + lhs.z + rhs); + } + + inline friend Vector3 operator + (const Real lhs, const Vector3& rhs) + { + return Vector3( + lhs + rhs.x, + lhs + rhs.y, + lhs + rhs.z); + } + + inline friend Vector3 operator - (const Vector3& lhs, const Real rhs) + { + return Vector3( + lhs.x - rhs, + lhs.y - rhs, + lhs.z - rhs); + } + + inline friend Vector3 operator - (const Real lhs, const Vector3& rhs) + { + return Vector3( + lhs - rhs.x, + lhs - rhs.y, + lhs - rhs.z); + } + + // arithmetic updates + inline Vector3& operator += ( const Vector3& rkVector ) + { + x += rkVector.x; + y += rkVector.y; + z += rkVector.z; + + return *this; + } + + inline Vector3& operator += ( const Real fScalar ) + { + x += fScalar; + y += fScalar; + z += fScalar; + return *this; + } + + inline Vector3& operator -= ( const Vector3& rkVector ) + { + x -= rkVector.x; + y -= rkVector.y; + z -= rkVector.z; + + return *this; + } + + inline Vector3& operator -= ( const Real fScalar ) + { + x -= fScalar; + y -= fScalar; + z -= fScalar; + return *this; + } + + inline Vector3& operator *= ( const Real fScalar ) + { + x *= fScalar; + y *= fScalar; + z *= fScalar; + return *this; + } + + inline Vector3& operator *= ( const Vector3& rkVector ) + { + x *= rkVector.x; + y *= rkVector.y; + z *= rkVector.z; + + return *this; + } + + inline Vector3& operator /= ( const Real fScalar ) + { + assert( fScalar != 0.0 ); + + Real fInv = 1.0 / fScalar; + + x *= fInv; + y *= fInv; + z *= fInv; + + return *this; + } + + inline Vector3& operator /= ( const Vector3& rkVector ) + { + x /= rkVector.x; + y /= rkVector.y; + z /= rkVector.z; + + return *this; + } + + + /** Returns the length (magnitude) of the vector. + @warning + This operation requires a square root and is expensive in + terms of CPU operations. If you don't need to know the exact + length (e.g. for just comparing lengths) use squaredLength() + instead. + */ + inline Real length () const + { + return Math::Sqrt( x * x + y * y + z * z ); + } + + /** Returns the square of the length(magnitude) of the vector. + @remarks + This method is for efficiency - calculating the actual + length of a vector requires a square root, which is expensive + in terms of the operations required. This method returns the + square of the length of the vector, i.e. the same as the + length but before the square root is taken. Use this if you + want to find the longest / shortest vector without incurring + the square root. + */ + inline Real squaredLength () const + { + return x * x + y * y + z * z; + } + + /** Returns the distance to another vector. + @warning + This operation requires a square root and is expensive in + terms of CPU operations. If you don't need to know the exact + distance (e.g. for just comparing distances) use squaredDistance() + instead. + */ + inline Real distance(const Vector3& rhs) const + { + return (*this - rhs).length(); + } + + /** Returns the square of the distance to another vector. + @remarks + This method is for efficiency - calculating the actual + distance to another vector requires a square root, which is + expensive in terms of the operations required. This method + returns the square of the distance to another vector, i.e. + the same as the distance but before the square root is taken. + Use this if you want to find the longest / shortest distance + without incurring the square root. + */ + inline Real squaredDistance(const Vector3& rhs) const + { + return (*this - rhs).squaredLength(); + } + + /** Calculates the dot (scalar) product of this vector with another. + @remarks + The dot product can be used to calculate the angle between 2 + vectors. If both are unit vectors, the dot product is the + cosine of the angle; otherwise the dot product must be + divided by the product of the lengths of both vectors to get + the cosine of the angle. This result can further be used to + calculate the distance of a point from a plane. + @param + vec Vector with which to calculate the dot product (together + with this one). + @returns + A float representing the dot product value. + */ + inline Real dotProduct(const Vector3& vec) const + { + return x * vec.x + y * vec.y + z * vec.z; + } + + /** Calculates the absolute dot (scalar) product of this vector with another. + @remarks + This function work similar dotProduct, except it use absolute value + of each component of the vector to computing. + @param + vec Vector with which to calculate the absolute dot product (together + with this one). + @returns + A Real representing the absolute dot product value. + */ + inline Real absDotProduct(const Vector3& vec) const + { + return Math::Abs(x * vec.x) + Math::Abs(y * vec.y) + Math::Abs(z * vec.z); + } + + /** Normalises the vector. + @remarks + This method normalises the vector such that it's + length / magnitude is 1. The result is called a unit vector. + @note + This function will not crash for zero-sized vectors, but there + will be no changes made to their components. + @returns The previous length of the vector. + */ + inline Real normalise() + { + Real fLength = Math::Sqrt( x * x + y * y + z * z ); + + // Will also work for zero-sized vectors, but will change nothing + if ( fLength > 1e-08 ) + { + Real fInvLength = 1.0 / fLength; + x *= fInvLength; + y *= fInvLength; + z *= fInvLength; + } + + return fLength; + } + + /** Calculates the cross-product of 2 vectors, i.e. the vector that + lies perpendicular to them both. + @remarks + The cross-product is normally used to calculate the normal + vector of a plane, by calculating the cross-product of 2 + non-equivalent vectors which lie on the plane (e.g. 2 edges + of a triangle). + @param + vec Vector which, together with this one, will be used to + calculate the cross-product. + @returns + A vector which is the result of the cross-product. This + vector will NOT be normalised, to maximise efficiency + - call Vector3::normalise on the result if you wish this to + be done. As for which side the resultant vector will be on, the + returned vector will be on the side from which the arc from 'this' + to rkVector is anticlockwise, e.g. UNIT_Y.crossProduct(UNIT_Z) + = UNIT_X, whilst UNIT_Z.crossProduct(UNIT_Y) = -UNIT_X. + This is because OGRE uses a right-handed coordinate system. + @par + For a clearer explanation, look a the left and the bottom edges + of your monitor's screen. Assume that the first vector is the + left edge and the second vector is the bottom edge, both of + them starting from the lower-left corner of the screen. The + resulting vector is going to be perpendicular to both of them + and will go inside the screen, towards the cathode tube + (assuming you're using a CRT monitor, of course). + */ + inline Vector3 crossProduct( const Vector3& rkVector ) const + { + return Vector3( + y * rkVector.z - z * rkVector.y, + z * rkVector.x - x * rkVector.z, + x * rkVector.y - y * rkVector.x); + } + + /** Returns a vector at a point half way between this and the passed + in vector. + */ + inline Vector3 midPoint( const Vector3& vec ) const + { + return Vector3( + ( x + vec.x ) * 0.5, + ( y + vec.y ) * 0.5, + ( z + vec.z ) * 0.5 ); + } + + /** Returns true if the vector's scalar components are all greater + that the ones of the vector it is compared against. + */ + inline bool operator < ( const Vector3& rhs ) const + { + if( x < rhs.x && y < rhs.y && z < rhs.z ) + return true; + return false; + } + + /** Returns true if the vector's scalar components are all smaller + that the ones of the vector it is compared against. + */ + inline bool operator > ( const Vector3& rhs ) const + { + if( x > rhs.x && y > rhs.y && z > rhs.z ) + return true; + return false; + } + + /** Sets this vector's components to the minimum of its own and the + ones of the passed in vector. + @remarks + 'Minimum' in this case means the combination of the lowest + value of x, y and z from both vectors. Lowest is taken just + numerically, not magnitude, so -1 < 0. + */ + inline void makeFloor( const Vector3& cmp ) + { + if( cmp.x < x ) x = cmp.x; + if( cmp.y < y ) y = cmp.y; + if( cmp.z < z ) z = cmp.z; + } + + /** Sets this vector's components to the maximum of its own and the + ones of the passed in vector. + @remarks + 'Maximum' in this case means the combination of the highest + value of x, y and z from both vectors. Highest is taken just + numerically, not magnitude, so 1 > -3. + */ + inline void makeCeil( const Vector3& cmp ) + { + if( cmp.x > x ) x = cmp.x; + if( cmp.y > y ) y = cmp.y; + if( cmp.z > z ) z = cmp.z; + } + + /** Generates a vector perpendicular to this vector (eg an 'up' vector). + @remarks + This method will return a vector which is perpendicular to this + vector. There are an infinite number of possibilities but this + method will guarantee to generate one of them. If you need more + control you should use the Quaternion class. + */ + inline Vector3 perpendicular(void) const + { + static const Real fSquareZero = 1e-06 * 1e-06; + + Vector3 perp = this->crossProduct( Vector3::UNIT_X ); + + // Check length + if( perp.squaredLength() < fSquareZero ) + { + /* This vector is the Y axis multiplied by a scalar, so we have + to use another axis. + */ + perp = this->crossProduct( Vector3::UNIT_Y ); + } + perp.normalise(); + + return perp; + } + /** Generates a new random vector which deviates from this vector by a + given angle in a random direction. + @remarks + This method assumes that the random number generator has already + been seeded appropriately. + @param + angle The angle at which to deviate + @param + up Any vector perpendicular to this one (which could generated + by cross-product of this vector and any other non-colinear + vector). If you choose not to provide this the function will + derive one on it's own, however if you provide one yourself the + function will be faster (this allows you to reuse up vectors if + you call this method more than once) + @returns + A random vector which deviates from this vector by angle. This + vector will not be normalised, normalise it if you wish + afterwards. + */ + inline Vector3 randomDeviant( + const Radian& angle, + const Vector3& up = Vector3::ZERO ) const + { + Vector3 newUp; + + if (up == Vector3::ZERO) + { + // Generate an up vector + newUp = this->perpendicular(); + } + else + { + newUp = up; + } + + // Rotate up vector by random amount around this + Quaternion q; + q.FromAngleAxis( Radian(Math::UnitRandom() * Math::TWO_PI), *this ); + newUp = q * newUp; + + // Finally rotate this by given angle around randomised up + q.FromAngleAxis( angle, newUp ); + return q * (*this); + } +#ifndef OGRE_FORCE_ANGLE_TYPES + inline Vector3 randomDeviant( + Real angle, + const Vector3& up = Vector3::ZERO ) const + { + return randomDeviant ( Radian(angle), up ); + } +#endif//OGRE_FORCE_ANGLE_TYPES + + /** Gets the shortest arc quaternion to rotate this vector to the destination + vector. + @remarks + If you call this with a dest vector that is close to the inverse + of this vector, we will rotate 180 degrees around the 'fallbackAxis' + (if specified, or a generated axis if not) since in this case + ANY axis of rotation is valid. + */ + Quaternion getRotationTo(const Vector3& dest, + const Vector3& fallbackAxis = Vector3::ZERO) const + { + // Based on Stan Melax's article in Game Programming Gems + Quaternion q; + // Copy, since cannot modify local + Vector3 v0 = *this; + Vector3 v1 = dest; + v0.normalise(); + v1.normalise(); + + Real d = v0.dotProduct(v1); + // If dot == 1, vectors are the same + if (d >= 1.0f) + { + return Quaternion::IDENTITY; + } + if (d < (1e-6f - 1.0f)) + { + if (fallbackAxis != Vector3::ZERO) + { + // rotate 180 degrees about the fallback axis + q.FromAngleAxis(Radian(Math::PI), fallbackAxis); + } + else + { + // Generate an axis + Vector3 axis = Vector3::UNIT_X.crossProduct(*this); + if (axis.isZeroLength()) // pick another if colinear + axis = Vector3::UNIT_Y.crossProduct(*this); + axis.normalise(); + q.FromAngleAxis(Radian(Math::PI), axis); + } + } + else + { + Real s = Math::Sqrt( (1+d)*2 ); + Real invs = 1 / s; + + Vector3 c = v0.crossProduct(v1); + + q.x = c.x * invs; + q.y = c.y * invs; + q.z = c.z * invs; + q.w = s * 0.5; + q.normalise(); + } + return q; + } + + /** Returns true if this vector is zero length. */ + inline bool isZeroLength(void) const + { + Real sqlen = (x * x) + (y * y) + (z * z); + return (sqlen < (1e-06 * 1e-06)); + + } + + /** As normalise, except that this vector is unaffected and the + normalised vector is returned as a copy. */ + inline Vector3 normalisedCopy(void) const + { + Vector3 ret = *this; + ret.normalise(); + return ret; + } + + /** Calculates a reflection vector to the plane with the given normal . + @remarks NB assumes 'this' is pointing AWAY FROM the plane, invert if it is not. + */ + inline Vector3 reflect(const Vector3& normal) const + { + return Vector3( *this - ( 2 * this->dotProduct(normal) * normal ) ); + } + + /** Returns whether this vector is within a positional tolerance + of another vector. + @param rhs The vector to compare with + @param tolerance The amount that each element of the vector may vary by + and still be considered equal + */ + inline bool positionEquals(const Vector3& rhs, Real tolerance = 1e-03) const + { + return Math::RealEqual(x, rhs.x, tolerance) && + Math::RealEqual(y, rhs.y, tolerance) && + Math::RealEqual(z, rhs.z, tolerance); + + } + + /** Returns whether this vector is within a positional tolerance + of another vector, also take scale of the vectors into account. + @param rhs The vector to compare with + @param tolerance The amount (related to the scale of vectors) that distance + of the vector may vary by and still be considered close + */ + inline bool positionCloses(const Vector3& rhs, Real tolerance = 1e-03f) const + { + return squaredDistance(rhs) <= + (squaredLength() + rhs.squaredLength()) * tolerance; + } + + /** Returns whether this vector is within a directional tolerance + of another vector. + @param rhs The vector to compare with + @param tolerance The maximum angle by which the vectors may vary and + still be considered equal + @note Both vectors should be normalised. + */ + inline bool directionEquals(const Vector3& rhs, + const Radian& tolerance) const + { + Real dot = dotProduct(rhs); + Radian angle = Math::ACos(dot); + + return Math::Abs(angle.valueRadians()) <= tolerance.valueRadians(); + + } + + // special points + static const Vector3 ZERO; + static const Vector3 UNIT_X; + static const Vector3 UNIT_Y; + static const Vector3 UNIT_Z; + static const Vector3 NEGATIVE_UNIT_X; + static const Vector3 NEGATIVE_UNIT_Y; + static const Vector3 NEGATIVE_UNIT_Z; + static const Vector3 UNIT_SCALE; + + /** Function for writing to a stream. + */ + inline _OgreExport friend std::ostream& operator << + ( std::ostream& o, const Vector3& v ) + { + o << "Vector3(" << v.x << ", " << v.y << ", " << v.z << ")"; + return o; + } + }; + +} +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreVector4.h b/school/informatik/verkerhssimulation/src/ogre/OgreVector4.h new file mode 100644 index 00000000..eadaee62 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreVector4.h @@ -0,0 +1,396 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Vector4_H__ +#define __Vector4_H__ + +#include "OgrePrerequisites.h" +#include "OgreVector3.h" + +namespace Ogre +{ + + /** 4-dimensional homogenous vector. + */ + class _OgreExport Vector4 + { + public: + Real x, y, z, w; + + public: + inline Vector4() + { + } + + inline Vector4( const Real fX, const Real fY, const Real fZ, const Real fW ) + : x( fX ), y( fY ), z( fZ ), w( fW) + { + } + + inline explicit Vector4( const Real afCoordinate[4] ) + : x( afCoordinate[0] ), + y( afCoordinate[1] ), + z( afCoordinate[2] ), + w( afCoordinate[3] ) + { + } + + inline explicit Vector4( const int afCoordinate[4] ) + { + x = (Real)afCoordinate[0]; + y = (Real)afCoordinate[1]; + z = (Real)afCoordinate[2]; + w = (Real)afCoordinate[3]; + } + + inline explicit Vector4( Real* const r ) + : x( r[0] ), y( r[1] ), z( r[2] ), w( r[3] ) + { + } + + inline explicit Vector4( const Real scaler ) + : x( scaler ) + , y( scaler ) + , z( scaler ) + , w( scaler ) + { + } + + inline explicit Vector4(const Vector3& rhs) + : x(rhs.x), y(rhs.y), z(rhs.z), w(1.0f) + { + } + + inline Vector4( const Vector4& rkVector ) + : x( rkVector.x ), y( rkVector.y ), z( rkVector.z ), w (rkVector.w) + { + } + + inline Real operator [] ( const size_t i ) const + { + assert( i < 4 ); + + return *(&x+i); + } + + inline Real& operator [] ( const size_t i ) + { + assert( i < 4 ); + + return *(&x+i); + } + + /// Pointer accessor for direct copying + inline Real* ptr() + { + return &x; + } + /// Pointer accessor for direct copying + inline const Real* ptr() const + { + return &x; + } + + /** Assigns the value of the other vector. + @param + rkVector The other vector + */ + inline Vector4& operator = ( const Vector4& rkVector ) + { + x = rkVector.x; + y = rkVector.y; + z = rkVector.z; + w = rkVector.w; + + return *this; + } + + inline Vector4& operator = ( const Real fScalar) + { + x = fScalar; + y = fScalar; + z = fScalar; + w = fScalar; + return *this; + } + + inline bool operator == ( const Vector4& rkVector ) const + { + return ( x == rkVector.x && + y == rkVector.y && + z == rkVector.z && + w == rkVector.w ); + } + + inline bool operator != ( const Vector4& rkVector ) const + { + return ( x != rkVector.x || + y != rkVector.y || + z != rkVector.z || + w != rkVector.w ); + } + + inline Vector4& operator = (const Vector3& rhs) + { + x = rhs.x; + y = rhs.y; + z = rhs.z; + w = 1.0f; + return *this; + } + + // arithmetic operations + inline Vector4 operator + ( const Vector4& rkVector ) const + { + return Vector4( + x + rkVector.x, + y + rkVector.y, + z + rkVector.z, + w + rkVector.w); + } + + inline Vector4 operator - ( const Vector4& rkVector ) const + { + return Vector4( + x - rkVector.x, + y - rkVector.y, + z - rkVector.z, + w - rkVector.w); + } + + inline Vector4 operator * ( const Real fScalar ) const + { + return Vector4( + x * fScalar, + y * fScalar, + z * fScalar, + w * fScalar); + } + + inline Vector4 operator * ( const Vector4& rhs) const + { + return Vector4( + rhs.x * x, + rhs.y * y, + rhs.z * z, + rhs.w * w); + } + + inline Vector4 operator / ( const Real fScalar ) const + { + assert( fScalar != 0.0 ); + + Real fInv = 1.0 / fScalar; + + return Vector4( + x * fInv, + y * fInv, + z * fInv, + w * fInv); + } + + inline Vector4 operator / ( const Vector4& rhs) const + { + return Vector4( + x / rhs.x, + y / rhs.y, + z / rhs.z, + w / rhs.w); + } + + inline const Vector4& operator + () const + { + return *this; + } + + inline Vector4 operator - () const + { + return Vector4(-x, -y, -z, -w); + } + + inline friend Vector4 operator * ( const Real fScalar, const Vector4& rkVector ) + { + return Vector4( + fScalar * rkVector.x, + fScalar * rkVector.y, + fScalar * rkVector.z, + fScalar * rkVector.w); + } + + inline friend Vector4 operator / ( const Real fScalar, const Vector4& rkVector ) + { + return Vector4( + fScalar / rkVector.x, + fScalar / rkVector.y, + fScalar / rkVector.z, + fScalar / rkVector.w); + } + + inline friend Vector4 operator + (const Vector4& lhs, const Real rhs) + { + return Vector4( + lhs.x + rhs, + lhs.y + rhs, + lhs.z + rhs, + lhs.w + rhs); + } + + inline friend Vector4 operator + (const Real lhs, const Vector4& rhs) + { + return Vector4( + lhs + rhs.x, + lhs + rhs.y, + lhs + rhs.z, + lhs + rhs.w); + } + + inline friend Vector4 operator - (const Vector4& lhs, Real rhs) + { + return Vector4( + lhs.x - rhs, + lhs.y - rhs, + lhs.z - rhs, + lhs.w - rhs); + } + + inline friend Vector4 operator - (const Real lhs, const Vector4& rhs) + { + return Vector4( + lhs - rhs.x, + lhs - rhs.y, + lhs - rhs.z, + lhs - rhs.w); + } + + // arithmetic updates + inline Vector4& operator += ( const Vector4& rkVector ) + { + x += rkVector.x; + y += rkVector.y; + z += rkVector.z; + w += rkVector.w; + + return *this; + } + + inline Vector4& operator -= ( const Vector4& rkVector ) + { + x -= rkVector.x; + y -= rkVector.y; + z -= rkVector.z; + w -= rkVector.w; + + return *this; + } + + inline Vector4& operator *= ( const Real fScalar ) + { + x *= fScalar; + y *= fScalar; + z *= fScalar; + w *= fScalar; + return *this; + } + + inline Vector4& operator += ( const Real fScalar ) + { + x += fScalar; + y += fScalar; + z += fScalar; + w += fScalar; + return *this; + } + + inline Vector4& operator -= ( const Real fScalar ) + { + x -= fScalar; + y -= fScalar; + z -= fScalar; + w -= fScalar; + return *this; + } + + inline Vector4& operator *= ( const Vector4& rkVector ) + { + x *= rkVector.x; + y *= rkVector.y; + z *= rkVector.z; + w *= rkVector.w; + + return *this; + } + + inline Vector4& operator /= ( const Real fScalar ) + { + assert( fScalar != 0.0 ); + + Real fInv = 1.0 / fScalar; + + x *= fInv; + y *= fInv; + z *= fInv; + w *= fInv; + + return *this; + } + + inline Vector4& operator /= ( const Vector4& rkVector ) + { + x /= rkVector.x; + y /= rkVector.y; + z /= rkVector.z; + w /= rkVector.w; + + return *this; + } + + /** Calculates the dot (scalar) product of this vector with another. + @param + vec Vector with which to calculate the dot product (together + with this one). + @returns + A float representing the dot product value. + */ + inline Real dotProduct(const Vector4& vec) const + { + return x * vec.x + y * vec.y + z * vec.z + w * vec.w; + } + /** Function for writing to a stream. + */ + inline _OgreExport friend std::ostream& operator << + ( std::ostream& o, const Vector4& v ) + { + o << "Vector4(" << v.x << ", " << v.y << ", " << v.z << ", " << v.w << ")"; + return o; + } + // special + static const Vector4 ZERO; + }; + +} +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreVertexBoneAssignment.h b/school/informatik/verkerhssimulation/src/ogre/OgreVertexBoneAssignment.h new file mode 100644 index 00000000..a9eed284 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreVertexBoneAssignment.h @@ -0,0 +1,56 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __VertexBoneAssignment_H__ +#define __VertexBoneAssignment_H__ + +#include "OgrePrerequisites.h" + + +namespace Ogre +{ + + /** Records the assignment of a single vertex to a single bone with the corresponding weight. + @remarks + This simple struct simply holds a vertex index, bone index and weight representing the + assignment of a vertex to a bone for skeletal animation. There may be many of these + per vertex if blended vertex assignments are allowed. + */ + typedef struct VertexBoneAssignment_s + { + unsigned int vertexIndex; + unsigned short boneIndex; + Real weight; + + } VertexBoneAssignment; + + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreVertexIndexData.h b/school/informatik/verkerhssimulation/src/ogre/OgreVertexIndexData.h new file mode 100644 index 00000000..3b5f2804 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreVertexIndexData.h @@ -0,0 +1,286 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __VertexIndexData_H__ +#define __VertexIndexData_H__ + +#include "OgrePrerequisites.h" +#include "OgreHardwareVertexBuffer.h" +#include "OgreHardwareIndexBuffer.h" + +namespace Ogre { + + /// Define a list of usage flags + typedef std::vector BufferUsageList; + + + /** Summary class collecting together vertex source information. */ + class _OgreExport VertexData + { + private: + /// Protected copy constructor, to prevent misuse + VertexData(const VertexData& rhs); /* do nothing, should not use */ + /// Protected operator=, to prevent misuse + VertexData& operator=(const VertexData& rhs); /* do not use */ + public: + VertexData(); + ~VertexData(); + + /** Declaration of the vertex to be used in this operation. + @remarks Note that this is created for you on construction. + */ + VertexDeclaration* vertexDeclaration; + /** The vertex buffer bindings to be used. + @remarks Note that this is created for you on construction. + */ + VertexBufferBinding* vertexBufferBinding; + /// The base vertex index to start from + size_t vertexStart; + /// The number of vertices used in this operation + size_t vertexCount; + + + /// Struct used to hold hardware morph / pose vertex data information + struct HardwareAnimationData + { + const VertexElement* targetVertexElement; + Real parametric; + }; + typedef std::vector HardwareAnimationDataList; + /// VertexElements used for hardware morph / pose animation + HardwareAnimationDataList hwAnimationDataList; + /// Number of hardware animation data items used + size_t hwAnimDataItemsUsed; + + /** Clones this vertex data, potentially including replicating any vertex buffers. + @remarks The caller is expected to delete the returned pointer when ready + */ + VertexData* clone(bool copyData = true) const; + + /** Modifies the vertex data to be suitable for use for rendering shadow geometry. + @remarks + Preparing vertex data to generate a shadow volume involves firstly ensuring that the + vertex buffer containing the positions is a standalone vertex buffer, + with no other components in it. This method will therefore break apart any existing + vertex buffers if position is sharing a vertex buffer. + Secondly, it will double the size of this vertex buffer so that there are 2 copies of + the position data for the mesh. The first half is used for the original, and the second + half is used for the 'extruded' version. The vertex count used to render will remain + the same though, so as not to add any overhead to regular rendering of the object. + Both copies of the position are required in one buffer because shadow volumes stretch + from the original mesh to the extruded version. + @par + It's important to appreciate that this method can fundamentally change the structure of your + vertex buffers, although in reality they will be new buffers. As it happens, if other + objects are using the original buffers then they will be unaffected because the reference + counting will keep them intact. However, if you have made any assumptions about the + structure of the vertex data in the buffers of this object, you may have to rethink them. + */ + void prepareForShadowVolume(void); + + /** Additional shadow volume vertex buffer storage. + @remarks + This additional buffer is only used where we have prepared this VertexData for + use in shadow volume contruction, and where the current render system supports + vertex programs. This buffer contains the 'w' vertex position component which will + be used by that program to differentiate between extruded and non-extruded vertices. + This 'w' component cannot be included in the original position buffer because + DirectX does not allow 4-component positions in the fixed-function pipeline, and the original + position buffer must still be usable for fixed-function rendering. + @par + Note that we don't store any vertex declaration or vertex buffer binding here becuase this + can be reused in the shadow algorithm. + */ + HardwareVertexBufferSharedPtr hardwareShadowVolWBuffer; + + + /** Reorganises the data in the vertex buffers according to the + new vertex declaration passed in. Note that new vertex buffers + are created and written to, so if the buffers being referenced + by this vertex data object are also used by others, then the + original buffers will not be damaged by this operation. + Once this operation has completed, the new declaration + passed in will overwrite the current one. + @param newDeclaration The vertex declaration which will be used + for the reorganised buffer state. Note that the new delcaration + must not include any elements which do not already exist in the + current declaration; you can drop elements by + excluding them from the declaration if you wish, however. + @param bufferUsages Vector of usage flags which indicate the usage options + for each new vertex buffer created. The indexes of the entries must correspond + to the buffer binding values referenced in the declaration. + */ + void reorganiseBuffers(VertexDeclaration* newDeclaration, const BufferUsageList& bufferUsage); + + /** Reorganises the data in the vertex buffers according to the + new vertex declaration passed in. Note that new vertex buffers + are created and written to, so if the buffers being referenced + by this vertex data object are also used by others, then the + original buffers will not be damaged by this operation. + Once this operation has completed, the new declaration + passed in will overwrite the current one. + This version of the method derives the buffer usages from the existing + buffers, by using the 'most flexible' usage from the equivalent sources. + @param newDeclaration The vertex declaration which will be used + for the reorganised buffer state. Note that the new delcaration + must not include any elements which do not already exist in the + current declaration; you can drop elements by + excluding them from the declaration if you wish, however. + */ + void reorganiseBuffers(VertexDeclaration* newDeclaration); + + /** Remove any gaps in the vertex buffer bindings. + @remarks + This is useful if you've removed elements and buffers from this vertex + data and want to remove any gaps in the vertex buffer bindings. This + method is mainly useful when reorganising vertex data manually. + @note + This will cause binding index of the elements in the vertex declaration + to be altered to new binding index. + */ + void closeGapsInBindings(void); + + /** Remove all vertex buffers that never used by the vertex declaration. + @remarks + This is useful if you've removed elements from the vertex declaration + and want to unreference buffers that never used any more. This method + is mainly useful when reorganising vertex data manually. + @note + This also remove any gaps in the vertex buffer bindings. + */ + void removeUnusedBuffers(void); + + /** Convert all packed colour values (VET_COLOUR_*) in buffers used to + another type. + @param srcType The source colour type to assume if the ambiguous VET_COLOUR + is encountered. + @param destType The destination colour type, must be VET_COLOUR_ABGR or + VET_COLOUR_ARGB. + */ + void convertPackedColour(VertexElementType srcType, VertexElementType destType); + + + /** Allocate elements to serve a holder of morph / pose target data + for hardware morphing / pose blending. + @remarks + This method will allocate the given number of 3D texture coordinate + sets for use as a morph target or target pose offset (3D position). + These elements will be saved in hwAnimationDataList. + It will also assume that the source of these new elements will be new + buffers which are not bound at this time, so will start the sources to + 1 higher than the current highest binding source. The caller is + expected to bind these new buffers when appropriate. For morph animation + the original position buffer will be the 'from' keyframe data, whilst + for pose animation it will be the original vertex data. + */ + void allocateHardwareAnimationElements(ushort count); + + + + }; + + /** Summary class collecting together index data source information. */ + class _OgreExport IndexData + { + protected: + /// Protected copy constructor, to prevent misuse + IndexData(const IndexData& rhs); /* do nothing, should not use */ + /// Protected operator=, to prevent misuse + IndexData& operator=(const IndexData& rhs); /* do not use */ + public: + IndexData(); + ~IndexData(); + /// pointer to the HardwareIndexBuffer to use, must be specified if useIndexes = true + HardwareIndexBufferSharedPtr indexBuffer; + + /// index in the buffer to start from for this operation + size_t indexStart; + + /// The number of indexes to use from the buffer + size_t indexCount; + + /** Clones this index data, potentially including replicating the index buffer. + @remarks The caller is expected to delete the returned pointer when finished + */ + IndexData* clone(bool copyData = true) const; + + /** Re-order the indexes in this index data structure to be more + vertex cache friendly; that is to re-use the same vertices as close + together as possible. + @remarks + Can only be used for index data which consists of triangle lists. + It would in fact be pointless to use it on triangle strips or fans + in any case. + */ + void optimiseVertexCacheTriList(void); + + }; + + /** Vertex cache profiler. + @remarks + Utility class for evaluating the effectiveness of the use of the vertex + cache by a given index buffer. + */ + class _OgreExport VertexCacheProfiler + { + public: + enum CacheType { + FIFO, LRU + }; + + VertexCacheProfiler(unsigned int cachesize = 16, CacheType cachetype = FIFO ) + : size ( cachesize ), type ( cachetype ), tail (0), buffersize (0), hit (0), miss (0) + { + cache = new uint32[size]; + }; + + ~VertexCacheProfiler() + { + delete[] cache; + } + + void profile(const HardwareIndexBufferSharedPtr& indexBuffer); + void reset() { hit = 0; miss = 0; tail = 0; buffersize = 0; }; + void flush() { tail = 0; buffersize = 0; }; + + unsigned int getHits() { return hit; }; + unsigned int getMisses() { return miss; }; + unsigned int getSize() { return size; }; + private: + unsigned int size; + uint32 *cache; + CacheType type; + + unsigned int tail, buffersize; + unsigned int hit, miss; + + bool inCache(unsigned int index); + }; +} +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreViewport.h b/school/informatik/verkerhssimulation/src/ogre/OgreViewport.h new file mode 100644 index 00000000..0ffad145 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreViewport.h @@ -0,0 +1,331 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Viewport_H__ +#define __Viewport_H__ + +#include "OgrePrerequisites.h" +#include "OgreCommon.h" +#include "OgreColourValue.h" + +namespace Ogre { + /** An abstraction of a viewport, i.e. a rendering region on a render + target. + @remarks + A viewport is the meeting of a camera and a rendering surface - + the camera renders the scene from a viewpoint, and places its + results into some subset of a rendering target, which may be the + whole surface or just a part of the surface. Each viewport has a + single camera as source and a single target as destination. A + camera only has 1 viewport, but a render target may have several. + A viewport also has a Z-order, i.e. if there is more than one + viewport on a single render target and they overlap, one must + obscure the other in some predetermined way. + */ + class _OgreExport Viewport + { + public: + /** The usual constructor. + @param + cam Pointer to a camera to be the source for the image. + @param + target Pointer to the render target to be the destination + for the rendering. + @param + left + @param + top + @param + width + @param + height + Dimensions of the viewport, expressed as a value between + 0 and 1. This allows the dimensions to apply irrespective of + changes in the target's size: e.g. to fill the whole area, + values of 0,0,1,1 are appropriate. + @param + ZOrder Relative Z-order on the target. Lower = further to + the front. + */ + Viewport( + Camera* camera, + RenderTarget* target, + Real left, Real top, + Real width, Real height, + int ZOrder); + + /** Default destructor. + */ + virtual ~Viewport(); + + /** Notifies the viewport of a possible change in dimensions. + @remarks + Used by the target to update the viewport's dimensions + (usually the result of a change in target size). + @note + Internal use by Ogre only. + */ + void _updateDimensions(void); + + /** Instructs the viewport to updates its contents. + */ + void update(void); + + /** Retrieves a pointer to the render target for this viewport. + */ + RenderTarget* getTarget(void) const; + + /** Retrieves a pointer to the camera for this viewport. + */ + Camera* getCamera(void) const; + + /** Sets the camera to use for rendering to this viewport. */ + void setCamera(Camera* cam); + + /** Gets the Z-Order of this viewport. */ + int getZOrder(void) const; + /** Gets one of the relative dimensions of the viewport, + a value between 0.0 and 1.0. + */ + Real getLeft(void) const; + + /** Gets one of the relative dimensions of the viewport, a value + between 0.0 and 1.0. + */ + Real getTop(void) const; + + /** Gets one of the relative dimensions of the viewport, a value + between 0.0 and 1.0. + */ + + Real getWidth(void) const; + /** Gets one of the relative dimensions of the viewport, a value + between 0.0 and 1.0. + */ + + Real getHeight(void) const; + /** Gets one of the actual dimensions of the viewport, a value in + pixels. + */ + + int getActualLeft(void) const; + /** Gets one of the actual dimensions of the viewport, a value in + pixels. + */ + + int getActualTop(void) const; + /** Gets one of the actual dimensions of the viewport, a value in + pixels. + */ + int getActualWidth(void) const; + /** Gets one of the actual dimensions of the viewport, a value in + pixels. + */ + + int getActualHeight(void) const; + + /** Sets the dimensions (after creation). + @param + left + @param + top + @param + width + @param + height Dimensions relative to the size of the target, + represented as real values between 0 and 1. i.e. the full + target area is 0, 0, 1, 1. + */ + void setDimensions(Real left, Real top, Real width, Real height); + + /** Sets the initial background colour of the viewport (before + rendering). + */ + void setBackgroundColour(const ColourValue& colour); + + /** Gets the background colour. + */ + const ColourValue& getBackgroundColour(void) const; + + /** Determines whether to clear the viewport before rendering. + @remarks + You can use this method to set which buffers are cleared + (if any) before rendering every frame. + @param clear Whether or not to clear any buffers + @param buffers One or more values from FrameBufferType denoting + which buffers to clear, if clear is set to true. Note you should + not clear the stencil buffer here unless you know what you're doing. + */ + void setClearEveryFrame(bool clear, unsigned int buffers = FBT_COLOUR | FBT_DEPTH); + + /** Determines if the viewport is cleared before every frame. + */ + bool getClearEveryFrame(void) const; + + /** Gets which buffers are to be cleared each frame. */ + unsigned int getClearBuffers(void) const; + + /** Set the material scheme which the viewport should use. + @remarks + This allows you to tell the system to use a particular + material scheme when rendering this viewport, which can + involve using different techniques to render your materials. + @see Technique::setSchemeName + */ + void setMaterialScheme(const String& schemeName) + { mMaterialSchemeName = schemeName; } + + /** Get the material scheme which the viewport should use. + */ + const String& getMaterialScheme(void) const + { return mMaterialSchemeName; } + + /** Access to actual dimensions (based on target size). + */ + void getActualDimensions( + int &left, int &top, int &width, int &height ) const; + + bool _isUpdated(void) const; + void _clearUpdatedFlag(void); + + /** Gets the number of rendered faces in the last update. + */ + unsigned int _getNumRenderedFaces(void) const; + + /** Gets the number of rendered batches in the last update. + */ + unsigned int _getNumRenderedBatches(void) const; + + /** Tells this viewport whether it should display Overlay objects. + @remarks + Overlay objects are layers which appear on top of the scene. They are created via + SceneManager::createOverlay and every viewport displays these by default. + However, you probably don't want this if you're using multiple viewports, + because one of them is probably a picture-in-picture which is not supposed to + have overlays of it's own. In this case you can turn off overlays on this viewport + by calling this method. + @param enabled If true, any overlays are displayed, if false they are not. + */ + void setOverlaysEnabled(bool enabled); + + /** Returns whether or not Overlay objects (created in the SceneManager) are displayed in this + viewport. */ + bool getOverlaysEnabled(void) const; + + /** Tells this viewport whether it should display skies. + @remarks + Skies are layers which appear on background of the scene. They are created via + SceneManager::setSkyBox, SceneManager::setSkyPlane and SceneManager::setSkyDome and + every viewport displays these by default. However, you probably don't want this if + you're using multiple viewports, because one of them is probably a picture-in-picture + which is not supposed to have skies of it's own. In this case you can turn off skies + on this viewport by calling this method. + @param enabled If true, any skies are displayed, if false they are not. + */ + void setSkiesEnabled(bool enabled); + + /** Returns whether or not skies (created in the SceneManager) are displayed in this + viewport. */ + bool getSkiesEnabled(void) const; + + /** Tells this viewport whether it should display shadows. + @remarks + This setting enables you to disable shadow rendering for a given viewport. The global + shadow technique set on SceneManager still controls the type and nature of shadows, + but this flag can override the setting so that no shadows are rendered for a given + viewport to save processing time where they are not required. + @param enabled If true, any shadows are displayed, if false they are not. + */ + void setShadowsEnabled(bool enabled); + + /** Returns whether or not shadows (defined in the SceneManager) are displayed in this + viewport. */ + bool getShadowsEnabled(void) const; + + + /** Sets a per-viewport visibility mask. + @remarks + The visibility mask is a way to exclude objects from rendering for + a given viewport. For each object in the frustum, a check is made + between this mask and the objects visibility flags + (@see MovableObject::setVisibilityFlags), and if a binary 'and' + returns zero, the object will not be rendered. + */ + void setVisibilityMask(uint32 mask) { mVisibilityMask = mask; } + + /** Gets a per-viewport visibility mask. + @see Viewport::setVisibilityMask + */ + uint getVisibilityMask(void) const { return mVisibilityMask; } + + /** Sets the use of a custom RenderQueueInvocationSequence for + rendering this target. + @remarks + RenderQueueInvocationSequence instances are managed through Root. By + setting this, you are indicating that you wish this RenderTarget to + be updated using a custom sequence of render queue invocations, with + potentially customised ordering and render state options. You should + create the named sequence through Root first, then set the name here. + @param The name of the RenderQueueInvocationSequence to use. If you + specify a blank string, behaviour will return to the defaul render + queue management. + */ + virtual void setRenderQueueInvocationSequenceName(const String& sequenceName); + /** Gets the name of the render queue invocation sequence for this target. */ + virtual const String& getRenderQueueInvocationSequenceName(void) const; + /// Get the invocation sequence - will return null if using standard + RenderQueueInvocationSequence* _getRenderQueueInvocationSequence(void); + + protected: + Camera* mCamera; + RenderTarget* mTarget; + // Relative dimensions, irrespective of target dimensions (0..1) + float mRelLeft, mRelTop, mRelWidth, mRelHeight; + // Actual dimensions, based on target dimensions + int mActLeft, mActTop, mActWidth, mActHeight; + /// ZOrder + int mZOrder; + /// Background options + ColourValue mBackColour; + bool mClearEveryFrame; + unsigned int mClearBuffers; + bool mUpdated; + bool mShowOverlays; + bool mShowSkies; + bool mShowShadows; + uint32 mVisibilityMask; + // Render queue invocation sequence name + String mRQSequenceName; + RenderQueueInvocationSequence* mRQSequence; + /// Material scheme + String mMaterialSchemeName; + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreWindowEventUtilities.h b/school/informatik/verkerhssimulation/src/ogre/OgreWindowEventUtilities.h new file mode 100644 index 00000000..b43f181b --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreWindowEventUtilities.h @@ -0,0 +1,151 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __OgreWindowEventUtils_H__ +#define __OgreWindowEventUtils_H__ + +#include "OgrePrerequisites.h" +#include "OgrePlatform.h" + +#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 +# define WIN32_LEAN_AND_MEAN +# include +#endif + +namespace Ogre +{ + /** + @Remarks + Callback class used to send out window events to client app + */ + class _OgreExport WindowEventListener + { + public: + virtual ~WindowEventListener() {}; + + /** + @Remarks + Window has moved position + @param rw + The RenderWindow which created this events + */ + virtual void windowMoved(RenderWindow* rw) {} + + /** + @Remarks + Window has resized + @param rw + The RenderWindow which created this events + */ + virtual void windowResized(RenderWindow* rw) {} + + /** + @Remarks + Window has been closed + @param rw + The RenderWindow which created this events + */ + virtual void windowClosed(RenderWindow* rw) {} + + /** + @Remarks + Window has lost/gained focuw + @param rw + The RenderWindow which created this events + */ + virtual void windowFocusChange(RenderWindow* rw) {} + }; + + /** + @Remarks + Utility class to handle Window Events/Pumping/Messages + */ + class _OgreExport WindowEventUtilities + { + public: + /** + @Remarks + Call this once per frame if not using Root:startRendering(). This will update all registered + RenderWindows (If using external Windows, you can optionally register those yourself) + */ + static void messagePump(); + + /** + @Remarks + Add a listener to listen to renderwindow events (multiple listener's per renderwindow is fine) + The same listener can listen to multiple windows, as the Window Pointer is sent along with + any messages. + @param window + The RenderWindow you are interested in monitoring + @param listner + Your callback listener + */ + static void addWindowEventListener( RenderWindow* window, WindowEventListener* listener ); + + /** + @Remarks + Remove previously added listener + @param window + The RenderWindow you registered with + @param listner + The listener registered + */ + static void removeWindowEventListener( RenderWindow* window, WindowEventListener* listener ); + + /** + @Remarks + Called by RenderWindows upon creation for Ogre generated windows. You are free to add your + external windows here too if needed. + @param window + The RenderWindow to monitor + */ + static void _addRenderWindow(RenderWindow* window); + + /** + @Remarks + Called by RenderWindows upon creation for Ogre generated windows. You are free to add your + external windows here too if needed. + @param window + The RenderWindow to remove from list + */ + static void _removeRenderWindow(RenderWindow* window); + +#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 + //! Internal winProc (RenderWindow's use this when creating the Win32 Window) + static LRESULT CALLBACK _WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); +#endif + + //These are public only so GLXProc can access them without adding Xlib headers header + typedef std::multimap WindowEventListeners; + static WindowEventListeners _msListeners; + + typedef std::vector Windows; + static Windows _msWindows; + }; +} +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreWireBoundingBox.h b/school/informatik/verkerhssimulation/src/ogre/OgreWireBoundingBox.h new file mode 100644 index 00000000..7f98bbc1 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreWireBoundingBox.h @@ -0,0 +1,81 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _WireBoundingBox_H__ +#define _WireBoundingBox_H__ + +#include "OgrePrerequisites.h" + +#include "OgreSimpleRenderable.h" + +namespace Ogre { + + /** Allows the rendering of a wireframe bounding box. + @remarks + This class builds a wireframe renderable from a given aabb. A pointer to this class can be + added to a render queue to display the bounding box of an object. + */ + class _OgreExport WireBoundingBox : public SimpleRenderable + { + protected: + /** Override this method to prevent parent transforms (rotation,translation,scale) + */ + void getWorldTransforms( Matrix4* xform ) const; + /** @copydoc Renderable::getWorldOrientation */ + const Quaternion& getWorldOrientation(void) const; + /** @copydoc Renderable::getWorldPosition */ + const Vector3& getWorldPosition(void) const; + + /** Builds the wireframe line list. + */ + void setupBoundingBoxVertices(const AxisAlignedBox& aab); + + Real mRadius; + + public: + + WireBoundingBox(); + ~WireBoundingBox(); + + /** Builds the wireframe line list. + @param + aabb bounding box to build a wireframe from. + */ + void setupBoundingBox(const AxisAlignedBox& aabb); + + Real getSquaredViewDepth(const Camera* cam) const; + + Real getBoundingRadius(void) const { return mRadius; } + + }; + +}// namespace + +#endif + + diff --git a/school/informatik/verkerhssimulation/src/ogre/OgreZip.h b/school/informatik/verkerhssimulation/src/ogre/OgreZip.h new file mode 100644 index 00000000..7558c57d --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/OgreZip.h @@ -0,0 +1,136 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Zip_H__ +#define __Zip_H__ + +#include "OgrePrerequisites.h" + +#include "OgreArchive.h" +#include "OgreArchiveFactory.h" + +// Forward declaration for zziplib to avoid header file dependency. +typedef struct zzip_dir ZZIP_DIR; +typedef struct zzip_file ZZIP_FILE; + +namespace Ogre { + + /** Specialisation of the Archive class to allow reading of files from a zip + format source archive. + @remarks + This archive format supports all archives compressed in the standard + zip format, including iD pk3 files. + */ + class _OgreExport ZipArchive : public Archive + { + protected: + /// Handle to root zip file + ZZIP_DIR* mZzipDir; + /// Handle any errors from zzip + void checkZzipError(int zzipError, const String& operation) const; + /// File list (since zziplib seems to only allow scanning of dir tree once) + FileInfoList mFileList; + public: + ZipArchive(const String& name, const String& archType ); + ~ZipArchive(); + /// @copydoc Archive::isCaseSensitive + bool isCaseSensitive(void) const { return false; } + + /// @copydoc Archive::load + void load(); + /// @copydoc Archive::unload + void unload(); + + /// @copydoc Archive::open + DataStreamPtr open(const String& filename) const; + + /// @copydoc Archive::list + StringVectorPtr list(bool recursive = true, bool dirs = false); + + /// @copydoc Archive::listFileInfo + FileInfoListPtr listFileInfo(bool recursive = true, bool dirs = false); + + /// @copydoc Archive::find + StringVectorPtr find(const String& pattern, bool recursive = true, + bool dirs = false); + + /// @copydoc Archive::findFileInfo + FileInfoListPtr findFileInfo(const String& pattern, bool recursive = true, + bool dirs = false); + + /// @copydoc Archive::exists + bool exists(const String& filename); + }; + + /** Specialisation of ArchiveFactory for Zip files. */ + class _OgrePrivate ZipArchiveFactory : public ArchiveFactory + { + public: + virtual ~ZipArchiveFactory() {} + /// @copydoc FactoryObj::getType + const String& getType(void) const; + /// @copydoc FactoryObj::createInstance + Archive *createInstance( const String& name ) + { + return new ZipArchive(name, "Zip"); + } + /// @copydoc FactoryObj::destroyInstance + void destroyInstance( Archive* arch) { delete arch; } + }; + + /** Specialisation of DataStream to handle streaming data from zip archives. */ + class _OgrePrivate ZipDataStream : public DataStream + { + protected: + ZZIP_FILE* mZzipFile; + public: + /// Unnamed constructor + ZipDataStream(ZZIP_FILE* zzipFile, size_t uncompressedSize); + /// Constructor for creating named streams + ZipDataStream(const String& name, ZZIP_FILE* zzipFile, size_t uncompressedSize); + ~ZipDataStream(); + /// @copydoc DataStream::read + size_t read(void* buf, size_t count); + /// @copydoc DataStream::skip + void skip(long count); + /// @copydoc DataStream::seek + void seek( size_t pos ); + /// @copydoc DataStream::seek + size_t tell(void) const; + /// @copydoc DataStream::eof + bool eof(void) const; + /// @copydoc DataStream::close + void close(void); + + + }; + + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/WIN32/OgreConfigDialogImp.h b/school/informatik/verkerhssimulation/src/ogre/WIN32/OgreConfigDialogImp.h new file mode 100644 index 00000000..b734ef09 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/WIN32/OgreConfigDialogImp.h @@ -0,0 +1,92 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Win32ConfigDialog_H__ +#define __Win32ConfigDialog_H__ + +#include "OgrePrerequisites.h" + +#define WIN32_LEAN_AND_MEAN +#include "windows.h" + +//Get around Windows hackery +#ifdef max +# undef max +#endif +#ifdef min +# undef min +#endif + +namespace Ogre +{ + /** Defines the behaviour of an automatic renderer configuration dialog. + @remarks + OGRE comes with it's own renderer configuration dialog, which + applications can use to easily allow the user to configure the + settings appropriate to their machine. This class defines the + interface to this standard dialog. Because dialogs are inherently + tied to a particular platform's windowing system, there will be a + different subclass for each platform. + @author + Steven J. Streeting + */ + class _OgreExport ConfigDialog + { + public: + ConfigDialog(); + ~ConfigDialog(); + + /** Displays the dialog. + @remarks + This method displays the dialog and from then on the dialog + interacts with the user independently. The dialog will be + calling the relevant OGRE rendering systems to query them for + options and to set the options the user selects. The method + returns when the user closes the dialog. + @returns + If the user accepted the dialog, true is returned. + @par + If the user cancelled the dialog (indicating the application + should probably terminate), false is returned. + @see + RenderSystem + */ + bool display(); + + protected: + /** Callback to process window events */ +#if OGRE_ARCHITECTURE_64 == OGRE_ARCH_TYPE + static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam); +#else + static BOOL CALLBACK DlgProc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam); +#endif + RenderSystem* mSelectedRenderSystem; + HINSTANCE mHInstance; // HInstance of application, for dialog + }; +} +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/WIN32/OgreErrorDialogImp.h b/school/informatik/verkerhssimulation/src/ogre/WIN32/OgreErrorDialogImp.h new file mode 100644 index 00000000..85cb8139 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/WIN32/OgreErrorDialogImp.h @@ -0,0 +1,75 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __WIN32ERRORDIALOG_H__ +#define __WIN32ERRORDIALOG_H__ + +#define WIN32_LEAN_AND_MEAN +#include "windows.h" + +//Get around Windows hackery +#ifdef max +# undef max +#endif +#ifdef min +# undef min +#endif + +namespace Ogre +{ + /** Class for displaying the error dialog if Ogre fails badly. */ + class _OgreExport ErrorDialog + { + public: + ErrorDialog(); + ~ErrorDialog() {} + + /** + @remarks + Displays the error dialog. + @param + errorMessage The error message which has caused the failure. + @param + logName Optional name of the log to display in the detail pane. + */ + void display(const String& errorMessage, String logName = ""); + + protected: + String mErrorMsg; + /** Callback to process window events */ +#if OGRE_ARCHITECTURE_64 == OGRE_ARCH_TYPE + static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam); +#else + static BOOL CALLBACK DlgProc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam); +#endif + + HINSTANCE mHInstance; // HInstance of application, for dialog + + }; +} +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/WIN32/OgreTimerImp.h b/school/informatik/verkerhssimulation/src/ogre/WIN32/OgreTimerImp.h new file mode 100644 index 00000000..022fc0ae --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/WIN32/OgreTimerImp.h @@ -0,0 +1,85 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Win32Timer_H__ +#define __Win32Timer_H__ + +#ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +#endif +#include "windows.h" + +//Get around Windows hackery +#ifdef max +# undef max +#endif +#ifdef min +# undef min +#endif + +#define FREQUENCY_RESAMPLE_RATE 200 + +namespace Ogre +{ + class _OgreExport Timer + { + private: + clock_t zeroClock; + + DWORD mStartTick; + LONGLONG mLastTime; + LARGE_INTEGER mStartTime; + LARGE_INTEGER mFrequency; + + DWORD mProcMask; + DWORD mSysMask; + + HANDLE mThread; + + DWORD mQueryCount; + public: + Timer(); + ~Timer(); + + /** Resets timer */ + void reset(); + + /** Returns milliseconds since initialisation or last reset */ + unsigned long getMilliseconds(); + + /** Returns microseconds since initialisation or last reset */ + unsigned long getMicroseconds(); + + /** Returns milliseconds since initialisation or last reset, only CPU time measured */ + unsigned long getMillisecondsCPU(); + + /** Returns microseconds since initialisation or last reset, only CPU time measured */ + unsigned long getMicrosecondsCPU(); + }; +} +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/asm_math.h b/school/informatik/verkerhssimulation/src/ogre/asm_math.h new file mode 100644 index 00000000..3379a861 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/asm_math.h @@ -0,0 +1,367 @@ +#ifndef __asm_math_H__ +#define __asm_math_H__ + +#include "OgrePrerequisites.h" + +namespace Ogre +{ + +/*============================================================================= + ASM math routines posted by davepermen et al on flipcode forums +=============================================================================*/ +const float pi = 4.0 * atan( 1.0 ); +const float half_pi = 0.5 * pi; + +/*============================================================================= + NO EXPLICIT RETURN REQUIRED FROM THESE METHODS!! +=============================================================================*/ +#if OGRE_COMPILER == OGRE_COMPILER_MSVC && OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32 +# pragma warning( push ) +# pragma warning( disable: 4035 ) +#endif + +float asm_arccos( float r ) { + // return half_pi + arctan( r / -sqr( 1.f - r * r ) ); + +#if OGRE_COMPILER == OGRE_COMPILER_MSVC && OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32 + + float asm_one = 1.f; + float asm_half_pi = half_pi; + __asm { + fld r // r0 = r + fld r // r1 = r0, r0 = r + fmul r // r0 = r0 * r + fsubr asm_one // r0 = r0 - 1.f + fsqrt // r0 = sqrtf( r0 ) + fchs // r0 = - r0 + fdiv // r0 = r1 / r0 + fld1 // {{ r0 = atan( r0 ) + fpatan // }} + fadd asm_half_pi // r0 = r0 + pi / 2 + } // returns r0 + +#else + + return float( acos( r ) ); + +#endif +} + +float asm_arcsin( float r ) { + // return arctan( r / sqr( 1.f - r * r ) ); + +#if OGRE_COMPILER == OGRE_COMPILER_MSVC && OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32 + + const float asm_one = 1.f; + __asm { + fld r // r0 = r + fld r // r1 = r0, r0 = r + fmul r // r0 = r0 * r + fsubr asm_one // r0 = r0 - 1.f + fsqrt // r0 = sqrtf( r0 ) + fdiv // r0 = r1 / r0 + fld1 // {{ r0 = atan( r0 ) + fpatan // }} + } // returns r0 + +#else + + return float( asin( r ) ); + +#endif + +} + +float asm_arctan( float r ) { + +#if OGRE_COMPILER == OGRE_COMPILER_MSVC && OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32 + + __asm { + fld r // r0 = r + fld1 // {{ r0 = atan( r0 ) + fpatan // }} + } // returns r0 + +#else + + return float( atan( r ) ); + +#endif + +} + +float asm_sin( float r ) { + +#if OGRE_COMPILER == OGRE_COMPILER_MSVC && OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32 + + __asm { + fld r // r0 = r + fsin // r0 = sinf( r0 ) + } // returns r0 + +#else + + return sin( r ); + +#endif + +} + +float asm_cos( float r ) { + +#if OGRE_COMPILER == OGRE_COMPILER_MSVC && OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32 + + __asm { + fld r // r0 = r + fcos // r0 = cosf( r0 ) + } // returns r0 + +#else + + return cos( r ); + +#endif +} + +float asm_tan( float r ) { + +#if OGRE_COMPILER == OGRE_COMPILER_MSVC && OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32 + + // return sin( r ) / cos( r ); + __asm { + fld r // r0 = r + fsin // r0 = sinf( r0 ) + fld r // r1 = r0, r0 = r + fcos // r0 = cosf( r0 ) + fdiv // r0 = r1 / r0 + } // returns r0 + +#else + + return tan( r ); + +#endif +} + +// returns a for a * a = r +float asm_sqrt( float r ) +{ +#if OGRE_COMPILER == OGRE_COMPILER_MSVC && OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32 + + __asm { + fld r // r0 = r + fsqrt // r0 = sqrtf( r0 ) + } // returns r0 + +#else + + return sqrt( r ); + +#endif +} + +// returns 1 / a for a * a = r +// -- Use this for Vector normalisation!!! +float asm_rsq( float r ) +{ +#if OGRE_COMPILER == OGRE_COMPILER_MSVC && OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32 + + __asm { + fld1 // r0 = 1.f + fld r // r1 = r0, r0 = r + fsqrt // r0 = sqrtf( r0 ) + fdiv // r0 = r1 / r0 + } // returns r0 + +#else + + return 1. / sqrt( r ); + +#endif +} + +// returns 1 / a for a * a = r +// Another version +float apx_rsq( float r ) { + +#if OGRE_COMPILER == OGRE_COMPILER_MSVC && OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32 + + const float asm_dot5 = 0.5f; + const float asm_1dot5 = 1.5f; + + __asm { + fld r // r0 = r + fmul asm_dot5 // r0 = r0 * .5f + mov eax, r // eax = r + shr eax, 0x1 // eax = eax >> 1 + neg eax // eax = -eax + add eax, 0x5F400000 // eax = eax & MAGICAL NUMBER + mov r, eax // r = eax + fmul r // r0 = r0 * r + fmul r // r0 = r0 * r + fsubr asm_1dot5 // r0 = 1.5f - r0 + fmul r // r0 = r0 * r + } // returns r0 + +#else + + return 1. / sqrt( r ); + +#endif +} + +/* very MS-specific, commented out for now + Finally the best InvSqrt implementation? + Use for vector normalisation instead of 1/length() * x,y,z +*/ +#if OGRE_COMPILER == OGRE_COMPILER_MSVC && OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32 + +__declspec(naked) float __fastcall InvSqrt(float fValue) +{ + __asm + { + mov eax, 0be6eb508h + mov dword ptr[esp-12],03fc00000h + sub eax, dword ptr[esp + 4] + sub dword ptr[esp+4], 800000h + shr eax, 1 + mov dword ptr[esp - 8], eax + + fld dword ptr[esp - 8] + fmul st, st + fld dword ptr[esp - 8] + fxch st(1) + fmul dword ptr[esp + 4] + fld dword ptr[esp - 12] + fld st(0) + fsub st,st(2) + + fld st(1) + fxch st(1) + fmul st(3),st + fmul st(3),st + fmulp st(4),st + fsub st,st(2) + + fmul st(2),st + fmul st(3),st + fmulp st(2),st + fxch st(1) + fsubp st(1),st + + fmulp st(1), st + ret 4 + } +} + +#endif + +// returns a random number +FORCEINLINE float asm_rand() +{ + +#if OGRE_COMPILER == OGRE_COMPILER_MSVC && OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32 + #if 0 + #if OGRE_COMP_VER >= 1300 + + static unsigned __int64 q = time( NULL ); + + _asm { + movq mm0, q + + // do the magic MMX thing + pshufw mm1, mm0, 0x1E + paddd mm0, mm1 + + // move to integer memory location and free MMX + movq q, mm0 + emms + } + + return float( q ); + #endif + #else + // VC6 does not support pshufw + return float( rand() ); + #endif +#else + // GCC etc + + return float( rand() ); + +#endif +} + +// returns the maximum random number +FORCEINLINE float asm_rand_max() +{ + +#if OGRE_COMPILER == OGRE_COMPILER_MSVC && OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32 + #if 0 + #if OGRE_COMP_VER >= 1300 + + return (std::numeric_limits< unsigned __int64 >::max)(); + return 9223372036854775807.0f; + #endif + #else + // VC6 does not support unsigned __int64 + return float( RAND_MAX ); + #endif + +#else + // GCC etc + return float( RAND_MAX ); + +#endif +} + +// returns log2( r ) / log2( e ) +float asm_ln( float r ) { + +#if OGRE_COMPILER == OGRE_COMPILER_MSVC && OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32 + + const float asm_e = 2.71828182846f; + const float asm_1_div_log2_e = .693147180559f; + const float asm_neg1_div_3 = -.33333333333333333333333333333f; + const float asm_neg2_div_3 = -.66666666666666666666666666667f; + const float asm_2 = 2.f; + + int log_2 = 0; + + __asm { + // log_2 = ( ( r >> 0x17 ) & 0xFF ) - 0x80; + mov eax, r + sar eax, 0x17 + and eax, 0xFF + sub eax, 0x80 + mov log_2, eax + + // r = ( r & 0x807fffff ) + 0x3f800000; + mov ebx, r + and ebx, 0x807FFFFF + add ebx, 0x3F800000 + mov r, ebx + + // r = ( asm_neg1_div_3 * r + asm_2 ) * r + asm_neg2_div_3; // (1) + fld r + fmul asm_neg1_div_3 + fadd asm_2 + fmul r + fadd asm_neg2_div_3 + fild log_2 + fadd + fmul asm_1_div_log2_e + } + +#else + + return log( r ); + +#endif +} + +#if OGRE_COMPILER == OGRE_COMPILER_MSVC && OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32 +# pragma warning( pop ) +#endif +} // namespace +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/lib/CEGUIBase.lib b/school/informatik/verkerhssimulation/src/ogre/lib/CEGUIBase.lib new file mode 100644 index 00000000..03d7b83f Binary files /dev/null and b/school/informatik/verkerhssimulation/src/ogre/lib/CEGUIBase.lib differ diff --git a/school/informatik/verkerhssimulation/src/ogre/lib/CEGUIBase_d.lib b/school/informatik/verkerhssimulation/src/ogre/lib/CEGUIBase_d.lib new file mode 100644 index 00000000..702cd645 Binary files /dev/null and b/school/informatik/verkerhssimulation/src/ogre/lib/CEGUIBase_d.lib differ diff --git a/school/informatik/verkerhssimulation/src/ogre/lib/OIS.lib b/school/informatik/verkerhssimulation/src/ogre/lib/OIS.lib new file mode 100644 index 00000000..87b33925 Binary files /dev/null and b/school/informatik/verkerhssimulation/src/ogre/lib/OIS.lib differ diff --git a/school/informatik/verkerhssimulation/src/ogre/lib/OIS_d.lib b/school/informatik/verkerhssimulation/src/ogre/lib/OIS_d.lib new file mode 100644 index 00000000..adcdc61a Binary files /dev/null and b/school/informatik/verkerhssimulation/src/ogre/lib/OIS_d.lib differ diff --git a/school/informatik/verkerhssimulation/src/ogre/lib/OgreGUIRenderer.lib b/school/informatik/verkerhssimulation/src/ogre/lib/OgreGUIRenderer.lib new file mode 100644 index 00000000..2c18ca8e Binary files /dev/null and b/school/informatik/verkerhssimulation/src/ogre/lib/OgreGUIRenderer.lib differ diff --git a/school/informatik/verkerhssimulation/src/ogre/lib/OgreGUIRenderer_d.lib b/school/informatik/verkerhssimulation/src/ogre/lib/OgreGUIRenderer_d.lib new file mode 100644 index 00000000..b6b80ad0 Binary files /dev/null and b/school/informatik/verkerhssimulation/src/ogre/lib/OgreGUIRenderer_d.lib differ diff --git a/school/informatik/verkerhssimulation/src/ogre/lib/OgreMain.lib b/school/informatik/verkerhssimulation/src/ogre/lib/OgreMain.lib new file mode 100644 index 00000000..16131bea Binary files /dev/null and b/school/informatik/verkerhssimulation/src/ogre/lib/OgreMain.lib differ diff --git a/school/informatik/verkerhssimulation/src/ogre/lib/OgreMain_d.lib b/school/informatik/verkerhssimulation/src/ogre/lib/OgreMain_d.lib new file mode 100644 index 00000000..80a0c41f Binary files /dev/null and b/school/informatik/verkerhssimulation/src/ogre/lib/OgreMain_d.lib differ diff --git a/school/informatik/verkerhssimulation/src/ogre/lib/ode.lib b/school/informatik/verkerhssimulation/src/ogre/lib/ode.lib new file mode 100644 index 00000000..129dbfae Binary files /dev/null and b/school/informatik/verkerhssimulation/src/ogre/lib/ode.lib differ diff --git a/school/informatik/verkerhssimulation/src/ogre/lib/opt/Plugin_BSPSceneManager.lib b/school/informatik/verkerhssimulation/src/ogre/lib/opt/Plugin_BSPSceneManager.lib new file mode 100644 index 00000000..4718b0a8 Binary files /dev/null and b/school/informatik/verkerhssimulation/src/ogre/lib/opt/Plugin_BSPSceneManager.lib differ diff --git a/school/informatik/verkerhssimulation/src/ogre/lib/opt/Plugin_BSPSceneManager_d.lib b/school/informatik/verkerhssimulation/src/ogre/lib/opt/Plugin_BSPSceneManager_d.lib new file mode 100644 index 00000000..8a2927bd Binary files /dev/null and b/school/informatik/verkerhssimulation/src/ogre/lib/opt/Plugin_BSPSceneManager_d.lib differ diff --git a/school/informatik/verkerhssimulation/src/ogre/lib/opt/Plugin_OctreeSceneManager.lib b/school/informatik/verkerhssimulation/src/ogre/lib/opt/Plugin_OctreeSceneManager.lib new file mode 100644 index 00000000..fc1240d9 Binary files /dev/null and b/school/informatik/verkerhssimulation/src/ogre/lib/opt/Plugin_OctreeSceneManager.lib differ diff --git a/school/informatik/verkerhssimulation/src/ogre/lib/opt/Plugin_OctreeSceneManager_d.lib b/school/informatik/verkerhssimulation/src/ogre/lib/opt/Plugin_OctreeSceneManager_d.lib new file mode 100644 index 00000000..64daeb55 Binary files /dev/null and b/school/informatik/verkerhssimulation/src/ogre/lib/opt/Plugin_OctreeSceneManager_d.lib differ diff --git a/school/informatik/verkerhssimulation/src/ogre/lib/opt/Plugin_ParticleFX.lib b/school/informatik/verkerhssimulation/src/ogre/lib/opt/Plugin_ParticleFX.lib new file mode 100644 index 00000000..2784fbd0 Binary files /dev/null and b/school/informatik/verkerhssimulation/src/ogre/lib/opt/Plugin_ParticleFX.lib differ diff --git a/school/informatik/verkerhssimulation/src/ogre/lib/opt/Plugin_ParticleFX_d.lib b/school/informatik/verkerhssimulation/src/ogre/lib/opt/Plugin_ParticleFX_d.lib new file mode 100644 index 00000000..3f30568e Binary files /dev/null and b/school/informatik/verkerhssimulation/src/ogre/lib/opt/Plugin_ParticleFX_d.lib differ diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/collision.h b/school/informatik/verkerhssimulation/src/ogre/ode/collision.h new file mode 100644 index 00000000..fdb8c792 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/collision.h @@ -0,0 +1,1379 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +#ifndef _ODE_COLLISION_H_ +#define _ODE_COLLISION_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup collide Collision Detection + * + * ODE has two main components: a dynamics simulation engine and a collision + * detection engine. The collision engine is given information about the + * shape of each body. At each time step it figures out which bodies touch + * each other and passes the resulting contact point information to the user. + * The user in turn creates contact joints between bodies. + * + * Using ODE's collision detection is optional - an alternative collision + * detection system can be used as long as it can supply the right kinds of + * contact information. + */ + + +/* ************************************************************************ */ +/* general functions */ + +/** + * @brief Destroy a geom, removing it from any space. + * + * Destroy a geom, removing it from any space it is in first. This one + * function destroys a geom of any type, but to create a geom you must call + * a creation function for that type. + * + * When a space is destroyed, if its cleanup mode is 1 (the default) then all + * the geoms in that space are automatically destroyed as well. + * + * @param geom the geom to be destroyed. + * @ingroup collide + */ +ODE_API void dGeomDestroy (dGeomID geom); + + +/** + * @brief Set the user-defined data pointer stored in the geom. + * + * @param geom the geom to hold the data + * @param data the data pointer to be stored + * @ingroup collide + */ +ODE_API void dGeomSetData (dGeomID geom, void* data); + + +/** + * @brief Get the user-defined data pointer stored in the geom. + * + * @param geom the geom containing the data + * @ingroup collide + */ +ODE_API void *dGeomGetData (dGeomID geom); + + +/** + * @brief Set the body associated with a placeable geom. + * + * Setting a body on a geom automatically combines the position vector and + * rotation matrix of the body and geom, so that setting the position or + * orientation of one will set the value for both objects. Setting a body + * ID of zero gives the geom its own position and rotation, independent + * from any body. If the geom was previously connected to a body then its + * new independent position/rotation is set to the current position/rotation + * of the body. + * + * Calling these functions on a non-placeable geom results in a runtime + * error in the debug build of ODE. + * + * @param geom the geom to connect + * @param body the body to attach to the geom + * @ingroup collide + */ +ODE_API void dGeomSetBody (dGeomID geom, dBodyID body); + + +/** + * @brief Get the body associated with a placeable geom. + * @param geom the geom to query. + * @sa dGeomSetBody + * @ingroup collide + */ +ODE_API dBodyID dGeomGetBody (dGeomID geom); + + +/** + * @brief Set the position vector of a placeable geom. + * + * If the geom is attached to a body, the body's position will also be changed. + * Calling this function on a non-placeable geom results in a runtime error in + * the debug build of ODE. + * + * @param geom the geom to set. + * @param x the new X coordinate. + * @param y the new Y coordinate. + * @param z the new Z coordinate. + * @sa dBodySetPosition + * @ingroup collide + */ +ODE_API void dGeomSetPosition (dGeomID geom, dReal x, dReal y, dReal z); + + +/** + * @brief Set the rotation matrix of a placeable geom. + * + * If the geom is attached to a body, the body's rotation will also be changed. + * Calling this function on a non-placeable geom results in a runtime error in + * the debug build of ODE. + * + * @param geom the geom to set. + * @param R the new rotation matrix. + * @sa dBodySetRotation + * @ingroup collide + */ +ODE_API void dGeomSetRotation (dGeomID geom, const dMatrix3 R); + + +/** + * @brief Set the rotation of a placeable geom. + * + * If the geom is attached to a body, the body's rotation will also be changed. + * + * Calling this function on a non-placeable geom results in a runtime error in + * the debug build of ODE. + * + * @param geom the geom to set. + * @param Q the new rotation. + * @sa dBodySetQuaternion + * @ingroup collide + */ +ODE_API void dGeomSetQuaternion (dGeomID geom, const dQuaternion Q); + + +/** + * @brief Get the position vector of a placeable geom. + * + * If the geom is attached to a body, the body's position will be returned. + * + * Calling this function on a non-placeable geom results in a runtime error in + * the debug build of ODE. + * + * @param geom the geom to query. + * @returns A pointer to the geom's position vector. + * @remarks The returned value is a pointer to the geom's internal + * data structure. It is valid until any changes are made + * to the geom. + * @sa dBodyGetPosition + * @ingroup collide + */ +ODE_API const dReal * dGeomGetPosition (dGeomID geom); + + +/** + * @brief Copy the position of a geom into a vector. + * @ingroup collide + * @param geom the geom to query + * @param pos a copy of the geom position + * @sa dGeomGetPosition + */ +ODE_API void dGeomCopyPosition (dGeomID geom, dVector3 pos); + + +/** + * @brief Get the rotation matrix of a placeable geom. + * + * If the geom is attached to a body, the body's rotation will be returned. + * + * Calling this function on a non-placeable geom results in a runtime error in + * the debug build of ODE. + * + * @param geom the geom to query. + * @returns A pointer to the geom's rotation matrix. + * @remarks The returned value is a pointer to the geom's internal + * data structure. It is valid until any changes are made + * to the geom. + * @sa dBodyGetRotation + * @ingroup collide + */ +ODE_API const dReal * dGeomGetRotation (dGeomID geom); + + +/** + * @brief Get the rotation matrix of a placeable geom. + * + * If the geom is attached to a body, the body's rotation will be returned. + * + * Calling this function on a non-placeable geom results in a runtime error in + * the debug build of ODE. + * + * @param geom the geom to query. + * @param R a copy of the geom rotation + * @sa dGeomGetRotation + * @ingroup collide + */ +ODE_API void dGeomCopyRotation(dGeomID geom, dMatrix3 R); + + +/** + * @brief Get the rotation quaternion of a placeable geom. + * + * If the geom is attached to a body, the body's quaternion will be returned. + * + * Calling this function on a non-placeable geom results in a runtime error in + * the debug build of ODE. + * + * @param geom the geom to query. + * @param result a copy of the rotation quaternion. + * @sa dBodyGetQuaternion + * @ingroup collide + */ +ODE_API void dGeomGetQuaternion (dGeomID geom, dQuaternion result); + + +/** + * @brief Return the axis-aligned bounding box. + * + * Return in aabb an axis aligned bounding box that surrounds the given geom. + * The aabb array has elements (minx, maxx, miny, maxy, minz, maxz). If the + * geom is a space, a bounding box that surrounds all contained geoms is + * returned. + * + * This function may return a pre-computed cached bounding box, if it can + * determine that the geom has not moved since the last time the bounding + * box was computed. + * + * @param geom the geom to query + * @param aabb the returned bounding box + * @ingroup collide + */ +ODE_API void dGeomGetAABB (dGeomID geom, dReal aabb[6]); + + +/** + * @brief Determing if a geom is a space. + * @param geom the geom to query + * @returns Non-zero if the geom is a space, zero otherwise. + * @ingroup collide + */ +ODE_API int dGeomIsSpace (dGeomID geom); + + +/** + * @brief Query for the space containing a particular geom. + * @param geom the geom to query + * @returns The space that contains the geom, or NULL if the geom is + * not contained by a space. + * @ingroup collide + */ +ODE_API dSpaceID dGeomGetSpace (dGeomID); + + +/** + * @brief Given a geom, this returns its class. + * + * The ODE classes are: + * @li dSphereClass + * @li dBoxClass + * @li dCylinderClass + * @li dPlaneClass + * @li dRayClass + * @li dConvexClass + * @li dGeomTransformClass + * @li dTriMeshClass + * @li dSimpleSpaceClass + * @li dHashSpaceClass + * @li dQuadTreeSpaceClass + * @li dFirstUserClass + * @li dLastUserClass + * + * User-defined class will return their own number. + * + * @param geom the geom to query + * @returns The geom class ID. + * @ingroup collide + */ +ODE_API int dGeomGetClass (dGeomID geom); + + +/** + * @brief Set the "category" bitfield for the given geom. + * + * The category bitfield is used by spaces to govern which geoms will + * interact with each other. The bitfield is guaranteed to be at least + * 32 bits wide. The default category values for newly created geoms + * have all bits set. + * + * @param geom the geom to set + * @param bits the new bitfield value + * @ingroup collide + */ +ODE_API void dGeomSetCategoryBits (dGeomID geom, unsigned long bits); + + +/** + * @brief Set the "collide" bitfield for the given geom. + * + * The collide bitfield is used by spaces to govern which geoms will + * interact with each other. The bitfield is guaranteed to be at least + * 32 bits wide. The default category values for newly created geoms + * have all bits set. + * + * @param geom the geom to set + * @param bits the new bitfield value + * @ingroup collide + */ +ODE_API void dGeomSetCollideBits (dGeomID geom, unsigned long bits); + + +/** + * @brief Get the "category" bitfield for the given geom. + * + * @param geom the geom to set + * @param bits the new bitfield value + * @sa dGeomSetCategoryBits + * @ingroup collide + */ +ODE_API unsigned long dGeomGetCategoryBits (dGeomID); + + +/** + * @brief Get the "collide" bitfield for the given geom. + * + * @param geom the geom to set + * @param bits the new bitfield value + * @sa dGeomSetCollideBits + * @ingroup collide + */ +ODE_API unsigned long dGeomGetCollideBits (dGeomID); + + +/** + * @brief Enable a geom. + * + * Disabled geoms are completely ignored by dSpaceCollide and dSpaceCollide2, + * although they can still be members of a space. New geoms are created in + * the enabled state. + * + * @param geom the geom to enable + * @sa dGeomDisable + * @sa dGeomIsEnabled + * @ingroup collide + */ +ODE_API void dGeomEnable (dGeomID geom); + + +/** + * @brief Disable a geom. + * + * Disabled geoms are completely ignored by dSpaceCollide and dSpaceCollide2, + * although they can still be members of a space. New geoms are created in + * the enabled state. + * + * @param geom the geom to disable + * @sa dGeomDisable + * @sa dGeomIsEnabled + * @ingroup collide + */ +ODE_API void dGeomDisable (dGeomID geom); + + +/** + * @brief Check to see if a geom is enabled. + * + * Disabled geoms are completely ignored by dSpaceCollide and dSpaceCollide2, + * although they can still be members of a space. New geoms are created in + * the enabled state. + * + * @param geom the geom to query + * @returns Non-zero if the geom is enabled, zero otherwise. + * @sa dGeomDisable + * @sa dGeomIsEnabled + * @ingroup collide + */ +ODE_API int dGeomIsEnabled (dGeomID geom); + +/* ************************************************************************ */ +/* geom offset from body */ + +/** + * @brief Set the local offset position of a geom from its body. + * + * Sets the geom's positional offset in local coordinates. + * After this call, the geom will be at a new position determined from the + * body's position and the offset. + * The geom must be attached to a body. + * If the geom did not have an offset, it is automatically created. + * + * @param geom the geom to set. + * @param x the new X coordinate. + * @param y the new Y coordinate. + * @param z the new Z coordinate. + * @ingroup collide + */ +ODE_API void dGeomSetOffsetPosition (dGeomID geom, dReal x, dReal y, dReal z); + + +/** + * @brief Set the local offset rotation matrix of a geom from its body. + * + * Sets the geom's rotational offset in local coordinates. + * After this call, the geom will be at a new position determined from the + * body's position and the offset. + * The geom must be attached to a body. + * If the geom did not have an offset, it is automatically created. + * + * @param geom the geom to set. + * @param R the new rotation matrix. + * @ingroup collide + */ +ODE_API void dGeomSetOffsetRotation (dGeomID geom, const dMatrix3 R); + + +/** + * @brief Set the local offset rotation of a geom from its body. + * + * Sets the geom's rotational offset in local coordinates. + * After this call, the geom will be at a new position determined from the + * body's position and the offset. + * The geom must be attached to a body. + * If the geom did not have an offset, it is automatically created. + * + * @param geom the geom to set. + * @param Q the new rotation. + * @ingroup collide + */ +ODE_API void dGeomSetOffsetQuaternion (dGeomID geom, const dQuaternion Q); + + +/** + * @brief Set the offset position of a geom from its body. + * + * Sets the geom's positional offset to move it to the new world + * coordinates. + * After this call, the geom will be at the world position passed in, + * and the offset will be the difference from the current body position. + * The geom must be attached to a body. + * If the geom did not have an offset, it is automatically created. + * + * @param geom the geom to set. + * @param x the new X coordinate. + * @param y the new Y coordinate. + * @param z the new Z coordinate. + * @ingroup collide + */ +ODE_API void dGeomSetOffsetWorldPosition (dGeomID geom, dReal x, dReal y, dReal z); + + +/** + * @brief Set the offset rotation of a geom from its body. + * + * Sets the geom's rotational offset to orient it to the new world + * rotation matrix. + * After this call, the geom will be at the world orientation passed in, + * and the offset will be the difference from the current body orientation. + * The geom must be attached to a body. + * If the geom did not have an offset, it is automatically created. + * + * @param geom the geom to set. + * @param R the new rotation matrix. + * @ingroup collide + */ +ODE_API void dGeomSetOffsetWorldRotation (dGeomID geom, const dMatrix3 R); + + +/** + * @brief Set the offset rotation of a geom from its body. + * + * Sets the geom's rotational offset to orient it to the new world + * rotation matrix. + * After this call, the geom will be at the world orientation passed in, + * and the offset will be the difference from the current body orientation. + * The geom must be attached to a body. + * If the geom did not have an offset, it is automatically created. + * + * @param geom the geom to set. + * @param Q the new rotation. + * @ingroup collide + */ +ODE_API void dGeomSetOffsetWorldQuaternion (dGeomID geom, const dQuaternion); + + +/** + * @brief Clear any offset from the geom. + * + * If the geom has an offset, it is eliminated and the geom is + * repositioned at the body's position. If the geom has no offset, + * this function does nothing. + * This is more efficient than calling dGeomSetOffsetPosition(zero) + * and dGeomSetOffsetRotation(identiy), because this function actually + * eliminates the offset, rather than leaving it as the identity transform. + * + * @param geom the geom to have its offset destroyed. + * @ingroup collide + */ +ODE_API void dGeomClearOffset(dGeomID geom); + + +/** + * @brief Check to see whether the geom has an offset. + * + * This function will return non-zero if the offset has been created. + * Note that there is a difference between a geom with no offset, + * and a geom with an offset that is the identity transform. + * In the latter case, although the observed behaviour is identical, + * there is a unnecessary computation involved because the geom will + * be applying the transform whenever it needs to recalculate its world + * position. + * + * @param geom the geom to query. + * @returns Non-zero if the geom has an offset, zero otherwise. + * @ingroup collide + */ +ODE_API int dGeomIsOffset(dGeomID geom); + + +/** + * @brief Get the offset position vector of a geom. + * + * Returns the positional offset of the geom in local coordinates. + * If the geom has no offset, this function returns the zero vector. + * + * @param geom the geom to query. + * @returns A pointer to the geom's offset vector. + * @remarks The returned value is a pointer to the geom's internal + * data structure. It is valid until any changes are made + * to the geom. + * @ingroup collide + */ +ODE_API const dReal * dGeomGetOffsetPosition (dGeomID geom); + + +/** + * @brief Copy the offset position vector of a geom. + * + * Returns the positional offset of the geom in local coordinates. + * If the geom has no offset, this function returns the zero vector. + * + * @param geom the geom to query. + * @param pos returns the offset position + * @ingroup collide + */ +ODE_API void dGeomCopyOffsetPosition (dGeomID geom, dVector3 pos); + + +/** + * @brief Get the offset rotation matrix of a geom. + * + * Returns the rotational offset of the geom in local coordinates. + * If the geom has no offset, this function returns the identity + * matrix. + * + * @param geom the geom to query. + * @returns A pointer to the geom's offset rotation matrix. + * @remarks The returned value is a pointer to the geom's internal + * data structure. It is valid until any changes are made + * to the geom. + * @ingroup collide + */ +ODE_API const dReal * dGeomGetOffsetRotation (dGeomID geom); + + +/** + * @brief Copy the offset rotation matrix of a geom. + * + * Returns the rotational offset of the geom in local coordinates. + * If the geom has no offset, this function returns the identity + * matrix. + * + * @param geom the geom to query. + * @param R returns the rotation matrix. + * @ingroup collide + */ +ODE_API void dGeomCopyOffsetRotation (dGeomID geom, dMatrix3 R); + + +/** + * @brief Get the offset rotation quaternion of a geom. + * + * Returns the rotation offset of the geom as a quaternion. + * If the geom has no offset, the identity quaternion is returned. + * + * @param geom the geom to query. + * @param result a copy of the rotation quaternion. + * @ingroup collide + */ +ODE_API void dGeomGetOffsetQuaternion (dGeomID geom, dQuaternion result); + + +/* ************************************************************************ */ +/* collision detection */ + +/** + * + * @brief Given two geoms o1 and o2 that potentially intersect, + * generate contact information for them. + * + * Internally, this just calls the correct class-specific collision + * functions for o1 and o2. + * + * @param o1 The first geom to test. + * @param o2 The second geom to test. + * + * @param flags The flags specify how contacts should be generated if + * the geoms touch. The lower 16 bits of flags is an integer that + * specifies the maximum number of contact points to generate. Note + * that if this number is zero, this function just pretends that it is + * one -- in other words you can not ask for zero contacts. All other bits + * in flags must be zero. In the future the other bits may be used to + * select from different contact generation strategies. + * + * @param contact Points to an array of dContactGeom structures. The array + * must be able to hold at least the maximum number of contacts. These + * dContactGeom structures may be embedded within larger structures in the + * array -- the skip parameter is the byte offset from one dContactGeom to + * the next in the array. If skip is sizeof(dContactGeom) then contact + * points to a normal (C-style) array. It is an error for skip to be smaller + * than sizeof(dContactGeom). + * + * @returns If the geoms intersect, this function returns the number of contact + * points generated (and updates the contact array), otherwise it returns 0 + * (and the contact array is not touched). + * + * @remarks If a space is passed as o1 or o2 then this function will collide + * all objects contained in o1 with all objects contained in o2, and return + * the resulting contact points. This method for colliding spaces with geoms + * (or spaces with spaces) provides no user control over the individual + * collisions. To get that control, use dSpaceCollide or dSpaceCollide2 instead. + * + * @remarks If o1 and o2 are the same geom then this function will do nothing + * and return 0. Technically speaking an object intersects with itself, but it + * is not useful to find contact points in this case. + * + * @remarks This function does not care if o1 and o2 are in the same space or not + * (or indeed if they are in any space at all). + * + * @ingroup collide + */ +ODE_API int dCollide (dGeomID o1, dGeomID o2, int flags, dContactGeom *contact, + int skip); + +/** + * @brief Determines which pairs of geoms in a space may potentially intersect, + * and calls the callback function for each candidate pair. + * + * @param space The space to test. + * + * @param data Passed from dSpaceCollide directly to the callback + * function. Its meaning is user defined. The o1 and o2 arguments are the + * geoms that may be near each other. + * + * @param callback A callback function is of type @ref dNearCallback. + * + * @remarks Other spaces that are contained within the colliding space are + * not treated specially, i.e. they are not recursed into. The callback + * function may be passed these contained spaces as one or both geom + * arguments. + * + * @remarks dSpaceCollide() is guaranteed to pass all intersecting geom + * pairs to the callback function, but may also pass close but + * non-intersecting pairs. The number of these calls depends on the + * internal algorithms used by the space. Thus you should not expect + * that dCollide will return contacts for every pair passed to the + * callback. + * + * @sa dSpaceCollide2 + * @ingroup collide + */ +ODE_API void dSpaceCollide (dSpaceID space, void *data, dNearCallback *callback); + + +/** + * @brief Determines which geoms from one space may potentially intersect with + * geoms from another space, and calls the callback function for each candidate + * pair. + * + * @param space1 The first space to test. + * + * @param space2 The second space to test. + * + * @param data Passed from dSpaceCollide directly to the callback + * function. Its meaning is user defined. The o1 and o2 arguments are the + * geoms that may be near each other. + * + * @param callback A callback function is of type @ref dNearCallback. + * + * @remarks This function can also test a single non-space geom against a + * space. This function is useful when there is a collision hierarchy, i.e. + * when there are spaces that contain other spaces. + * + * @remarks Other spaces that are contained within the colliding space are + * not treated specially, i.e. they are not recursed into. The callback + * function may be passed these contained spaces as one or both geom + * arguments. + * + * @remarks dSpaceCollide2() is guaranteed to pass all intersecting geom + * pairs to the callback function, but may also pass close but + * non-intersecting pairs. The number of these calls depends on the + * internal algorithms used by the space. Thus you should not expect + * that dCollide will return contacts for every pair passed to the + * callback. + * + * @sa dSpaceCollide + * @ingroup collide + */ +ODE_API void dSpaceCollide2 (dGeomID space1, dGeomID space2, void *data, dNearCallback *callback); + + +/* ************************************************************************ */ +/* standard classes */ + +/* the maximum number of user classes that are supported */ +enum { + dMaxUserClasses = 4 +}; + +/* class numbers - each geometry object needs a unique number */ +enum { + dSphereClass = 0, + dBoxClass, + dCapsuleClass, + dCylinderClass, + dPlaneClass, + dRayClass, + dConvexClass, + dGeomTransformClass, + dTriMeshClass, + dHeightfieldClass, + + dFirstSpaceClass, + dSimpleSpaceClass = dFirstSpaceClass, + dHashSpaceClass, + dQuadTreeSpaceClass, + dLastSpaceClass = dQuadTreeSpaceClass, + + dFirstUserClass, + dLastUserClass = dFirstUserClass + dMaxUserClasses - 1, + dGeomNumClasses +}; + + +/** + * @defgroup collide_sphere Sphere Class + * @ingroup collide + */ + +/** + * @brief Create a sphere geom of the given radius, and return its ID. + * + * @param space a space to contain the new geom. May be null. + * @param radius the radius of the sphere. + * + * @returns A new sphere geom. + * + * @remarks The point of reference for a sphere is its center. + * + * @sa dGeomDestroy + * @sa dGeomSphereSetRadius + * @ingroup collide_sphere + */ +ODE_API dGeomID dCreateSphere (dSpaceID space, dReal radius); + + +/** + * @brief Set the radius of a sphere geom. + * + * @param sphere the sphere to set. + * @param radius the new radius. + * + * @sa dGeomSphereGetRadius + * @ingroup collide_sphere + */ +ODE_API void dGeomSphereSetRadius (dGeomID sphere, dReal radius); + + +/** + * @brief Retrieves the radius of a sphere geom. + * + * @param sphere the sphere to query. + * + * @sa dGeomSphereSetRadius + * @ingroup collide_sphere + */ +ODE_API dReal dGeomSphereGetRadius (dGeomID sphere); + + +/** + * @brief Calculate the depth of the a given point within a sphere. + * + * @param sphere the sphere to query. + * @param x the X coordinate of the point. + * @param y the Y coordinate of the point. + * @param z the Z coordinate of the point. + * + * @returns The depth of the point. Points inside the sphere will have a + * positive depth, points outside it will have a negative depth, and points + * on the surface will have a depth of zero. + * + * @ingroup collide_sphere + */ +ODE_API dReal dGeomSpherePointDepth (dGeomID sphere, dReal x, dReal y, dReal z); + + +//--> Convex Functions +ODE_API dGeomID dCreateConvex (dSpaceID space, + dReal *_planes, + unsigned int _planecount, + dReal *_points, + unsigned int _pointcount,unsigned int *_polygons); + +ODE_API void dGeomSetConvex (dGeomID g, + dReal *_planes, + unsigned int _count, + dReal *_points, + unsigned int _pointcount,unsigned int *_polygons); +//<-- Convex Functions + +/** + * @defgroup collide_box Box Class + * @ingroup collide + */ + +/** + * @brief Create a box geom with the provided side lengths. + * + * @param space a space to contain the new geom. May be null. + * @param lx the length of the box along the X axis + * @param ly the length of the box along the Y axis + * @param lz the length of the box along the Z axis + * + * @returns A new box geom. + * + * @remarks The point of reference for a box is its center. + * + * @sa dGeomDestroy + * @sa dGeomBoxSetLengths + * @ingroup collide_box + */ +ODE_API dGeomID dCreateBox (dSpaceID space, dReal lx, dReal ly, dReal lz); + + +/** + * @brief Set the side lengths of the given box. + * + * @param box the box to set + * @param lx the length of the box along the X axis + * @param ly the length of the box along the Y axis + * @param lz the length of the box along the Z axis + * + * @sa dGeomBoxGetLengths + * @ingroup collide_box + */ +ODE_API void dGeomBoxSetLengths (dGeomID box, dReal lx, dReal ly, dReal lz); + + +/** + * @brief Get the side lengths of a box. + * + * @param box the box to query + * @param result the returned side lengths + * + * @sa dGeomBoxSetLengths + * @ingroup collide_box + */ +ODE_API void dGeomBoxGetLengths (dGeomID box, dVector3 result); + + +/** + * @brief Return the depth of a point in a box. + * + * @param box the box to query + * @param x the X coordinate of the point to test. + * @param y the Y coordinate of the point to test. + * @param z the Z coordinate of the point to test. + * + * @returns The depth of the point. Points inside the box will have a + * positive depth, points outside it will have a negative depth, and points + * on the surface will have a depth of zero. + */ +ODE_API dReal dGeomBoxPointDepth (dGeomID box, dReal x, dReal y, dReal z); + + +ODE_API dGeomID dCreatePlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d); +ODE_API void dGeomPlaneSetParams (dGeomID plane, dReal a, dReal b, dReal c, dReal d); +ODE_API void dGeomPlaneGetParams (dGeomID plane, dVector4 result); +ODE_API dReal dGeomPlanePointDepth (dGeomID plane, dReal x, dReal y, dReal z); + +ODE_API dGeomID dCreateCapsule (dSpaceID space, dReal radius, dReal length); +ODE_API void dGeomCapsuleSetParams (dGeomID ccylinder, dReal radius, dReal length); +ODE_API void dGeomCapsuleGetParams (dGeomID ccylinder, dReal *radius, dReal *length); +ODE_API dReal dGeomCapsulePointDepth (dGeomID ccylinder, dReal x, dReal y, dReal z); + +// For now we want to have a backwards compatible C-API, note: C++ API is not. +#define dCreateCCylinder dCreateCapsule +#define dGeomCCylinderSetParams dGeomCapsuleSetParams +#define dGeomCCylinderGetParams dGeomCapsuleGetParams +#define dGeomCCylinderPointDepth dGeomCapsulePointDepth +#define dCCylinderClass dCapsuleClass + +ODE_API dGeomID dCreateCylinder (dSpaceID space, dReal radius, dReal length); +ODE_API void dGeomCylinderSetParams (dGeomID cylinder, dReal radius, dReal length); +ODE_API void dGeomCylinderGetParams (dGeomID cylinder, dReal *radius, dReal *length); + +ODE_API dGeomID dCreateRay (dSpaceID space, dReal length); +ODE_API void dGeomRaySetLength (dGeomID ray, dReal length); +ODE_API dReal dGeomRayGetLength (dGeomID ray); +ODE_API void dGeomRaySet (dGeomID ray, dReal px, dReal py, dReal pz, + dReal dx, dReal dy, dReal dz); +ODE_API void dGeomRayGet (dGeomID ray, dVector3 start, dVector3 dir); + +/* + * Set/get ray flags that influence ray collision detection. + * These flags are currently only noticed by the trimesh collider, because + * they can make a major differences there. + */ +ODE_API void dGeomRaySetParams (dGeomID g, int FirstContact, int BackfaceCull); +ODE_API void dGeomRayGetParams (dGeomID g, int *FirstContact, int *BackfaceCull); +ODE_API void dGeomRaySetClosestHit (dGeomID g, int closestHit); +ODE_API int dGeomRayGetClosestHit (dGeomID g); + +#include "collision_trimesh.h" + +ODE_API dGeomID dCreateGeomTransform (dSpaceID space); +ODE_API void dGeomTransformSetGeom (dGeomID g, dGeomID obj); +ODE_API dGeomID dGeomTransformGetGeom (dGeomID g); +ODE_API void dGeomTransformSetCleanup (dGeomID g, int mode); +ODE_API int dGeomTransformGetCleanup (dGeomID g); +ODE_API void dGeomTransformSetInfo (dGeomID g, int mode); +ODE_API int dGeomTransformGetInfo (dGeomID g); + + +/* ************************************************************************ */ +/* heightfield functions */ + + +// Data storage for heightfield data. +struct dxHeightfieldData; +typedef struct dxHeightfieldData* dHeightfieldDataID; + + +/** + * @brief Callback prototype + * + * Used by the callback heightfield data type to sample a height for a + * given cell position. + * + * @param p_user_data User data specified when creating the dHeightfieldDataID + * @param x The index of a sample in the local x axis. It is a value + * in the range zero to ( nWidthSamples - 1 ). + * @param x The index of a sample in the local z axis. It is a value + * in the range zero to ( nDepthSamples - 1 ). + * + * @return The sample height which is then scaled and offset using the + * values specified when the heightfield data was created. + * + * @ingroup collide + */ +typedef dReal dHeightfieldGetHeight( void* p_user_data, int x, int z ); + + + +/** + * @brief Creates a heightfield geom. + * + * Uses the information in the given dHeightfieldDataID to construct + * a geom representing a heightfield in a collision space. + * + * @param space The space to add the geom to. + * @param data The dHeightfieldDataID created by dGeomHeightfieldDataCreate and + * setup by dGeomHeightfieldDataBuildCallback, dGeomHeightfieldDataBuildByte, + * dGeomHeightfieldDataBuildShort or dGeomHeightfieldDataBuildFloat. + * @param bPlaceable If non-zero this geom can be transformed in the world using the + * usual functions such as dGeomSetPosition and dGeomSetRotation. If the geom is + * not set as placeable, then it uses a fixed orientation where the global y axis + * represents the dynamic 'height' of the heightfield. + * + * @return A geom id to reference this geom in other calls. + * + * @ingroup collide + */ +ODE_API dGeomID dCreateHeightfield( dSpaceID space, + dHeightfieldDataID data, int bPlaceable ); + + +/** + * @brief Creates a new empty dHeightfieldDataID. + * + * Allocates a new dHeightfieldDataID and returns it. You must call + * dGeomHeightfieldDataDestroy to destroy it after the geom has been removed. + * The dHeightfieldDataID value is used when specifying a data format type. + * + * @return A dHeightfieldDataID for use with dGeomHeightfieldDataBuildCallback, + * dGeomHeightfieldDataBuildByte, dGeomHeightfieldDataBuildShort or + * dGeomHeightfieldDataBuildFloat. + * @ingroup collide + */ +ODE_API dHeightfieldDataID dGeomHeightfieldDataCreate(); + + +/** + * @brief Destroys a dHeightfieldDataID. + * + * Deallocates a given dHeightfieldDataID and all managed resources. + * + * @param d A dHeightfieldDataID created by dGeomHeightfieldDataCreate + * @ingroup collide + */ +ODE_API void dGeomHeightfieldDataDestroy( dHeightfieldDataID d ); + + + +/** + * @brief Configures a dHeightfieldDataID to use a callback to + * retrieve height data. + * + * Before a dHeightfieldDataID can be used by a geom it must be + * configured to specify the format of the height data. + * This call specifies that the heightfield data is computed by + * the user and it should use the given callback when determining + * the height of a given element of it's shape. + * + * @param d A new dHeightfieldDataID created by dGeomHeightfieldDataCreate + * + * @param width Specifies the total 'width' of the heightfield along + * the geom's local x axis. + * @param depth Specifies the total 'depth' of the heightfield along + * the geom's local z axis. + * + * @param widthSamples Specifies the number of vertices to sample + * along the width of the heightfield. Each vertex has a corresponding + * height value which forms the overall shape. + * Naturally this value must be at least two or more. + * @param depthSamples Specifies the number of vertices to sample + * along the depth of the heightfield. + * + * @param scale A uniform scale applied to all raw height data. + * @param offset An offset applied to the scaled height data. + * + * @param thickness A value subtracted from the lowest height + * value which in effect adds an additional cuboid to the base of the + * heightfield. This is used to prevent geoms from looping under the + * desired terrain and not registering as a collision. Note that the + * thickness is not affected by the scale or offset parameters. + * + * @param bWrap If non-zero the heightfield will infinitely tile in both + * directions along the local x and z axes. If zero the heightfield is + * bounded from zero to width in the local x axis, and zero to depth in + * the local z axis. + * + * @ingroup collide + */ +ODE_API void dGeomHeightfieldDataBuildCallback( dHeightfieldDataID d, + void* pUserData, dHeightfieldGetHeight* pCallback, + dReal width, dReal depth, int widthSamples, int depthSamples, + dReal scale, dReal offset, dReal thickness, int bWrap ); + +/** + * @brief Configures a dHeightfieldDataID to use height data in byte format. + * + * Before a dHeightfieldDataID can be used by a geom it must be + * configured to specify the format of the height data. + * This call specifies that the heightfield data is stored as a rectangular + * array of bytes (8 bit unsigned) representing the height at each sample point. + * + * @param d A new dHeightfieldDataID created by dGeomHeightfieldDataCreate + * + * @param pHeightData A pointer to the height data. + * @param bCopyHeightData When non-zero the height data is copied to an + * internal store. When zero the height data is accessed by reference and + * so must persist throughout the lifetime of the heightfield. + * + * @param width Specifies the total 'width' of the heightfield along + * the geom's local x axis. + * @param depth Specifies the total 'depth' of the heightfield along + * the geom's local z axis. + * + * @param widthSamples Specifies the number of vertices to sample + * along the width of the heightfield. Each vertex has a corresponding + * height value which forms the overall shape. + * Naturally this value must be at least two or more. + * @param depthSamples Specifies the number of vertices to sample + * along the depth of the heightfield. + * + * @param scale A uniform scale applied to all raw height data. + * @param offset An offset applied to the scaled height data. + * + * @param thickness A value subtracted from the lowest height + * value which in effect adds an additional cuboid to the base of the + * heightfield. This is used to prevent geoms from looping under the + * desired terrain and not registering as a collision. Note that the + * thickness is not affected by the scale or offset parameters. + * + * @param bWrap If non-zero the heightfield will infinitely tile in both + * directions along the local x and z axes. If zero the heightfield is + * bounded from zero to width in the local x axis, and zero to depth in + * the local z axis. + * + * @ingroup collide + */ +ODE_API void dGeomHeightfieldDataBuildByte( dHeightfieldDataID d, + const unsigned char* pHeightData, int bCopyHeightData, + dReal width, dReal depth, int widthSamples, int depthSamples, + dReal scale, dReal offset, dReal thickness, int bWrap ); + +/** + * @brief Configures a dHeightfieldDataID to use height data in short format. + * + * Before a dHeightfieldDataID can be used by a geom it must be + * configured to specify the format of the height data. + * This call specifies that the heightfield data is stored as a rectangular + * array of shorts (16 bit signed) representing the height at each sample point. + * + * @param d A new dHeightfieldDataID created by dGeomHeightfieldDataCreate + * + * @param pHeightData A pointer to the height data. + * @param bCopyHeightData When non-zero the height data is copied to an + * internal store. When zero the height data is accessed by reference and + * so must persist throughout the lifetime of the heightfield. + * + * @param width Specifies the total 'width' of the heightfield along + * the geom's local x axis. + * @param depth Specifies the total 'depth' of the heightfield along + * the geom's local z axis. + * + * @param widthSamples Specifies the number of vertices to sample + * along the width of the heightfield. Each vertex has a corresponding + * height value which forms the overall shape. + * Naturally this value must be at least two or more. + * @param depthSamples Specifies the number of vertices to sample + * along the depth of the heightfield. + * + * @param scale A uniform scale applied to all raw height data. + * @param offset An offset applied to the scaled height data. + * + * @param thickness A value subtracted from the lowest height + * value which in effect adds an additional cuboid to the base of the + * heightfield. This is used to prevent geoms from looping under the + * desired terrain and not registering as a collision. Note that the + * thickness is not affected by the scale or offset parameters. + * + * @param bWrap If non-zero the heightfield will infinitely tile in both + * directions along the local x and z axes. If zero the heightfield is + * bounded from zero to width in the local x axis, and zero to depth in + * the local z axis. + * + * @ingroup collide + */ +ODE_API void dGeomHeightfieldDataBuildShort( dHeightfieldDataID d, + const short* pHeightData, int bCopyHeightData, + dReal width, dReal depth, int widthSamples, int depthSamples, + dReal scale, dReal offset, dReal thickness, int bWrap ); + +/** + * @brief Configures a dHeightfieldDataID to use height data in + * single precision floating point format. + * + * Before a dHeightfieldDataID can be used by a geom it must be + * configured to specify the format of the height data. + * This call specifies that the heightfield data is stored as a rectangular + * array of single precision floats representing the height at each + * sample point. + * + * @param d A new dHeightfieldDataID created by dGeomHeightfieldDataCreate + * + * @param pHeightData A pointer to the height data. + * @param bCopyHeightData When non-zero the height data is copied to an + * internal store. When zero the height data is accessed by reference and + * so must persist throughout the lifetime of the heightfield. + * + * @param width Specifies the total 'width' of the heightfield along + * the geom's local x axis. + * @param depth Specifies the total 'depth' of the heightfield along + * the geom's local z axis. + * + * @param widthSamples Specifies the number of vertices to sample + * along the width of the heightfield. Each vertex has a corresponding + * height value which forms the overall shape. + * Naturally this value must be at least two or more. + * @param depthSamples Specifies the number of vertices to sample + * along the depth of the heightfield. + * + * @param scale A uniform scale applied to all raw height data. + * @param offset An offset applied to the scaled height data. + * + * @param thickness A value subtracted from the lowest height + * value which in effect adds an additional cuboid to the base of the + * heightfield. This is used to prevent geoms from looping under the + * desired terrain and not registering as a collision. Note that the + * thickness is not affected by the scale or offset parameters. + * + * @param bWrap If non-zero the heightfield will infinitely tile in both + * directions along the local x and z axes. If zero the heightfield is + * bounded from zero to width in the local x axis, and zero to depth in + * the local z axis. + * + * @ingroup collide + */ +ODE_API void dGeomHeightfieldDataBuildSingle( dHeightfieldDataID d, + const float* pHeightData, int bCopyHeightData, + dReal width, dReal depth, int widthSamples, int depthSamples, + dReal scale, dReal offset, dReal thickness, int bWrap ); + +/** + * @brief Configures a dHeightfieldDataID to use height data in + * double precision floating point format. + * + * Before a dHeightfieldDataID can be used by a geom it must be + * configured to specify the format of the height data. + * This call specifies that the heightfield data is stored as a rectangular + * array of double precision floats representing the height at each + * sample point. + * + * @param d A new dHeightfieldDataID created by dGeomHeightfieldDataCreate + * + * @param pHeightData A pointer to the height data. + * @param bCopyHeightData When non-zero the height data is copied to an + * internal store. When zero the height data is accessed by reference and + * so must persist throughout the lifetime of the heightfield. + * + * @param width Specifies the total 'width' of the heightfield along + * the geom's local x axis. + * @param depth Specifies the total 'depth' of the heightfield along + * the geom's local z axis. + * + * @param widthSamples Specifies the number of vertices to sample + * along the width of the heightfield. Each vertex has a corresponding + * height value which forms the overall shape. + * Naturally this value must be at least two or more. + * @param depthSamples Specifies the number of vertices to sample + * along the depth of the heightfield. + * + * @param scale A uniform scale applied to all raw height data. + * @param offset An offset applied to the scaled height data. + * + * @param thickness A value subtracted from the lowest height + * value which in effect adds an additional cuboid to the base of the + * heightfield. This is used to prevent geoms from looping under the + * desired terrain and not registering as a collision. Note that the + * thickness is not affected by the scale or offset parameters. + * + * @param bWrap If non-zero the heightfield will infinitely tile in both + * directions along the local x and z axes. If zero the heightfield is + * bounded from zero to width in the local x axis, and zero to depth in + * the local z axis. + * + * @ingroup collide + */ +ODE_API void dGeomHeightfieldDataBuildDouble( dHeightfieldDataID d, + const double* pHeightData, int bCopyHeightData, + dReal width, dReal depth, int widthSamples, int depthSamples, + dReal scale, dReal offset, dReal thickness, int bWrap ); + +/** + * @brief Manually set the minimum and maximum height bounds. + * + * This call allows you to set explicit min / max values after initial + * creation typically for callback heightfields which default to +/- infinity, + * or those whose data has changed. This must be set prior to binding with a + * geom, as the the AABB is not recomputed after it's first generation. + * + * @remarks The minimum and maximum values are used to compute the AABB + * for the heightfield which is used for early rejection of collisions. + * A close fit will yield a more efficient collision check. + * + * @param d A dHeightfieldDataID created by dGeomHeightfieldDataCreate + * @param min_height The new minimum height value. Scale, offset and thickness is then applied. + * @param max_height The new maximum height value. Scale and offset is then applied. + * @ingroup collide + */ +ODE_API void dGeomHeightfieldDataSetBounds( dHeightfieldDataID d, + dReal minHeight, dReal maxHeight ); + + +/** + * @brief Assigns a dHeightfieldDataID to a heightfield geom. + * + * Associates the given dHeightfieldDataID with a heightfield geom. + * This is done without affecting the GEOM_PLACEABLE flag. + * + * @param g A geom created by dCreateHeightfield + * @param d A dHeightfieldDataID created by dGeomHeightfieldDataCreate + * @ingroup collide + */ +ODE_API void dGeomHeightfieldSetHeightfieldData( dGeomID g, dHeightfieldDataID d ); + + +/** + * @brief Gets the dHeightfieldDataID bound to a heightfield geom. + * + * Returns the dHeightfieldDataID associated with a heightfield geom. + * + * @param g A geom created by dCreateHeightfield + * @return The dHeightfieldDataID which may be NULL if none was assigned. + * @ingroup collide + */ +ODE_API dHeightfieldDataID dGeomHeightfieldGetHeightfieldData( dGeomID g ); + + + +/* ************************************************************************ */ +/* utility functions */ + +ODE_API void dClosestLineSegmentPoints (const dVector3 a1, const dVector3 a2, + const dVector3 b1, const dVector3 b2, + dVector3 cp1, dVector3 cp2); + +ODE_API int dBoxTouchesBox (const dVector3 _p1, const dMatrix3 R1, + const dVector3 side1, const dVector3 _p2, + const dMatrix3 R2, const dVector3 side2); + +ODE_API int dBoxBox (const dVector3 p1, const dMatrix3 R1, + const dVector3 side1, const dVector3 p2, + const dMatrix3 R2, const dVector3 side2, + dVector3 normal, dReal *depth, int *return_code, + int maxc, dContactGeom *contact, int skip); + +ODE_API void dInfiniteAABB (dGeomID geom, dReal aabb[6]); +ODE_API void dInitODE(void); +ODE_API void dCloseODE(void); + +/* ************************************************************************ */ +/* custom classes */ + +typedef void dGetAABBFn (dGeomID, dReal aabb[6]); +typedef int dColliderFn (dGeomID o1, dGeomID o2, + int flags, dContactGeom *contact, int skip); +typedef dColliderFn * dGetColliderFnFn (int num); +typedef void dGeomDtorFn (dGeomID o); +typedef int dAABBTestFn (dGeomID o1, dGeomID o2, dReal aabb[6]); + +typedef struct dGeomClass { + int bytes; + dGetColliderFnFn *collider; + dGetAABBFn *aabb; + dAABBTestFn *aabb_test; + dGeomDtorFn *dtor; +} dGeomClass; + +ODE_API int dCreateGeomClass (const dGeomClass *classptr); +ODE_API void * dGeomGetClassData (dGeomID); +ODE_API dGeomID dCreateGeom (int classnum); + +/* ************************************************************************ */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/collision_space.h b/school/informatik/verkerhssimulation/src/ogre/ode/collision_space.h new file mode 100644 index 00000000..fb1f83f6 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/collision_space.h @@ -0,0 +1,76 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +#ifndef _ODE_COLLISION_SPACE_H_ +#define _ODE_COLLISION_SPACE_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct dContactGeom; + +/** + * @brief User callback for geom-geom collision testing. + * + * @param data The user data object, as passed to dSpaceCollide. + * @param o1 The first geom being tested. + * @param o2 The second geom being test. + * + * @remarks The callback function can call dCollide on o1 and o2 to generate + * contact points between each pair. Then these contact points may be added + * to the simulation as contact joints. The user's callback function can of + * course chose not to call dCollide for any pair, e.g. if the user decides + * that those pairs should not interact. + * + * @ingroup collide + */ +typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2); + + +ODE_API dSpaceID dSimpleSpaceCreate (dSpaceID space); +ODE_API dSpaceID dHashSpaceCreate (dSpaceID space); +ODE_API dSpaceID dQuadTreeSpaceCreate (dSpaceID space, dVector3 Center, dVector3 Extents, int Depth); + +ODE_API void dSpaceDestroy (dSpaceID); + +ODE_API void dHashSpaceSetLevels (dSpaceID space, int minlevel, int maxlevel); +ODE_API void dHashSpaceGetLevels (dSpaceID space, int *minlevel, int *maxlevel); + +ODE_API void dSpaceSetCleanup (dSpaceID space, int mode); +ODE_API int dSpaceGetCleanup (dSpaceID space); + +ODE_API void dSpaceAdd (dSpaceID, dGeomID); +ODE_API void dSpaceRemove (dSpaceID, dGeomID); +ODE_API int dSpaceQuery (dSpaceID, dGeomID); +ODE_API void dSpaceClean (dSpaceID); +ODE_API int dSpaceGetNumGeoms (dSpaceID); +ODE_API dGeomID dSpaceGetGeom (dSpaceID, int i); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/collision_trimesh.h b/school/informatik/verkerhssimulation/src/ogre/ode/collision_trimesh.h new file mode 100644 index 00000000..ad85a6eb --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/collision_trimesh.h @@ -0,0 +1,205 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +/* + * TriMesh code by Erwin de Vries. + * + * Trimesh data. + * This is where the actual vertexdata (pointers), and BV tree is stored. + * Vertices should be single precision! + * This should be more sophisticated, so that the user can easyly implement + * another collision library, but this is a lot of work, and also costs some + * performance because some data has to be copied. + */ + +#ifndef _ODE_COLLISION_TRIMESH_H_ +#define _ODE_COLLISION_TRIMESH_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Data storage for triangle meshes. + */ +struct dxTriMeshData; +typedef struct dxTriMeshData* dTriMeshDataID; + +/* + * These dont make much sense now, but they will later when we add more + * features. + */ +ODE_API dTriMeshDataID dGeomTriMeshDataCreate(void); +ODE_API void dGeomTriMeshDataDestroy(dTriMeshDataID g); + + + +enum { TRIMESH_FACE_NORMALS }; +ODE_API void dGeomTriMeshDataSet(dTriMeshDataID g, int data_id, void* in_data); +ODE_API void* dGeomTriMeshDataGet(dTriMeshDataID g, int data_id); + + + +/** + * We need to set the last transform after each time step for + * accurate collision response. These functions get and set that transform. + * It is stored per geom instance, rather than per dTriMeshDataID. + */ +ODE_API void dGeomTriMeshSetLastTransform( dGeomID g, dMatrix4 last_trans ); +ODE_API dReal* dGeomTriMeshGetLastTransform( dGeomID g ); + +/* + * Build TriMesh data with single precision used in vertex data . + */ +ODE_API void dGeomTriMeshDataBuildSingle(dTriMeshDataID g, + const void* Vertices, int VertexStride, int VertexCount, + const void* Indices, int IndexCount, int TriStride); +/* same again with a normals array (used as trimesh-trimesh optimization) */ +ODE_API void dGeomTriMeshDataBuildSingle1(dTriMeshDataID g, + const void* Vertices, int VertexStride, int VertexCount, + const void* Indices, int IndexCount, int TriStride, + const void* Normals); +/* +* Build TriMesh data with double pricision used in vertex data . +*/ +ODE_API void dGeomTriMeshDataBuildDouble(dTriMeshDataID g, + const void* Vertices, int VertexStride, int VertexCount, + const void* Indices, int IndexCount, int TriStride); +/* same again with a normals array (used as trimesh-trimesh optimization) */ +ODE_API void dGeomTriMeshDataBuildDouble1(dTriMeshDataID g, + const void* Vertices, int VertexStride, int VertexCount, + const void* Indices, int IndexCount, int TriStride, + const void* Normals); + +/* + * Simple build. Single/double precision based on dSINGLE/dDOUBLE! + */ +ODE_API void dGeomTriMeshDataBuildSimple(dTriMeshDataID g, + const dReal* Vertices, int VertexCount, + const int* Indices, int IndexCount); +/* same again with a normals array (used as trimesh-trimesh optimization) */ +ODE_API void dGeomTriMeshDataBuildSimple1(dTriMeshDataID g, + const dReal* Vertices, int VertexCount, + const int* Indices, int IndexCount, + const int* Normals); + +/* Preprocess the trimesh data to remove mark unnecessary edges and vertices */ +ODE_API void dGeomTriMeshDataPreprocess(dTriMeshDataID g); +/* Get and set the internal preprocessed trimesh data buffer, for loading and saving */ +ODE_API void dGeomTriMeshDataGetBuffer(dTriMeshDataID g, unsigned char** buf, int* bufLen); +ODE_API void dGeomTriMeshDataSetBuffer(dTriMeshDataID g, unsigned char* buf); + + +/* + * Per triangle callback. Allows the user to say if he wants a collision with + * a particular triangle. + */ +typedef int dTriCallback(dGeomID TriMesh, dGeomID RefObject, int TriangleIndex); +ODE_API void dGeomTriMeshSetCallback(dGeomID g, dTriCallback* Callback); +ODE_API dTriCallback* dGeomTriMeshGetCallback(dGeomID g); + +/* + * Per object callback. Allows the user to get the list of triangles in 1 + * shot. Maybe we should remove this one. + */ +typedef void dTriArrayCallback(dGeomID TriMesh, dGeomID RefObject, const int* TriIndices, int TriCount); +ODE_API void dGeomTriMeshSetArrayCallback(dGeomID g, dTriArrayCallback* ArrayCallback); +ODE_API dTriArrayCallback* dGeomTriMeshGetArrayCallback(dGeomID g); + +/* + * Ray callback. + * Allows the user to say if a ray collides with a triangle on barycentric + * coords. The user can for example sample a texture with alpha transparency + * to determine if a collision should occur. + */ +typedef int dTriRayCallback(dGeomID TriMesh, dGeomID Ray, int TriangleIndex, dReal u, dReal v); +ODE_API void dGeomTriMeshSetRayCallback(dGeomID g, dTriRayCallback* Callback); +ODE_API dTriRayCallback* dGeomTriMeshGetRayCallback(dGeomID g); + +/* + * Trimesh class + * Construction. Callbacks are optional. + */ +ODE_API dGeomID dCreateTriMesh(dSpaceID space, dTriMeshDataID Data, dTriCallback* Callback, dTriArrayCallback* ArrayCallback, dTriRayCallback* RayCallback); + +ODE_API void dGeomTriMeshSetData(dGeomID g, dTriMeshDataID Data); +ODE_API dTriMeshDataID dGeomTriMeshGetData(dGeomID g); + + +// enable/disable/check temporal coherence +ODE_API void dGeomTriMeshEnableTC(dGeomID g, int geomClass, int enable); +ODE_API int dGeomTriMeshIsTCEnabled(dGeomID g, int geomClass); + +/* + * Clears the internal temporal coherence caches. When a geom has its + * collision checked with a trimesh once, data is stored inside the trimesh. + * With large worlds with lots of seperate objects this list could get huge. + * We should be able to do this automagically. + */ +ODE_API void dGeomTriMeshClearTCCache(dGeomID g); + + +/* + * returns the TriMeshDataID + */ +ODE_API dTriMeshDataID dGeomTriMeshGetTriMeshDataID(dGeomID g); + +/* + * Gets a triangle. + */ +ODE_API void dGeomTriMeshGetTriangle(dGeomID g, int Index, dVector3* v0, dVector3* v1, dVector3* v2); + +/* + * Gets the point on the requested triangle and the given barycentric + * coordinates. + */ +ODE_API void dGeomTriMeshGetPoint(dGeomID g, int Index, dReal u, dReal v, dVector3 Out); + +/* + +This is how the strided data works: + +struct StridedVertex{ + dVector3 Vertex; + // Userdata +}; +int VertexStride = sizeof(StridedVertex); + +struct StridedTri{ + int Indices[3]; + // Userdata +}; +int TriStride = sizeof(StridedTri); + +*/ + + +ODE_API int dGeomTriMeshGetTriangleCount (dGeomID g); + +ODE_API void dGeomTriMeshDataUpdate(dTriMeshDataID g); + +#ifdef __cplusplus +} +#endif + +#endif /* _ODE_COLLISION_TRIMESH_H_ */ + diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/common.h b/school/informatik/verkerhssimulation/src/ogre/ode/common.h new file mode 100644 index 00000000..154e69d7 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/common.h @@ -0,0 +1,374 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +#ifndef _ODE_COMMON_H_ +#define _ODE_COMMON_H_ +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* configuration stuff */ + +/* the efficient alignment. most platforms align data structures to some + * number of bytes, but this is not always the most efficient alignment. + * for example, many x86 compilers align to 4 bytes, but on a pentium it + * is important to align doubles to 8 byte boundaries (for speed), and + * the 4 floats in a SIMD register to 16 byte boundaries. many other + * platforms have similar behavior. setting a larger alignment can waste + * a (very) small amount of memory. NOTE: this number must be a power of + * two. this is set to 16 by default. + */ +#define EFFICIENT_ALIGNMENT 16 + + +/* constants */ + +/* pi and 1/sqrt(2) are defined here if necessary because they don't get + * defined in on some platforms (like MS-Windows) + */ + +#ifndef M_PI +#define M_PI REAL(3.1415926535897932384626433832795029) +#endif +#ifndef M_SQRT1_2 +#define M_SQRT1_2 REAL(0.7071067811865475244008443621048490) +#endif + + +/* debugging: + * IASSERT is an internal assertion, i.e. a consistency check. if it fails + * we want to know where. + * UASSERT is a user assertion, i.e. if it fails a nice error message + * should be printed for the user. + * AASSERT is an arguments assertion, i.e. if it fails "bad argument(s)" + * is printed. + * DEBUGMSG just prints out a message + */ + +#ifndef dNODEBUG +#ifdef __GNUC__ +#define dIASSERT(a) if (!(a)) dDebug (d_ERR_IASSERT, \ + "assertion \"" #a "\" failed in %s() [%s]",__FUNCTION__,__FILE__); +#define dUASSERT(a,msg) if (!(a)) dDebug (d_ERR_UASSERT, \ + msg " in %s()", __FUNCTION__); +#define dDEBUGMSG(msg) dMessage (d_ERR_UASSERT, \ +msg " in %s() File %s Line %d", __FUNCTION__, __FILE__,__LINE__); +#else +#define dIASSERT(a) if (!(a)) dDebug (d_ERR_IASSERT, \ + "assertion \"" #a "\" failed in %s:%d",__FILE__,__LINE__); +#define dUASSERT(a,msg) if (!(a)) dDebug (d_ERR_UASSERT, \ + msg " (%s:%d)", __FILE__,__LINE__); +#define dDEBUGMSG(msg) dMessage (d_ERR_UASSERT, \ + msg " (%s:%d)", __FILE__,__LINE__); +#endif +#else +#define dIASSERT(a) ; +#define dUASSERT(a,msg) ; +#define dDEBUGMSG(msg) ; +#endif +#define dAASSERT(a) dUASSERT(a,"Bad argument(s)") + +/* floating point data type, vector, matrix and quaternion types */ + +#if defined(dSINGLE) +typedef float dReal; +#ifdef dDOUBLE +#error You can only #define dSINGLE or dDOUBLE, not both. +#endif // dDOUBLE +#elif defined(dDOUBLE) +typedef double dReal; +#else +#error You must #define dSINGLE or dDOUBLE +#endif + + +/* round an integer up to a multiple of 4, except that 0 and 1 are unmodified + * (used to compute matrix leading dimensions) + */ +#define dPAD(a) (((a) > 1) ? ((((a)-1)|3)+1) : (a)) + +/* these types are mainly just used in headers */ +typedef dReal dVector3[4]; +typedef dReal dVector4[4]; +typedef dReal dMatrix3[4*3]; +typedef dReal dMatrix4[4*4]; +typedef dReal dMatrix6[8*6]; +typedef dReal dQuaternion[4]; + + +/* precision dependent scalar math functions */ + +#if defined(dSINGLE) + +#define REAL(x) (x ## f) /* form a constant */ +#define dRecip(x) ((1.0f/(x))) /* reciprocal */ +#define dSqrt(x) (sqrtf(x)) /* square root */ +#define dRecipSqrt(x) ((1.0f/sqrtf(x))) /* reciprocal square root */ +#define dSin(x) (sinf(x)) /* sine */ +#define dCos(x) (cosf(x)) /* cosine */ +#define dFabs(x) (fabsf(x)) /* absolute value */ +#define dAtan2(y,x) (atan2f(y,x)) /* arc tangent with 2 args */ +#define dFMod(a,b) (fmodf(a,b)) /* modulo */ + +#ifdef HAVE___ISNANF +#define dIsNan(x) (__isnanf(x)) +#elif defined(HAVE__ISNANF) +#define dIsNan(x) (_isnanf(x)) +#elif defined(HAVE_ISNANF) +#define dIsNan(x) (isnanf(x)) +#else + /* + fall back to _isnan which is the VC way, + this may seem redundant since we already checked + for _isnan before, but if isnan is detected by + configure but is not found during compilation + we should always make sure we check for __isnanf, + _isnanf and isnanf in that order before falling + back to a default + */ +#define dIsNan(x) (_isnan(x)) +#endif + +#define dCopySign(a,b) ((dReal)copysignf(a,b)) + +#elif defined(dDOUBLE) + +#define REAL(x) (x) +#define dRecip(x) (1.0/(x)) +#define dSqrt(x) sqrt(x) +#define dRecipSqrt(x) (1.0/sqrt(x)) +#define dSin(x) sin(x) +#define dCos(x) cos(x) +#define dFabs(x) fabs(x) +#define dAtan2(y,x) atan2((y),(x)) +#define dFMod(a,b) (fmod((a),(b))) +#ifdef HAVE___ISNAN +#define dIsNan(x) (__isnan(x)) +#elif defined(HAVE__ISNAN) +#define dIsNan(x) (_isnan(x)) +#elif defined(HAVE_ISNAN) +#define dIsNan(x) (isnan(x)) +#else +#define dIsNan(x) (_isnan(x)) +#endif + +#define dCopySign(a,b) (copysign((a),(b))) + +#else +#error You must #define dSINGLE or dDOUBLE +#endif + + +/* utility */ + + +/* round something up to be a multiple of the EFFICIENT_ALIGNMENT */ + +#define dEFFICIENT_SIZE(x) ((((x)-1)|(EFFICIENT_ALIGNMENT-1))+1) + + +/* alloca aligned to the EFFICIENT_ALIGNMENT. note that this can waste + * up to 15 bytes per allocation, depending on what alloca() returns. + */ + +#define dALLOCA16(n) \ + ((char*)dEFFICIENT_SIZE(((size_t)(alloca((n)+(EFFICIENT_ALIGNMENT-1)))))) + + +// Use the error-checking memory allocation system. Because this system uses heap +// (malloc) instead of stack (alloca), it is slower. However, it allows you to +// simulate larger scenes, as well as handle out-of-memory errors in a somewhat +// graceful manner + +// #define dUSE_MALLOC_FOR_ALLOCA + +#ifdef dUSE_MALLOC_FOR_ALLOCA +enum { + d_MEMORY_OK = 0, /* no memory errors */ + d_MEMORY_OUT_OF_MEMORY /* malloc failed due to out of memory error */ +}; + +#endif + + + +/* internal object types (all prefixed with `dx') */ + +struct dxWorld; /* dynamics world */ +struct dxSpace; /* collision space */ +struct dxBody; /* rigid body (dynamics object) */ +struct dxGeom; /* geometry (collision object) */ +struct dxJoint; +struct dxJointNode; +struct dxJointGroup; + +typedef struct dxWorld *dWorldID; +typedef struct dxSpace *dSpaceID; +typedef struct dxBody *dBodyID; +typedef struct dxGeom *dGeomID; +typedef struct dxJoint *dJointID; +typedef struct dxJointGroup *dJointGroupID; + + +/* error numbers */ + +enum { + d_ERR_UNKNOWN = 0, /* unknown error */ + d_ERR_IASSERT, /* internal assertion failed */ + d_ERR_UASSERT, /* user assertion failed */ + d_ERR_LCP /* user assertion failed */ +}; + + +/* joint type numbers */ + +enum { + dJointTypeNone = 0, /* or "unknown" */ + dJointTypeBall, + dJointTypeHinge, + dJointTypeSlider, + dJointTypeContact, + dJointTypeUniversal, + dJointTypeHinge2, + dJointTypeFixed, + dJointTypeNull, + dJointTypeAMotor, + dJointTypeLMotor, + dJointTypePlane2D, + dJointTypePR +}; + + +/* an alternative way of setting joint parameters, using joint parameter + * structures and member constants. we don't actually do this yet. + */ + +/* +typedef struct dLimot { + int mode; + dReal lostop, histop; + dReal vel, fmax; + dReal fudge_factor; + dReal bounce, soft; + dReal suspension_erp, suspension_cfm; +} dLimot; + +enum { + dLimotLoStop = 0x0001, + dLimotHiStop = 0x0002, + dLimotVel = 0x0004, + dLimotFMax = 0x0008, + dLimotFudgeFactor = 0x0010, + dLimotBounce = 0x0020, + dLimotSoft = 0x0040 +}; +*/ + + +/* standard joint parameter names. why are these here? - because we don't want + * to include all the joint function definitions in joint.cpp. hmmmm. + * MSVC complains if we call D_ALL_PARAM_NAMES_X with a blank second argument, + * which is why we have the D_ALL_PARAM_NAMES macro as well. please copy and + * paste between these two. + */ + +#define D_ALL_PARAM_NAMES(start) \ + /* parameters for limits and motors */ \ + dParamLoStop = start, \ + dParamHiStop, \ + dParamVel, \ + dParamFMax, \ + dParamFudgeFactor, \ + dParamBounce, \ + dParamCFM, \ + dParamStopERP, \ + dParamStopCFM, \ + /* parameters for suspension */ \ + dParamSuspensionERP, \ + dParamSuspensionCFM, + +#define D_ALL_PARAM_NAMES_X(start,x) \ + /* parameters for limits and motors */ \ + dParamLoStop ## x = start, \ + dParamHiStop ## x, \ + dParamVel ## x, \ + dParamFMax ## x, \ + dParamFudgeFactor ## x, \ + dParamBounce ## x, \ + dParamCFM ## x, \ + dParamStopERP ## x, \ + dParamStopCFM ## x, \ + /* parameters for suspension */ \ + dParamSuspensionERP ## x, \ + dParamSuspensionCFM ## x, + +enum { + D_ALL_PARAM_NAMES(0) + D_ALL_PARAM_NAMES_X(0x100,2) + D_ALL_PARAM_NAMES_X(0x200,3) + + /* add a multiple of this constant to the basic parameter numbers to get + * the parameters for the second, third etc axes. + */ + dParamGroup=0x100 +}; + + +/* angular motor mode numbers */ + +enum{ + dAMotorUser = 0, + dAMotorEuler = 1 +}; + + +/* joint force feedback information */ + +typedef struct dJointFeedback { + dVector3 f1; /* force applied to body 1 */ + dVector3 t1; /* torque applied to body 1 */ + dVector3 f2; /* force applied to body 2 */ + dVector3 t2; /* torque applied to body 2 */ +} dJointFeedback; + + +/* private functions that must be implemented by the collision library: + * (1) indicate that a geom has moved, (2) get the next geom in a body list. + * these functions are called whenever the position of geoms connected to a + * body have changed, e.g. with dBodySetPosition(), dBodySetRotation(), or + * when the ODE step function updates the body state. + */ + +void dGeomMoved (dGeomID); +dGeomID dGeomGetBodyNext (dGeomID); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/compatibility.h b/school/informatik/verkerhssimulation/src/ogre/ode/compatibility.h new file mode 100644 index 00000000..b3709866 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/compatibility.h @@ -0,0 +1,40 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +#ifndef _ODE_COMPATIBILITY_H_ +#define _ODE_COMPATIBILITY_H_ + +/* + * ODE's backward compatibility system ensures that as ODE's API + * evolves, user code will not break. + */ + +/* + * These new rotation function names are more consistent with the + * rest of the API. + */ +#define dQtoR(q,R) dRfromQ((R),(q)) +#define dRtoQ(R,q) dQfromR((q),(R)) +#define dWtoDQ(w,q,dq) dDQfromW((dq),(w),(q)) + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/config.h b/school/informatik/verkerhssimulation/src/ogre/ode/config.h new file mode 100644 index 00000000..2da9da02 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/config.h @@ -0,0 +1,168 @@ +/* This file was autogenerated by Premake */ +#ifndef _ODE_CONFIG_H_ +#define _ODE_CONFIG_H_ + + +/****************************************************************** + * CONFIGURATON SETTINGS - you can change these, and then rebuild + * ODE to modify the behavior of the library. + * + * dSINGLE/dDOUBLE - force ODE to use single-precision (float) + * or double-precision (double) for numbers. + * Only one should be defined. + * + * dTRIMESH_ENABLED - enable/disable trimesh support + * dTRIMESH_OPCODE - use the OPCODE trimesh engine + * dTRIMESH_GIMPACT - use the GIMPACT trimesh engine + * + * dUSE_MALLOC_FOR_ALLOCA (experimental)- + * Use malloc() instead of alloca(). Slower, + * but allows for larger systems and more + * graceful out-of-memory handling. + ******************************************************************/ + +#define dSINGLE +/* #define dDOUBLE */ + +#define dTRIMESH_ENABLED 1 +#define dTRIMESH_OPCODE 1 + +/* #define dUSE_MALLOC_FOR_ALLOCA */ + + +/****************************************************************** + * SYSTEM SETTINGS - you shouldn't need to change these. If you + * run into an issue with these settings, please report it to + * the ODE bug tracker at: + * http://sf.net/tracker/?group_id=24884&atid=382799 + ******************************************************************/ + +/* Try to identify the platform */ +#if defined(_XENON) + #define ODE_PLATFORM_XBOX360 +#elif defined(SN_TARGET_PSP_HW) + #define ODE_PLATFORM_PSP +#elif defined(SN_TARGET_PS3) + #define ODE_PLATFORM_PS3 +#elif defined(_MSC_VER) || defined(__CYGWIN32__) || defined(__MINGW32__) + #define ODE_PLATFORM_WINDOWS +#elif defined(__linux__) + #define ODE_PLATFORM_LINUX +#elif defined(__APPLE__) && defined(__MACH__) + #define ODE_PLATFORM_OSX +#else + #error "Need some help identifying the platform!" +#endif + +/* Additional platform defines used in the code */ +#if defined(ODE_PLATFORM_WINDOWS) && !defined(WIN32) + #define WIN32 +#endif + +#if defined(__CYGWIN32__) || defined(__MINGW32__) + #define CYGWIN +#endif + +#if defined(ODE_PLATFORM_OSX) + #define macintosh +#endif + + +/* Define a DLL export symbol for those platforms that need it */ +#if defined(ODE_PLATFORM_WINDOWS) + #if defined(ODE_DLL) + #define ODE_API __declspec(dllexport) + #elif !defined(ODE_LIB) + #define ODE_DLL_API __declspec(dllimport) + #endif +#endif + +#if !defined(ODE_API) + #define ODE_API +#endif + + +/* Pull in the standard headers */ +#include +#include +#include +#include +#include +#include + +#if !defined(ODE_PLATFORM_PS3) + #include +#endif + +#if !defined(ODE_PLATFORM_WINDOWS) + #include +#endif + + +/* Visual C does not define these functions */ +#if defined(_MSC_VER) + #define copysignf _copysign + #define copysign _copysign +#endif + + +/* Define a value for infinity */ +#if defined(HUGE_VALF) + #define ODE_INFINITY4 HUGE_VALF + #define ODE_INFINITY8 HUGE_VAL +#elif defined(FLT_MAX) + #define ODE_INFINITY4 FLT_MAX + #define ODE_INFINITY8 DBL_MAX +#else + static union { unsigned char __c[4]; float __f; } __ode_huge_valf = {{0,0,0x80,0x7f}}; + static union { unsigned char __c[8]; double __d; } __ode_huge_val = {{0,0,0,0,0,0,0xf0,0x7f}}; + #define ODE_INFINITY4 (__ode_huge_valf.__f) + #define ODE_INFINITY8 (__ode_huge_val.__d) +#endif + +#ifdef dSINGLE + #define dInfinity ODE_INFINITY4 + #define dEpsilon FLT_EPSILON +#else + #define dInfinity ODE_INFINITY8 + #define dEpsilon DBL_EPSILON +#endif + + +/* Well-defined common data types...need to define for 64 bit systems */ +#if defined(_M_IA64) || defined(__ia64__) || defined(_M_AMD64) || defined(__x86_64__) + #define X86_64_SYSTEM 1 + typedef int int32; + typedef unsigned int uint32; + typedef short int16; + typedef unsigned short uint16; + typedef char int8; + typedef unsigned char uint8; +#else + typedef int int32; + typedef unsigned int uint32; + typedef short int16; + typedef unsigned short uint16; + typedef char int8; + typedef unsigned char uint8; +#endif + +/* An integer type that can be safely cast to a pointer. This definition + * should be safe even on 64-bit systems */ +typedef size_t intP; + + +/* The efficient alignment. most platforms align data structures to some + * number of bytes, but this is not always the most efficient alignment. + * for example, many x86 compilers align to 4 bytes, but on a pentium it is + * important to align doubles to 8 byte boundaries (for speed), and the 4 + * floats in a SIMD register to 16 byte boundaries. many other platforms have + * similar behavior. setting a larger alignment can waste a (very) small + * amount of memory. NOTE: this number must be a power of two. */ +#define EFFICIENT_ALIGNMENT 16 + + +/* Define this if your system supports anonymous memory maps (linux does) */ +#define MMAP_ANONYMOUS + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/contact.h b/school/informatik/verkerhssimulation/src/ogre/ode/contact.h new file mode 100644 index 00000000..fc634e7e --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/contact.h @@ -0,0 +1,103 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +#ifndef _ODE_CONTACT_H_ +#define _ODE_CONTACT_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +enum { + dContactMu2 = 0x001, + dContactFDir1 = 0x002, + dContactBounce = 0x004, + dContactSoftERP = 0x008, + dContactSoftCFM = 0x010, + dContactMotion1 = 0x020, + dContactMotion2 = 0x040, + dContactSlip1 = 0x080, + dContactSlip2 = 0x100, + + dContactApprox0 = 0x0000, + dContactApprox1_1 = 0x1000, + dContactApprox1_2 = 0x2000, + dContactApprox1 = 0x3000 +}; + + +typedef struct dSurfaceParameters { + /* must always be defined */ + int mode; + dReal mu; + + /* only defined if the corresponding flag is set in mode */ + dReal mu2; + dReal bounce; + dReal bounce_vel; + dReal soft_erp; + dReal soft_cfm; + dReal motion1,motion2; + dReal slip1,slip2; +} dSurfaceParameters; + + +/** + * @brief Describe the contact point between two geoms. + * + * If two bodies touch, or if a body touches a static feature in its + * environment, the contact is represented by one or more "contact + * points", described by dContactGeom. + * + * The convention is that if body 1 is moved along the normal vector by + * a distance depth (or equivalently if body 2 is moved the same distance + * in the opposite direction) then the contact depth will be reduced to + * zero. This means that the normal vector points "in" to body 1. + * + * @ingroup collide + */ +typedef struct dContactGeom { + dVector3 pos; ///< contact position + dVector3 normal; ///< normal vector + dReal depth; ///< penetration depth + dGeomID g1,g2; ///< the colliding geoms + int side1,side2; ///< (to be documented) +} dContactGeom; + + +/* contact info used by contact joint */ + +typedef struct dContact { + dSurfaceParameters surface; + dContactGeom geom; + dVector3 fdir1; +} dContact; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/error.h b/school/informatik/verkerhssimulation/src/ogre/ode/error.h new file mode 100644 index 00000000..bdeec377 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/error.h @@ -0,0 +1,63 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +/* this comes from the `reuse' library. copy any changes back to the source */ + +#ifndef _ODE_ERROR_H_ +#define _ODE_ERROR_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* all user defined error functions have this type. error and debug functions + * should not return. + */ +typedef void dMessageFunction (int errnum, const char *msg, va_list ap); + +/* set a new error, debug or warning handler. if fn is 0, the default handlers + * are used. + */ +ODE_API void dSetErrorHandler (dMessageFunction *fn); +ODE_API void dSetDebugHandler (dMessageFunction *fn); +ODE_API void dSetMessageHandler (dMessageFunction *fn); + +/* return the current error, debug or warning handler. if the return value is + * 0, the default handlers are in place. + */ +ODE_API dMessageFunction *dGetErrorHandler(void); +ODE_API dMessageFunction *dGetDebugHandler(void); +ODE_API dMessageFunction *dGetMessageHandler(void); + +/* generate a fatal error, debug trap or a message. */ +ODE_API void dError (int num, const char *msg, ...); +ODE_API void dDebug (int num, const char *msg, ...); +ODE_API void dMessage (int num, const char *msg, ...); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/export-dif.h b/school/informatik/verkerhssimulation/src/ogre/ode/export-dif.h new file mode 100644 index 00000000..ca479adc --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/export-dif.h @@ -0,0 +1,32 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +#ifndef _ODE_EXPORT_DIF_ +#define _ODE_EXPORT_DIF_ + +#include + + +ODE_API void dWorldExportDIF (dWorldID w, FILE *file, const char *world_name); + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/mass.h b/school/informatik/verkerhssimulation/src/ogre/ode/mass.h new file mode 100644 index 00000000..dacde01d --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/mass.h @@ -0,0 +1,123 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +#ifndef _ODE_MASS_H_ +#define _ODE_MASS_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct dMass; +typedef struct dMass dMass; + +/** + * Check if a mass structure has valid value. + * The function check if the mass and innertia matrix are positive definits + * + * @param m A mass structure to check + * + * @return 1 if both codition are met + */ +ODE_API int dMassCheck(const dMass *m); + +ODE_API void dMassSetZero (dMass *); + +ODE_API void dMassSetParameters (dMass *, dReal themass, + dReal cgx, dReal cgy, dReal cgz, + dReal I11, dReal I22, dReal I33, + dReal I12, dReal I13, dReal I23); + +ODE_API void dMassSetSphere (dMass *, dReal density, dReal radius); +ODE_API void dMassSetSphereTotal (dMass *, dReal total_mass, dReal radius); + +ODE_API void dMassSetCapsule (dMass *, dReal density, int direction, + dReal radius, dReal length); +ODE_API void dMassSetCapsuleTotal (dMass *, dReal total_mass, int direction, + dReal radius, dReal length); + +ODE_API void dMassSetCylinder (dMass *, dReal density, int direction, + dReal radius, dReal length); +ODE_API void dMassSetCylinderTotal (dMass *, dReal total_mass, int direction, + dReal radius, dReal length); + +ODE_API void dMassSetBox (dMass *, dReal density, + dReal lx, dReal ly, dReal lz); +ODE_API void dMassSetBoxTotal (dMass *, dReal total_mass, + dReal lx, dReal ly, dReal lz); + +ODE_API void dMassSetTrimesh (dMass *, dReal density, dGeomID g); + +ODE_API void dMassAdjust (dMass *, dReal newmass); + +ODE_API void dMassTranslate (dMass *, dReal x, dReal y, dReal z); + +ODE_API void dMassRotate (dMass *, const dMatrix3 R); + +ODE_API void dMassAdd (dMass *a, const dMass *b); + +// Backwards compatible API +#define dMassSetCappedCylinder dMassSetCapsule +#define dMassSetCappedCylinderTotal dMassSetCapsuleTotal + + +struct dMass { + dReal mass; + dVector4 c; + dMatrix3 I; + +#ifdef __cplusplus + dMass() + { dMassSetZero (this); } + void setZero() + { dMassSetZero (this); } + void setParameters (dReal themass, dReal cgx, dReal cgy, dReal cgz, + dReal I11, dReal I22, dReal I33, + dReal I12, dReal I13, dReal I23) + { dMassSetParameters (this,themass,cgx,cgy,cgz,I11,I22,I33,I12,I13,I23); } + void setSphere (dReal density, dReal radius) + { dMassSetSphere (this,density,radius); } + void setCapsule (dReal density, int direction, dReal a, dReal b) + { dMassSetCappedCylinder (this,density,direction,a,b); } + void setCappedCylinder (dReal density, int direction, dReal a, dReal b) + { setCapsule(density, direction, a, b); } + void setBox (dReal density, dReal lx, dReal ly, dReal lz) + { dMassSetBox (this,density,lx,ly,lz); } + void adjust (dReal newmass) + { dMassAdjust (this,newmass); } + void translate (dReal x, dReal y, dReal z) + { dMassTranslate (this,x,y,z); } + void rotate (const dMatrix3 R) + { dMassRotate (this,R); } + void add (const dMass *b) + { dMassAdd (this,b); } +#endif +}; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/matrix.h b/school/informatik/verkerhssimulation/src/ogre/ode/matrix.h new file mode 100644 index 00000000..eeb004d8 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/matrix.h @@ -0,0 +1,194 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +/* optimized and unoptimized vector and matrix functions */ + +#ifndef _ODE_MATRIX_H_ +#define _ODE_MATRIX_H_ + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* set a vector/matrix of size n to all zeros, or to a specific value. */ + +ODE_API void dSetZero (dReal *a, int n); +ODE_API void dSetValue (dReal *a, int n, dReal value); + + +/* get the dot product of two n*1 vectors. if n <= 0 then + * zero will be returned (in which case a and b need not be valid). + */ + +ODE_API dReal dDot (const dReal *a, const dReal *b, int n); + + +/* get the dot products of (a0,b), (a1,b), etc and return them in outsum. + * all vectors are n*1. if n <= 0 then zeroes will be returned (in which case + * the input vectors need not be valid). this function is somewhat faster + * than calling dDot() for all of the combinations separately. + */ + +/* NOT INCLUDED in the library for now. +void dMultidot2 (const dReal *a0, const dReal *a1, + const dReal *b, dReal *outsum, int n); +*/ + + +/* matrix multiplication. all matrices are stored in standard row format. + * the digit refers to the argument that is transposed: + * 0: A = B * C (sizes: A:p*r B:p*q C:q*r) + * 1: A = B' * C (sizes: A:p*r B:q*p C:q*r) + * 2: A = B * C' (sizes: A:p*r B:p*q C:r*q) + * case 1,2 are equivalent to saying that the operation is A=B*C but + * B or C are stored in standard column format. + */ + +ODE_API void dMultiply0 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); +ODE_API void dMultiply1 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); +ODE_API void dMultiply2 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); + + +/* do an in-place cholesky decomposition on the lower triangle of the n*n + * symmetric matrix A (which is stored by rows). the resulting lower triangle + * will be such that L*L'=A. return 1 on success and 0 on failure (on failure + * the matrix is not positive definite). + */ + +ODE_API int dFactorCholesky (dReal *A, int n); + + +/* solve for x: L*L'*x = b, and put the result back into x. + * L is size n*n, b is size n*1. only the lower triangle of L is considered. + */ + +ODE_API void dSolveCholesky (const dReal *L, dReal *b, int n); + + +/* compute the inverse of the n*n positive definite matrix A and put it in + * Ainv. this is not especially fast. this returns 1 on success (A was + * positive definite) or 0 on failure (not PD). + */ + +ODE_API int dInvertPDMatrix (const dReal *A, dReal *Ainv, int n); + + +/* check whether an n*n matrix A is positive definite, return 1/0 (yes/no). + * positive definite means that x'*A*x > 0 for any x. this performs a + * cholesky decomposition of A. if the decomposition fails then the matrix + * is not positive definite. A is stored by rows. A is not altered. + */ + +ODE_API int dIsPositiveDefinite (const dReal *A, int n); + + +/* factorize a matrix A into L*D*L', where L is lower triangular with ones on + * the diagonal, and D is diagonal. + * A is an n*n matrix stored by rows, with a leading dimension of n rounded + * up to 4. L is written into the strict lower triangle of A (the ones are not + * written) and the reciprocal of the diagonal elements of D are written into + * d. + */ +ODE_API void dFactorLDLT (dReal *A, dReal *d, int n, int nskip); + + +/* solve L*x=b, where L is n*n lower triangular with ones on the diagonal, + * and x,b are n*1. b is overwritten with x. + * the leading dimension of L is `nskip'. + */ +ODE_API void dSolveL1 (const dReal *L, dReal *b, int n, int nskip); + + +/* solve L'*x=b, where L is n*n lower triangular with ones on the diagonal, + * and x,b are n*1. b is overwritten with x. + * the leading dimension of L is `nskip'. + */ +ODE_API void dSolveL1T (const dReal *L, dReal *b, int n, int nskip); + + +/* in matlab syntax: a(1:n) = a(1:n) .* d(1:n) */ + +ODE_API void dVectorScale (dReal *a, const dReal *d, int n); + + +/* given `L', a n*n lower triangular matrix with ones on the diagonal, + * and `d', a n*1 vector of the reciprocal diagonal elements of an n*n matrix + * D, solve L*D*L'*x=b where x,b are n*1. x overwrites b. + * the leading dimension of L is `nskip'. + */ + +ODE_API void dSolveLDLT (const dReal *L, const dReal *d, dReal *b, int n, int nskip); + + +/* given an L*D*L' factorization of an n*n matrix A, return the updated + * factorization L2*D2*L2' of A plus the following "top left" matrix: + * + * [ b a' ] <-- b is a[0] + * [ a 0 ] <-- a is a[1..n-1] + * + * - L has size n*n, its leading dimension is nskip. L is lower triangular + * with ones on the diagonal. only the lower triangle of L is referenced. + * - d has size n. d contains the reciprocal diagonal elements of D. + * - a has size n. + * the result is written into L, except that the left column of L and d[0] + * are not actually modified. see ldltaddTL.m for further comments. + */ +ODE_API void dLDLTAddTL (dReal *L, dReal *d, const dReal *a, int n, int nskip); + + +/* given an L*D*L' factorization of a permuted matrix A, produce a new + * factorization for row and column `r' removed. + * - A has size n1*n1, its leading dimension in nskip. A is symmetric and + * positive definite. only the lower triangle of A is referenced. + * A itself may actually be an array of row pointers. + * - L has size n2*n2, its leading dimension in nskip. L is lower triangular + * with ones on the diagonal. only the lower triangle of L is referenced. + * - d has size n2. d contains the reciprocal diagonal elements of D. + * - p is a permutation vector. it contains n2 indexes into A. each index + * must be in the range 0..n1-1. + * - r is the row/column of L to remove. + * the new L will be written within the old L, i.e. will have the same leading + * dimension. the last row and column of L, and the last element of d, are + * undefined on exit. + * + * a fast O(n^2) algorithm is used. see ldltremove.m for further comments. + */ +ODE_API void dLDLTRemove (dReal **A, const int *p, dReal *L, dReal *d, + int n1, int n2, int r, int nskip); + + +/* given an n*n matrix A (with leading dimension nskip), remove the r'th row + * and column by moving elements. the new matrix will have the same leading + * dimension. the last row and column of A are untouched on exit. + */ +ODE_API void dRemoveRowCol (dReal *A, int n, int nskip, int r); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/memory.h b/school/informatik/verkerhssimulation/src/ogre/ode/memory.h new file mode 100644 index 00000000..c1af051a --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/memory.h @@ -0,0 +1,59 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +/* this comes from the `reuse' library. copy any changes back to the source */ + +#ifndef _ODE_MEMORY_H_ +#define _ODE_MEMORY_H_ + +#include "ode/config.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* function types to allocate and free memory */ +typedef void * dAllocFunction (size_t size); +typedef void * dReallocFunction (void *ptr, size_t oldsize, size_t newsize); +typedef void dFreeFunction (void *ptr, size_t size); + +/* set new memory management functions. if fn is 0, the default handlers are + * used. */ +ODE_API void dSetAllocHandler (dAllocFunction *fn); +ODE_API void dSetReallocHandler (dReallocFunction *fn); +ODE_API void dSetFreeHandler (dFreeFunction *fn); + +/* get current memory management functions */ +ODE_API dAllocFunction *dGetAllocHandler (void); +ODE_API dReallocFunction *dGetReallocHandler (void); +ODE_API dFreeFunction *dGetFreeHandler (void); + +/* allocate and free memory. */ +ODE_API void * dAlloc (size_t size); +ODE_API void * dRealloc (void *ptr, size_t oldsize, size_t newsize); +ODE_API void dFree (void *ptr, size_t size); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/misc.h b/school/informatik/verkerhssimulation/src/ogre/ode/misc.h new file mode 100644 index 00000000..0c55fc5b --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/misc.h @@ -0,0 +1,85 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +/* miscellaneous math functions. these are mostly useful for testing */ + +#ifndef _ODE_MISC_H_ +#define _ODE_MISC_H_ + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* return 1 if the random number generator is working. */ +ODE_API int dTestRand(void); + +/* return next 32 bit random number. this uses a not-very-random linear + * congruential method. + */ +ODE_API unsigned long dRand(void); + +/* get and set the current random number seed. */ +ODE_API unsigned long dRandGetSeed(void); +ODE_API void dRandSetSeed (unsigned long s); + +/* return a random integer between 0..n-1. the distribution will get worse + * as n approaches 2^32. + */ +ODE_API int dRandInt (int n); + +/* return a random real number between 0..1 */ +ODE_API dReal dRandReal(void); + +/* print out a matrix */ +#ifdef __cplusplus +ODE_API void dPrintMatrix (const dReal *A, int n, int m, char *fmt = "%10.4f ", + FILE *f=stdout); +#else +ODE_API void dPrintMatrix (const dReal *A, int n, int m, char *fmt, FILE *f); +#endif + +/* make a random vector with entries between +/- range. A has n elements. */ +ODE_API void dMakeRandomVector (dReal *A, int n, dReal range); + +/* make a random matrix with entries between +/- range. A has size n*m. */ +ODE_API void dMakeRandomMatrix (dReal *A, int n, int m, dReal range); + +/* clear the upper triangle of a square matrix */ +ODE_API void dClearUpperTriangle (dReal *A, int n); + +/* return the maximum element difference between the two n*m matrices */ +ODE_API dReal dMaxDifference (const dReal *A, const dReal *B, int n, int m); + +/* return the maximum element difference between the lower triangle of two + * n*n matrices */ +ODE_API dReal dMaxDifferenceLowerTriangle (const dReal *A, const dReal *B, int n); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/objects.h b/school/informatik/verkerhssimulation/src/ogre/ode/objects.h new file mode 100644 index 00000000..7eff5dbe --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/objects.h @@ -0,0 +1,1941 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +#ifndef _ODE_OBJECTS_H_ +#define _ODE_OBJECTS_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup world World + * + * The world object is a container for rigid bodies and joints. Objects in + * different worlds can not interact, for example rigid bodies from two + * different worlds can not collide. + * + * All the objects in a world exist at the same point in time, thus one + * reason to use separate worlds is to simulate systems at different rates. + * Most applications will only need one world. + */ + + +/** + * @brief Create a new, empty world and return its ID number. + * @return an identifier + * @ingroup world + */ +ODE_API dWorldID dWorldCreate(void); + + +/** + * @brief Destroy a world and everything in it. + * + * This includes all bodies, and all joints that are not part of a joint + * group. Joints that are part of a joint group will be deactivated, and + * can be destroyed by calling, for example, dJointGroupEmpty(). + * @ingroup world + * @param world the identifier for the world the be destroyed. + */ +ODE_API void dWorldDestroy (dWorldID world); + + +/** + * @brief Set the world's global gravity vector. + * + * The units are m/s^2, so Earth's gravity vector would be (0,0,-9.81), + * assuming that +z is up. The default is no gravity, i.e. (0,0,0). + * + * @ingroup world + */ +ODE_API void dWorldSetGravity (dWorldID, dReal x, dReal y, dReal z); + + +/** + * @brief Get the gravity vector for a given world. + * @ingroup world + */ +ODE_API void dWorldGetGravity (dWorldID, dVector3 gravity); + + +/** + * @brief Set the global ERP value, that controls how much error + * correction is performed in each time step. + * @ingroup world + * @param dWorldID the identifier of the world. + * @param erp Typical values are in the range 0.1--0.8. The default is 0.2. + */ +ODE_API void dWorldSetERP (dWorldID, dReal erp); + +/** + * @brief Get the error reduction parameter. + * @ingroup world + * @return ERP value + */ +ODE_API dReal dWorldGetERP (dWorldID); + + +/** + * @brief Set the global CFM (constraint force mixing) value. + * @ingroup world + * @param cfm Typical values are in the range @m{10^{-9}} -- 1. + * The default is 10^-5 if single precision is being used, or 10^-10 + * if double precision is being used. + */ +ODE_API void dWorldSetCFM (dWorldID, dReal cfm); + +/** + * @brief Get the constraint force mixing value. + * @ingroup world + * @return CFM value + */ +ODE_API dReal dWorldGetCFM (dWorldID); + + +/** + * @brief Step the world. + * + * This uses a "big matrix" method that takes time on the order of m^3 + * and memory on the order of m^2, where m is the total number of constraint + * rows. For large systems this will use a lot of memory and can be very slow, + * but this is currently the most accurate method. + * @ingroup world + * @param stepsize The number of seconds that the simulation has to advance. + */ +ODE_API void dWorldStep (dWorldID, dReal stepsize); + + +/** + * @brief Converts an impulse to a force. + * @ingroup world + * @remarks + * If you want to apply a linear or angular impulse to a rigid body, + * instead of a force or a torque, then you can use this function to convert + * the desired impulse into a force/torque vector before calling the + * BodyAdd... function. + * The current algorithm simply scales the impulse by 1/stepsize, + * where stepsize is the step size for the next step that will be taken. + * This function is given a dWorldID because, in the future, the force + * computation may depend on integrator parameters that are set as + * properties of the world. + */ +ODE_API void dWorldImpulseToForce +( + dWorldID, dReal stepsize, + dReal ix, dReal iy, dReal iz, dVector3 force +); + + +/** + * @brief Step the world. + * @ingroup world + * @remarks + * This uses an iterative method that takes time on the order of m*N + * and memory on the order of m, where m is the total number of constraint + * rows N is the number of iterations. + * For large systems this is a lot faster than dWorldStep(), + * but it is less accurate. + * @remarks + * QuickStep is great for stacks of objects especially when the + * auto-disable feature is used as well. + * However, it has poor accuracy for near-singular systems. + * Near-singular systems can occur when using high-friction contacts, motors, + * or certain articulated structures. For example, a robot with multiple legs + * sitting on the ground may be near-singular. + * @remarks + * There are ways to help overcome QuickStep's inaccuracy problems: + * \li Increase CFM. + * \li Reduce the number of contacts in your system (e.g. use the minimum + * number of contacts for the feet of a robot or creature). + * \li Don't use excessive friction in the contacts. + * \li Use contact slip if appropriate + * \li Avoid kinematic loops (however, kinematic loops are inevitable in + * legged creatures). + * \li Don't use excessive motor strength. + * \liUse force-based motors instead of velocity-based motors. + * + * Increasing the number of QuickStep iterations may help a little bit, but + * it is not going to help much if your system is really near singular. + */ +ODE_API void dWorldQuickStep (dWorldID w, dReal stepsize); + + +/** + * @brief Set the number of iterations that the QuickStep method performs per + * step. + * @ingroup world + * @remarks + * More iterations will give a more accurate solution, but will take + * longer to compute. + * @param num The default is 20 iterations. + */ +ODE_API void dWorldSetQuickStepNumIterations (dWorldID, int num); + + +/** + * @brief Get the number of iterations that the QuickStep method performs per + * step. + * @ingroup world + * @return nr of iterations + */ +ODE_API int dWorldGetQuickStepNumIterations (dWorldID); + +/** + * @brief Set the SOR over-relaxation parameter + * @ingroup world + * @param over_relaxation value to use by SOR + */ +ODE_API void dWorldSetQuickStepW (dWorldID, dReal over_relaxation); + +/** + * @brief Get the SOR over-relaxation parameter + * @ingroup world + * @returns the over-relaxation setting + */ +ODE_API dReal dWorldGetQuickStepW (dWorldID); + +/* World contact parameter functions */ + +/** + * @brief Set the maximum correcting velocity that contacts are allowed + * to generate. + * @ingroup world + * @param vel The default value is infinity (i.e. no limit). + * @remarks + * Reducing this value can help prevent "popping" of deeply embedded objects. + */ +ODE_API void dWorldSetContactMaxCorrectingVel (dWorldID, dReal vel); + +/** + * @brief Get the maximum correcting velocity that contacts are allowed + * to generated. + * @ingroup world + */ +ODE_API dReal dWorldGetContactMaxCorrectingVel (dWorldID); + +/** + * @brief Set the depth of the surface layer around all geometry objects. + * @ingroup world + * @remarks + * Contacts are allowed to sink into the surface layer up to the given + * depth before coming to rest. + * @param depth The default value is zero. + * @remarks + * Increasing this to some small value (e.g. 0.001) can help prevent + * jittering problems due to contacts being repeatedly made and broken. + */ +ODE_API void dWorldSetContactSurfaceLayer (dWorldID, dReal depth); + +/** + * @brief Get the depth of the surface layer around all geometry objects. + * @ingroup world + * @returns the depth + */ +ODE_API dReal dWorldGetContactSurfaceLayer (dWorldID); + +/* StepFast1 functions */ + +/** + * @brief Step the world using the StepFast1 algorithm. + * @param stepsize the nr of seconds to advance the simulation. + * @param maxiterations The number of iterations to perform. + * @ingroup world + */ +ODE_API void dWorldStepFast1(dWorldID, dReal stepsize, int maxiterations); + + +/** + * @defgroup disable Automatic Enabling and Disabling + * + * Every body can be enabled or disabled. Enabled bodies participate in the + * simulation, while disabled bodies are turned off and do not get updated + * during a simulation step. New bodies are always created in the enabled state. + * + * A disabled body that is connected through a joint to an enabled body will be + * automatically re-enabled at the next simulation step. + * + * Disabled bodies do not consume CPU time, therefore to speed up the simulation + * bodies should be disabled when they come to rest. This can be done automatically + * with the auto-disable feature. + * + * If a body has its auto-disable flag turned on, it will automatically disable + * itself when + * @li It has been idle for a given number of simulation steps. + * @li It has also been idle for a given amount of simulation time. + * + * A body is considered to be idle when the magnitudes of both its + * linear average velocity and angular average velocity are below given thresholds. + * The sample size for the average defaults to one and can be disabled by setting + * to zero with + * + * Thus, every body has six auto-disable parameters: an enabled flag, a idle step + * count, an idle time, linear/angular average velocity thresholds, and the + * average samples count. + * + * Newly created bodies get these parameters from world. + */ + +/** + * @brief Set the AutoEnableDepth parameter used by the StepFast1 algorithm. + * @ingroup disable + */ +ODE_API void dWorldSetAutoEnableDepthSF1(dWorldID, int autoEnableDepth); + +/** + * @brief Get the AutoEnableDepth parameter used by the StepFast1 algorithm. + * @ingroup disable + */ +ODE_API int dWorldGetAutoEnableDepthSF1(dWorldID); + +/** + * @brief Get auto disable linear threshold for newly created bodies. + * @ingroup disable + * @return the threshold + */ +ODE_API dReal dWorldGetAutoDisableLinearThreshold (dWorldID); + +/** + * @brief Set auto disable linear threshold for newly created bodies. + * @param linear_threshold default is 0.01 + * @ingroup disable + */ +ODE_API void dWorldSetAutoDisableLinearThreshold (dWorldID, dReal linear_threshold); + +/** + * @brief Get auto disable angular threshold for newly created bodies. + * @ingroup disable + * @return the threshold + */ +ODE_API dReal dWorldGetAutoDisableAngularThreshold (dWorldID); + +/** + * @brief Set auto disable angular threshold for newly created bodies. + * @param linear_threshold default is 0.01 + * @ingroup disable + */ +ODE_API void dWorldSetAutoDisableAngularThreshold (dWorldID, dReal angular_threshold); + +/** + * @brief Get auto disable linear average threshold for newly created bodies. + * @ingroup disable + * @return the threshold + */ +ODE_API dReal dWorldGetAutoDisableLinearAverageThreshold (dWorldID); + +/** + * @brief Set auto disable linear average threshold for newly created bodies. + * @param linear_average_threshold default is 0.01 + * @ingroup disable + */ +ODE_API void dWorldSetAutoDisableLinearAverageThreshold (dWorldID, dReal linear_average_threshold); + +/** + * @brief Get auto disable angular average threshold for newly created bodies. + * @ingroup disable + * @return the threshold + */ +ODE_API dReal dWorldGetAutoDisableAngularAverageThreshold (dWorldID); + +/** + * @brief Set auto disable angular average threshold for newly created bodies. + * @param linear_average_threshold default is 0.01 + * @ingroup disable + */ +ODE_API void dWorldSetAutoDisableAngularAverageThreshold (dWorldID, dReal angular_average_threshold); + +/** + * @brief Get auto disable sample count for newly created bodies. + * @ingroup disable + * @return number of samples used + */ +ODE_API int dWorldGetAutoDisableAverageSamplesCount (dWorldID); + +/** + * @brief Set auto disable average sample count for newly created bodies. + * @ingroup disable + * @param average_samples_count Default is 1, meaning only instantaneous velocity is used. + * Set to zero to disable sampling and thus prevent any body from auto-disabling. + */ +ODE_API void dWorldSetAutoDisableAverageSamplesCount (dWorldID, unsigned int average_samples_count ); + +/** + * @brief Get auto disable steps for newly created bodies. + * @ingroup disable + * @return nr of steps + */ +ODE_API int dWorldGetAutoDisableSteps (dWorldID); + +/** + * @brief Set auto disable steps for newly created bodies. + * @ingroup disable + * @param steps default is 10 + */ +ODE_API void dWorldSetAutoDisableSteps (dWorldID, int steps); + +/** + * @brief Get auto disable time for newly created bodies. + * @ingroup disable + * @return nr of seconds + */ +ODE_API dReal dWorldGetAutoDisableTime (dWorldID); + +/** + * @brief Set auto disable time for newly created bodies. + * @ingroup disable + * @param time default is 0 seconds + */ +ODE_API void dWorldSetAutoDisableTime (dWorldID, dReal time); + +/** + * @brief Get auto disable flag for newly created bodies. + * @ingroup disable + * @return 0 or 1 + */ +ODE_API int dWorldGetAutoDisableFlag (dWorldID); + +/** + * @brief Set auto disable flag for newly created bodies. + * @ingroup disable + * @param do_auto_disable default is false. + */ +ODE_API void dWorldSetAutoDisableFlag (dWorldID, int do_auto_disable); + + + +/** + * @defgroup bodies Rigid Bodies + * + * A rigid body has various properties from the point of view of the + * simulation. Some properties change over time: + * + * @li Position vector (x,y,z) of the body's point of reference. + * Currently the point of reference must correspond to the body's center of mass. + * @li Linear velocity of the point of reference, a vector (vx,vy,vz). + * @li Orientation of a body, represented by a quaternion (qs,qx,qy,qz) or + * a 3x3 rotation matrix. + * @li Angular velocity vector (wx,wy,wz) which describes how the orientation + * changes over time. + * + * Other body properties are usually constant over time: + * + * @li Mass of the body. + * @li Position of the center of mass with respect to the point of reference. + * In the current implementation the center of mass and the point of + * reference must coincide. + * @li Inertia matrix. This is a 3x3 matrix that describes how the body's mass + * is distributed around the center of mass. Conceptually each body has an + * x-y-z coordinate frame embedded in it that moves and rotates with the body. + * + * The origin of this coordinate frame is the body's point of reference. Some values + * in ODE (vectors, matrices etc) are relative to the body coordinate frame, and others + * are relative to the global coordinate frame. + * + * Note that the shape of a rigid body is not a dynamical property (except insofar as + * it influences the various mass properties). It is only collision detection that cares + * about the detailed shape of the body. + */ + + +/** + * @brief Get auto disable linear average threshold. + * @ingroup bodies + * @return the threshold + */ +ODE_API dReal dBodyGetAutoDisableLinearThreshold (dBodyID); + +/** + * @brief Set auto disable linear average threshold. + * @ingroup bodies + * @return the threshold + */ +ODE_API void dBodySetAutoDisableLinearThreshold (dBodyID, dReal linear_average_threshold); + +/** + * @brief Get auto disable angular average threshold. + * @ingroup bodies + * @return the threshold + */ +ODE_API dReal dBodyGetAutoDisableAngularThreshold (dBodyID); + +/** + * @brief Set auto disable angular average threshold. + * @ingroup bodies + * @return the threshold + */ +ODE_API void dBodySetAutoDisableAngularThreshold (dBodyID, dReal angular_average_threshold); + +/** + * @brief Get auto disable average size (samples count). + * @ingroup bodies + * @return the nr of steps/size. + */ +ODE_API int dBodyGetAutoDisableAverageSamplesCount (dBodyID); + +/** + * @brief Set auto disable average buffer size (average steps). + * @ingroup bodies + * @param average_samples_count the nr of samples to review. + */ +ODE_API void dBodySetAutoDisableAverageSamplesCount (dBodyID, unsigned int average_samples_count); + + +/** + * @brief Get auto steps a body must be thought of as idle to disable + * @ingroup bodies + * @return the nr of steps + */ +ODE_API int dBodyGetAutoDisableSteps (dBodyID); + +/** + * @brief Set auto disable steps. + * @ingroup bodies + * @param steps the nr of steps. + */ +ODE_API void dBodySetAutoDisableSteps (dBodyID, int steps); + +/** + * @brief Get auto disable time. + * @ingroup bodies + * @return nr of seconds + */ +ODE_API dReal dBodyGetAutoDisableTime (dBodyID); + +/** + * @brief Set auto disable time. + * @ingroup bodies + * @param time nr of seconds. + */ +ODE_API void dBodySetAutoDisableTime (dBodyID, dReal time); + +/** + * @brief Get auto disable flag. + * @ingroup bodies + * @return 0 or 1 + */ +ODE_API int dBodyGetAutoDisableFlag (dBodyID); + +/** + * @brief Set auto disable flag. + * @ingroup bodies + * @param do_auto_disable 0 or 1 + */ +ODE_API void dBodySetAutoDisableFlag (dBodyID, int do_auto_disable); + +/** + * @brief Set auto disable defaults. + * @remarks + * Set the values for the body to those set as default for the world. + * @ingroup bodies + */ +ODE_API void dBodySetAutoDisableDefaults (dBodyID); + + +/** + * @brief Retrives the world attached to te given body. + * @remarks + * + * @ingroup bodies + */ +ODE_API dWorldID dBodyGetWorld (dBodyID); + +/** + * @brief Create a body in given world. + * @remarks + * Default mass parameters are at position (0,0,0). + * @ingroup bodies + */ +ODE_API dBodyID dBodyCreate (dWorldID); + +/** + * @brief Destroy a body. + * @remarks + * All joints that are attached to this body will be put into limbo: + * i.e. unattached and not affecting the simulation, but they will NOT be + * deleted. + * @ingroup bodies + */ +ODE_API void dBodyDestroy (dBodyID); + +/** + * @brief Set the body's user-data pointer. + * @ingroup bodies + * @param data arbitraty pointer + */ +ODE_API void dBodySetData (dBodyID, void *data); + +/** + * @brief Get the body's user-data pointer. + * @ingroup bodies + * @return a pointer to the user's data. + */ +ODE_API void *dBodyGetData (dBodyID); + +/** + * @brief Set position of a body. + * @remarks + * After setting, the outcome of the simulation is undefined + * if the new configuration is inconsistent with the joints/constraints + * that are present. + * @ingroup bodies + */ +ODE_API void dBodySetPosition (dBodyID, dReal x, dReal y, dReal z); + +/** + * @brief Set the orientation of a body. + * @ingroup bodies + * @remarks + * After setting, the outcome of the simulation is undefined + * if the new configuration is inconsistent with the joints/constraints + * that are present. + */ +ODE_API void dBodySetRotation (dBodyID, const dMatrix3 R); + +/** + * @brief Set the orientation of a body. + * @ingroup bodies + * @remarks + * After setting, the outcome of the simulation is undefined + * if the new configuration is inconsistent with the joints/constraints + * that are present. + */ +ODE_API void dBodySetQuaternion (dBodyID, const dQuaternion q); + +/** + * @brief Set the linear velocity of a body. + * @ingroup bodies + */ +ODE_API void dBodySetLinearVel (dBodyID, dReal x, dReal y, dReal z); + +/** + * @brief Set the angular velocity of a body. + * @ingroup bodies + */ +ODE_API void dBodySetAngularVel (dBodyID, dReal x, dReal y, dReal z); + +/** + * @brief Get the position of a body. + * @ingroup bodies + * @remarks + * When getting, the returned values are pointers to internal data structures, + * so the vectors are valid until any changes are made to the rigid body + * system structure. + * @sa dBodyCopyPosition + */ +ODE_API const dReal * dBodyGetPosition (dBodyID); + + +/** + * @brief Copy the position of a body into a vector. + * @ingroup bodies + * @param body the body to query + * @param pos a copy of the body position + * @sa dBodyGetPosition + */ +ODE_API void dBodyCopyPosition (dBodyID body, dVector3 pos); + + +/** + * @brief Get the rotation of a body. + * @ingroup bodies + * @return pointer to a 4x3 rotation matrix. + */ +ODE_API const dReal * dBodyGetRotation (dBodyID); + + +/** + * @brief Copy the rotation of a body. + * @ingroup bodies + * @param body the body to query + * @param R a copy of the rotation matrix + * @sa dBodyGetRotation + */ +ODE_API void dBodyCopyRotation (dBodyID, dMatrix3 R); + + +/** + * @brief Get the rotation of a body. + * @ingroup bodies + * @return pointer to 4 scalars that represent the quaternion. + */ +ODE_API const dReal * dBodyGetQuaternion (dBodyID); + + +/** + * @brief Copy the orientation of a body into a quaternion. + * @ingroup bodies + * @param body the body to query + * @param quat a copy of the orientation quaternion + * @sa dBodyGetQuaternion + */ +ODE_API void dBodyCopyQuaternion(dBodyID body, dQuaternion quat); + + +/** + * @brief Get the linear velocity of a body. + * @ingroup bodies + */ +ODE_API const dReal * dBodyGetLinearVel (dBodyID); + +/** + * @brief Get the angular velocity of a body. + * @ingroup bodies + */ +ODE_API const dReal * dBodyGetAngularVel (dBodyID); + +/** + * @brief Set the mass of a body. + * @ingroup bodies + */ +ODE_API void dBodySetMass (dBodyID, const dMass *mass); + +/** + * @brief Get the mass of a body. + * @ingroup bodies + */ +ODE_API void dBodyGetMass (dBodyID, dMass *mass); + +/** + * @brief Add force at centre of mass of body in absolute coordinates. + * @ingroup bodies + */ +ODE_API void dBodyAddForce (dBodyID, dReal fx, dReal fy, dReal fz); + +/** + * @brief Add torque at centre of mass of body in absolute coordinates. + * @ingroup bodies + */ +ODE_API void dBodyAddTorque (dBodyID, dReal fx, dReal fy, dReal fz); + +/** + * @brief Add force at centre of mass of body in coordinates relative to body. + * @ingroup bodies + */ +ODE_API void dBodyAddRelForce (dBodyID, dReal fx, dReal fy, dReal fz); + +/** + * @brief Add torque at centre of mass of body in coordinates relative to body. + * @ingroup bodies + */ +ODE_API void dBodyAddRelTorque (dBodyID, dReal fx, dReal fy, dReal fz); + +/** + * @brief Add force at specified point in body in global coordinates. + * @ingroup bodies + */ +ODE_API void dBodyAddForceAtPos (dBodyID, dReal fx, dReal fy, dReal fz, + dReal px, dReal py, dReal pz); +/** + * @brief Add force at specified point in body in local coordinates. + * @ingroup bodies + */ +ODE_API void dBodyAddForceAtRelPos (dBodyID, dReal fx, dReal fy, dReal fz, + dReal px, dReal py, dReal pz); +/** + * @brief Add force at specified point in body in global coordinates. + * @ingroup bodies + */ +ODE_API void dBodyAddRelForceAtPos (dBodyID, dReal fx, dReal fy, dReal fz, + dReal px, dReal py, dReal pz); +/** + * @brief Add force at specified point in body in local coordinates. + * @ingroup bodies + */ +ODE_API void dBodyAddRelForceAtRelPos (dBodyID, dReal fx, dReal fy, dReal fz, + dReal px, dReal py, dReal pz); + +/** + * @brief Return the current accumulated force vector. + * @return points to an array of 3 reals. + * @remarks + * The returned values are pointers to internal data structures, so + * the vectors are only valid until any changes are made to the rigid + * body system. + * @ingroup bodies + */ +ODE_API const dReal * dBodyGetForce (dBodyID); + +/** + * @brief Return the current accumulated torque vector. + * @return points to an array of 3 reals. + * @remarks + * The returned values are pointers to internal data structures, so + * the vectors are only valid until any changes are made to the rigid + * body system. + * @ingroup bodies + */ +ODE_API const dReal * dBodyGetTorque (dBodyID); + +/** + * @brief Set the body force accumulation vector. + * @remarks + * This is mostly useful to zero the force and torque for deactivated bodies + * before they are reactivated, in the case where the force-adding functions + * were called on them while they were deactivated. + * @ingroup bodies + */ +ODE_API void dBodySetForce (dBodyID b, dReal x, dReal y, dReal z); + +/** + * @brief Set the body torque accumulation vector. + * @remarks + * This is mostly useful to zero the force and torque for deactivated bodies + * before they are reactivated, in the case where the force-adding functions + * were called on them while they were deactivated. + * @ingroup bodies + */ +ODE_API void dBodySetTorque (dBodyID b, dReal x, dReal y, dReal z); + +/** + * @brief Get world position of a relative point on body. + * @ingroup bodies + * @param result will contain the result. + */ +ODE_API void dBodyGetRelPointPos +( + dBodyID, dReal px, dReal py, dReal pz, + dVector3 result +); + +/** + * @brief Get velocity vector in global coords of a relative point on body. + * @ingroup bodies + * @param result will contain the result. + */ +ODE_API void dBodyGetRelPointVel +( + dBodyID, dReal px, dReal py, dReal pz, + dVector3 result +); + +/** + * @brief Get velocity vector in global coords of a globally + * specified point on a body. + * @ingroup bodies + * @param result will contain the result. + */ +ODE_API void dBodyGetPointVel +( + dBodyID, dReal px, dReal py, dReal pz, + dVector3 result +); + +/** + * @brief takes a point in global coordinates and returns + * the point's position in body-relative coordinates. + * @remarks + * This is the inverse of dBodyGetRelPointPos() + * @ingroup bodies + * @param result will contain the result. + */ +ODE_API void dBodyGetPosRelPoint +( + dBodyID, dReal px, dReal py, dReal pz, + dVector3 result +); + +/** + * @brief Convert from local to world coordinates. + * @ingroup bodies + * @param result will contain the result. + */ +ODE_API void dBodyVectorToWorld +( + dBodyID, dReal px, dReal py, dReal pz, + dVector3 result +); + +/** + * @brief Convert from world to local coordinates. + * @ingroup bodies + * @param result will contain the result. + */ +ODE_API void dBodyVectorFromWorld +( + dBodyID, dReal px, dReal py, dReal pz, + dVector3 result +); + +/** + * @brief controls the way a body's orientation is updated at each timestep. + * @ingroup bodies + * @param mode can be 0 or 1: + * \li 0: An ``infinitesimal'' orientation update is used. + * This is fast to compute, but it can occasionally cause inaccuracies + * for bodies that are rotating at high speed, especially when those + * bodies are joined to other bodies. + * This is the default for every new body that is created. + * \li 1: A ``finite'' orientation update is used. + * This is more costly to compute, but will be more accurate for high + * speed rotations. + * @remarks + * Note however that high speed rotations can result in many types of + * error in a simulation, and the finite mode will only fix one of those + * sources of error. + */ +ODE_API void dBodySetFiniteRotationMode (dBodyID, int mode); + +/** + * @brief sets the finite rotation axis for a body. + * @ingroup bodies + * @remarks + * This is axis only has meaning when the finite rotation mode is set + * If this axis is zero (0,0,0), full finite rotations are performed on + * the body. + * If this axis is nonzero, the body is rotated by performing a partial finite + * rotation along the axis direction followed by an infinitesimal rotation + * along an orthogonal direction. + * @remarks + * This can be useful to alleviate certain sources of error caused by quickly + * spinning bodies. For example, if a car wheel is rotating at high speed + * you can call this function with the wheel's hinge axis as the argument to + * try and improve its behavior. + */ +ODE_API void dBodySetFiniteRotationAxis (dBodyID, dReal x, dReal y, dReal z); + +/** + * @brief Get the way a body's orientation is updated each timestep. + * @ingroup bodies + * @return the mode 0 (infitesimal) or 1 (finite). + */ +ODE_API int dBodyGetFiniteRotationMode (dBodyID); + +/** + * @brief Get the finite rotation axis. + * @param result will contain the axis. + * @ingroup bodies + */ +ODE_API void dBodyGetFiniteRotationAxis (dBodyID, dVector3 result); + +/** + * @brief Get the number of joints that are attached to this body. + * @ingroup bodies + * @return nr of joints + */ +ODE_API int dBodyGetNumJoints (dBodyID b); + +/** + * @brief Return a joint attached to this body, given by index. + * @ingroup bodies + * @param index valid range is 0 to n-1 where n is the value returned by + * dBodyGetNumJoints(). + */ +ODE_API dJointID dBodyGetJoint (dBodyID, int index); + +/** + * @brief Manually enable a body. + * @param dBodyID identification of body. + * @ingroup bodies + */ +ODE_API void dBodyEnable (dBodyID); + +/** + * @brief Manually disable a body. + * @ingroup bodies + * @remarks + * A disabled body that is connected through a joint to an enabled body will + * be automatically re-enabled at the next simulation step. + */ +ODE_API void dBodyDisable (dBodyID); + +/** + * @brief Check wether a body is enabled. + * @ingroup bodies + * @return 1 if a body is currently enabled or 0 if it is disabled. + */ +ODE_API int dBodyIsEnabled (dBodyID); + +/** + * @brief Set whether the body is influenced by the world's gravity or not. + * @ingroup bodies + * @param mode when nonzero gravity affects this body. + * @remarks + * Newly created bodies are always influenced by the world's gravity. + */ +ODE_API void dBodySetGravityMode (dBodyID b, int mode); + +/** + * @brief Get whether the body is influenced by the world's gravity or not. + * @ingroup bodies + * @return nonzero means gravity affects this body. + */ +ODE_API int dBodyGetGravityMode (dBodyID b); + + + +/** + * @defgroup joints Joints + * + * In real life a joint is something like a hinge, that is used to connect two + * objects. + * In ODE a joint is very similar: It is a relationship that is enforced between + * two bodies so that they can only have certain positions and orientations + * relative to each other. + * This relationship is called a constraint -- the words joint and + * constraint are often used interchangeably. + * + * A joint has a set of parameters that can be set. These include: + * + * + * \li dParamLoStop Low stop angle or position. Setting this to + * -dInfinity (the default value) turns off the low stop. + * For rotational joints, this stop must be greater than -pi to be + * effective. + * \li dParamHiStop High stop angle or position. Setting this to + * dInfinity (the default value) turns off the high stop. + * For rotational joints, this stop must be less than pi to be + * effective. + * If the high stop is less than the low stop then both stops will + * be ineffective. + * \li dParamVel Desired motor velocity (this will be an angular or + * linear velocity). + * \li dParamFMax The maximum force or torque that the motor will use to + * achieve the desired velocity. + * This must always be greater than or equal to zero. + * Setting this to zero (the default value) turns off the motor. + * \li dParamFudgeFactor The current joint stop/motor implementation has + * a small problem: + * when the joint is at one stop and the motor is set to move it away + * from the stop, too much force may be applied for one time step, + * causing a ``jumping'' motion. + * This fudge factor is used to scale this excess force. + * It should have a value between zero and one (the default value). + * If the jumping motion is too visible in a joint, the value can be + * reduced. + * Making this value too small can prevent the motor from being able to + * move the joint away from a stop. + * \li dParamBounce The bouncyness of the stops. + * This is a restitution parameter in the range 0..1. + * 0 means the stops are not bouncy at all, 1 means maximum bouncyness. + * \li dParamCFM The constraint force mixing (CFM) value used when not + * at a stop. + * \li dParamStopERP The error reduction parameter (ERP) used by the + * stops. + * \li dParamStopCFM The constraint force mixing (CFM) value used by the + * stops. Together with the ERP value this can be used to get spongy or + * soft stops. + * Note that this is intended for unpowered joints, it does not really + * work as expected when a powered joint reaches its limit. + * \li dParamSuspensionERP Suspension error reduction parameter (ERP). + * Currently this is only implemented on the hinge-2 joint. + * \li dParamSuspensionCFM Suspension constraint force mixing (CFM) value. + * Currently this is only implemented on the hinge-2 joint. + * + * If a particular parameter is not implemented by a given joint, setting it + * will have no effect. + * These parameter names can be optionally followed by a digit (2 or 3) + * to indicate the second or third set of parameters, e.g. for the second axis + * in a hinge-2 joint, or the third axis in an AMotor joint. + */ + + +/** + * @brief Create a new joint of the ball type. + * @ingroup joints + * @remarks + * The joint is initially in "limbo" (i.e. it has no effect on the simulation) + * because it does not connect to any bodies. + * @param dJointGroupID set to 0 to allocate the joint normally. + * If it is nonzero the joint is allocated in the given joint group. + */ +ODE_API dJointID dJointCreateBall (dWorldID, dJointGroupID); + +/** + * @brief Create a new joint of the hinge type. + * @ingroup joints + * @param dJointGroupID set to 0 to allocate the joint normally. + * If it is nonzero the joint is allocated in the given joint group. + */ +ODE_API dJointID dJointCreateHinge (dWorldID, dJointGroupID); + +/** + * @brief Create a new joint of the slider type. + * @ingroup joints + * @param dJointGroupID set to 0 to allocate the joint normally. + * If it is nonzero the joint is allocated in the given joint group. + */ +ODE_API dJointID dJointCreateSlider (dWorldID, dJointGroupID); + +/** + * @brief Create a new joint of the contact type. + * @ingroup joints + * @param dJointGroupID set to 0 to allocate the joint normally. + * If it is nonzero the joint is allocated in the given joint group. + */ +ODE_API dJointID dJointCreateContact (dWorldID, dJointGroupID, const dContact *); + +/** + * @brief Create a new joint of the hinge2 type. + * @ingroup joints + * @param dJointGroupID set to 0 to allocate the joint normally. + * If it is nonzero the joint is allocated in the given joint group. + */ +ODE_API dJointID dJointCreateHinge2 (dWorldID, dJointGroupID); + +/** + * @brief Create a new joint of the universal type. + * @ingroup joints + * @param dJointGroupID set to 0 to allocate the joint normally. + * If it is nonzero the joint is allocated in the given joint group. + */ +ODE_API dJointID dJointCreateUniversal (dWorldID, dJointGroupID); + +/** + * @brief Create a new joint of the PR (Prismatic and Rotoide) type. + * @ingroup joints + * @param dJointGroupID set to 0 to allocate the joint normally. + * If it is nonzero the joint is allocated in the given joint group. + */ +ODE_API dJointID dJointCreatePR (dWorldID, dJointGroupID); + +/** + * @brief Create a new joint of the fixed type. + * @ingroup joints + * @param dJointGroupID set to 0 to allocate the joint normally. + * If it is nonzero the joint is allocated in the given joint group. + */ +ODE_API dJointID dJointCreateFixed (dWorldID, dJointGroupID); + +ODE_API dJointID dJointCreateNull (dWorldID, dJointGroupID); + +/** + * @brief Create a new joint of the A-motor type. + * @ingroup joints + * @param dJointGroupID set to 0 to allocate the joint normally. + * If it is nonzero the joint is allocated in the given joint group. + */ +ODE_API dJointID dJointCreateAMotor (dWorldID, dJointGroupID); + +/** + * @brief Create a new joint of the L-motor type. + * @ingroup joints + * @param dJointGroupID set to 0 to allocate the joint normally. + * If it is nonzero the joint is allocated in the given joint group. + */ +ODE_API dJointID dJointCreateLMotor (dWorldID, dJointGroupID); + +/** + * @brief Create a new joint of the plane-2d type. + * @ingroup joints + * @param dJointGroupID set to 0 to allocate the joint normally. + * If it is nonzero the joint is allocated in the given joint group. + */ +ODE_API dJointID dJointCreatePlane2D (dWorldID, dJointGroupID); + +/** + * @brief Destroy a joint. + * @ingroup joints + * + * disconnects it from its attached bodies and removing it from the world. + * However, if the joint is a member of a group then this function has no + * effect - to destroy that joint the group must be emptied or destroyed. + */ +ODE_API void dJointDestroy (dJointID); + + +/** + * @brief Create a joint group + * @ingroup joints + * @param max_size deprecated. Set to 0. + */ +ODE_API dJointGroupID dJointGroupCreate (int max_size); + +/** + * @brief Destroy a joint group. + * @ingroup joints + * + * All joints in the joint group will be destroyed. + */ +ODE_API void dJointGroupDestroy (dJointGroupID); + +/** + * @brief Empty a joint group. + * @ingroup joints + * + * All joints in the joint group will be destroyed, + * but the joint group itself will not be destroyed. + */ +ODE_API void dJointGroupEmpty (dJointGroupID); + +/** + * @brief Attach the joint to some new bodies. + * @ingroup joints + * + * If the joint is already attached, it will be detached from the old bodies + * first. + * To attach this joint to only one body, set body1 or body2 to zero - a zero + * body refers to the static environment. + * Setting both bodies to zero puts the joint into "limbo", i.e. it will + * have no effect on the simulation. + * @remarks + * Some joints, like hinge-2 need to be attached to two bodies to work. + */ +ODE_API void dJointAttach (dJointID, dBodyID body1, dBodyID body2); + +/** + * @brief Set the user-data pointer + * @ingroup joints + */ +ODE_API void dJointSetData (dJointID, void *data); + +/** + * @brief Get the user-data pointer + * @ingroup joints + */ +ODE_API void *dJointGetData (dJointID); + +/** + * @brief Get the type of the joint + * @ingroup joints + * @return the type, being one of these: + * \li JointTypeBall + * \li JointTypeHinge + * \li JointTypeSlider + * \li JointTypeContact + * \li JointTypeUniversal + * \li JointTypeHinge2 + * \li JointTypeFixed + * \li JointTypeAMotor + * \li JointTypeLMotor + */ +ODE_API int dJointGetType (dJointID); + +/** + * @brief Return the bodies that this joint connects. + * @ingroup joints + * @param index return the first (0) or second (1) body. + * @remarks + * If one of these returned body IDs is zero, the joint connects the other body + * to the static environment. + * If both body IDs are zero, the joint is in ``limbo'' and has no effect on + * the simulation. + */ +ODE_API dBodyID dJointGetBody (dJointID, int index); + +/** + * @brief Sets the datastructure that is to receive the feedback. + * + * The feedback can be used by the user, so that it is known how + * much force an individual joint exerts. + * @ingroup joints + */ +ODE_API void dJointSetFeedback (dJointID, dJointFeedback *); + +/** + * @brief Gets the datastructure that is to receive the feedback. + * @ingroup joints + */ +ODE_API dJointFeedback *dJointGetFeedback (dJointID); + +/** + * @brief Set the joint anchor point. + * @ingroup joints + * + * The joint will try to keep this point on each body + * together. The input is specified in world coordinates. + */ +ODE_API void dJointSetBallAnchor (dJointID, dReal x, dReal y, dReal z); + +/** + * @brief Set the joint anchor point. + * @ingroup joints + */ +ODE_API void dJointSetBallAnchor2 (dJointID, dReal x, dReal y, dReal z); + +/** + * @brief Set hinge anchor parameter. + * @ingroup joints + */ +ODE_API void dJointSetHingeAnchor (dJointID, dReal x, dReal y, dReal z); + +ODE_API void dJointSetHingeAnchorDelta (dJointID, dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az); + +/** + * @brief Set hinge axis. + * @ingroup joints + */ +ODE_API void dJointSetHingeAxis (dJointID, dReal x, dReal y, dReal z); + +/** + * @brief set joint parameter + * @ingroup joints + */ +ODE_API void dJointSetHingeParam (dJointID, int parameter, dReal value); + +/** + * @brief Applies the torque about the hinge axis. + * + * That is, it applies a torque with specified magnitude in the direction + * of the hinge axis, to body 1, and with the same magnitude but in opposite + * direction to body 2. This function is just a wrapper for dBodyAddTorque()} + * @ingroup joints + */ +ODE_API void dJointAddHingeTorque(dJointID joint, dReal torque); + +/** + * @brief set the joint axis + * @ingroup joints + */ +ODE_API void dJointSetSliderAxis (dJointID, dReal x, dReal y, dReal z); + +/** + * @ingroup joints + */ +ODE_API void dJointSetSliderAxisDelta (dJointID, dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az); + +/** + * @brief set joint parameter + * @ingroup joints + */ +ODE_API void dJointSetSliderParam (dJointID, int parameter, dReal value); + +/** + * @brief Applies the given force in the slider's direction. + * + * That is, it applies a force with specified magnitude, in the direction of + * slider's axis, to body1, and with the same magnitude but opposite + * direction to body2. This function is just a wrapper for dBodyAddForce(). + * @ingroup joints + */ +ODE_API void dJointAddSliderForce(dJointID joint, dReal force); + +/** + * @brief set anchor + * @ingroup joints + */ +ODE_API void dJointSetHinge2Anchor (dJointID, dReal x, dReal y, dReal z); + +/** + * @brief set axis + * @ingroup joints + */ +ODE_API void dJointSetHinge2Axis1 (dJointID, dReal x, dReal y, dReal z); + +/** + * @brief set axis + * @ingroup joints + */ +ODE_API void dJointSetHinge2Axis2 (dJointID, dReal x, dReal y, dReal z); + +/** + * @brief set joint parameter + * @ingroup joints + */ +ODE_API void dJointSetHinge2Param (dJointID, int parameter, dReal value); + +/** + * @brief Applies torque1 about the hinge2's axis 1, torque2 about the + * hinge2's axis 2. + * @remarks This function is just a wrapper for dBodyAddTorque(). + * @ingroup joints + */ +ODE_API void dJointAddHinge2Torques(dJointID joint, dReal torque1, dReal torque2); + +/** + * @brief set anchor + * @ingroup joints + */ +ODE_API void dJointSetUniversalAnchor (dJointID, dReal x, dReal y, dReal z); + +/** + * @brief set axis + * @ingroup joints + */ +ODE_API void dJointSetUniversalAxis1 (dJointID, dReal x, dReal y, dReal z); + +/** + * @brief set axis + * @ingroup joints + */ +ODE_API void dJointSetUniversalAxis2 (dJointID, dReal x, dReal y, dReal z); + +/** + * @brief set joint parameter + * @ingroup joints + */ +ODE_API void dJointSetUniversalParam (dJointID, int parameter, dReal value); + +/** + * @brief Applies torque1 about the universal's axis 1, torque2 about the + * universal's axis 2. + * @remarks This function is just a wrapper for dBodyAddTorque(). + * @ingroup joints + */ +ODE_API void dJointAddUniversalTorques(dJointID joint, dReal torque1, dReal torque2); + + +/** + * @brief set anchor + * @ingroup joints + */ +ODE_API void dJointSetPRAnchor (dJointID, dReal x, dReal y, dReal z); + +/** + * @brief set the axis for the prismatic articulation + * @ingroup joints + */ +ODE_API void dJointSetPRAxis1 (dJointID, dReal x, dReal y, dReal z); + +/** + * @brief set the axis for the rotoide articulation + * @ingroup joints + */ +ODE_API void dJointSetPRAxis2 (dJointID, dReal x, dReal y, dReal z); + +/** + * @brief set joint parameter + * @ingroup joints + * + * @note parameterX where X equal 2 refer to parameter for the rotoide articulation + */ +ODE_API void dJointSetPRParam (dJointID, int parameter, dReal value); + +/** + * @brief Applies the torque about the rotoide axis of the PR joint + * + * That is, it applies a torque with specified magnitude in the direction + * of the rotoide axis, to body 1, and with the same magnitude but in opposite + * direction to body 2. This function is just a wrapper for dBodyAddTorque()} + * @ingroup joints + */ +ODE_API void dJointAddPRTorque (dJointID j, dReal torque); + + +/** + * @brief Call this on the fixed joint after it has been attached to + * remember the current desired relative offset and desired relative + * rotation between the bodies. + * @ingroup joints + */ +ODE_API void dJointSetFixed (dJointID); + +/** + * @brief set the nr of axes + * @param num 0..3 + * @ingroup joints + */ +ODE_API void dJointSetAMotorNumAxes (dJointID, int num); + +/** + * @brief set axis + * @ingroup joints + */ +ODE_API void dJointSetAMotorAxis (dJointID, int anum, int rel, + dReal x, dReal y, dReal z); + +/** + * @brief Tell the AMotor what the current angle is along axis anum. + * + * This function should only be called in dAMotorUser mode, because in this + * mode the AMotor has no other way of knowing the joint angles. + * The angle information is needed if stops have been set along the axis, + * but it is not needed for axis motors. + * @ingroup joints + */ +ODE_API void dJointSetAMotorAngle (dJointID, int anum, dReal angle); + +/** + * @brief set joint parameter + * @ingroup joints + */ +ODE_API void dJointSetAMotorParam (dJointID, int parameter, dReal value); + +/** + * @brief set mode + * @ingroup joints + */ +ODE_API void dJointSetAMotorMode (dJointID, int mode); + +/** + * @brief Applies torque0 about the AMotor's axis 0, torque1 about the + * AMotor's axis 1, and torque2 about the AMotor's axis 2. + * @remarks + * If the motor has fewer than three axes, the higher torques are ignored. + * This function is just a wrapper for dBodyAddTorque(). + * @ingroup joints + */ +ODE_API void dJointAddAMotorTorques (dJointID, dReal torque1, dReal torque2, dReal torque3); + +/** + * @brief Set the number of axes that will be controlled by the LMotor. + * @param num can range from 0 (which effectively deactivates the joint) to 3. + * @ingroup joints + */ +ODE_API void dJointSetLMotorNumAxes (dJointID, int num); + +/** + * @brief Set the AMotor axes. + * @param anum selects the axis to change (0,1 or 2). + * @param rel Each axis can have one of three ``relative orientation'' modes + * \li 0: The axis is anchored to the global frame. + * \li 1: The axis is anchored to the first body. + * \li 2: The axis is anchored to the second body. + * @remarks The axis vector is always specified in global coordinates + * regardless of the setting of rel. + * @ingroup joints + */ +ODE_API void dJointSetLMotorAxis (dJointID, int anum, int rel, dReal x, dReal y, dReal z); + +/** + * @brief set joint parameter + * @ingroup joints + */ +ODE_API void dJointSetLMotorParam (dJointID, int parameter, dReal value); + +/** + * @ingroup joints + */ +ODE_API void dJointSetPlane2DXParam (dJointID, int parameter, dReal value); + +/** + * @ingroup joints + */ + +ODE_API void dJointSetPlane2DYParam (dJointID, int parameter, dReal value); + +/** + * @ingroup joints + */ +ODE_API void dJointSetPlane2DAngleParam (dJointID, int parameter, dReal value); + +/** + * @brief Get the joint anchor point, in world coordinates. + * + * This returns the point on body 1. If the joint is perfectly satisfied, + * this will be the same as the point on body 2. + */ +ODE_API void dJointGetBallAnchor (dJointID, dVector3 result); + +/** + * @brief Get the joint anchor point, in world coordinates. + * + * This returns the point on body 2. You can think of a ball and socket + * joint as trying to keep the result of dJointGetBallAnchor() and + * dJointGetBallAnchor2() the same. If the joint is perfectly satisfied, + * this function will return the same value as dJointGetBallAnchor() to + * within roundoff errors. dJointGetBallAnchor2() can be used, along with + * dJointGetBallAnchor(), to see how far the joint has come apart. + */ +ODE_API void dJointGetBallAnchor2 (dJointID, dVector3 result); + +/** + * @brief Get the hinge anchor point, in world coordinates. + * + * This returns the point on body 1. If the joint is perfectly satisfied, + * this will be the same as the point on body 2. + * @ingroup joints + */ +ODE_API void dJointGetHingeAnchor (dJointID, dVector3 result); + +/** + * @brief Get the joint anchor point, in world coordinates. + * @return The point on body 2. If the joint is perfectly satisfied, + * this will return the same value as dJointGetHingeAnchor(). + * If not, this value will be slightly different. + * This can be used, for example, to see how far the joint has come apart. + * @ingroup joints + */ +ODE_API void dJointGetHingeAnchor2 (dJointID, dVector3 result); + +/** + * @brief get axis + * @ingroup joints + */ +ODE_API void dJointGetHingeAxis (dJointID, dVector3 result); + +/** + * @brief get joint parameter + * @ingroup joints + */ +ODE_API dReal dJointGetHingeParam (dJointID, int parameter); + +/** + * @brief Get the hinge angle. + * + * The angle is measured between the two bodies, or between the body and + * the static environment. + * The angle will be between -pi..pi. + * When the hinge anchor or axis is set, the current position of the attached + * bodies is examined and that position will be the zero angle. + * @ingroup joints + */ +ODE_API dReal dJointGetHingeAngle (dJointID); + +/** + * @brief Get the hinge angle time derivative. + * @ingroup joints + */ +ODE_API dReal dJointGetHingeAngleRate (dJointID); + +/** + * @brief Get the slider linear position (i.e. the slider's extension) + * + * When the axis is set, the current position of the attached bodies is + * examined and that position will be the zero position. + * @ingroup joints + */ +ODE_API dReal dJointGetSliderPosition (dJointID); + +/** + * @brief Get the slider linear position's time derivative. + * @ingroup joints + */ +ODE_API dReal dJointGetSliderPositionRate (dJointID); + +/** + * @brief Get the slider axis + * @ingroup joints + */ +ODE_API void dJointGetSliderAxis (dJointID, dVector3 result); + +/** + * @brief get joint parameter + * @ingroup joints + */ +ODE_API dReal dJointGetSliderParam (dJointID, int parameter); + +/** + * @brief Get the joint anchor point, in world coordinates. + * @return the point on body 1. If the joint is perfectly satisfied, + * this will be the same as the point on body 2. + * @ingroup joints + */ +ODE_API void dJointGetHinge2Anchor (dJointID, dVector3 result); + +/** + * @brief Get the joint anchor point, in world coordinates. + * This returns the point on body 2. If the joint is perfectly satisfied, + * this will return the same value as dJointGetHinge2Anchor. + * If not, this value will be slightly different. + * This can be used, for example, to see how far the joint has come apart. + * @ingroup joints + */ +ODE_API void dJointGetHinge2Anchor2 (dJointID, dVector3 result); + +/** + * @brief Get joint axis + * @ingroup joints + */ +ODE_API void dJointGetHinge2Axis1 (dJointID, dVector3 result); + +/** + * @brief Get joint axis + * @ingroup joints + */ +ODE_API void dJointGetHinge2Axis2 (dJointID, dVector3 result); + +/** + * @brief get joint parameter + * @ingroup joints + */ +ODE_API dReal dJointGetHinge2Param (dJointID, int parameter); + +/** + * @brief Get angle + * @ingroup joints + */ +ODE_API dReal dJointGetHinge2Angle1 (dJointID); + +/** + * @brief Get time derivative of angle + * @ingroup joints + */ +ODE_API dReal dJointGetHinge2Angle1Rate (dJointID); + +/** + * @brief Get time derivative of angle + * @ingroup joints + */ +ODE_API dReal dJointGetHinge2Angle2Rate (dJointID); + +/** + * @brief Get the joint anchor point, in world coordinates. + * @return the point on body 1. If the joint is perfectly satisfied, + * this will be the same as the point on body 2. + * @ingroup joints + */ +ODE_API void dJointGetUniversalAnchor (dJointID, dVector3 result); + +/** + * @brief Get the joint anchor point, in world coordinates. + * @return This returns the point on body 2. + * @remarks + * You can think of the ball and socket part of a universal joint as + * trying to keep the result of dJointGetBallAnchor() and + * dJointGetBallAnchor2() the same. If the joint is + * perfectly satisfied, this function will return the same value + * as dJointGetUniversalAnchor() to within roundoff errors. + * dJointGetUniversalAnchor2() can be used, along with + * dJointGetUniversalAnchor(), to see how far the joint has come apart. + * @ingroup joints + */ +ODE_API void dJointGetUniversalAnchor2 (dJointID, dVector3 result); + +/** + * @brief Get axis + * @ingroup joints + */ +ODE_API void dJointGetUniversalAxis1 (dJointID, dVector3 result); + +/** + * @brief Get axis + * @ingroup joints + */ +ODE_API void dJointGetUniversalAxis2 (dJointID, dVector3 result); + + +/** + * @brief get joint parameter + * @ingroup joints + */ +ODE_API dReal dJointGetUniversalParam (dJointID, int parameter); + +/** + * @brief Get both angles at the same time. + * @ingroup joints + * + * @param joint The universal joint for which we want to calculate the angles + * @param angle1 The angle between the body1 and the axis 1 + * @param angle2 The angle between the body2 and the axis 2 + * + * @note This function combine getUniversalAngle1 and getUniversalAngle2 together + * and try to avoid redundant calculation + */ +ODE_API void dJointGetUniversalAngles (dJointID, dReal *angle1, dReal *angle2); + +/** + * @brief Get angle + * @ingroup joints + */ +ODE_API dReal dJointGetUniversalAngle1 (dJointID); + +/** + * @brief Get angle + * @ingroup joints + */ +ODE_API dReal dJointGetUniversalAngle2 (dJointID); + +/** + * @brief Get time derivative of angle + * @ingroup joints + */ +ODE_API dReal dJointGetUniversalAngle1Rate (dJointID); + +/** + * @brief Get time derivative of angle + * @ingroup joints + */ +ODE_API dReal dJointGetUniversalAngle2Rate (dJointID); + + + +/** + * @brief Get the joint anchor point, in world coordinates. + * @return the point on body 1. If the joint is perfectly satisfied, + * this will be the same as the point on body 2. + * @ingroup joints + */ +ODE_API void dJointGetPRAnchor (dJointID, dVector3 result); + +/** + * @brief Get the PR linear position (i.e. the prismatic's extension) + * + * When the axis is set, the current position of the attached bodies is + * examined and that position will be the zero position. + * + * The position is the "oriented" length between the + * position = (Prismatic axis) dot_product [(body1 + offset) - (body2 + anchor2)] + * + * @ingroup joints + */ +ODE_API dReal dJointGetPRPosition (dJointID); + +/** + * @brief Get the PR linear position's time derivative + * + * @ingroup joints + */ +ODE_API dReal dJointGetPRPositionRate (dJointID); + + +/** + * @brief Get the prismatic axis + * @ingroup joints + */ +ODE_API void dJointGetPRAxis1 (dJointID, dVector3 result); + +/** + * @brief Get the Rotoide axis + * @ingroup joints + */ +ODE_API void dJointGetPRAxis2 (dJointID, dVector3 result); + +/** + * @brief get joint parameter + * @ingroup joints + */ +ODE_API dReal dJointGetPRParam (dJointID, int parameter); + + + +/** + * @brief Get the number of angular axes that will be controlled by the + * AMotor. + * @param num can range from 0 (which effectively deactivates the + * joint) to 3. + * This is automatically set to 3 in dAMotorEuler mode. + * @ingroup joints + */ +ODE_API int dJointGetAMotorNumAxes (dJointID); + +/** + * @brief Get the AMotor axes. + * @param anum selects the axis to change (0,1 or 2). + * @param rel Each axis can have one of three ``relative orientation'' modes. + * \li 0: The axis is anchored to the global frame. + * \li 1: The axis is anchored to the first body. + * \li 2: The axis is anchored to the second body. + * @ingroup joints + */ +ODE_API void dJointGetAMotorAxis (dJointID, int anum, dVector3 result); + +/** + * @brief Get axis + * @remarks + * The axis vector is always specified in global coordinates regardless + * of the setting of rel. + * There are two GetAMotorAxis functions, one to return the axis and one to + * return the relative mode. + * + * For dAMotorEuler mode: + * \li Only axes 0 and 2 need to be set. Axis 1 will be determined + automatically at each time step. + * \li Axes 0 and 2 must be perpendicular to each other. + * \li Axis 0 must be anchored to the first body, axis 2 must be anchored + to the second body. + * @ingroup joints + */ +ODE_API int dJointGetAMotorAxisRel (dJointID, int anum); + +/** + * @brief Get the current angle for axis. + * @remarks + * In dAMotorUser mode this is simply the value that was set with + * dJointSetAMotorAngle(). + * In dAMotorEuler mode this is the corresponding euler angle. + * @ingroup joints + */ +ODE_API dReal dJointGetAMotorAngle (dJointID, int anum); + +/** + * @brief Get the current angle rate for axis anum. + * @remarks + * In dAMotorUser mode this is always zero, as not enough information is + * available. + * In dAMotorEuler mode this is the corresponding euler angle rate. + * @ingroup joints + */ +ODE_API dReal dJointGetAMotorAngleRate (dJointID, int anum); + +/** + * @brief get joint parameter + * @ingroup joints + */ +ODE_API dReal dJointGetAMotorParam (dJointID, int parameter); + +/** + * @brief Get the angular motor mode. + * @param mode must be one of the following constants: + * \li dAMotorUser The AMotor axes and joint angle settings are entirely + * controlled by the user. This is the default mode. + * \li dAMotorEuler Euler angles are automatically computed. + * The axis a1 is also automatically computed. + * The AMotor axes must be set correctly when in this mode, + * as described below. + * When this mode is initially set the current relative orientations + * of the bodies will correspond to all euler angles at zero. + * @ingroup joints + */ +ODE_API int dJointGetAMotorMode (dJointID); + +/** + * @brief Get nr of axes. + * @ingroup joints + */ +ODE_API int dJointGetLMotorNumAxes (dJointID); + +/** + * @brief Get axis. + * @ingroup joints + */ +ODE_API void dJointGetLMotorAxis (dJointID, int anum, dVector3 result); + +/** + * @brief get joint parameter + * @ingroup joints + */ +ODE_API dReal dJointGetLMotorParam (dJointID, int parameter); + + +/** + * @ingroup joints + */ +ODE_API dJointID dConnectingJoint (dBodyID, dBodyID); + +/** + * @ingroup joints + */ +ODE_API int dConnectingJointList (dBodyID, dBodyID, dJointID*); + +/** + * @brief Utility function + * @return 1 if the two bodies are connected together by + * a joint, otherwise return 0. + * @ingroup joints + */ +ODE_API int dAreConnected (dBodyID, dBodyID); + +/** + * @brief Utility function + * @return 1 if the two bodies are connected together by + * a joint that does not have type @arg{joint_type}, otherwise return 0. + * @param body1 A body to check. + * @param body2 A body to check. + * @param joint_type is a dJointTypeXXX constant. + * This is useful for deciding whether to add contact joints between two bodies: + * if they are already connected by non-contact joints then it may not be + * appropriate to add contacts, however it is okay to add more contact between- + * bodies that already have contacts. + * @ingroup joints + */ +ODE_API int dAreConnectedExcluding (dBodyID body1, dBodyID body2, int joint_type); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/ode.h b/school/informatik/verkerhssimulation/src/ogre/ode/ode.h new file mode 100644 index 00000000..00cd500b --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/ode.h @@ -0,0 +1,47 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +#ifndef _ODE_ODE_H_ +#define _ODE_ODE_H_ + +/* include *everything* here */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/odecpp.h b/school/informatik/verkerhssimulation/src/ogre/ode/odecpp.h new file mode 100644 index 00000000..13a6aa2b --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/odecpp.h @@ -0,0 +1,702 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +/* C++ interface for non-collision stuff */ + + +#ifndef _ODE_ODECPP_H_ +#define _ODE_ODECPP_H_ +#ifdef __cplusplus + +#include + + +class dWorld { + dWorldID _id; + + // intentionally undefined, don't use these + dWorld (const dWorld &); + void operator= (const dWorld &); + +public: + dWorld() + { _id = dWorldCreate(); } + ~dWorld() + { dWorldDestroy (_id); } + + dWorldID id() const + { return _id; } + operator dWorldID() const + { return _id; } + + void setGravity (dReal x, dReal y, dReal z) + { dWorldSetGravity (_id,x,y,z); } + void getGravity (dVector3 g) const + { dWorldGetGravity (_id,g); } + + void setERP (dReal erp) + { dWorldSetERP(_id, erp); } + dReal getERP() const + { return dWorldGetERP(_id); } + + void setCFM (dReal cfm) + { dWorldSetCFM(_id, cfm); } + dReal getCFM() const + { return dWorldGetCFM(_id); } + + void step (dReal stepsize) + { dWorldStep (_id,stepsize); } + + void stepFast1 (dReal stepsize, int maxiterations) + { dWorldStepFast1 (_id,stepsize,maxiterations); } + void setAutoEnableDepthSF1(dWorldID, int depth) + { dWorldSetAutoEnableDepthSF1 (_id, depth); } + int getAutoEnableDepthSF1(dWorldID) + { return dWorldGetAutoEnableDepthSF1 (_id); } + + void setAutoDisableLinearThreshold (dReal threshold) + { dWorldSetAutoDisableLinearThreshold (_id,threshold); } + dReal getAutoDisableLinearThreshold() + { return dWorldGetAutoDisableLinearThreshold (_id); } + void setAutoDisableAngularThreshold (dReal threshold) + { dWorldSetAutoDisableAngularThreshold (_id,threshold); } + dReal getAutoDisableAngularThreshold() + { return dWorldGetAutoDisableAngularThreshold (_id); } + void setAutoDisableSteps (int steps) + { dWorldSetAutoDisableSteps (_id,steps); } + int getAutoDisableSteps() + { return dWorldGetAutoDisableSteps (_id); } + void setAutoDisableTime (dReal time) + { dWorldSetAutoDisableTime (_id,time); } + dReal getAutoDisableTime() + { return dWorldGetAutoDisableTime (_id); } + void setAutoDisableFlag (int do_auto_disable) + { dWorldSetAutoDisableFlag (_id,do_auto_disable); } + int getAutoDisableFlag() + { return dWorldGetAutoDisableFlag (_id); } + + void impulseToForce (dReal stepsize, dReal ix, dReal iy, dReal iz, + dVector3 force) + { dWorldImpulseToForce (_id,stepsize,ix,iy,iz,force); } +}; + + +class dBody { + dBodyID _id; + + // intentionally undefined, don't use these + dBody (const dBody &); + void operator= (const dBody &); + +public: + dBody() + { _id = 0; } + dBody (dWorldID world) + { _id = dBodyCreate (world); } + ~dBody() + { if (_id) dBodyDestroy (_id); } + + void create (dWorldID world) { + if (_id) dBodyDestroy (_id); + _id = dBodyCreate (world); + } + + dBodyID id() const + { return _id; } + operator dBodyID() const + { return _id; } + + void setData (void *data) + { dBodySetData (_id,data); } + void *getData() const + { return dBodyGetData (_id); } + + void setPosition (dReal x, dReal y, dReal z) + { dBodySetPosition (_id,x,y,z); } + void setRotation (const dMatrix3 R) + { dBodySetRotation (_id,R); } + void setQuaternion (const dQuaternion q) + { dBodySetQuaternion (_id,q); } + void setLinearVel (dReal x, dReal y, dReal z) + { dBodySetLinearVel (_id,x,y,z); } + void setAngularVel (dReal x, dReal y, dReal z) + { dBodySetAngularVel (_id,x,y,z); } + + const dReal * getPosition() const + { return dBodyGetPosition (_id); } + const dReal * getRotation() const + { return dBodyGetRotation (_id); } + const dReal * getQuaternion() const + { return dBodyGetQuaternion (_id); } + const dReal * getLinearVel() const + { return dBodyGetLinearVel (_id); } + const dReal * getAngularVel() const + { return dBodyGetAngularVel (_id); } + + void setMass (const dMass *mass) + { dBodySetMass (_id,mass); } + void getMass (dMass *mass) const + { dBodyGetMass (_id,mass); } + + void addForce (dReal fx, dReal fy, dReal fz) + { dBodyAddForce (_id, fx, fy, fz); } + void addTorque (dReal fx, dReal fy, dReal fz) + { dBodyAddTorque (_id, fx, fy, fz); } + void addRelForce (dReal fx, dReal fy, dReal fz) + { dBodyAddRelForce (_id, fx, fy, fz); } + void addRelTorque (dReal fx, dReal fy, dReal fz) + { dBodyAddRelTorque (_id, fx, fy, fz); } + void addForceAtPos (dReal fx, dReal fy, dReal fz, + dReal px, dReal py, dReal pz) + { dBodyAddForceAtPos (_id, fx, fy, fz, px, py, pz); } + void addForceAtRelPos (dReal fx, dReal fy, dReal fz, + dReal px, dReal py, dReal pz) + { dBodyAddForceAtRelPos (_id, fx, fy, fz, px, py, pz); } + void addRelForceAtPos (dReal fx, dReal fy, dReal fz, + dReal px, dReal py, dReal pz) + { dBodyAddRelForceAtPos (_id, fx, fy, fz, px, py, pz); } + void addRelForceAtRelPos (dReal fx, dReal fy, dReal fz, + dReal px, dReal py, dReal pz) + { dBodyAddRelForceAtRelPos (_id, fx, fy, fz, px, py, pz); } + + const dReal * getForce() const + { return dBodyGetForce(_id); } + const dReal * getTorque() const + { return dBodyGetTorque(_id); } + void setForce (dReal x, dReal y, dReal z) + { dBodySetForce (_id,x,y,z); } + void setTorque (dReal x, dReal y, dReal z) + { dBodySetTorque (_id,x,y,z); } + + void enable() + { dBodyEnable (_id); } + void disable() + { dBodyDisable (_id); } + int isEnabled() const + { return dBodyIsEnabled (_id); } + + void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result) const + { dBodyGetRelPointPos (_id, px, py, pz, result); } + void getRelPointVel (dReal px, dReal py, dReal pz, dVector3 result) const + { dBodyGetRelPointVel (_id, px, py, pz, result); } + void getPointVel (dReal px, dReal py, dReal pz, dVector3 result) const + { dBodyGetPointVel (_id,px,py,pz,result); } + void getPosRelPoint (dReal px, dReal py, dReal pz, dVector3 result) const + { dBodyGetPosRelPoint (_id,px,py,pz,result); } + void vectorToWorld (dReal px, dReal py, dReal pz, dVector3 result) const + { dBodyVectorToWorld (_id,px,py,pz,result); } + void vectorFromWorld (dReal px, dReal py, dReal pz, dVector3 result) const + { dBodyVectorFromWorld (_id,px,py,pz,result); } + + void setFiniteRotationMode (int mode) + { dBodySetFiniteRotationMode (_id, mode); } + void setFiniteRotationAxis (dReal x, dReal y, dReal z) + { dBodySetFiniteRotationAxis (_id, x, y, z); } + + int getFiniteRotationMode() const + { return dBodyGetFiniteRotationMode (_id); } + void getFiniteRotationAxis (dVector3 result) const + { dBodyGetFiniteRotationAxis (_id, result); } + + int getNumJoints() const + { return dBodyGetNumJoints (_id); } + dJointID getJoint (int index) const + { return dBodyGetJoint (_id, index); } + + void setGravityMode (int mode) + { dBodySetGravityMode (_id,mode); } + int getGravityMode() const + { return dBodyGetGravityMode (_id); } + + int isConnectedTo (dBodyID body) const + { return dAreConnected (_id, body); } + + void setAutoDisableLinearThreshold (dReal threshold) + { dBodySetAutoDisableLinearThreshold (_id,threshold); } + dReal getAutoDisableLinearThreshold() + { return dBodyGetAutoDisableLinearThreshold (_id); } + void setAutoDisableAngularThreshold (dReal threshold) + { dBodySetAutoDisableAngularThreshold (_id,threshold); } + dReal getAutoDisableAngularThreshold() + { return dBodyGetAutoDisableAngularThreshold (_id); } + void setAutoDisableSteps (int steps) + { dBodySetAutoDisableSteps (_id,steps); } + int getAutoDisableSteps() + { return dBodyGetAutoDisableSteps (_id); } + void setAutoDisableTime (dReal time) + { dBodySetAutoDisableTime (_id,time); } + dReal getAutoDisableTime() + { return dBodyGetAutoDisableTime (_id); } + void setAutoDisableFlag (int do_auto_disable) + { dBodySetAutoDisableFlag (_id,do_auto_disable); } + int getAutoDisableFlag() + { return dBodyGetAutoDisableFlag (_id); } +}; + + +class dJointGroup { + dJointGroupID _id; + + // intentionally undefined, don't use these + dJointGroup (const dJointGroup &); + void operator= (const dJointGroup &); + +public: + dJointGroup (int dummy_arg=0) + { _id = dJointGroupCreate (0); } + ~dJointGroup() + { dJointGroupDestroy (_id); } + void create (int dummy_arg=0) { + if (_id) dJointGroupDestroy (_id); + _id = dJointGroupCreate (0); + } + + dJointGroupID id() const + { return _id; } + operator dJointGroupID() const + { return _id; } + + void empty() + { dJointGroupEmpty (_id); } +}; + + +class dJoint { +private: + // intentionally undefined, don't use these + dJoint (const dJoint &) ; + void operator= (const dJoint &); + +protected: + dJointID _id; + +public: + dJoint() + { _id = 0; } + ~dJoint() + { if (_id) dJointDestroy (_id); } + + dJointID id() const + { return _id; } + operator dJointID() const + { return _id; } + + void attach (dBodyID body1, dBodyID body2) + { dJointAttach (_id, body1, body2); } + + void setData (void *data) + { dJointSetData (_id, data); } + void *getData() const + { return dJointGetData (_id); } + + int getType() const + { return dJointGetType (_id); } + + dBodyID getBody (int index) const + { return dJointGetBody (_id, index); } + + void setFeedback(dJointFeedback *fb) + { dJointSetFeedback(_id, fb); } + dJointFeedback *getFeedback() const + { return dJointGetFeedback(_id); } +}; + + +class dBallJoint : public dJoint { +private: + // intentionally undefined, don't use these + dBallJoint (const dBallJoint &); + void operator= (const dBallJoint &); + +public: + dBallJoint() { } + dBallJoint (dWorldID world, dJointGroupID group=0) + { _id = dJointCreateBall (world, group); } + + void create (dWorldID world, dJointGroupID group=0) { + if (_id) dJointDestroy (_id); + _id = dJointCreateBall (world, group); + } + + void setAnchor (dReal x, dReal y, dReal z) + { dJointSetBallAnchor (_id, x, y, z); } + void getAnchor (dVector3 result) const + { dJointGetBallAnchor (_id, result); } + void getAnchor2 (dVector3 result) const + { dJointGetBallAnchor2 (_id, result); } +} ; + + +class dHingeJoint : public dJoint { + // intentionally undefined, don't use these + dHingeJoint (const dHingeJoint &); + void operator = (const dHingeJoint &); + +public: + dHingeJoint() { } + dHingeJoint (dWorldID world, dJointGroupID group=0) + { _id = dJointCreateHinge (world, group); } + + void create (dWorldID world, dJointGroupID group=0) { + if (_id) dJointDestroy (_id); + _id = dJointCreateHinge (world, group); + } + + void setAnchor (dReal x, dReal y, dReal z) + { dJointSetHingeAnchor (_id, x, y, z); } + void getAnchor (dVector3 result) const + { dJointGetHingeAnchor (_id, result); } + void getAnchor2 (dVector3 result) const + { dJointGetHingeAnchor2 (_id, result); } + + void setAxis (dReal x, dReal y, dReal z) + { dJointSetHingeAxis (_id, x, y, z); } + void getAxis (dVector3 result) const + { dJointGetHingeAxis (_id, result); } + + dReal getAngle() const + { return dJointGetHingeAngle (_id); } + dReal getAngleRate() const + { return dJointGetHingeAngleRate (_id); } + + void setParam (int parameter, dReal value) + { dJointSetHingeParam (_id, parameter, value); } + dReal getParam (int parameter) const + { return dJointGetHingeParam (_id, parameter); } + + void addTorque (dReal torque) + { dJointAddHingeTorque(_id, torque); } +}; + + +class dSliderJoint : public dJoint { + // intentionally undefined, don't use these + dSliderJoint (const dSliderJoint &); + void operator = (const dSliderJoint &); + +public: + dSliderJoint() { } + dSliderJoint (dWorldID world, dJointGroupID group=0) + { _id = dJointCreateSlider (world, group); } + + void create (dWorldID world, dJointGroupID group=0) { + if (_id) dJointDestroy (_id); + _id = dJointCreateSlider (world, group); + } + + void setAxis (dReal x, dReal y, dReal z) + { dJointSetSliderAxis (_id, x, y, z); } + void getAxis (dVector3 result) const + { dJointGetSliderAxis (_id, result); } + + dReal getPosition() const + { return dJointGetSliderPosition (_id); } + dReal getPositionRate() const + { return dJointGetSliderPositionRate (_id); } + + void setParam (int parameter, dReal value) + { dJointSetSliderParam (_id, parameter, value); } + dReal getParam (int parameter) const + { return dJointGetSliderParam (_id, parameter); } + + void addForce (dReal force) + { dJointAddSliderForce(_id, force); } +}; + + +class dUniversalJoint : public dJoint { + // intentionally undefined, don't use these + dUniversalJoint (const dUniversalJoint &); + void operator = (const dUniversalJoint &); + +public: + dUniversalJoint() { } + dUniversalJoint (dWorldID world, dJointGroupID group=0) + { _id = dJointCreateUniversal (world, group); } + + void create (dWorldID world, dJointGroupID group=0) { + if (_id) dJointDestroy (_id); + _id = dJointCreateUniversal (world, group); + } + + void setAnchor (dReal x, dReal y, dReal z) + { dJointSetUniversalAnchor (_id, x, y, z); } + void setAxis1 (dReal x, dReal y, dReal z) + { dJointSetUniversalAxis1 (_id, x, y, z); } + void setAxis2 (dReal x, dReal y, dReal z) + { dJointSetUniversalAxis2 (_id, x, y, z); } + void setParam (int parameter, dReal value) + { dJointSetUniversalParam (_id, parameter, value); } + + void getAnchor (dVector3 result) const + { dJointGetUniversalAnchor (_id, result); } + void getAnchor2 (dVector3 result) const + { dJointGetUniversalAnchor2 (_id, result); } + void getAxis1 (dVector3 result) const + { dJointGetUniversalAxis1 (_id, result); } + void getAxis2 (dVector3 result) const + { dJointGetUniversalAxis2 (_id, result); } + dReal getParam (int parameter) const + { return dJointGetUniversalParam (_id, parameter); } + void getAngles(dReal *angle1, dReal *angle2) const + { dJointGetUniversalAngles (_id, angle1, angle2); } + + dReal getAngle1() const + { return dJointGetUniversalAngle1 (_id); } + dReal getAngle1Rate() const + { return dJointGetUniversalAngle1Rate (_id); } + dReal getAngle2() const + { return dJointGetUniversalAngle2 (_id); } + dReal getAngle2Rate() const + { return dJointGetUniversalAngle2Rate (_id); } + + void addTorques (dReal torque1, dReal torque2) + { dJointAddUniversalTorques(_id, torque1, torque2); } +}; + + +class dHinge2Joint : public dJoint { + // intentionally undefined, don't use these + dHinge2Joint (const dHinge2Joint &); + void operator = (const dHinge2Joint &); + +public: + dHinge2Joint() { } + dHinge2Joint (dWorldID world, dJointGroupID group=0) + { _id = dJointCreateHinge2 (world, group); } + + void create (dWorldID world, dJointGroupID group=0) { + if (_id) dJointDestroy (_id); + _id = dJointCreateHinge2 (world, group); + } + + void setAnchor (dReal x, dReal y, dReal z) + { dJointSetHinge2Anchor (_id, x, y, z); } + void setAxis1 (dReal x, dReal y, dReal z) + { dJointSetHinge2Axis1 (_id, x, y, z); } + void setAxis2 (dReal x, dReal y, dReal z) + { dJointSetHinge2Axis2 (_id, x, y, z); } + + void getAnchor (dVector3 result) const + { dJointGetHinge2Anchor (_id, result); } + void getAnchor2 (dVector3 result) const + { dJointGetHinge2Anchor2 (_id, result); } + void getAxis1 (dVector3 result) const + { dJointGetHinge2Axis1 (_id, result); } + void getAxis2 (dVector3 result) const + { dJointGetHinge2Axis2 (_id, result); } + + dReal getAngle1() const + { return dJointGetHinge2Angle1 (_id); } + dReal getAngle1Rate() const + { return dJointGetHinge2Angle1Rate (_id); } + dReal getAngle2Rate() const + { return dJointGetHinge2Angle2Rate (_id); } + + void setParam (int parameter, dReal value) + { dJointSetHinge2Param (_id, parameter, value); } + dReal getParam (int parameter) const + { return dJointGetHinge2Param (_id, parameter); } + + void addTorques(dReal torque1, dReal torque2) + { dJointAddHinge2Torques(_id, torque1, torque2); } +}; + + +class dPRJoint : public dJoint { + dPRJoint (const dPRJoint &); + void operator = (const dPRJoint &); + +public: + dPRJoint() { } + dPRJoint (dWorldID world, dJointGroupID group=0) + { _id = dJointCreatePR (world, group); } + + void create (dWorldID world, dJointGroupID group=0) { + if (_id) dJointDestroy (_id); + _id = dJointCreatePR (world, group); + } + + void setAnchor (dReal x, dReal y, dReal z) + { dJointSetPRAnchor (_id, x, y, z); } + void setAxis1 (dReal x, dReal y, dReal z) + { dJointSetPRAxis1 (_id, x, y, z); } + void setAxis2 (dReal x, dReal y, dReal z) + { dJointSetPRAxis2 (_id, x, y, z); } + + void getAnchor (dVector3 result) const + { dJointGetPRAnchor (_id, result); } + void getAxis1 (dVector3 result) const + { dJointGetPRAxis1 (_id, result); } + void getAxis2 (dVector3 result) const + { dJointGetPRAxis2 (_id, result); } + + dReal getPosition() const + { return dJointGetPRPosition (_id); } + dReal getPositionRate() const + { return dJointGetPRPositionRate (_id); } + + void setParam (int parameter, dReal value) + { dJointSetPRParam (_id, parameter, value); } + dReal getParam (int parameter) const + { return dJointGetPRParam (_id, parameter); } +}; + + +class dFixedJoint : public dJoint { + // intentionally undefined, don't use these + dFixedJoint (const dFixedJoint &); + void operator = (const dFixedJoint &); + +public: + dFixedJoint() { } + dFixedJoint (dWorldID world, dJointGroupID group=0) + { _id = dJointCreateFixed (world, group); } + + void create (dWorldID world, dJointGroupID group=0) { + if (_id) dJointDestroy (_id); + _id = dJointCreateFixed (world, group); + } + + void set() + { dJointSetFixed (_id); } +}; + + +class dContactJoint : public dJoint { + // intentionally undefined, don't use these + dContactJoint (const dContactJoint &); + void operator = (const dContactJoint &); + +public: + dContactJoint() { } + dContactJoint (dWorldID world, dJointGroupID group, dContact *contact) + { _id = dJointCreateContact (world, group, contact); } + + void create (dWorldID world, dJointGroupID group, dContact *contact) { + if (_id) dJointDestroy (_id); + _id = dJointCreateContact (world, group, contact); + } +}; + + +class dNullJoint : public dJoint { + // intentionally undefined, don't use these + dNullJoint (const dNullJoint &); + void operator = (const dNullJoint &); + +public: + dNullJoint() { } + dNullJoint (dWorldID world, dJointGroupID group=0) + { _id = dJointCreateNull (world, group); } + + void create (dWorldID world, dJointGroupID group=0) { + if (_id) dJointDestroy (_id); + _id = dJointCreateNull (world, group); + } +}; + + +class dAMotorJoint : public dJoint { + // intentionally undefined, don't use these + dAMotorJoint (const dAMotorJoint &); + void operator = (const dAMotorJoint &); + +public: + dAMotorJoint() { } + dAMotorJoint (dWorldID world, dJointGroupID group=0) + { _id = dJointCreateAMotor (world, group); } + + void create (dWorldID world, dJointGroupID group=0) { + if (_id) dJointDestroy (_id); + _id = dJointCreateAMotor (world, group); + } + + void setMode (int mode) + { dJointSetAMotorMode (_id, mode); } + int getMode() const + { return dJointGetAMotorMode (_id); } + + void setNumAxes (int num) + { dJointSetAMotorNumAxes (_id, num); } + int getNumAxes() const + { return dJointGetAMotorNumAxes (_id); } + + void setAxis (int anum, int rel, dReal x, dReal y, dReal z) + { dJointSetAMotorAxis (_id, anum, rel, x, y, z); } + void getAxis (int anum, dVector3 result) const + { dJointGetAMotorAxis (_id, anum, result); } + int getAxisRel (int anum) const + { return dJointGetAMotorAxisRel (_id, anum); } + + void setAngle (int anum, dReal angle) + { dJointSetAMotorAngle (_id, anum, angle); } + dReal getAngle (int anum) const + { return dJointGetAMotorAngle (_id, anum); } + dReal getAngleRate (int anum) + { return dJointGetAMotorAngleRate (_id,anum); } + + void setParam (int parameter, dReal value) + { dJointSetAMotorParam (_id, parameter, value); } + dReal getParam (int parameter) const + { return dJointGetAMotorParam (_id, parameter); } + + void addTorques(dReal torque1, dReal torque2, dReal torque3) + { dJointAddAMotorTorques(_id, torque1, torque2, torque3); } +}; + + +class dLMotorJoint : public dJoint { + // intentionally undefined, don't use these + dLMotorJoint (const dLMotorJoint &); + void operator = (const dLMotorJoint &); + +public: + dLMotorJoint() { } + dLMotorJoint (dWorldID world, dJointGroupID group=0) + { _id = dJointCreateLMotor (world, group); } + + void create (dWorldID world, dJointGroupID group=0) { + if (_id) dJointDestroy (_id); + _id = dJointCreateLMotor (world, group); + } + + void setNumAxes (int num) + { dJointSetLMotorNumAxes (_id, num); } + int getNumAxes() const + { return dJointGetLMotorNumAxes (_id); } + + void setAxis (int anum, int rel, dReal x, dReal y, dReal z) + { dJointSetLMotorAxis (_id, anum, rel, x, y, z); } + void getAxis (int anum, dVector3 result) const + { dJointGetLMotorAxis (_id, anum, result); } + + void setParam (int parameter, dReal value) + { dJointSetLMotorParam (_id, parameter, value); } + dReal getParam (int parameter) const + { return dJointGetLMotorParam (_id, parameter); } +}; + + + +#endif +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/odecpp_collision.h b/school/informatik/verkerhssimulation/src/ogre/ode/odecpp_collision.h new file mode 100644 index 00000000..16ca78f7 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/odecpp_collision.h @@ -0,0 +1,346 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +/* C++ interface for new collision API */ + + +#ifndef _ODE_ODECPP_COLLISION_H_ +#define _ODE_ODECPP_COLLISION_H_ +#ifdef __cplusplus + +#include + + +class dGeom { + // intentionally undefined, don't use these + dGeom (dGeom &); + void operator= (dGeom &); + +protected: + dGeomID _id; + +public: + dGeom() + { _id = 0; } + ~dGeom() + { if (_id) dGeomDestroy (_id); } + + dGeomID id() const + { return _id; } + operator dGeomID() const + { return _id; } + + void destroy() { + if (_id) dGeomDestroy (_id); + _id = 0; + } + + int getClass() const + { return dGeomGetClass (_id); } + + dSpaceID getSpace() const + { return dGeomGetSpace (_id); } + + void setData (void *data) + { dGeomSetData (_id,data); } + void *getData() const + { return dGeomGetData (_id); } + + void setBody (dBodyID b) + { dGeomSetBody (_id,b); } + dBodyID getBody() const + { return dGeomGetBody (_id); } + + void setPosition (dReal x, dReal y, dReal z) + { dGeomSetPosition (_id,x,y,z); } + const dReal * getPosition() const + { return dGeomGetPosition (_id); } + + void setRotation (const dMatrix3 R) + { dGeomSetRotation (_id,R); } + const dReal * getRotation() const + { return dGeomGetRotation (_id); } + + void setQuaternion (const dQuaternion quat) + { dGeomSetQuaternion (_id,quat); } + void getQuaternion (dQuaternion quat) const + { dGeomGetQuaternion (_id,quat); } + + void getAABB (dReal aabb[6]) const + { dGeomGetAABB (_id, aabb); } + + int isSpace() + { return dGeomIsSpace (_id); } + + void setCategoryBits (unsigned long bits) + { dGeomSetCategoryBits (_id, bits); } + void setCollideBits (unsigned long bits) + { dGeomSetCollideBits (_id, bits); } + unsigned long getCategoryBits() + { return dGeomGetCategoryBits (_id); } + unsigned long getCollideBits() + { return dGeomGetCollideBits (_id); } + + void enable() + { dGeomEnable (_id); } + void disable() + { dGeomDisable (_id); } + int isEnabled() + { return dGeomIsEnabled (_id); } + + void collide2 (dGeomID g, void *data, dNearCallback *callback) + { dSpaceCollide2 (_id,g,data,callback); } +}; + + +class dSpace : public dGeom { + // intentionally undefined, don't use these + dSpace (dSpace &); + void operator= (dSpace &); + +protected: + // the default constructor is protected so that you + // can't instance this class. you must instance one + // of its subclasses instead. + dSpace () { _id = 0; } + +public: + dSpaceID id() const + { return (dSpaceID) _id; } + operator dSpaceID() const + { return (dSpaceID) _id; } + + void setCleanup (int mode) + { dSpaceSetCleanup (id(), mode); } + int getCleanup() + { return dSpaceGetCleanup (id()); } + + void add (dGeomID x) + { dSpaceAdd (id(), x); } + void remove (dGeomID x) + { dSpaceRemove (id(), x); } + int query (dGeomID x) + { return dSpaceQuery (id(),x); } + + int getNumGeoms() + { return dSpaceGetNumGeoms (id()); } + dGeomID getGeom (int i) + { return dSpaceGetGeom (id(),i); } + + void collide (void *data, dNearCallback *callback) + { dSpaceCollide (id(),data,callback); } +}; + + +class dSimpleSpace : public dSpace { + // intentionally undefined, don't use these + dSimpleSpace (dSimpleSpace &); + void operator= (dSimpleSpace &); + +public: + dSimpleSpace (dSpaceID space) + { _id = (dGeomID) dSimpleSpaceCreate (space); } +}; + + +class dHashSpace : public dSpace { + // intentionally undefined, don't use these + dHashSpace (dHashSpace &); + void operator= (dHashSpace &); + +public: + dHashSpace (dSpaceID space) + { _id = (dGeomID) dHashSpaceCreate (space); } + void setLevels (int minlevel, int maxlevel) + { dHashSpaceSetLevels (id(),minlevel,maxlevel); } +}; + + +class dQuadTreeSpace : public dSpace { + // intentionally undefined, don't use these + dQuadTreeSpace (dQuadTreeSpace &); + void operator= (dQuadTreeSpace &); + +public: + dQuadTreeSpace (dSpaceID space, dVector3 center, dVector3 extents, int depth) + { _id = (dGeomID) dQuadTreeSpaceCreate (space,center,extents,depth); } +}; + + +class dSphere : public dGeom { + // intentionally undefined, don't use these + dSphere (dSphere &); + void operator= (dSphere &); + +public: + dSphere () { } + dSphere (dSpaceID space, dReal radius) + { _id = dCreateSphere (space, radius); } + + void create (dSpaceID space, dReal radius) { + if (_id) dGeomDestroy (_id); + _id = dCreateSphere (space, radius); + } + + void setRadius (dReal radius) + { dGeomSphereSetRadius (_id, radius); } + dReal getRadius() const + { return dGeomSphereGetRadius (_id); } +}; + + +class dBox : public dGeom { + // intentionally undefined, don't use these + dBox (dBox &); + void operator= (dBox &); + +public: + dBox () { } + dBox (dSpaceID space, dReal lx, dReal ly, dReal lz) + { _id = dCreateBox (space,lx,ly,lz); } + + void create (dSpaceID space, dReal lx, dReal ly, dReal lz) { + if (_id) dGeomDestroy (_id); + _id = dCreateBox (space,lx,ly,lz); + } + + void setLengths (dReal lx, dReal ly, dReal lz) + { dGeomBoxSetLengths (_id, lx, ly, lz); } + void getLengths (dVector3 result) const + { dGeomBoxGetLengths (_id,result); } +}; + + +class dPlane : public dGeom { + // intentionally undefined, don't use these + dPlane (dPlane &); + void operator= (dPlane &); + +public: + dPlane() { } + dPlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d) + { _id = dCreatePlane (space,a,b,c,d); } + + void create (dSpaceID space, dReal a, dReal b, dReal c, dReal d) { + if (_id) dGeomDestroy (_id); + _id = dCreatePlane (space,a,b,c,d); + } + + void setParams (dReal a, dReal b, dReal c, dReal d) + { dGeomPlaneSetParams (_id, a, b, c, d); } + void getParams (dVector4 result) const + { dGeomPlaneGetParams (_id,result); } +}; + + +class dCapsule : public dGeom { + // intentionally undefined, don't use these + dCapsule (dCapsule &); + void operator= (dCapsule &); + +public: + dCapsule() { } + dCapsule (dSpaceID space, dReal radius, dReal length) + { _id = dCreateCapsule (space,radius,length); } + + void create (dSpaceID space, dReal radius, dReal length) { + if (_id) dGeomDestroy (_id); + _id = dCreateCapsule (space,radius,length); + } + + void setParams (dReal radius, dReal length) + { dGeomCapsuleSetParams (_id, radius, length); } + void getParams (dReal *radius, dReal *length) const + { dGeomCapsuleGetParams (_id,radius,length); } +}; + + +class dRay : public dGeom { + // intentionally undefined, don't use these + dRay (dRay &); + void operator= (dRay &); + +public: + dRay() { } + dRay (dSpaceID space, dReal length) + { _id = dCreateRay (space,length); } + + void create (dSpaceID space, dReal length) { + if (_id) dGeomDestroy (_id); + _id = dCreateRay (space,length); + } + + void setLength (dReal length) + { dGeomRaySetLength (_id, length); } + dReal getLength() + { return dGeomRayGetLength (_id); } + + void set (dReal px, dReal py, dReal pz, dReal dx, dReal dy, dReal dz) + { dGeomRaySet (_id, px, py, pz, dx, dy, dz); } + void get (dVector3 start, dVector3 dir) + { dGeomRayGet (_id, start, dir); } + + void setParams (int firstContact, int backfaceCull) + { dGeomRaySetParams (_id, firstContact, backfaceCull); } + void getParams (int *firstContact, int *backfaceCull) + { dGeomRayGetParams (_id, firstContact, backfaceCull); } + void setClosestHit (int closestHit) + { dGeomRaySetClosestHit (_id, closestHit); } + int getClosestHit() + { return dGeomRayGetClosestHit (_id); } +}; + + +class dGeomTransform : public dGeom { + // intentionally undefined, don't use these + dGeomTransform (dGeomTransform &); + void operator= (dGeomTransform &); + +public: + dGeomTransform() { } + dGeomTransform (dSpaceID space) + { _id = dCreateGeomTransform (space); } + + void create (dSpaceID space=0) { + if (_id) dGeomDestroy (_id); + _id = dCreateGeomTransform (space); + } + + void setGeom (dGeomID geom) + { dGeomTransformSetGeom (_id, geom); } + dGeomID getGeom() const + { return dGeomTransformGetGeom (_id); } + + void setCleanup (int mode) + { dGeomTransformSetCleanup (_id,mode); } + int getCleanup () + { return dGeomTransformGetCleanup (_id); } + + void setInfo (int mode) + { dGeomTransformSetInfo (_id,mode); } + int getInfo() + { return dGeomTransformGetInfo (_id); } +}; + + +#endif +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/odecpp_old.h b/school/informatik/verkerhssimulation/src/ogre/ode/odecpp_old.h new file mode 100644 index 00000000..49e7d7f3 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/odecpp_old.h @@ -0,0 +1,316 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +/* this is the old C++ interface, the new C++ interface is not quite + * compatible with this. but this file is kept around in case you were + * using the old interface. + */ + +#ifndef _ODE_ODECPP_H_ +#define _ODE_ODECPP_H_ +#ifdef __cplusplus + +#include + + +class dWorld { + dWorldID _id; + + dWorld (dWorld &) { dDebug (0,"bad"); } + void operator= (dWorld &) { dDebug (0,"bad"); } + +public: + dWorld() + { _id = dWorldCreate(); } + ~dWorld() + { dWorldDestroy (_id); } + dWorldID id() + { return _id; } + + void setGravity (dReal x, dReal y, dReal z) + { dWorldSetGravity (_id,x,y,z); } + void getGravity (dVector3 g) + { dWorldGetGravity (_id,g); } + void step (dReal stepsize) + { dWorldStep (_id,stepsize); } +}; + + +class dBody { + dBodyID _id; + + dBody (dBody &) { dDebug (0,"bad"); } + void operator= (dBody &) { dDebug (0,"bad"); } + +public: + dBody() + { _id = 0; } + dBody (dWorld &world) + { _id = dBodyCreate (world.id()); } + ~dBody() + { dBodyDestroy (_id); } + void create (dWorld &world) + { if (_id) dBodyDestroy (_id); _id = dBodyCreate (world.id()); } + dBodyID id() + { return _id; } + + void setData (void *data) + { dBodySetData (_id,data); } + void *getData() + { return dBodyGetData (_id); } + + void setPosition (dReal x, dReal y, dReal z) + { dBodySetPosition (_id,x,y,z); } + void setRotation (const dMatrix3 R) + { dBodySetRotation (_id,R); } + void setQuaternion (const dQuaternion q) + { dBodySetQuaternion (_id,q); } + void setLinearVel (dReal x, dReal y, dReal z) + { dBodySetLinearVel (_id,x,y,z); } + void setAngularVel (dReal x, dReal y, dReal z) + { dBodySetAngularVel (_id,x,y,z); } + + const dReal * getPosition() + { return dBodyGetPosition (_id); } + const dReal * getRotation() + { return dBodyGetRotation (_id); } + const dReal * getQuaternion() + { return dBodyGetQuaternion (_id); } + const dReal * getLinearVel() + { return dBodyGetLinearVel (_id); } + const dReal * getAngularVel() + { return dBodyGetAngularVel (_id); } + + void setMass (const dMass *mass) + { dBodySetMass (_id,mass); } + void getMass (dMass *mass) + { dBodyGetMass (_id,mass); } + + void addForce (dReal fx, dReal fy, dReal fz) + { dBodyAddForce (_id, fx, fy, fz); } + void addTorque (dReal fx, dReal fy, dReal fz) + { dBodyAddTorque (_id, fx, fy, fz); } + void addRelForce (dReal fx, dReal fy, dReal fz) + { dBodyAddRelForce (_id, fx, fy, fz); } + void addRelTorque (dReal fx, dReal fy, dReal fz) + { dBodyAddRelTorque (_id, fx, fy, fz); } + void addForceAtPos (dReal fx, dReal fy, dReal fz, + dReal px, dReal py, dReal pz) + { dBodyAddForceAtPos (_id, fx, fy, fz, px, py, pz); } + void addRelForceAtPos (dReal fx, dReal fy, dReal fz, + dReal px, dReal py, dReal pz) + { dBodyAddRelForceAtPos (_id, fx, fy, fz, px, py, pz); } + void addRelForceAtRelPos (dReal fx, dReal fy, dReal fz, + dReal px, dReal py, dReal pz) + { dBodyAddRelForceAtRelPos (_id, fx, fy, fz, px, py, pz); } + + void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result) + { dBodyGetRelPointPos (_id, px, py, pz, result); } + void getRelPointVel (dReal px, dReal py, dReal pz, dVector3 result) + { dBodyGetRelPointVel (_id, px, py, pz, result); } + + int isConnectedTo (const dBody &b) + { return dAreConnected (_id,b._id); } +}; + + +class dJointGroup { + dJointGroupID _id; + + dJointGroup (dJointGroup &) { dDebug (0,"bad"); } + void operator= (dJointGroup &) { dDebug (0,"bad"); } + +public: + dJointGroup() + { _id = 0; } + dJointGroup (int max_size) + { _id = dJointGroupCreate (max_size); } + ~dJointGroup() + { dJointGroupDestroy (_id); } + void create (int max_size) + { if (_id) dJointGroupDestroy (_id); _id = dJointGroupCreate (max_size); } + dJointGroupID id() + { return _id; } + + void empty() + { dJointGroupEmpty (_id); } +}; + + +class dJoint { + dJointID _id; + + dJoint (dJoint &) { dDebug (0,"bad"); } + void operator= (dJoint &) { dDebug (0,"bad"); } + +public: + dJoint() + { _id = 0; } + ~dJoint() + { dJointDestroy (_id); } + dJointID id() + { return _id; } + + void createBall (dWorld &world, dJointGroup *group=0) { + if (_id) dJointDestroy (_id); + _id = dJointCreateBall (world.id(), group ? group->id() : 0); + } + void createHinge (dWorld &world, dJointGroup *group=0) { + if (_id) dJointDestroy (_id); + _id = dJointCreateHinge (world.id(), group ? group->id() : 0); + } + void createSlider (dWorld &world, dJointGroup *group=0) { + if (_id) dJointDestroy (_id); + _id = dJointCreateSlider (world.id(), group ? group->id() : 0); + } + void createContact (dWorld &world, dJointGroup *group, dContact *contact) { + if (_id) dJointDestroy (_id); + _id = dJointCreateContact (world.id(), group ? group->id() : 0, contact); + } + + void attach (dBody &body1, dBody &body2) + { dJointAttach (_id, body1.id(), body2.id()); } + + void setBallAnchor (dReal x, dReal y, dReal z) + { dJointSetBallAnchor (_id, x, y, z); } + void setHingeAnchor (dReal x, dReal y, dReal z) + { dJointSetHingeAnchor (_id, x, y, z); } + + void setHingeAxis (dReal x, dReal y, dReal z) + { dJointSetHingeAxis (_id, x, y, z); } + void setSliderAxis (dReal x, dReal y, dReal z) + { dJointSetSliderAxis (_id, x, y, z); } + + void getBallAnchor (dVector3 result) + { dJointGetBallAnchor (_id, result); } + void getHingeAnchor (dVector3 result) + { dJointGetHingeAnchor (_id, result); } + + void getHingeAxis (dVector3 result) + { dJointGetHingeAxis (_id, result); } + void getSliderAxis (dVector3 result) + { dJointGetSliderAxis (_id, result); } +}; + + +class dSpace { + dSpaceID _id; + + dSpace (dSpace &) { dDebug (0,"bad"); } + void operator= (dSpace &) { dDebug (0,"bad"); } + +public: + dSpace () + { _id = dHashSpaceCreate(); } + ~dSpace() + { dSpaceDestroy (_id); } + dSpaceID id() + { return _id; } + void collide (void *data, dNearCallback *callback) + { dSpaceCollide (_id,data,callback); } +}; + + +class dGeom { + dGeomID _id; + + dGeom (dGeom &) { dDebug (0,"bad"); } + void operator= (dGeom &) { dDebug (0,"bad"); } + +public: + dGeom() + { _id = 0; } + ~dGeom() + { dGeomDestroy (_id); } + dGeomID id() + { return _id; } + + void createSphere (dSpace &space, dReal radius) { + if (_id) dGeomDestroy (_id); + _id = dCreateSphere (space.id(),radius); + } + + void createBox (dSpace &space, dReal lx, dReal ly, dReal lz) { + if (_id) dGeomDestroy (_id); + _id = dCreateBox (space.id(),lx,ly,lz); + } + + void createPlane (dSpace &space, dReal a, dReal b, dReal c, dReal d) { + if (_id) dGeomDestroy (_id); + _id = dCreatePlane (space.id(),a,b,c,d); + } + + void createCCylinder (dSpace &space, dReal radius, dReal length) { + if (_id) dGeomDestroy (_id); + _id = dCreateCCylinder (space.id(),radius,length); + } + + void destroy() { + if (_id) dGeomDestroy (_id); + _id = 0; + } + + int getClass() + { return dGeomGetClass (_id); } + + dReal sphereGetRadius() + { return dGeomSphereGetRadius (_id); } + + void boxGetLengths (dVector3 result) + { dGeomBoxGetLengths (_id,result); } + + void planeGetParams (dVector4 result) + { dGeomPlaneGetParams (_id,result); } + + void CCylinderGetParams (dReal *radius, dReal *length) + { dGeomCCylinderGetParams (_id,radius,length); } + + void setData (void *data) + { dGeomSetData (_id,data); } + + void *getData() + { return dGeomGetData (_id); } + + void setBody (dBody &b) + { dGeomSetBody (_id,b.id()); } + void setBody (dBodyID b) + { dGeomSetBody (_id,b); } + + dBodyID getBody() + { return dGeomGetBody (_id); } + + void setPosition (dReal x, dReal y, dReal z) + { dGeomSetPosition (_id,x,y,z); } + + void setRotation (const dMatrix3 R) + { dGeomSetRotation (_id,R); } + + const dReal * getPosition() + { return dGeomGetPosition (_id); } + + const dReal * getRotation() + { return dGeomGetRotation (_id); } +}; + + +#endif +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/odemath.h b/school/informatik/verkerhssimulation/src/ogre/ode/odemath.h new file mode 100644 index 00000000..1db0604d --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/odemath.h @@ -0,0 +1,308 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +#ifndef _ODE_ODEMATH_H_ +#define _ODE_ODEMATH_H_ + +#include + +#ifdef __GNUC__ +#define PURE_INLINE extern inline +#else +#define PURE_INLINE inline +#endif + +/* + * macro to access elements i,j in an NxM matrix A, independent of the + * matrix storage convention. + */ +#define dACCESS33(A,i,j) ((A)[(i)*4+(j)]) + +/* + * Macro to test for valid floating point values + */ +#define dVALIDVEC3(v) (!(dIsNan(v[0]) || dIsNan(v[1]) || dIsNan(v[2]))) +#define dVALIDVEC4(v) (!(dIsNan(v[0]) || dIsNan(v[2]) || dIsNan(v[2]) || dIsNan(v[3]))) +#define dVALIDMAT3(m) (!(dIsNan(m[0]) || dIsNan(m[1]) || dIsNan(m[2]) || dIsNan(m[3]) || dIsNan(m[4]) || dIsNan(m[5]) || dIsNan(m[6]) || dIsNan(m[7]) || dIsNan(m[8]) || dIsNan(m[9]) || dIsNan(m[10]) || dIsNan(m[11]))) +#define dVALIDMAT4(m) (!(dIsNan(m[0]) || dIsNan(m[1]) || dIsNan(m[2]) || dIsNan(m[3]) || dIsNan(m[4]) || dIsNan(m[5]) || dIsNan(m[6]) || dIsNan(m[7]) || dIsNan(m[8]) || dIsNan(m[9]) || dIsNan(m[10]) || dIsNan(m[11]) || dIsNan(m[12]) || dIsNan(m[13]) || dIsNan(m[14]) || dIsNan(m[15]) )) + + + +/* + * General purpose vector operations with other vectors or constants. + */ + +#define dOP(a,op,b,c) \ + (a)[0] = ((b)[0]) op ((c)[0]); \ + (a)[1] = ((b)[1]) op ((c)[1]); \ + (a)[2] = ((b)[2]) op ((c)[2]); +#define dOPC(a,op,b,c) \ + (a)[0] = ((b)[0]) op (c); \ + (a)[1] = ((b)[1]) op (c); \ + (a)[2] = ((b)[2]) op (c); +#define dOPE(a,op,b) \ + (a)[0] op ((b)[0]); \ + (a)[1] op ((b)[1]); \ + (a)[2] op ((b)[2]); +#define dOPEC(a,op,c) \ + (a)[0] op (c); \ + (a)[1] op (c); \ + (a)[2] op (c); + + +/* + * Length, and squared length helpers. dLENGTH returns the length of a dVector3. + * dLENGTHSQUARED return the squared length of a dVector3. + */ + +#define dLENGTHSQUARED(a) (((a)[0])*((a)[0]) + ((a)[1])*((a)[1]) + ((a)[2])*((a)[2])) + +#ifdef __cplusplus + +PURE_INLINE dReal dLENGTH (const dReal *a) { return dSqrt(dLENGTHSQUARED(a)); } + +#else + +#define dLENGTH(a) ( dSqrt( ((a)[0])*((a)[0]) + ((a)[1])*((a)[1]) + ((a)[2])*((a)[2]) ) ) + +#endif /* __cplusplus */ + + + + + +/* + * 3-way dot product. dDOTpq means that elements of `a' and `b' are spaced + * p and q indexes apart respectively. dDOT() means dDOT11. + * in C++ we could use function templates to get all the versions of these + * functions - but on some compilers this will result in sub-optimal code. + */ + +#define dDOTpq(a,b,p,q) ((a)[0]*(b)[0] + (a)[p]*(b)[q] + (a)[2*(p)]*(b)[2*(q)]) + +#ifdef __cplusplus + +PURE_INLINE dReal dDOT (const dReal *a, const dReal *b) { return dDOTpq(a,b,1,1); } +PURE_INLINE dReal dDOT13 (const dReal *a, const dReal *b) { return dDOTpq(a,b,1,3); } +PURE_INLINE dReal dDOT31 (const dReal *a, const dReal *b) { return dDOTpq(a,b,3,1); } +PURE_INLINE dReal dDOT33 (const dReal *a, const dReal *b) { return dDOTpq(a,b,3,3); } +PURE_INLINE dReal dDOT14 (const dReal *a, const dReal *b) { return dDOTpq(a,b,1,4); } +PURE_INLINE dReal dDOT41 (const dReal *a, const dReal *b) { return dDOTpq(a,b,4,1); } +PURE_INLINE dReal dDOT44 (const dReal *a, const dReal *b) { return dDOTpq(a,b,4,4); } + +#else + +#define dDOT(a,b) dDOTpq(a,b,1,1) +#define dDOT13(a,b) dDOTpq(a,b,1,3) +#define dDOT31(a,b) dDOTpq(a,b,3,1) +#define dDOT33(a,b) dDOTpq(a,b,3,3) +#define dDOT14(a,b) dDOTpq(a,b,1,4) +#define dDOT41(a,b) dDOTpq(a,b,4,1) +#define dDOT44(a,b) dDOTpq(a,b,4,4) + +#endif /* __cplusplus */ + + +/* + * cross product, set a = b x c. dCROSSpqr means that elements of `a', `b' + * and `c' are spaced p, q and r indexes apart respectively. + * dCROSS() means dCROSS111. `op' is normally `=', but you can set it to + * +=, -= etc to get other effects. + */ + +#define dCROSS(a,op,b,c) \ +do { \ + (a)[0] op ((b)[1]*(c)[2] - (b)[2]*(c)[1]); \ + (a)[1] op ((b)[2]*(c)[0] - (b)[0]*(c)[2]); \ + (a)[2] op ((b)[0]*(c)[1] - (b)[1]*(c)[0]); \ +} while(0) +#define dCROSSpqr(a,op,b,c,p,q,r) \ +do { \ + (a)[ 0] op ((b)[ q]*(c)[2*r] - (b)[2*q]*(c)[ r]); \ + (a)[ p] op ((b)[2*q]*(c)[ 0] - (b)[ 0]*(c)[2*r]); \ + (a)[2*p] op ((b)[ 0]*(c)[ r] - (b)[ q]*(c)[ 0]); \ +} while(0) +#define dCROSS114(a,op,b,c) dCROSSpqr(a,op,b,c,1,1,4) +#define dCROSS141(a,op,b,c) dCROSSpqr(a,op,b,c,1,4,1) +#define dCROSS144(a,op,b,c) dCROSSpqr(a,op,b,c,1,4,4) +#define dCROSS411(a,op,b,c) dCROSSpqr(a,op,b,c,4,1,1) +#define dCROSS414(a,op,b,c) dCROSSpqr(a,op,b,c,4,1,4) +#define dCROSS441(a,op,b,c) dCROSSpqr(a,op,b,c,4,4,1) +#define dCROSS444(a,op,b,c) dCROSSpqr(a,op,b,c,4,4,4) + + +/* + * set a 3x3 submatrix of A to a matrix such that submatrix(A)*b = a x b. + * A is stored by rows, and has `skip' elements per row. the matrix is + * assumed to be already zero, so this does not write zero elements! + * if (plus,minus) is (+,-) then a positive version will be written. + * if (plus,minus) is (-,+) then a negative version will be written. + */ + +#define dCROSSMAT(A,a,skip,plus,minus) \ +do { \ + (A)[1] = minus (a)[2]; \ + (A)[2] = plus (a)[1]; \ + (A)[(skip)+0] = plus (a)[2]; \ + (A)[(skip)+2] = minus (a)[0]; \ + (A)[2*(skip)+0] = minus (a)[1]; \ + (A)[2*(skip)+1] = plus (a)[0]; \ +} while(0) + + +/* + * compute the distance between two 3D-vectors + */ + +#ifdef __cplusplus +PURE_INLINE dReal dDISTANCE (const dVector3 a, const dVector3 b) + { return dSqrt( (a[0]-b[0])*(a[0]-b[0]) + (a[1]-b[1])*(a[1]-b[1]) + (a[2]-b[2])*(a[2]-b[2]) ); } +#else +#define dDISTANCE(a,b) \ + (dSqrt( ((a)[0]-(b)[0])*((a)[0]-(b)[0]) + ((a)[1]-(b)[1])*((a)[1]-(b)[1]) + ((a)[2]-(b)[2])*((a)[2]-(b)[2]) )) +#endif + + +/* + * special case matrix multipication, with operator selection + */ + +#define dMULTIPLYOP0_331(A,op,B,C) \ +do { \ + (A)[0] op dDOT((B),(C)); \ + (A)[1] op dDOT((B+4),(C)); \ + (A)[2] op dDOT((B+8),(C)); \ +} while(0) +#define dMULTIPLYOP1_331(A,op,B,C) \ +do { \ + (A)[0] op dDOT41((B),(C)); \ + (A)[1] op dDOT41((B+1),(C)); \ + (A)[2] op dDOT41((B+2),(C)); \ +} while(0) +#define dMULTIPLYOP0_133(A,op,B,C) \ +do { \ + (A)[0] op dDOT14((B),(C)); \ + (A)[1] op dDOT14((B),(C+1)); \ + (A)[2] op dDOT14((B),(C+2)); \ +} while(0) +#define dMULTIPLYOP0_333(A,op,B,C) \ +do { \ + (A)[0] op dDOT14((B),(C)); \ + (A)[1] op dDOT14((B),(C+1)); \ + (A)[2] op dDOT14((B),(C+2)); \ + (A)[4] op dDOT14((B+4),(C)); \ + (A)[5] op dDOT14((B+4),(C+1)); \ + (A)[6] op dDOT14((B+4),(C+2)); \ + (A)[8] op dDOT14((B+8),(C)); \ + (A)[9] op dDOT14((B+8),(C+1)); \ + (A)[10] op dDOT14((B+8),(C+2)); \ +} while(0) +#define dMULTIPLYOP1_333(A,op,B,C) \ +do { \ + (A)[0] op dDOT44((B),(C)); \ + (A)[1] op dDOT44((B),(C+1)); \ + (A)[2] op dDOT44((B),(C+2)); \ + (A)[4] op dDOT44((B+1),(C)); \ + (A)[5] op dDOT44((B+1),(C+1)); \ + (A)[6] op dDOT44((B+1),(C+2)); \ + (A)[8] op dDOT44((B+2),(C)); \ + (A)[9] op dDOT44((B+2),(C+1)); \ + (A)[10] op dDOT44((B+2),(C+2)); \ +} while(0) +#define dMULTIPLYOP2_333(A,op,B,C) \ +do { \ + (A)[0] op dDOT((B),(C)); \ + (A)[1] op dDOT((B),(C+4)); \ + (A)[2] op dDOT((B),(C+8)); \ + (A)[4] op dDOT((B+4),(C)); \ + (A)[5] op dDOT((B+4),(C+4)); \ + (A)[6] op dDOT((B+4),(C+8)); \ + (A)[8] op dDOT((B+8),(C)); \ + (A)[9] op dDOT((B+8),(C+4)); \ + (A)[10] op dDOT((B+8),(C+8)); \ +} while(0) + +#ifdef __cplusplus + +#define DECL template PURE_INLINE void + +DECL dMULTIPLY0_331(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_331(A,=,B,C); } +DECL dMULTIPLY1_331(TA *A, const TB *B, const TC *C) { dMULTIPLYOP1_331(A,=,B,C); } +DECL dMULTIPLY0_133(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_133(A,=,B,C); } +DECL dMULTIPLY0_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_333(A,=,B,C); } +DECL dMULTIPLY1_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP1_333(A,=,B,C); } +DECL dMULTIPLY2_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP2_333(A,=,B,C); } + +DECL dMULTIPLYADD0_331(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_331(A,+=,B,C); } +DECL dMULTIPLYADD1_331(TA *A, const TB *B, const TC *C) { dMULTIPLYOP1_331(A,+=,B,C); } +DECL dMULTIPLYADD0_133(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_133(A,+=,B,C); } +DECL dMULTIPLYADD0_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_333(A,+=,B,C); } +DECL dMULTIPLYADD1_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP1_333(A,+=,B,C); } +DECL dMULTIPLYADD2_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP2_333(A,+=,B,C); } + +#undef DECL + +#else + +#define dMULTIPLY0_331(A,B,C) dMULTIPLYOP0_331(A,=,B,C) +#define dMULTIPLY1_331(A,B,C) dMULTIPLYOP1_331(A,=,B,C) +#define dMULTIPLY0_133(A,B,C) dMULTIPLYOP0_133(A,=,B,C) +#define dMULTIPLY0_333(A,B,C) dMULTIPLYOP0_333(A,=,B,C) +#define dMULTIPLY1_333(A,B,C) dMULTIPLYOP1_333(A,=,B,C) +#define dMULTIPLY2_333(A,B,C) dMULTIPLYOP2_333(A,=,B,C) + +#define dMULTIPLYADD0_331(A,B,C) dMULTIPLYOP0_331(A,+=,B,C) +#define dMULTIPLYADD1_331(A,B,C) dMULTIPLYOP1_331(A,+=,B,C) +#define dMULTIPLYADD0_133(A,B,C) dMULTIPLYOP0_133(A,+=,B,C) +#define dMULTIPLYADD0_333(A,B,C) dMULTIPLYOP0_333(A,+=,B,C) +#define dMULTIPLYADD1_333(A,B,C) dMULTIPLYOP1_333(A,+=,B,C) +#define dMULTIPLYADD2_333(A,B,C) dMULTIPLYOP2_333(A,+=,B,C) + +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * normalize 3x1 and 4x1 vectors (i.e. scale them to unit length) + */ +ODE_API void dNormalize3 (dVector3 a); +ODE_API void dNormalize4 (dVector4 a); + + +/* + * given a unit length "normal" vector n, generate vectors p and q vectors + * that are an orthonormal basis for the plane space perpendicular to n. + * i.e. this makes p,q such that n,p,q are all perpendicular to each other. + * q will equal n x p. if n is not unit length then p will be unit length but + * q wont be. + */ + +ODE_API void dPlaneSpace (const dVector3 n, dVector3 p, dVector3 q); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/rotation.h b/school/informatik/verkerhssimulation/src/ogre/ode/rotation.h new file mode 100644 index 00000000..a72be27f --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/rotation.h @@ -0,0 +1,70 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +#ifndef _ODE_ROTATION_H_ +#define _ODE_ROTATION_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +ODE_API void dRSetIdentity (dMatrix3 R); + +ODE_API void dRFromAxisAndAngle (dMatrix3 R, dReal ax, dReal ay, dReal az, + dReal angle); + +ODE_API void dRFromEulerAngles (dMatrix3 R, dReal phi, dReal theta, dReal psi); + +ODE_API void dRFrom2Axes (dMatrix3 R, dReal ax, dReal ay, dReal az, + dReal bx, dReal by, dReal bz); + +ODE_API void dRFromZAxis (dMatrix3 R, dReal ax, dReal ay, dReal az); + +ODE_API void dQSetIdentity (dQuaternion q); + +ODE_API void dQFromAxisAndAngle (dQuaternion q, dReal ax, dReal ay, dReal az, + dReal angle); + +/* Quaternion multiplication, analogous to the matrix multiplication routines. */ +/* qa = rotate by qc, then qb */ +ODE_API void dQMultiply0 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc); +/* qa = rotate by qc, then by inverse of qb */ +ODE_API void dQMultiply1 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc); +/* qa = rotate by inverse of qc, then by qb */ +ODE_API void dQMultiply2 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc); +/* qa = rotate by inverse of qc, then by inverse of qb */ +ODE_API void dQMultiply3 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc); + +ODE_API void dRfromQ (dMatrix3 R, const dQuaternion q); +ODE_API void dQfromR (dQuaternion q, const dMatrix3 R); +ODE_API void dDQfromW (dReal dq[4], const dVector3 w, const dQuaternion q); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/ode/timer.h b/school/informatik/verkerhssimulation/src/ogre/ode/timer.h new file mode 100644 index 00000000..c3f42a7a --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/ode/timer.h @@ -0,0 +1,76 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * + * All rights reserved. Email: russ@q12.org Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +#ifndef _ODE_TIMER_H_ +#define _ODE_TIMER_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* stop watch objects */ + +typedef struct dStopwatch { + double time; /* total clock count */ + unsigned long cc[2]; /* clock count since last `start' */ +} dStopwatch; + +ODE_API void dStopwatchReset (dStopwatch *); +ODE_API void dStopwatchStart (dStopwatch *); +ODE_API void dStopwatchStop (dStopwatch *); +ODE_API double dStopwatchTime (dStopwatch *); /* returns total time in secs */ + + +/* code timers */ + +ODE_API void dTimerStart (const char *description); /* pass a static string here */ +ODE_API void dTimerNow (const char *description); /* pass a static string here */ +ODE_API void dTimerEnd(void); + +/* print out a timer report. if `average' is nonzero, print out the average + * time for each slot (this is only meaningful if the same start-now-end + * calls are being made repeatedly. + */ +ODE_API void dTimerReport (FILE *fout, int average); + + +/* resolution */ + +/* returns the timer ticks per second implied by the timing hardware or API. + * the actual timer resolution may not be this great. + */ +ODE_API double dTimerTicksPerSecond(void); + +/* returns an estimate of the actual timer resolution, in seconds. this may + * be greater than 1/ticks_per_second. + */ +ODE_API double dTimerResolution(void); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreAreaEmitter.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreAreaEmitter.h new file mode 100644 index 00000000..5d9bda6c --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreAreaEmitter.h @@ -0,0 +1,147 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __AreaEmitter_H__ +#define __AreaEmitter_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleEmitter.h" + +namespace Ogre { + + /** Particle emitter which emits particles randomly from points inside + an area (box, sphere, ellipsoid whatever subclasses choose to be). + @remarks + This is an empty superclass and needs to be subclassed. Basic particle + emitter emits particles from/in an (unspecified) area. The + initial direction of these particles can either be a single direction + (i.e. a line), a random scattering inside a cone, or a random + scattering in all directions, depending the 'angle' parameter, which + is the angle across which to scatter the particles either side of the + base direction of the emitter. + */ + class _OgreParticleFXExport AreaEmitter : public ParticleEmitter + { + public: + /** Command object for area emitter size (see ParamCommand).*/ + class CmdWidth : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /** Command object for area emitter size (see ParamCommand).*/ + class CmdHeight : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /** Command object for area emitter size (see ParamCommand).*/ + class CmdDepth : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + + AreaEmitter(ParticleSystem* psys) : ParticleEmitter(psys) {} + + + /** See ParticleEmitter. */ + unsigned short _getEmissionCount(Real timeElapsed); + + /** Overloaded to update the trans. matrix */ + void setDirection( const Vector3& direction ); + + /** Sets the size of the area from which particles are emitted. + @param + size Vector describing the size of the area. The area extends + around the center point by half the x, y and z components of + this vector. The box is aligned such that it's local Z axis points + along it's direction (see setDirection) + */ + void setSize(const Vector3& size); + + /** Sets the size of the area from which particles are emitted. + @param x,y,z + Individual axis lengths describing the size of the area. The area + extends around the center point by half the x, y and z components + of this vector. The box is aligned such that it's local Z axis + points along it's direction (see setDirection) + */ + void setSize(Real x, Real y, Real z); + /** Sets the size of the clear space inside the area from where NO particles are emitted. + @param x,y,z + Individual axis lengths describing the size of the clear space. + The clear space is aligned like the outer area. + (see setDirection and setSize) + */ +// void setClearSpace(Real x, Real y, Real z); + + /** Sets the width (local x size) of the emitter. */ + void setWidth(Real width); + /** Gets the width (local x size) of the emitter. */ + Real getWidth(void) const; + /** Sets the height (local y size) of the emitter. */ + void setHeight(Real Height); + /** Gets the height (local y size) of the emitter. */ + Real getHeight(void) const; + /** Sets the depth (local y size) of the emitter. */ + void setDepth(Real Depth); + /** Gets the depth (local y size) of the emitter. */ + Real getDepth(void) const; + + protected: + /// Size of the area + Vector3 mSize; + + /// Local axes, not normalised, their magnitude reflects area size + Vector3 mXRange, mYRange, mZRange; + + /// Internal method for generating the area axes + void genAreaAxes(void); + /** Internal for initializing some defaults and parameters + @returns True if custom parameters need initialising + */ + bool initDefaults(const String& mType); + + /// Command objects + static CmdWidth msWidthCmd; + static CmdHeight msHeightCmd; + static CmdDepth msDepthCmd; + + + + }; + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreBoxEmitter.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreBoxEmitter.h new file mode 100644 index 00000000..5bfd8ab7 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreBoxEmitter.h @@ -0,0 +1,61 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __BoxEmitter_H__ +#define __BoxEmitter_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreAreaEmitter.h" + +namespace Ogre { + + /** Particle emitter which emits particles randomly from points inside a box. + @remarks + This basic particle emitter emits particles from a box area. The + initial direction of these particles can either be a single direction (i.e. a line), + a random scattering inside a cone, or a random scattering in all directions, + depending the 'angle' parameter, which is the angle across which to scatter the + particles either side of the base direction of the emitter. + */ + class _OgreParticleFXExport BoxEmitter : public AreaEmitter + { + public: + + BoxEmitter(ParticleSystem* psys); + + /** See ParticleEmitter. */ + void _initParticle(Particle* pParticle); + + protected: + + }; + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreBoxEmitterFactory.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreBoxEmitterFactory.h new file mode 100644 index 00000000..20f1d878 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreBoxEmitterFactory.h @@ -0,0 +1,67 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __BoxEmitterFactory_H__ +#define __BoxEmitterFactory_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleEmitterFactory.h" +#include "OgreBoxEmitter.h" + + +namespace Ogre { + + /** Factory class for particle emitter of type "Box". + @remarks + Creates instances of BoxEmitter to be used in particle systems. + */ + class _OgreParticleFXExport BoxEmitterFactory : public ParticleEmitterFactory + { + protected: + + public: + /** See ParticleEmitterFactory */ + String getName() const + { + return "Box"; + } + + /** See ParticleEmitterFactory */ + ParticleEmitter* createEmitter(ParticleSystem* psys) + { + ParticleEmitter* emit = new BoxEmitter(psys); + mEmitters.push_back(emit); + return emit; + } + + }; + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspLevel.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspLevel.h new file mode 100644 index 00000000..a9bbc449 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspLevel.h @@ -0,0 +1,278 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _BspLevel_H__ +#define _BspLevel_H__ + +#include "OgreBspPrerequisites.h" +#include "OgreResource.h" +#include "OgreStaticFaceGroup.h" +#include "OgreSceneManager.h" +#include "OgreBspNode.h" +#include "OgreHardwareBufferManager.h" +#include "OgreDefaultHardwareBufferManager.h" +#include "OgreQuake3Level.h" + + +namespace Ogre { + + /** Holds all the data associated with a Binary Space Parition + (BSP) based indoor level. + The data used here is populated by loading level files via + the BspLevelManager::load method, although application users + are more likely to call SceneManager::setWorldGeometry which will + automatically arrange the loading of the level. Note that this assumes + that you have asked for an indoor-specialised SceneManager (specify + ST_INDOOR when calling Root::getSceneManager).

      + Ogre currently only supports loading from Quake3 Arena level files, + although any source that can be converted into this classes structure + could also be used. The Quake3 level load process is in a different + class called Quake3Level to keep the specifics separate.

      + */ + class BspLevel : public Resource + { + friend class BspSceneManager; + public: + /** Default constructor - used by BspResourceManager (do not call directly) */ + BspLevel(ResourceManager* creator, const String& name, ResourceHandle handle, + const String& group, bool isManual = false, ManualResourceLoader* loader = 0); + ~BspLevel(); + + /** Determines if one leaf node is visible from another. */ + bool isLeafVisible(const BspNode* from, const BspNode* to) const; + + /** Returns a pointer to the root node (BspNode) of the BSP tree. */ + const BspNode* getRootNode(void); + + /** Walks the entire BSP tree and returns the leaf + which contains the given point. + */ + BspNode* findLeaf(const Vector3& point) const; + + /** Ensures that the MovableObject is attached to the right leaves of the + BSP tree. + */ + void _notifyObjectMoved(const MovableObject* mov, + const Vector3& pos); + /** Internal method, makes sure an object is removed from the leaves when detached from a node. */ + void _notifyObjectDetached(const MovableObject* mov); + /** Gets a pointer to the start of the leaf nodes. */ + BspNode* getLeafStart(void) {return &mRootNode[mLeafStart]; } + /** Gets the number of leaf nodes */ + int getNumLeaves(void) const { return mNumLeaves; } + + /** Calculate the number of loading stages required for a given level */ + static size_t calculateLoadingStages(const String& levelName); + /** Calculate the number of loading stages required for a given level */ + static size_t calculateLoadingStages(DataStreamPtr& stream); + + /** Load direct from stream */ + void load(DataStreamPtr& stream); + + /** Is sky enabled? */ + bool isSkyEnabled(void) const; + /** Get Sky material name */ + const String& getSkyMaterialName(void) const; + /** Get sky curvature */ + Real getSkyCurvature(void) const; + + /** Utility class just to enable queueing of patches */ + protected: + /** @copydoc Resource::loadImpl. */ + void loadImpl(void); + /** @copydoc Resource::unloadImpl. */ + void unloadImpl(void); + /** @copydoc Resource::calculateSize. */ + size_t calculateSize(void) const; + /** Pointer to the root node of the BSP tree; + This pointer actually has a dual purpose; to avoid allocating lots of small chunks of + memory, the BspLevel actually allocates all nodes required through this pointer. So this + pointer is the handle for the allocation of memory for all nodes. It also happens to point + to the root node, since the first one in the memory chunk is the root node. + */ + BspNode* mRootNode; + int mNumNodes; + int mNumLeaves; + int mLeafStart; // the index at which leaf nodes begin + + /** Vertex format for fixed geometry. + Note that in this case vertex components (position, normal, texture coords etc) + are held interleaved in the same buffer. However, the format here is different from + the format used by Quake because older Direct3d drivers like the vertex elements + to be in a particular order within the buffer. See VertexDeclaration for full + details of this marvellous(not) feature. + */ + struct BspVertex + { + float position[3]; + float normal[3]; + int colour; + float texcoords[2]; + float lightmap[2]; + }; + /* + /// Array of vertices for whole level. + BspVertex* mVertices; + int mNumVertices; + */ + /// Vertex data holding all the data for the level, but able to render parts of it + VertexData* mVertexData; + + /** Array of indexes into the mFaceGroups array. This buffer is organised + by leaf node so leaves can just use contiguous chunks of it and + get repointed to the actual entries in mFaceGroups. */ + int* mLeafFaceGroups; + int mNumLeafFaceGroups; + + /** Array of face groups, indexed into by contents of mLeafFaceGroups. */ + StaticFaceGroup* mFaceGroups; + int mNumFaceGroups; + + + /* + /// Array of elements i.e. vertex indexes as used by face groups. + int* mElements; + int mNumElements; + */ + + /// indexes for the whole level, will be copied to the real indexdata per frame + size_t mNumIndexes; + // system-memory buffer + HardwareIndexBufferSharedPtr mIndexes; + + /// Brushes as used for collision, main memory is here + BspNode::Brush *mBrushes; + + /** Vector of player start points */ + std::vector mPlayerStarts; + + /** Internal utility function for loading data from Quake3. */ + void loadQuake3Level(const Quake3Level& q3lvl); + /** Internal lookup table to determine visibility between leaves. + Leaf nodes are assigned to 'clusters' of nodes, which are used to group nodes together for + visibility testing. This data holds a lookup table which is used to determine if one cluster of leaves + is visible from another cluster. Whilst it would be possible to expand all this out so that + each node had a list of pointers to other visible nodes, this would be very expensive in terms + of storage (using the cluster method there is a table which is 1-bit squared per cluster, rounded + up to the nearest byte obviously, which uses far less space than 4-bytes per linked node per source + node). Of course the limitation here is that you have to each leaf in turn to determine if it is visible + rather than just following a list, but since this is only done once per frame this is not such a big + overhead.

      + Each row in the table is a 'from' cluster, with each bit in the row corresponding to a 'to' cluster, + both ordered based on cluster index. A 0 in the bit indicates the 'to' cluster is not visible from the + 'from' cluster, whilst a 1 indicates it is.

      + As many will notice, this is lifted directly from the Quake implementation of PVS. + */ + struct VisData + { + unsigned char *tableData; + int numClusters; // Number of clusters, therefore number of rows + int rowLength; // Length in bytes of each row (num clusters / 8 rounded up) + }; + + VisData mVisData; + + + /** Internal method for parsing chosen entities. */ + void loadEntities(const Quake3Level& q3lvl); + + typedef std::map > MovableToNodeMap; + /// Map for locating the nodes a movable is currently a member of + MovableToNodeMap mMovableToNodeMap; + + void tagNodesWithMovable(BspNode* node, const MovableObject* mov, const Vector3& pos); + + // Storage of patches + typedef std::map PatchMap; + PatchMap mPatches; + // Total number of vertices required for all patches + size_t mPatchVertexCount; + // Total number of indexes required for all patches + size_t mPatchIndexCount; + // Sky enabled? + bool mSkyEnabled; + // Sky material + String mSkyMaterial; + // Sky details + Real mSkyCurvature; + + + void initQuake3Patches(const Quake3Level & q3lvl, VertexDeclaration* decl); + void buildQuake3Patches(size_t vertOffset, size_t indexOffset); + + void quakeVertexToBspVertex(const bsp_vertex_t* src, BspVertex* dest); + + + }; + /** Specialisation of SharedPtr to allow SharedPtr to be assigned to BspLevelPtr + @note Has to be a subclass since we need operator=. + We could templatise this instead of repeating per Resource subclass, + except to do so requires a form VC6 does not support i.e. + ResourceSubclassPtr : public SharedPtr + */ + class BspLevelPtr : public SharedPtr + { + public: + BspLevelPtr() : SharedPtr() {} + explicit BspLevelPtr(BspLevel* rep) : SharedPtr(rep) {} + BspLevelPtr(const BspLevelPtr& r) : SharedPtr(r) {} + BspLevelPtr(const ResourcePtr& r) : SharedPtr() + { + // lock & copy other mutex pointer + OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME) + OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME) + pRep = static_cast(r.getPointer()); + pUseCount = r.useCountPointer(); + if (pUseCount) + { + ++(*pUseCount); + } + } + + /// Operator used to convert a ResourcePtr to a BspLevelPtr + BspLevelPtr& operator=(const ResourcePtr& r) + { + if (pRep == static_cast(r.getPointer())) + return *this; + release(); + // lock & copy other mutex pointer + OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME) + OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME) + pRep = static_cast(r.getPointer()); + pUseCount = r.useCountPointer(); + if (pUseCount) + { + ++(*pUseCount); + } + return *this; + } + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspNode.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspNode.h new file mode 100644 index 00000000..0230d86b --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspNode.h @@ -0,0 +1,213 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _BspNode_H__ +#define _BspNode_H__ + +#include "OgreBspPrerequisites.h" +#include "OgrePlane.h" +#include "OgreAxisAlignedBox.h" +#include "OgreSceneQuery.h" + +namespace Ogre { + + /** Encapsulates a node in a BSP tree. + A BSP tree represents space partitioned by planes . The space which is + partitioned is either the world (in the case of the root node) or the space derived + from their parent node. Each node can have elements which are in front or behind it, which are + it's children and these elements can either be further subdivided by planes, + or they can be undivided spaces or 'leaf nodes' - these are the nodes which actually contain + objects and world geometry.The leaves of the tree are the stopping point of any tree walking algorithm, + both for rendering and collision detection etc.

      + Ogre chooses not to represent splitting nodes and leaves as separate structures, but to merge the two for simplicity + of the walking algorithm. If a node is a leaf, the isLeaf() method returns true and both getFront() and + getBack() return null pointers. If the node is a partitioning plane isLeaf() returns false and getFront() + and getBack() will return the corresponding BspNode objects. + */ + class BspNode + { + friend class BspLevel; + + public: + /** Constructor, only to be used by BspLevel. */ + BspNode(BspLevel* owner, bool isLeaf); + + BspNode(); + ~BspNode(); + + /** Returns true if this node is a leaf (i.e. contains geometry) or false if it is a splitting plane. + A BspNode can either be a splitting plane (the typical representation of a BSP node) or an undivided + region contining geometry (a leaf node). Ogre represents both using the same class for simplicity + of tree walking. However it is important that you use this method to determine which type you are dealing + with, since certain methods are only supported with one of the subtypes. Details are given in the individual methods. + Note that I could have represented splitting / leaf nodes as a class hierarchy but the + virtual methods / run-time type identification would have a performance hit, and it would not make the + code much (any?) simpler anyway. I think this is a fair trade-off in this case. + */ + bool isLeaf(void) const; + + /** Returns a pointer to a BspNode containing the subspace on the positive side of the splitting plane. + This method should only be called on a splitting node, i.e. where isLeaf() returns false. Calling this + method on a leaf node will throw an exception. + */ + BspNode* getFront(void) const; + + /** Returns a pointer to a BspNode containing the subspace on the negative side of the splitting plane. + This method should only be called on a splitting node, i.e. where isLeaf() returns false. Calling this + method on a leaf node will throw an exception. + */ + BspNode* getBack(void) const; + + /** Determines which side of the splitting plane a worldspace point is. + This method should only be called on a splitting node, i.e. where isLeaf() returns false. Calling this + method on a leaf node will throw an exception. + */ + Plane::Side getSide (const Vector3& point) const; + + /** Gets the next node down in the tree, with the intention of + locating the leaf containing the given point. + This method should only be called on a splitting node, i.e. where isLeaf() returns false. Calling this + method on a leaf node will throw an exception. + */ + BspNode* getNextNode(const Vector3& point) const; + + + /** Returns details of the plane which is used to subdivide the space of his node's children. + This method should only be called on a splitting node, i.e. where isLeaf() returns false. Calling this + method on a leaf node will throw an exception. + */ + const Plane& getSplitPlane(void) const; + + /** Returns the axis-aligned box which contains this node if it is a leaf. + This method should only be called on a leaf node. It returns a box which can be used in calls like + Camera::isVisible to determine if the leaf node is visible in the view. + */ + const AxisAlignedBox& getBoundingBox(void) const; + + /** Returns the number of faces contained in this leaf node. + Should only be called on a leaf node. + */ + int getNumFaceGroups(void) const; + /** Returns the index to the face group index list for this leaf node. + The contents of this buffer is a list of indexes which point to the + actual face groups held in a central buffer in the BspLevel class (in + actual fact for efficency the indexes themselves are also held in a single + buffer in BspLevel too). The reason for this indirection is that the buffer + of indexes to face groups is organised in chunks relative to nodes, whilst the + main buffer of face groups may not be. + Should only be called on a leaf node. + */ + int getFaceGroupStart(void) const; + + /** Determines if the passed in node (must also be a leaf) is visible from this leaf. + Must only be called on a leaf node, and the parameter must also be a leaf node. If + this method returns true, then the leaf passed in is visible from this leaf. + Note that internally this uses the Potentially Visible Set (PVS) which is precalculated + and stored with the BSP level. + */ + bool isLeafVisible(const BspNode* leaf) const; + + friend std::ostream& operator<< (std::ostream& o, BspNode& n); + + /// Internal method for telling the node that a movable intersects it + void _addMovable(const MovableObject* mov); + + /// Internal method for telling the node that a movable no longer intersects it + void _removeMovable(const MovableObject* mov); + + /// Gets the signed distance to the dividing plane + Real getDistance(const Vector3& pos) const; + + typedef std::set IntersectingObjectSet; + + struct Brush + { + std::list planes; + SceneQuery::WorldFragment fragment; // For query reporting + }; + typedef std::vector NodeBrushList; // Main brush memory held on level + + /** Get the list of solid Brushes for this node. + @remarks Only applicable for leaf nodes. + */ + const NodeBrushList& getSolidBrushes(void) const; + protected: + BspLevel* mOwner; // Back-reference to containing level + bool mIsLeaf; + + // Node-only members + /** The plane which splits space in a non-leaf node. + Note that nodes do not allocate the memory for other nodes - for simplicity and bulk-allocation + of memory the BspLevel is responsible for assigning enough memory for all nodes in one go. + */ + Plane mSplitPlane; + /** Pointer to the node in front of this non-leaf node. */ + BspNode* mFront; + /** Pointer to the node behind this non-leaf node. */ + BspNode* mBack; + + // Leaf-only members + /** The cluster number of this leaf. + Leaf nodes are assigned to 'clusters' of nodes, which are used to group nodes together for + visibility testing. There is a lookup table which is used to determine if one cluster of leaves + is visible from another cluster. Whilst it would be possible to expand all this out so that + each node had a list of pointers to other visible nodes, this would be very expensive in terms + of storage (using the cluster method there is a table which is 1-bit squared per cluster, rounded + up to the nearest byte obviously, which uses far less space than 4-bytes per linked node per source + node). Of course the limitation here is that you have to each leaf in turn to determine if it is visible + rather than just following a list, but since this is only done once per frame this is not such a big + overhead. + */ + int mVisCluster; + + /** The axis-aligned box which bounds node if it is a leaf. */ + AxisAlignedBox mBounds; + /** Number of face groups in this node if it is a leaf. */ + int mNumFaceGroups; + /** Index to the part of the main leaf facegroup index buffer(held in BspLevel) for this leaf. + This leaf uses mNumFaceGroups from this pointer onwards. From here you use the index + in this buffer to look up the actual face. + Note that again for simplicity and bulk memory allocation the face + group list itself is allocated by the BspLevel for all nodes, and each leaf node is given a section of it to + work on. This saves lots of small memory allocations / deallocations which limits memory fragmentation. + */ + int mFaceGroupStart; + + IntersectingObjectSet mMovables; + + NodeBrushList mSolidBrushes; + public: + const IntersectingObjectSet& getObjects(void) const { return mMovables; } + + + }; + + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspPrerequisites.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspPrerequisites.h new file mode 100644 index 00000000..7dfc80d6 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspPrerequisites.h @@ -0,0 +1,66 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __BspPrerequisites_H__ +#define __BspPrerequisites_H__ + +#include "OgrePrerequisites.h" + +namespace Ogre { + + // Predeclare classes + + class BspLevel; + class BspNode; + class BspResourceManager; + class BspSceneManager; + class Quake3Level; + class Quake3ShaderManager; + class Quake3Shader; + +#if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32) && !defined(OGRE_STATIC_LIB) +# ifdef OGRE_BSPPLUGIN_EXPORTS +# define _OgreBspPluginExport __declspec(dllexport) +# else +# if defined( __MINGW32__ ) +# define _OgreBspPluginExport +# else +# define _OgreBspPluginExport __declspec(dllimport) +# endif +# endif +#elif defined ( OGRE_GCC_VISIBILITY ) +# define _OgreBspPluginExport __attribute__ ((visibility("default"))) +#else +# define _OgreBspPluginExport +#endif // OGRE_WIN32 + + +} + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspResourceManager.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspResourceManager.h new file mode 100644 index 00000000..bfabf5b5 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspResourceManager.h @@ -0,0 +1,111 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef _BspLevelManager_H__ +#define _BspLevelManager_H__ + +#include "OgreBspPrerequisites.h" +#include "OgreResourceManager.h" +#include "OgreSingleton.h" + +namespace Ogre { + + /** Manages the locating and loading of BSP-based indoor levels. + Like other ResourceManager specialisations it manages the location and loading + of a specific type of resource, in this case files containing Binary + Space Partition (BSP) based level files e.g. Quake3 levels.

      + However, note that unlike other ResourceManager implementations, + only 1 BspLevel resource is allowed to be loaded at one time. Loading + another automatically unloads the currently loaded level if any. + */ + class BspResourceManager : public ResourceManager, public Singleton + { + public: + BspResourceManager(); + ~BspResourceManager(); + + /** Loads a BSP-based level from the named file. + Currently only supports loading of Quake3 .bsp files. + */ + ResourcePtr load(const String& name, + const String& group, bool isManual = false, + ManualResourceLoader* loader = 0, const NameValuePairList* loadParams = 0); + + /** Loads a BSP-based level from a stream. + Currently only supports loading of Quake3 .bsp files. + */ + ResourcePtr load(DataStreamPtr& stream, const String& group); + + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static BspResourceManager& getSingleton(void); + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static BspResourceManager* getSingletonPtr(void); + + + protected: + /** @copydoc ResourceManager::createImpl. */ + Resource* createImpl(const String& name, ResourceHandle handle, + const String& group, bool isManual, ManualResourceLoader* loader, + const NameValuePairList* createParams); + + // Singleton managed by this class + Quake3ShaderManager *mShaderMgr; + + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspSceneManager.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspSceneManager.h new file mode 100644 index 00000000..fd16a1cd --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspSceneManager.h @@ -0,0 +1,282 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __BspSceneManager_H__ +#define __BspSceneManager_H__ + + +#include "OgreBspPrerequisites.h" +#include "OgreSceneManager.h" +#include "OgreStaticFaceGroup.h" +#include "OgreRenderOperation.h" +#include "OgreBspLevel.h" +#include + + +namespace Ogre { + + + /** Specialisation of the SceneManager class to deal with indoor scenes + based on a BSP tree. + This class refines the behaviour of the default SceneManager to manage + a scene whose bulk of geometry is made up of an indoor environment which + is organised by a Binary Space Partition (BSP) tree.

      + A BSP tree progressively subdivides the space using planes which are the nodes of the tree. + At some point we stop subdividing and everything in the remaining space is part of a 'leaf' which + contains a number of polygons. Typically we traverse the tree to locate the leaf in which a + point in space is (say the camera origin) and work from there. A second structure, the + Potentially Visible Set, tells us which other leaves can been seen from this + leaf, and we test their bounding boxes against the camera frustum to see which + we need to draw. Leaves are also a good place to start for collision detection since + they divide the level into discrete areas for testing.

      + This BSP and PVS technique has been made famous by engines such as Quake and Unreal. Ogre + provides support for loading Quake3 level files to populate your world through this class, + by calling the BspSceneManager::setWorldGeometry. Note that this interface is made + available at the top level of the SceneManager class so you don't have to write your code + specifically for this class - just call Root::getSceneManager passing a SceneType of ST_INTERIOR + and in the current implementation you will get a BspSceneManager silently disguised as a + standard SceneManager. + */ + class BspSceneManager : public SceneManager + { + protected: + + // World geometry + BspLevelPtr mLevel; + + // State variables for rendering WIP + // Set of face groups (by index) already included + typedef std::set FaceGroupSet; + FaceGroupSet mFaceGroupSet; + // Material -> face group hashmap + typedef std::map, materialLess > MaterialFaceGroupMap; + MaterialFaceGroupMap mMatFaceGroupMap; + + RenderOperation mRenderOp; + + // Debugging features + bool mShowNodeAABs; + RenderOperation mAABGeometry; + + /** Walks the BSP tree looking for the node which the camera + is in, and tags any geometry which is in a visible leaf for + later processing. + @param camera Pointer to the viewpoint. + @returns The BSP node the camera was found in, for info. + */ + BspNode* walkTree(Camera* camera, VisibleObjectsBoundsInfo* visibleBounds, bool onlyShadowCasters); + /** Tags geometry in the leaf specified for later rendering. */ + void processVisibleLeaf(BspNode* leaf, Camera* cam, + VisibleObjectsBoundsInfo* visibleBounds, bool onlyShadowCasters); + + /** Caches a face group for imminent rendering. */ + unsigned int cacheGeometry(unsigned int* pIndexes, const StaticFaceGroup* faceGroup); + + /** Frees up allocated memory for geometry caches. */ + void freeMemory(void); + + /** Adds a bounding box to draw if turned on. */ + void addBoundingBox(const AxisAlignedBox& aab, bool visible); + + /** Renders the static level geometry tagged in walkTree. */ + void renderStaticGeometry(void); + + /** @copydoc SceneManager::clearScene */ + void clearScene(void); + + + typedef std::set MovablesForRendering; + MovablesForRendering mMovablesForRendering; + + public: + BspSceneManager(const String& name); + ~BspSceneManager(); + + + /// @copydoc SceneManager::getTypeName + const String& getTypeName(void) const; + + /** Specialised from SceneManager to support Quake3 bsp files. */ + void setWorldGeometry(const String& filename); + + /** Specialised from SceneManager to support Quake3 bsp files. */ + size_t estimateWorldGeometry(const String& filename); + + /** Specialised from SceneManager to support Quake3 bsp files. */ + void setWorldGeometry(DataStreamPtr& stream, + const String& typeName = StringUtil::BLANK); + + /** Specialised from SceneManager to support Quake3 bsp files. */ + size_t estimateWorldGeometry(DataStreamPtr& stream, + const String& typeName = StringUtil::BLANK); + + /** Tells the manager whether to draw the axis-aligned boxes that surround + nodes in the Bsp tree. For debugging purposes. + */ + void showNodeBoxes(bool show); + + /** Specialised to suggest viewpoints. */ + ViewPoint getSuggestedViewpoint(bool random = false); + + const BspLevelPtr& getLevel(void) {return mLevel; } + + /** Overriden from SceneManager. */ + void _findVisibleObjects(Camera* cam, VisibleObjectsBoundsInfo* visibleBounds, + bool onlyShadowCasters); + + /** Overriden from SceneManager. */ + void _renderVisibleObjects(void); + + /** Creates a specialized BspSceneNode */ + SceneNode * createSceneNode ( void ); + /** Creates a specialized BspSceneNode */ + SceneNode * createSceneNode ( const String &name ); + + /** Internal method for tagging BspNodes with objects which intersect them. */ + void _notifyObjectMoved(const MovableObject* mov, const Vector3& pos); + /** Internal method for notifying the level that an object has been detached from a node */ + void _notifyObjectDetached(const MovableObject* mov); + + /** Creates an AxisAlignedBoxSceneQuery for this scene manager. + @remarks + This method creates a new instance of a query object for this scene manager, + for an axis aligned box region. See SceneQuery and AxisAlignedBoxSceneQuery + for full details. + @par + The instance returned from this method must be destroyed by calling + SceneManager::destroyQuery when it is no longer required. + @param box Details of the box which describes the region for this query. + @param mask The query mask to apply to this query; can be used to filter out + certain objects; see SceneQuery for details. + */ + /* + virtual AxisAlignedBoxSceneQuery* + createAABBQuery(const AxisAlignedBox& box, unsigned long mask = 0xFFFFFFFF); + */ + /** Creates a SphereSceneQuery for this scene manager. + @remarks + This method creates a new instance of a query object for this scene manager, + for a spherical region. See SceneQuery and SphereSceneQuery + for full details. + @par + The instance returned from this method must be destroyed by calling + SceneManager::destroyQuery when it is no longer required. + @param sphere Details of the sphere which describes the region for this query. + @param mask The query mask to apply to this query; can be used to filter out + certain objects; see SceneQuery for details. + */ + /* + virtual SphereSceneQuery* + createSphereQuery(const Sphere& sphere, unsigned long mask = 0xFFFFFFFF); + */ + /** Creates a RaySceneQuery for this scene manager. + @remarks + This method creates a new instance of a query object for this scene manager, + looking for objects which fall along a ray. See SceneQuery and RaySceneQuery + for full details. + @par + The instance returned from this method must be destroyed by calling + SceneManager::destroyQuery when it is no longer required. + @param ray Details of the ray which describes the region for this query. + @param mask The query mask to apply to this query; can be used to filter out + certain objects; see SceneQuery for details. + */ + virtual RaySceneQuery* + createRayQuery(const Ray& ray, unsigned long mask = 0xFFFFFFFF); + /** Creates an IntersectionSceneQuery for this scene manager. + @remarks + This method creates a new instance of a query object for locating + intersecting objects. See SceneQuery and IntersectionSceneQuery + for full details. + @par + The instance returned from this method must be destroyed by calling + SceneManager::destroyQuery when it is no longer required. + @param mask The query mask to apply to this query; can be used to filter out + certain objects; see SceneQuery for details. + */ + virtual IntersectionSceneQuery* + createIntersectionQuery(unsigned long mask = 0xFFFFFFFF); + + }; + + /** BSP specialisation of IntersectionSceneQuery */ + class BspIntersectionSceneQuery : public DefaultIntersectionSceneQuery + { + public: + BspIntersectionSceneQuery(SceneManager* creator); + + /** See IntersectionSceneQuery. */ + void execute(IntersectionSceneQueryListener* listener); + + }; + + /** BSP specialisation of RaySceneQuery */ + class BspRaySceneQuery : public DefaultRaySceneQuery + { + public: + BspRaySceneQuery(SceneManager* creator); + ~BspRaySceneQuery(); + + /** See RaySceneQuery. */ + void execute(RaySceneQueryListener* listener); + protected: + /// Set for eliminating duplicates since objects can be in > 1 node + std::set mObjsThisQuery; + /// list of the last single intersection world fragments (derived) + std::vector mSingleIntersections; + + void clearTemporaries(void); + /** Internal processing of a single node. + @returns true if we should continue tracing, false otherwise + */ + bool processNode(const BspNode* node, const Ray& tracingRay, RaySceneQueryListener* listener, + Real maxDistance = Math::POS_INFINITY, Real traceDistance = 0.0f); + /** Internal processing of a single leaf. + @returns true if we should continue tracing, false otherwise + */ + bool processLeaf(const BspNode* node, const Ray& tracingRay, RaySceneQueryListener* listener, + Real maxDistance = Math::POS_INFINITY, Real traceDistance = 0.0f); + + }; + + /// Factory for BspSceneManager + class BspSceneManagerFactory : public SceneManagerFactory + { + protected: + void initMetaData(void) const; + public: + BspSceneManagerFactory() {} + ~BspSceneManagerFactory() {} + /// Factory type name + static const String FACTORY_TYPE_NAME; + SceneManager* createInstance(const String& instanceName); + void destroyInstance(SceneManager* instance); + }; +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspSceneManagerPlugin.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspSceneManagerPlugin.h new file mode 100644 index 00000000..7abfb222 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspSceneManagerPlugin.h @@ -0,0 +1,68 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __BspSceneManagerPlugin_H__ +#define __BspSceneManagerPlugin_H__ + +#include "OgrePlugin.h" +#include "OgreBspSceneManager.h" +#include "OgreBspResourceManager.h" + +namespace Ogre +{ + + /** Plugin instance for BSPSceneManager */ + class BspSceneManagerPlugin : public Plugin + { + public: + BspSceneManagerPlugin(); + + + /// @copydoc Plugin::getName + const String& getName() const; + + /// @copydoc Plugin::install + void install(); + + /// @copydoc Plugin::initialise + void initialise(); + + /// @copydoc Plugin::shutdown + void shutdown(); + + /// @copydoc Plugin::uninstall + void uninstall(); + protected: + BspSceneManagerFactory* mBspFactory; + BspResourceManager* mBspResourceManager; + + + }; +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspSceneNode.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspSceneNode.h new file mode 100644 index 00000000..e3e0ecbf --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreBspSceneNode.h @@ -0,0 +1,80 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __BSPSCENENODE_H__ +#define __BSPSCENENODE_H__ + +#include "OgreBspPrerequisites.h" +#include "OgreSceneNode.h" + +namespace Ogre { + + /** Specialisation of SceneNode for the BspSceneManager. + @remarks + This specialisation of SceneNode is to enable information about the + leaf node in which any attached objects are held is stored for + use in the visibility determination. + @par + Do not confuse this class with BspNode, which reflects nodes in the + BSP tree itself. This class is just like a regular SceneNode, except that + it should be locating BspNode leaf elements which objects should be included + in. Note that because objects are movable, and thus may very well be overlapping + the boundaries of more than one leaf, that it is possible that an object attached + to one BspSceneNode may actually be associated with more than one BspNode. + */ + class BspSceneNode : public SceneNode + { + protected: + /// Overridden from SceneNode + void setInSceneGraph(bool inGraph); + public: + BspSceneNode(SceneManager* creator) : SceneNode(creator) {} + BspSceneNode(SceneManager* creator, const String& name) + : SceneNode(creator, name) {} + /// Overridden from Node + void _update(bool updateChildren, bool parentHasChanged); + /** Detaches the indexed object from this scene node. + @remarks + Detaches by index, see the alternate version to detach by name. Object indexes + may change as other objects are added / removed. + */ + MovableObject* detachObject(unsigned short index); + + /** Detaches the named object from this node and returns a pointer to it. */ + MovableObject* detachObject(const String& name); + + /** Detaches all objects attached to this node. + */ + void detachAllObjects(void); + + + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourFaderAffector.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourFaderAffector.h new file mode 100644 index 00000000..14967b23 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourFaderAffector.h @@ -0,0 +1,168 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ColourFaderAffector_H__ +#define __ColourFaderAffector_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleAffector.h" +#include "OgreStringInterface.h" + +namespace Ogre { + + + /** This plugin subclass of ParticleAffector allows you to alter the colour of particles. + @remarks + This class supplies the ParticleAffector implementation required to modify the colour of + particle in mid-flight. + */ + class _OgreParticleFXExport ColourFaderAffector : public ParticleAffector + { + public: + + /** Command object for red adjust (see ParamCommand).*/ + class CmdRedAdjust : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Command object for green adjust (see ParamCommand).*/ + class CmdGreenAdjust : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Command object for blue adjust (see ParamCommand).*/ + class CmdBlueAdjust : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Command object for alpha adjust (see ParamCommand).*/ + class CmdAlphaAdjust : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + + /** Default constructor. */ + ColourFaderAffector(ParticleSystem* psys); + + /** See ParticleAffector. */ + void _affectParticles(ParticleSystem* pSystem, Real timeElapsed); + + /** Sets the colour adjustment to be made per second to particles. + @param red, green, blue, alpha + Sets the adjustment to be made to each of the colour components per second. These + values will be added to the colour of all particles every second, scaled over each frame + for a smooth adjustment. + */ + void setAdjust(float red, float green, float blue, float alpha = 0.0); + /** Sets the red adjustment to be made per second to particles. + @param red + The adjustment to be made to the colour component per second. This + value will be added to the colour of all particles every second, scaled over each frame + for a smooth adjustment. + */ + void setRedAdjust(float red); + + /** Gets the red adjustment to be made per second to particles. */ + float getRedAdjust(void) const; + + /** Sets the green adjustment to be made per second to particles. + @param green + The adjustment to be made to the colour component per second. This + value will be added to the colour of all particles every second, scaled over each frame + for a smooth adjustment. + */ + void setGreenAdjust(float green); + /** Gets the green adjustment to be made per second to particles. */ + float getGreenAdjust(void) const; + /** Sets the blue adjustment to be made per second to particles. + @param blue + The adjustment to be made to the colour component per second. This + value will be added to the colour of all particles every second, scaled over each frame + for a smooth adjustment. + */ + void setBlueAdjust(float blue); + /** Gets the blue adjustment to be made per second to particles. */ + float getBlueAdjust(void) const; + + /** Sets the alpha adjustment to be made per second to particles. + @param alpha + The adjustment to be made to the colour component per second. This + value will be added to the colour of all particles every second, scaled over each frame + for a smooth adjustment. + */ + void setAlphaAdjust(float alpha); + /** Gets the alpha adjustment to be made per second to particles. */ + float getAlphaAdjust(void) const; + + static CmdRedAdjust msRedCmd; + static CmdGreenAdjust msGreenCmd; + static CmdBlueAdjust msBlueCmd; + static CmdAlphaAdjust msAlphaCmd; + + protected: + float mRedAdj; + float mGreenAdj; + float mBlueAdj; + float mAlphaAdj; + + /** Internal method for adjusting while clamping to [0,1] */ + inline void applyAdjustWithClamp(float* pComponent, float adjust) + { + *pComponent += adjust; + // Limit to 0 + if (*pComponent < 0.0) + { + *pComponent = 0.0f; + } + // Limit to 1 + else if (*pComponent > 1.0) + { + *pComponent = 1.0f; + } + } + + }; + + +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourFaderAffector2.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourFaderAffector2.h new file mode 100644 index 00000000..ab806b0b --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourFaderAffector2.h @@ -0,0 +1,227 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ColourFaderAffector2_H__ +#define __ColourFaderAffector2_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleAffector.h" +#include "OgreStringInterface.h" + +namespace Ogre { + + + /** This plugin subclass of ParticleAffector allows you to alter the colour of particles. + @remarks + This class supplies the ParticleAffector implementation required to modify the colour of + particle in mid-flight. + */ + class _OgreParticleFXExport ColourFaderAffector2 : public ParticleAffector + { + public: + + /** Command object for red adjust (see ParamCommand).*/ + class CmdRedAdjust1 : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Command object for green adjust (see ParamCommand).*/ + class CmdGreenAdjust1 : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Command object for blue adjust (see ParamCommand).*/ + class CmdBlueAdjust1 : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Command object for alpha adjust (see ParamCommand).*/ + class CmdAlphaAdjust1 : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Command object for red adjust (see ParamCommand).*/ + class CmdRedAdjust2 : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Command object for green adjust (see ParamCommand).*/ + class CmdGreenAdjust2 : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Command object for blue adjust (see ParamCommand).*/ + class CmdBlueAdjust2 : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Command object for alpha adjust (see ParamCommand).*/ + class CmdAlphaAdjust2 : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Command object for alpha adjust (see ParamCommand).*/ + class CmdStateChange : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + + /** Default constructor. */ + ColourFaderAffector2(ParticleSystem* psys); + + /** See ParticleAffector. */ + void _affectParticles(ParticleSystem* pSystem, Real timeElapsed); + + /** Sets the colour adjustment to be made per second to particles. + @param red, green, blue, alpha + Sets the adjustment to be made to each of the colour components per second. These + values will be added to the colour of all particles every second, scaled over each frame + for a smooth adjustment. + */ + void setAdjust1(float red, float green, float blue, float alpha = 0.0); + void setAdjust2(float red, float green, float blue, float alpha = 0.0); + /** Sets the red adjustment to be made per second to particles. + @param red + The adjustment to be made to the colour component per second. This + value will be added to the colour of all particles every second, scaled over each frame + for a smooth adjustment. + */ + void setRedAdjust1(float red); + void setRedAdjust2(float red); + + /** Gets the red adjustment to be made per second to particles. */ + float getRedAdjust1(void) const; + float getRedAdjust2(void) const; + + /** Sets the green adjustment to be made per second to particles. + @param green + The adjustment to be made to the colour component per second. This + value will be added to the colour of all particles every second, scaled over each frame + for a smooth adjustment. + */ + void setGreenAdjust1(float green); + void setGreenAdjust2(float green); + /** Gets the green adjustment to be made per second to particles. */ + float getGreenAdjust1(void) const; + float getGreenAdjust2(void) const; + /** Sets the blue adjustment to be made per second to particles. + @param blue + The adjustment to be made to the colour component per second. This + value will be added to the colour of all particles every second, scaled over each frame + for a smooth adjustment. + */ + void setBlueAdjust1(float blue); + void setBlueAdjust2(float blue); + /** Gets the blue adjustment to be made per second to particles. */ + float getBlueAdjust1(void) const; + float getBlueAdjust2(void) const; + + /** Sets the alpha adjustment to be made per second to particles. + @param alpha + The adjustment to be made to the colour component per second. This + value will be added to the colour of all particles every second, scaled over each frame + for a smooth adjustment. + */ + void setAlphaAdjust1(float alpha); + void setAlphaAdjust2(float alpha); + /** Gets the alpha adjustment to be made per second to particles. */ + float getAlphaAdjust1(void) const; + float getAlphaAdjust2(void) const; + + + void setStateChange(Real NewValue ); + Real getStateChange(void) const; + + static CmdRedAdjust1 msRedCmd1; + static CmdRedAdjust2 msRedCmd2; + static CmdGreenAdjust1 msGreenCmd1; + static CmdGreenAdjust2 msGreenCmd2; + static CmdBlueAdjust1 msBlueCmd1; + static CmdBlueAdjust2 msBlueCmd2; + static CmdAlphaAdjust1 msAlphaCmd1; + static CmdAlphaAdjust2 msAlphaCmd2; + static CmdStateChange msStateCmd; + + protected: + float mRedAdj1, mRedAdj2; + float mGreenAdj1, mGreenAdj2; + float mBlueAdj1, mBlueAdj2; + float mAlphaAdj1, mAlphaAdj2; + Real StateChangeVal; + + /** Internal method for adjusting while clamping to [0,1] */ + inline void applyAdjustWithClamp(float* pComponent, float adjust) + { + *pComponent += adjust; + // Limit to 0 + if (*pComponent < 0.0) + { + *pComponent = 0.0f; + } + // Limit to 1 + else if (*pComponent > 1.0) + { + *pComponent = 1.0f; + } + } + + }; + + +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourFaderAffectorFactory.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourFaderAffectorFactory.h new file mode 100644 index 00000000..de09250f --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourFaderAffectorFactory.h @@ -0,0 +1,57 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ColourFaderAffectorFactory_H__ +#define __ColourFaderAffectorFactory_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleAffectorFactory.h" +#include "OgreColourFaderAffector.h" + +namespace Ogre { + + /** Factory class for ColourFaderAffector. */ + class _OgreParticleFXExport ColourFaderAffectorFactory : public ParticleAffectorFactory + { + /** See ParticleAffectorFactory */ + String getName() const { return "ColourFader"; } + + /** See ParticleAffectorFactory */ + ParticleAffector* createAffector(ParticleSystem* psys) + { + ParticleAffector* p = new ColourFaderAffector(psys); + mAffectors.push_back(p); + return p; + } + }; + + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourFaderAffectorFactory2.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourFaderAffectorFactory2.h new file mode 100644 index 00000000..228e660d --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourFaderAffectorFactory2.h @@ -0,0 +1,57 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ColourFaderAffectorFactory2_H__ +#define __ColourFaderAffectorFactory2_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleAffectorFactory.h" +#include "OgreColourFaderAffector2.h" + +namespace Ogre { + + /** Factory class for ColourFaderAffector. */ + class _OgreParticleFXExport ColourFaderAffectorFactory2 : public ParticleAffectorFactory + { + /** See ParticleAffectorFactory */ + String getName() const { return "ColourFader2"; } + + /** See ParticleAffectorFactory */ + ParticleAffector* createAffector(ParticleSystem* psys) + { + ParticleAffector* p = new ColourFaderAffector2(psys); + mAffectors.push_back(p); + return p; + } + }; + + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourImageAffector.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourImageAffector.h new file mode 100644 index 00000000..240a9dc8 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourImageAffector.h @@ -0,0 +1,81 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ColourImageAffector_H__ +#define __ColourImageAffector_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleAffector.h" +#include "OgreStringInterface.h" +#include "OgreColourValue.h" +#include "OgreImage.h" + +namespace Ogre { + + + class _OgreParticleFXExport ColourImageAffector : public ParticleAffector + { + public: + /** Command object for red adjust (see ParamCommand).*/ + class CmdImageAdjust : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Default constructor. */ + ColourImageAffector(ParticleSystem* psys); + + /** See ParticleAffector. */ + void _initParticle(Particle* pParticle); + + /** See ParticleAffector. */ + void _affectParticles(ParticleSystem* pSystem, Real timeElapsed); + + void setImageAdjust(String name); + String getImageAdjust(void) const; + + + static CmdImageAdjust msImageCmd; + + protected: + Image mColourImage; + bool mColourImageLoaded; + String mColourImageName; + + /** Internal method to load the image */ + void _loadImage(void); + }; + + +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourImageAffectorFactory.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourImageAffectorFactory.h new file mode 100644 index 00000000..3081be7a --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourImageAffectorFactory.h @@ -0,0 +1,57 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ColourImageAffectorFactory_H__ +#define __ColourImageAffectorFactory_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleAffectorFactory.h" +#include "OgreColourImageAffector.h" + +namespace Ogre { + + /** Factory class for ColourImageAffector. */ + class _OgreParticleFXExport ColourImageAffectorFactory : public ParticleAffectorFactory + { + /** See ParticleAffectorFactory */ + String getName() const { return "ColourImage"; } + + /** See ParticleAffectorFactory */ + ParticleAffector* createAffector(ParticleSystem* psys) + { + ParticleAffector* p = new ColourImageAffector(psys); + mAffectors.push_back(p); + return p; + } + }; + + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourInterpolatorAffector.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourInterpolatorAffector.h new file mode 100644 index 00000000..5c2c033f --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourInterpolatorAffector.h @@ -0,0 +1,98 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ColourInterpolatorAffector_H__ +#define __ColourInterpolatorAffector_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleAffector.h" +#include "OgreStringInterface.h" +#include "OgreColourValue.h" + +namespace Ogre { + + + class _OgreParticleFXExport ColourInterpolatorAffector : public ParticleAffector + { + public: + // this is something of a hack.. + // needs to be replaced with something more.. + // ..elegant + enum { MAX_STAGES = 6 }; + + + /** Command object for red adjust (see ParamCommand).*/ + class CmdColourAdjust : public ParamCommand + { + public: + size_t mIndex; + + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Command object for red adjust (see ParamCommand).*/ + class CmdTimeAdjust : public ParamCommand + { + public: + size_t mIndex; + + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Default constructor. */ + ColourInterpolatorAffector(ParticleSystem* psys); + + /** See ParticleAffector. */ + void _affectParticles(ParticleSystem* pSystem, Real timeElapsed); + + void setColourAdjust(size_t index, ColourValue colour); + ColourValue getColourAdjust(size_t index) const; + + void setTimeAdjust(size_t index, Real time); + Real getTimeAdjust(size_t index) const; + + + static CmdColourAdjust msColourCmd[MAX_STAGES]; + static CmdTimeAdjust msTimeCmd[MAX_STAGES]; + + protected: + ColourValue mColourAdj[MAX_STAGES]; + Real mTimeAdj[MAX_STAGES]; + + }; + + +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourInterpolatorAffectorFactory.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourInterpolatorAffectorFactory.h new file mode 100644 index 00000000..89b36d8f --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreColourInterpolatorAffectorFactory.h @@ -0,0 +1,57 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ColourInterpolatorAffectorFactory_H__ +#define __ColourInterpolatorAffectorFactory_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleAffectorFactory.h" +#include "OgreColourInterpolatorAffector.h" + +namespace Ogre { + + /** Factory class for ColourInterpolatorAffector. */ + class _OgreParticleFXExport ColourInterpolatorAffectorFactory : public ParticleAffectorFactory + { + /** See ParticleAffectorFactory */ + String getName() const { return "ColourInterpolator"; } + + /** See ParticleAffectorFactory */ + ParticleAffector* createAffector(ParticleSystem* psys) + { + ParticleAffector* p = new ColourInterpolatorAffector(psys); + mAffectors.push_back(p); + return p; + } + }; + + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreCylinderEmitter.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreCylinderEmitter.h new file mode 100644 index 00000000..2b8dbf98 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreCylinderEmitter.h @@ -0,0 +1,67 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright ) 2002 Tels based on CylinderEmitter +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __CylinderEmitter_H__ +#define __CylinderEmitter_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreAreaEmitter.h" + +namespace Ogre { + + /** Particle emitter which emits particles randomly from points inside a cylinder. + @remarks + This basic particle emitter emits particles from a cylinder area. The + initial direction of these particles can either be a single direction + (i.e. a line), a random scattering inside a cone, or a random + scattering in all directions, depending the 'angle' parameter, which + is the angle across which to scatter the particles either side of the + base direction of the emitter. + */ + class _OgreParticleFXExport CylinderEmitter : public AreaEmitter + { + public: + // See AreaEmitter + + CylinderEmitter(ParticleSystem* psys); + + /** See ParticleEmitter. */ + void _initParticle(Particle* pParticle); + + protected: + // See AreaEmitter + + + + + }; + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreCylinderEmitterFactory.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreCylinderEmitterFactory.h new file mode 100644 index 00000000..c66571ef --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreCylinderEmitterFactory.h @@ -0,0 +1,67 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright ) 2002 Tels >http://bloodgate.com> based on CylinderEmitter +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __CylinderEmitterFactory_H__ +#define __CylinderEmitterFactory_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleEmitterFactory.h" +#include "OgreCylinderEmitter.h" + + +namespace Ogre { + + /** Factory class for particle emitter of type "Cylinder". + @remarks + Creates instances of CylinderEmitter to be used in particle systems. + */ + class _OgreParticleFXExport CylinderEmitterFactory : public ParticleEmitterFactory + { + protected: + + public: + /** See ParticleEmitterFactory */ + String getName() const + { + return "Cylinder"; + } + + /** See ParticleEmitterFactory */ + ParticleEmitter* createEmitter(ParticleSystem* psys) + { + ParticleEmitter* emit = new CylinderEmitter(psys); + mEmitters.push_back(emit); + return emit; + } + + }; + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreDeflectorPlaneAffector.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreDeflectorPlaneAffector.h new file mode 100644 index 00000000..890707e8 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreDeflectorPlaneAffector.h @@ -0,0 +1,115 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __DeflectorPlaneAffector_H__ +#define __DeflectorPlaneAffector_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleAffector.h" +#include "OgreVector3.h" + + +namespace Ogre { + + /** This class defines a ParticleAffector which deflects particles. + @remarks + This affector (see ParticleAffector) offers a simple (and inaccurate) physical deflection. + All particles which hit the plane are reflected. + @par + The plane is defined by a point (plane_point) and the normal (plane_normal). + In addition it is possible to change the strenght of the recoil by using the bounce parameter. + */ + class _OgreParticleFXExport DeflectorPlaneAffector : public ParticleAffector + { + public: + /** Command object for plane point (see ParamCommand).*/ + class CmdPlanePoint : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Command object for plane normal (see ParamCommand).*/ + class CmdPlaneNormal : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Command object for bounce (see ParamCommand).*/ + class CmdBounce : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /// Default constructor + DeflectorPlaneAffector(ParticleSystem* psys); + + /** See ParticleAffector. */ + void _affectParticles(ParticleSystem* pSystem, Real timeElapsed); + + /** Sets the plane point of the deflector plane. */ + void setPlanePoint(const Vector3& pos); + + /** Gets the plane point of the deflector plane. */ + Vector3 getPlanePoint(void) const; + + /** Sets the plane normal of the deflector plane. */ + void setPlaneNormal(const Vector3& normal); + + /** Gets the plane normal of the deflector plane. */ + Vector3 getPlaneNormal(void) const; + + /** Sets the bounce value of the deflection. */ + void setBounce(Real bounce); + + /** Gets the bounce value of the deflection. */ + Real getBounce(void) const; + + /// Command objects + static CmdPlanePoint msPlanePointCmd; + static CmdPlaneNormal msPlaneNormalCmd; + static CmdBounce msBounceCmd; + + protected: + /// deflector plane point + Vector3 mPlanePoint; + /// deflector plane normal vector + Vector3 mPlaneNormal; + + /// bounce factor (0.5 means 50 percent) + Real mBounce; + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreDeflectorPlaneAffectorFactory.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreDeflectorPlaneAffectorFactory.h new file mode 100644 index 00000000..2eff7f88 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreDeflectorPlaneAffectorFactory.h @@ -0,0 +1,57 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __DeflectorPlaneAffectorFactory_H__ +#define __DeflectorPlaneAffectorFactory_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleAffectorFactory.h" +#include "OgreDeflectorPlaneAffector.h" + +namespace Ogre { + + /** Factory class for DeflectorPlaneAffector. */ + class _OgreParticleFXExport DeflectorPlaneAffectorFactory : public ParticleAffectorFactory + { + /** See ParticleAffectorFactory */ + String getName() const { return "DeflectorPlane"; } + + /** See ParticleAffectorFactory */ + ParticleAffector* createAffector(ParticleSystem* psys) + { + ParticleAffector* p = new DeflectorPlaneAffector(psys); + mAffectors.push_back(p); + return p; + } + }; + + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreDirectionRandomiserAffector.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreDirectionRandomiserAffector.h new file mode 100644 index 00000000..90a08640 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreDirectionRandomiserAffector.h @@ -0,0 +1,110 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __DirectionRandomiserAffector_H__ +#define __DirectionRandomiserAffector_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleAffector.h" +#include "OgreVector3.h" + + +namespace Ogre { + + /** This class defines a ParticleAffector which applies randomness to the movement of the particles. + @remarks + This affector (see ParticleAffector) applies randomness to the movement of the particles by + changing the direction vectors. + @par + The most important parameter to control the effect is randomness. It controls the range in which changes + are applied to each axis of the direction vector. + The parameter scope can be used to limit the effect to a certain percentage of the particles. + */ + class _OgreParticleFXExport DirectionRandomiserAffector : public ParticleAffector + { + public: + /** Command object for randomness (see ParamCommand).*/ + class CmdRandomness : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Command object for scope (see ParamCommand).*/ + class CmdScope : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Command object for keep_velocity (see ParamCommand).*/ + class CmdKeepVelocity : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /// Default constructor + DirectionRandomiserAffector(ParticleSystem* psys); + + /** See ParticleAffector. */ + void _affectParticles(ParticleSystem* pSystem, Real timeElapsed); + + + /** Sets the randomness to apply to the particles in a system. */ + void setRandomness(Real force); + /** Sets the scope (percentage of particles which are randomised). */ + void setScope(Real force); + /** Set flag which detemines whether particle speed is changed. */ + void setKeepVelocity(bool keepVelocity); + + /** Gets the randomness to apply to the particles in a system. */ + Real getRandomness(void) const; + /** Gets the scope (percentage of particles which are randomised). */ + Real getScope(void) const; + /** Gets flag which detemines whether particle speed is changed. */ + bool getKeepVelocity(void) const; + + /// Command objects + static CmdRandomness msRandomnessCmd; + static CmdScope msScopeCmd; + static CmdKeepVelocity msKeepVelocityCmd; + + protected: + Real mRandomness; + Real mScope; + bool mKeepVelocity; + + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreDirectionRandomiserAffectorFactory.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreDirectionRandomiserAffectorFactory.h new file mode 100644 index 00000000..3185bc27 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreDirectionRandomiserAffectorFactory.h @@ -0,0 +1,55 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __DirectionRandomiserAffectorFactory_H__ +#define __DirectionRandomiserAffectorFactory_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleAffectorFactory.h" +#include "OgreDirectionRandomiserAffector.h" + +namespace Ogre { + + /** Factory class for DirectionRandomiserAffector. */ + class _OgreParticleFXExport DirectionRandomiserAffectorFactory : public ParticleAffectorFactory + { + /** See ParticleAffectorFactory */ + String getName() const { return "DirectionRandomiser"; } + + /** See ParticleAffectorFactory */ + ParticleAffector* createAffector(ParticleSystem* psys) + { + ParticleAffector* p = new DirectionRandomiserAffector(psys); + mAffectors.push_back(p); + return p; + } + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreEllipsoidEmitter.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreEllipsoidEmitter.h new file mode 100644 index 00000000..9b6f1e8e --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreEllipsoidEmitter.h @@ -0,0 +1,64 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright ) 2002 Tels based on BoxEmitter +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __EllipsoidEmitter_H__ +#define __EllipsoidEmitter_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreAreaEmitter.h" + +namespace Ogre { + + /** Particle emitter which emits particles randomly from points inside an ellipsoid. + @remarks + This basic particle emitter emits particles from a ellipsoid area. + The initial direction of these particles can either be a single + direction (i.e. a line), a random scattering inside a cone, or a random + scattering in all directions, depending the 'angle' parameter, which + is the angle across which to scatter the particles either side of the + base direction of the emitter. + */ + class _OgreParticleFXExport EllipsoidEmitter : public AreaEmitter + { + public: + // See AreaEmitter + + EllipsoidEmitter(ParticleSystem* psys); + + /** See ParticleEmitter. */ + void _initParticle(Particle* pParticle); + + protected: + + + }; + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreEllipsoidEmitterFactory.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreEllipsoidEmitterFactory.h new file mode 100644 index 00000000..57595b23 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreEllipsoidEmitterFactory.h @@ -0,0 +1,67 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright ) 2002 Tels >http://bloodgate.com> based on BoxEmitter +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __EllipsoidEmitterFactory_H__ +#define __EllipsoidEmitterFactory_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleEmitterFactory.h" +#include "OgreEllipsoidEmitter.h" + + +namespace Ogre { + + /** Factory class for particle emitter of type "Ellipsoid". + @remarks + Creates instances of EllipsoidEmitter to be used in particle systems. + */ + class _OgreParticleFXExport EllipsoidEmitterFactory : public ParticleEmitterFactory + { + protected: + + public: + /** See ParticleEmitterFactory */ + String getName() const + { + return "Ellipsoid"; + } + + /** See ParticleEmitterFactory */ + ParticleEmitter* createEmitter(ParticleSystem* psys) + { + ParticleEmitter* emit = new EllipsoidEmitter(psys); + mEmitters.push_back(emit); + return emit; + } + + }; + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreHeightmapTerrainPageSource.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreHeightmapTerrainPageSource.h new file mode 100644 index 00000000..fe07016c --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreHeightmapTerrainPageSource.h @@ -0,0 +1,82 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __HeightmapTerrainPageSource_H__ +#define __HeightmapTerrainPageSource_H__ + +#include "OgreTerrainPrerequisites.h" +#include "OgreTerrainPageSource.h" +#include "OgreImage.h" + +namespace Ogre { + + /** Specialisation of the TerrainPageSource class to provide tiles loaded + from a 2D greyscale image. + @remarks + This is a simple tile provider that does not support paging; it is + assumed that the entire heightmap is loaded as one page. + */ + class _OgreOctreePluginExport HeightmapTerrainPageSource : public TerrainPageSource + { + protected: + /// Is this input RAW? + bool mIsRaw; + /// Should we flip terrain vertically? + bool mFlipTerrain; + /// Image containing the source heightmap if loaded from non-RAW + Image mImage; + /// Arbitrary data loaded from RAW + MemoryDataStreamPtr mRawData; + /// The (single) terrain page this source will provide + TerrainPage* mPage; + /// Source file name + String mSource; + /// Manual size if source is RAW + size_t mRawSize; + /// Manual bpp if source is RAW + uchar mRawBpp; + + /// Load a heightmap + void loadHeightmap(void); + public: + HeightmapTerrainPageSource(); + ~HeightmapTerrainPageSource(); + /// @see TerrainPageSource + void shutdown(void); + /// @see TerrainPageSource + void requestPage(ushort x, ushort y); + /// @see TerrainPageSource + void expirePage(ushort x, ushort y); + /// @see TerrainPageSource + void initialise(TerrainSceneManager* tsm, + ushort tileSize, ushort pageSize, bool asyncLoading, + TerrainPageSourceOptionList& optionList); + }; +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreHollowEllipsoidEmitter.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreHollowEllipsoidEmitter.h new file mode 100644 index 00000000..7dd0e783 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreHollowEllipsoidEmitter.h @@ -0,0 +1,126 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright ) 2002 Tels based on BoxEmitter +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __HollowEllipsoidEmitter_H__ +#define __HollowEllipsoidEmitter_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreEllipsoidEmitter.h" + +namespace Ogre { + + /** Particle emitter which emits particles randomly from points inside a hollow ellipsoid. + @remarks + This particle emitter emits particles from a hollow ellipsoid area. + The initial direction of these particles can either be a single + direction (i.e. a line), a random scattering inside a cone, or a random + scattering in all directions, depending the 'angle' parameter, which + is the angle across which to scatter the particles either side of the + base direction of the emitter. + */ + class _OgreParticleFXExport HollowEllipsoidEmitter : public EllipsoidEmitter + { + public: + /** Command object for inner size (see ParamCommand).*/ + class CmdInnerX : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /** Command object for inner size (see ParamCommand).*/ + class CmdInnerY : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /** Command object for inner size (see ParamCommand).*/ + class CmdInnerZ : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + // See AreaEmitter + + HollowEllipsoidEmitter(ParticleSystem* psys); + + /** See ParticleEmitter. */ + void _initParticle(Particle* pParticle); + + /** Sets the size of the clear space inside the area from where NO particles are emitted. + @param x,y,z + Parametric values describing the proportion of the shape which is hollow in each direction. + E.g. 0 is solid, 0.5 is half-hollow etc + */ + void setInnerSize(Real x, Real y, Real z); + + /** Sets the x component of the area inside the ellipsoid which doesn't emit particles. + @param x + Parametric value describing the proportion of the shape which is hollow in this direction. + E.g. 0 is solid, 0.5 is half-hollow etc + */ + void setInnerSizeX(Real x); + /** Sets the y component of the area inside the ellipsoid which doesn't emit particles. + @param y + Parametric value describing the proportion of the shape which is hollow in this direction. + E.g. 0 is solid, 0.5 is half-hollow etc + */ + void setInnerSizeY(Real y); + /** Sets the z component of the area inside the ellipsoid which doesn't emit particles. + @param z + Parametric value describing the proportion of the shape which is hollow in this direction. + E.g. 0 is solid, 0.5 is half-hollow etc + */ + void setInnerSizeZ(Real z); + /** Gets the x component of the area inside the ellipsoid which doesn't emit particles. */ + Real getInnerSizeX(void) const; + /** Gets the y component of the area inside the ellipsoid which doesn't emit particles. */ + Real getInnerSizeY(void) const; + /** Gets the z component of the area inside the ellipsoid which doesn't emit particles. */ + Real getInnerSizeZ(void) const; + + protected: + // See ParticleEmitter + + /// Size of 'clear' center area (> 0 and < 1.0) + Vector3 mInnerSize; + + static CmdInnerX msCmdInnerX; + static CmdInnerY msCmdInnerY; + static CmdInnerZ msCmdInnerZ; + + + + }; + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreHollowEllipsoidEmitterFactory.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreHollowEllipsoidEmitterFactory.h new file mode 100644 index 00000000..31ad7435 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreHollowEllipsoidEmitterFactory.h @@ -0,0 +1,67 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright ) 2002 Tels >http://bloodgate.com> based on BoxEmitter +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __HollowEllipsoidEmitterFactory_H__ +#define __HollowEllipsoidEmitterFactory_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleEmitterFactory.h" +#include "OgreHollowEllipsoidEmitter.h" + + +namespace Ogre { + + /** Factory class for particle emitter of type "HollowEllipsoid". + @remarks + Creates instances of HollowEllipsoidEmitter to be used in particle systems. + */ + class _OgreParticleFXExport HollowEllipsoidEmitterFactory : public ParticleEmitterFactory + { + protected: + + public: + /** See ParticleEmitterFactory */ + String getName() const + { + return "HollowEllipsoid"; + } + + /** See ParticleEmitterFactory */ + ParticleEmitter* createEmitter(ParticleSystem* psys) + { + ParticleEmitter* emit = new HollowEllipsoidEmitter(psys); + mEmitters.push_back(emit); + return emit; + } + + }; + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreLinearForceAffector.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreLinearForceAffector.h new file mode 100644 index 00000000..81ea7f12 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreLinearForceAffector.h @@ -0,0 +1,121 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __LinearForceAffector_H__ +#define __LinearForceAffector_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleAffector.h" +#include "OgreVector3.h" + + +namespace Ogre { + + /** This class defines a ParticleAffector which applies a linear force to particles in a system. + @remarks + This affector (see ParticleAffector) applies a linear force, such as gravity, to a particle system. + This force can be applied in 2 ways: by taking the average of the particle's current momentum and the + force vector, or by adding the force vector to the current particle's momentum. + @par + The former approach is self-stabilising i.e. once a particle's momentum + is equal to the force vector, no further change is made to it's momentum. It also results in + a non-linear acceleration of particles. + The latter approach is simpler and applies a constant acceleration to particles. However, + it is not self-stabilising and can lead to perpetually increasing particle velocities. + You choose the approach by calling the setForceApplication method. + */ + class _OgreParticleFXExport LinearForceAffector : public ParticleAffector + { + public: + /** Command object for force vector (see ParamCommand).*/ + class CmdForceVector : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Command object for force application (see ParamCommand).*/ + class CmdForceApp : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /// Choice of how to apply the force vector to particles + enum ForceApplication + { + /// Take the average of the force vector and the particle momentum + FA_AVERAGE, + /// Add the force vector to the particle momentum + FA_ADD + }; + /// Default constructor + LinearForceAffector(ParticleSystem* psys); + + /** See ParticleAffector. */ + void _affectParticles(ParticleSystem* pSystem, Real timeElapsed); + + + /** Sets the force vector to apply to the particles in a system. */ + void setForceVector(const Vector3& force); + + /** Gets the force vector to apply to the particles in a system. */ + Vector3 getForceVector(void) const; + + /** Sets how the force vector is applied to a particle. + @remarks + The default is FA_ADD. + @param fa A member of the ForceApplication enum. + */ + void setForceApplication(ForceApplication fa); + + /** Retrieves how the force vector is applied to a particle. + @param fa A member of the ForceApplication enum. + */ + ForceApplication getForceApplication(void) const; + + /// Command objects + static CmdForceVector msForceVectorCmd; + static CmdForceApp msForceAppCmd; + + protected: + /// Force vector + Vector3 mForceVector; + + /// How to apply force + ForceApplication mForceApplication; + + }; + + +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreLinearForceAffectorFactory.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreLinearForceAffectorFactory.h new file mode 100644 index 00000000..57940aa0 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreLinearForceAffectorFactory.h @@ -0,0 +1,57 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __LinearForceAffectorFactory_H__ +#define __LinearForceAffectorFactory_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleAffectorFactory.h" +#include "OgreLinearForceAffector.h" + +namespace Ogre { + + /** Factory class for LinearForceAffector. */ + class _OgreParticleFXExport LinearForceAffectorFactory : public ParticleAffectorFactory + { + /** See ParticleAffectorFactory */ + String getName() const { return "LinearForce"; } + + /** See ParticleAffectorFactory */ + ParticleAffector* createAffector(ParticleSystem* psys) + { + ParticleAffector* p = new LinearForceAffector(psys); + mAffectors.push_back(p); + return p; + } + }; + + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreOctree.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreOctree.h new file mode 100644 index 00000000..74beed25 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreOctree.h @@ -0,0 +1,167 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +/*************************************************************************** +octree.h - description +------------------- +begin : Mon Sep 30 2002 +copyright : (C) 2002 by Jon Anderson +email : janders@users.sf.net + +Enhancements 2003 - 2004 (C) The OGRE Team +***************************************************************************/ + +#ifndef OCTREE_H +#define OCTREE_H + +#include +#include + +#include + +namespace Ogre +{ + +class OctreeNode; + +typedef std::list < OctreeNode * > NodeList; + + +/** Octree datastructure for managing scene nodes. +@remarks +This is a loose octree implementation, meaning that each +octant child of the octree actually overlaps it's siblings by a factor +of .5. This guarantees that any thing that is half the size of the parent will +fit completely into a child, with no splitting necessary. +*/ + +class Octree +{ +public: + Octree( Octree * p ); + ~Octree(); + + /** Adds an Octree scene node to this octree level. + @remarks + This is called by the OctreeSceneManager after + it has determined the correct Octree to insert the node into. + */ + void _addNode( OctreeNode * ); + + /** Removes an Octree scene node to this octree level. + */ + void _removeNode( OctreeNode * ); + + /** Returns the number of scene nodes attached to this octree + */ + int numNodes() + { + return mNumNodes; + }; + + /** The bounding box of the octree + @remarks + This is used for octant index determination and rendering, but not culling + */ + AxisAlignedBox mBox; + WireBoundingBox* mWireBoundingBox; + + /** Creates the wire frame bounding box for this octant + */ + WireBoundingBox* getWireBoundingBox(); + + /** Vector containing the dimensions of this octree / 2 + */ + Vector3 mHalfSize; + + /** 3D array of children of this octree. + @remarks + Children are dynamically created as needed when nodes are inserted in the Octree. + If, later, all the nodes are removed from the child, it is still kept around. + */ + Octree * mChildren[ 2 ][ 2 ][ 2 ]; + + /** Determines if this octree is twice as big as the given box. + @remarks + This method is used by the OctreeSceneManager to determine if the given + box will fit into a child of this octree. + */ + bool _isTwiceSize( const AxisAlignedBox &box ) const; + + /** Returns the appropriate indexes for the child of this octree into which the box will fit. + @remarks + This is used by the OctreeSceneManager to determine which child to traverse next when + finding the appropriate octree to insert the box. Since it is a loose octree, only the + center of the box is checked to determine the octant. + */ + void _getChildIndexes( const AxisAlignedBox &, int *x, int *y, int *z ) const; + + /** Creates the AxisAlignedBox used for culling this octree. + @remarks + Since it's a loose octree, the culling bounds can be different than the actual bounds of the octree. + */ + void _getCullBounds( AxisAlignedBox * ) const; + + + /** Public list of SceneNodes attached to this particular octree + */ + NodeList mNodes; + +protected: + + /** Increments the overall node count of this octree and all its parents + */ + inline void _ref() + { + mNumNodes++; + + if ( mParent != 0 ) mParent -> _ref(); + }; + + /** Decrements the overall node count of this octree and all its parents + */ + inline void _unref() + { + mNumNodes--; + + if ( mParent != 0 ) mParent -> _unref(); + }; + + ///number of SceneNodes in this octree and all its children. + int mNumNodes; + + ///parent octree + Octree * mParent; + +}; + +} + +#endif + + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreOctreeCamera.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreOctreeCamera.h new file mode 100644 index 00000000..c9b367a5 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreOctreeCamera.h @@ -0,0 +1,90 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +/*************************************************************************** +octreecamera.h - description +------------------- +begin : Fri Sep 27 2002 +copyright : (C) 2002 by Jon Anderson +email : janders@users.sf.net + +Enhancements 2003 - 2004 (C) The OGRE Team +***************************************************************************/ + +#ifndef OCTREECAMERA_H +#define OCTREECAMERA_H + +#include +#include +#include +#include "OgreTerrainPrerequisites.h" + +/** +*@author Jon Anderson +*/ + +namespace Ogre +{ + +class Octree; + + +/** Specialized viewpoint from which an Octree can be rendered. +@remarks +This class contains several specializations of the Ogre::Camera class. It +implements the getRenderOperation method in order to return displayable geometry +for debugging purposes. It also implements a visibility function that is more granular +than the default. +*/ + +class _OgreOctreePluginExport OctreeCamera : public Camera +{ +public: + + /** Visibility types */ + enum Visibility + { + NONE, + PARTIAL, + FULL + }; + + /* Standard constructor */ + OctreeCamera( const String& name, SceneManager* sm ); + /* Standard destructor */ + ~OctreeCamera(); + + /** Returns the visiblity of the box + */ + OctreeCamera::Visibility getVisibility( const AxisAlignedBox &bound ); + +}; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreOctreeNode.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreOctreeNode.h new file mode 100644 index 00000000..520c2a22 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreOctreeNode.h @@ -0,0 +1,149 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +/*************************************************************************** +octreenode.h - description +------------------- +begin : Fri Sep 27 2002 +copyright : (C) 2002 by Jon Anderson +email : janders@users.sf.net + +Enhancements 2003 - 2004 (C) The OGRE Team +***************************************************************************/ + +#ifndef OCTREENODE_H +#define OCTREENODE_H + +#include + +#include +#include "OgreTerrainPrerequisites.h" + +namespace Ogre +{ + +/** Specialized SceneNode that is customized for working within an Octree. Each node +* maintains its own bounding box, rather than merging it with all the children. +* +*/ + +class _OgreOctreePluginExport OctreeNode : public SceneNode +{ +public: + /** Standard constructor */ + OctreeNode( SceneManager* creator ); + /** Standard constructor */ + OctreeNode( SceneManager* creator, const String& name ); + /** Standard destructor */ + ~OctreeNode(); + + /** Overridden from Node to remove any reference to octants */ + Node * removeChild( unsigned short index ); + + /** Overridden from Node to remove any reference to octants */ + Node * removeChild( const String & name ); + + /** Overridden from Node to remove any reference to octants */ + Node * removeChild( Node* child); + + /** Overridden from Node to remove any reference to octants */ + void removeAllChildren(void); + + /** Returns the Octree in which this OctreeNode resides + */ + Octree * getOctant() + { + return mOctant; + }; + + /** Sets the Octree in which this OctreeNode resides + */ + void setOctant( Octree *o ) + { + mOctant = o; + }; + + /** Determines if the center of this node is within the given box + */ + bool _isIn( AxisAlignedBox &box ); + + /** Adds all the attached scenenodes to the render queue + */ + virtual void _addToRenderQueue( Camera* cam, RenderQueue * q, bool onlyShadowCasters, + VisibleObjectsBoundsInfo* visibleBounds); + + /** Sets up the LegacyRenderOperation for rendering this scene node as geometry. + @remarks + This will render the scenenode as a bounding box. + */ + virtual void getRenderOperation( RenderOperation& op ); + + /** Returns the local bounding box of this OctreeNode. + @remarks + This is used to render the bounding box, rather then the global. + */ + AxisAlignedBox & _getLocalAABB() + { + return mLocalAABB; + }; + + + + +protected: + + /** Internal method for updating the bounds for this OctreeNode. + @remarks + This method determines the bounds solely from the attached objects, not + any children. If the node has changed its bounds, it is removed from its + current octree, and reinserted into the tree. + */ + void _updateBounds( void ); + + void _removeNodeAndChildren( ); + + ///local bounding box + AxisAlignedBox mLocalAABB; + + ///Octree this node is attached to. + Octree *mOctant; + + ///preallocated corners for rendering + Real mCorners[ 24 ]; + ///shared colors for rendering + static unsigned long mColors[ 8 ]; + ///shared indexes for rendering + static unsigned short mIndexes[ 24 ]; + + +}; + +} + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreOctreePlugin.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreOctreePlugin.h new file mode 100644 index 00000000..3ecdabf8 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreOctreePlugin.h @@ -0,0 +1,68 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __OctreePlugin_H__ +#define __OctreePlugin_H__ + +#include "OgrePlugin.h" +#include "OgreOctreeSceneManager.h" +#include "OgreTerrainSceneManager.h" + +namespace Ogre +{ + + /** Plugin instance for Octree Manager */ + class OctreePlugin : public Plugin + { + public: + OctreePlugin(); + + + /// @copydoc Plugin::getName + const String& getName() const; + + /// @copydoc Plugin::install + void install(); + + /// @copydoc Plugin::initialise + void initialise(); + + /// @copydoc Plugin::shutdown + void shutdown(); + + /// @copydoc Plugin::uninstall + void uninstall(); + protected: + OctreeSceneManagerFactory* mOctreeSMFactory; + TerrainSceneManagerFactory* mTerrainSMFactory; + TerrainPageSourceListenerManager* mTerrainPSListenerManager; + + }; +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreOctreeSceneManager.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreOctreeSceneManager.h new file mode 100644 index 00000000..bfbbfcf2 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreOctreeSceneManager.h @@ -0,0 +1,255 @@ +/*************************************************************************** +octreescenemanager.h - description +------------------- +begin : Fri Sep 27 2002 +copyright : (C) 2002 by Jon Anderson +email : janders@users.sf.net +***************************************************************************/ + +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef OCTREESCENEMANAGER_H +#define OCTREESCENEMANAGER_H + +#include "OgreTerrainPrerequisites.h" +#include "OgreSceneManager.h" +#include "OgreRenderOperation.h" +#include "OgreSphere.h" + +#include +#include + +#include + + +namespace Ogre +{ + +class OctreeNode; + +class OctreeCamera; +class OctreeIntersectionSceneQuery; +class OctreeRaySceneQuery; +class OctreeSphereSceneQuery; +class OctreeAxisAlignedBoxSceneQuery; +class OctreePlaneBoundedVolumeListSceneQuery; + + +typedef std::list < WireBoundingBox * > BoxList; +typedef std::list < unsigned long > ColorList; +//typedef std::list < SceneNode * > SceneNodeList; + + +/** Specialized SceneManager that divides the geometry into an octree in order to facilitate spatial queries. +@remarks +*/ + +class _OgreOctreePluginExport OctreeSceneManager : public SceneManager +{ + friend class OctreeIntersectionSceneQuery; + friend class OctreeRaySceneQuery; + friend class OctreeSphereSceneQuery; + friend class OctreeAxisAlignedBoxSceneQuery; + friend class OctreePlaneBoundedVolumeListSceneQuery; + +public: + static int intersect_call; + /** Standard Constructor. Initializes the octree to -10000,-10000,-10000 to 10000,10000,10000 with a depth of 8. */ + OctreeSceneManager(const String& name); + /** Standard Constructor */ + OctreeSceneManager(const String& name, AxisAlignedBox &box, int max_depth ); + /** Standard destructor */ + ~OctreeSceneManager(); + + /// @copydoc SceneManager::getTypeName + const String& getTypeName(void) const; + + /** Initializes the manager to the given box and depth. + */ + void init( AxisAlignedBox &box, int d ); + + /** Creates a specialized OctreeNode */ + virtual SceneNode * createSceneNode ( void ); + /** Creates a specialized OctreeNode */ + virtual SceneNode * createSceneNode ( const String &name ); + /** Creates a specialized OctreeCamera */ + virtual Camera * createCamera( const String &name ); + + /** Deletes a scene node */ + virtual void destroySceneNode( const String &name ); + + + + /** Does nothing more */ + virtual void _updateSceneGraph( Camera * cam ); + /** Recurses through the octree determining which nodes are visible. */ + virtual void _findVisibleObjects ( Camera * cam, + VisibleObjectsBoundsInfo* visibleBounds, bool onlyShadowCasters ); + + /** Alerts each unculled object, notifying it that it will be drawn. + * Useful for doing calculations only on nodes that will be drawn, prior + * to drawing them... + */ + virtual void _alertVisibleObjects( void ); + + /** Walks through the octree, adding any visible objects to the render queue. + @remarks + If any octant in the octree if completely within the view frustum, + all subchildren are automatically added with no visibility tests. + */ + void walkOctree( OctreeCamera *, RenderQueue *, Octree *, + VisibleObjectsBoundsInfo* visibleBounds, bool foundvisible, + bool onlyShadowCasters); + + /** Checks the given OctreeNode, and determines if it needs to be moved + * to a different octant. + */ + void _updateOctreeNode( OctreeNode * ); + /** Removes the given octree node */ + void _removeOctreeNode( OctreeNode * ); + /** Adds the Octree Node, starting at the given octree, and recursing at max to the specified depth. + */ + void _addOctreeNode( OctreeNode *, Octree *octree, int depth = 0 ); + + /** Recurses the octree, adding any nodes intersecting with the box into the given list. + It ignores the exclude scene node. + */ + void findNodesIn( const AxisAlignedBox &box, std::list < SceneNode * > &list, SceneNode *exclude = 0 ); + + /** Recurses the octree, adding any nodes intersecting with the sphere into the given list. + It ignores the exclude scene node. + */ + void findNodesIn( const Sphere &sphere, std::list < SceneNode * > &list, SceneNode *exclude = 0 ); + + /** Recurses the octree, adding any nodes intersecting with the volume into the given list. + It ignores the exclude scene node. + */ + void findNodesIn( const PlaneBoundedVolume &volume, std::list < SceneNode * > &list, SceneNode *exclude=0 ); + + /** Recurses the octree, adding any nodes intersecting with the ray into the given list. + It ignores the exclude scene node. + */ + void findNodesIn( const Ray &ray, std::list < SceneNode * > &list, SceneNode *exclude=0 ); + + /** Sets the box visibility flag */ + void setShowBoxes( bool b ) + { + mShowBoxes = b; + }; + + void setLooseOctree( bool b ) + { + mLoose = b; + }; + + + /** Resizes the octree to the given size */ + void resize( const AxisAlignedBox &box ); + + /** Sets the given option for the SceneManager + @remarks + Options are: + "Size", AxisAlignedBox *; + "Depth", int *; + "ShowOctree", bool *; + */ + + virtual bool setOption( const String &, const void * ); + /** Gets the given option for the Scene Manager. + @remarks + See setOption + */ + virtual bool getOption( const String &, void * ); + + bool getOptionValues( const String & key, StringVector &refValueList ); + bool getOptionKeys( StringVector &refKeys ); + /** Overridden from SceneManager */ + void clearScene(void); + + AxisAlignedBoxSceneQuery* createAABBQuery(const AxisAlignedBox& box, unsigned long mask); + SphereSceneQuery* createSphereQuery(const Sphere& sphere, unsigned long mask); + PlaneBoundedVolumeListSceneQuery* createPlaneBoundedVolumeQuery(const PlaneBoundedVolumeList& volumes, unsigned long mask); + RaySceneQuery* createRayQuery(const Ray& ray, unsigned long mask); + IntersectionSceneQuery* createIntersectionQuery(unsigned long mask); + + +protected: + + + NodeList mVisible; + + /// The root octree + Octree *mOctree; + + /// List of boxes to be rendered + BoxList mBoxes; + + /// Number of rendered objs + int mNumObjects; + + /// Max depth for the tree + int mMaxDepth; + /// Size of the octree + AxisAlignedBox mBox; + + /// Boxes visibility flag + bool mShowBoxes; + + + bool mLoose; + + Real mCorners[ 24 ]; + static unsigned long mColors[ 8 ]; + static unsigned short mIndexes[ 24 ]; + + Matrix4 mScaleFactor; + +}; + +/// Factory for OctreeSceneManager +class OctreeSceneManagerFactory : public SceneManagerFactory +{ +protected: + void initMetaData(void) const; +public: + OctreeSceneManagerFactory() {} + ~OctreeSceneManagerFactory() {} + /// Factory type name + static const String FACTORY_TYPE_NAME; + SceneManager* createInstance(const String& instanceName); + void destroyInstance(SceneManager* instance); +}; + + + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreOctreeSceneQuery.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreOctreeSceneQuery.h new file mode 100644 index 00000000..021cfa20 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreOctreeSceneQuery.h @@ -0,0 +1,103 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright 2000-2005 The OGRE Team +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +/*************************************************************************** +OgreOctreeSceneQuery.h - description +------------------- +begin : Tues July 20, 2004 +copyright : (C) 2004 by Jon Anderson +email : janders@users.sf.net +***************************************************************************/ + +#ifndef OCTREESCENEQUERY_H +#define OCTREESCENEQUERY_H + +#include "OgreTerrainPrerequisites.h" +#include + + +namespace Ogre +{ +/** Octree implementation of IntersectionSceneQuery. */ +class _OgreOctreePluginExport OctreeIntersectionSceneQuery : public DefaultIntersectionSceneQuery +{ +public: + OctreeIntersectionSceneQuery(SceneManager* creator); + ~OctreeIntersectionSceneQuery(); + + /** See IntersectionSceneQuery. */ + void execute(IntersectionSceneQueryListener* listener); +}; + +/** Octree implementation of RaySceneQuery. */ +class _OgreOctreePluginExport OctreeRaySceneQuery : public DefaultRaySceneQuery +{ +public: + OctreeRaySceneQuery(SceneManager* creator); + ~OctreeRaySceneQuery(); + + /** See RayScenQuery. */ + void execute(RaySceneQueryListener* listener); +}; +/** Octree implementation of SphereSceneQuery. */ +class _OgreOctreePluginExport OctreeSphereSceneQuery : public DefaultSphereSceneQuery +{ +public: + OctreeSphereSceneQuery(SceneManager* creator); + ~OctreeSphereSceneQuery(); + + /** See SceneQuery. */ + void execute(SceneQueryListener* listener); +}; +/** Octree implementation of PlaneBoundedVolumeListSceneQuery. */ +class _OgreOctreePluginExport OctreePlaneBoundedVolumeListSceneQuery : public DefaultPlaneBoundedVolumeListSceneQuery +{ +public: + OctreePlaneBoundedVolumeListSceneQuery(SceneManager* creator); + ~OctreePlaneBoundedVolumeListSceneQuery(); + + /** See SceneQuery. */ + void execute(SceneQueryListener* listener); +}; +/** Octree implementation of AxisAlignedBoxSceneQuery. */ +class _OgreOctreePluginExport OctreeAxisAlignedBoxSceneQuery : public DefaultAxisAlignedBoxSceneQuery +{ +public: + OctreeAxisAlignedBoxSceneQuery(SceneManager* creator); + ~OctreeAxisAlignedBoxSceneQuery(); + + /** See RaySceneQuery. */ + void execute(SceneQueryListener* listener); +}; + + +} + +#endif + + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreParticleFXPlugin.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreParticleFXPlugin.h new file mode 100644 index 00000000..583a96f3 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreParticleFXPlugin.h @@ -0,0 +1,67 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ParticleFXPlugin_H__ +#define __ParticleFXPlugin_H__ + +#include "OgrePlugin.h" +#include "OgreParticleAffectorFactory.h" +#include "OgreParticleEmitterFactory.h" + +namespace Ogre +{ + + /** Plugin instance for ParticleFX Manager */ + class ParticleFXPlugin : public Plugin + { + public: + ParticleFXPlugin(); + + + /// @copydoc Plugin::getName + const String& getName() const; + + /// @copydoc Plugin::install + void install(); + + /// @copydoc Plugin::initialise + void initialise(); + + /// @copydoc Plugin::shutdown + void shutdown(); + + /// @copydoc Plugin::uninstall + void uninstall(); + protected: + std::vector mEmitterFactories; + std::vector mAffectorFactories; + + }; +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreParticleFXPrerequisites.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreParticleFXPrerequisites.h new file mode 100644 index 00000000..a4868ed8 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreParticleFXPrerequisites.h @@ -0,0 +1,69 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __SfxPluginPrerequisites_H__ +#define __SfxPluginPrerequisites_H__ + +#include "OgrePrerequisites.h" + +//----------------------------------------------------------------------- +// Windows Settings +//----------------------------------------------------------------------- +#if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32) && !defined(OGRE_STATIC_LIB) +# ifdef OGRE_PARTICLEFXPLUGIN_EXPORTS +# define _OgreParticleFXExport __declspec(dllexport) +# else +# if defined( __MINGW32__ ) +# define _OgreParticleFXExport +# else +# define _OgreParticleFXExport __declspec(dllimport) +# endif +# endif +#elif defined ( OGRE_GCC_VISIBILITY ) +# define _OgreParticleFXExport __attribute__ ((visibility("default"))) +#else +# define _OgreParticleFXExport +#endif + + +namespace Ogre { + + // Predeclare classes + class PointEmitter; + class PointEmitterFactory; + class LinearForceAffector; + class LinearForceAffectorFactory; + class DirectionRandomiserAffectorFactory; + class DeflectorPlaneAffectorFactory; + + + +} + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgrePointEmitter.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgrePointEmitter.h new file mode 100644 index 00000000..45bb9d3d --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgrePointEmitter.h @@ -0,0 +1,63 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __PointEmitter_H__ +#define __PointEmitter_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleEmitter.h" + +namespace Ogre { + + /** Particle emitter which emits particles from a single point. + @remarks + This basic particle emitter emits particles from a single point in space. The + initial direction of these particles can either be a single direction (i.e. a line), + a random scattering inside a cone, or a random scattering in all directions, + depending the 'angle' parameter, which is the angle across which to scatter the + particles either side of the base direction of the emitter. + */ + class _OgreParticleFXExport PointEmitter : public ParticleEmitter + { + public: + PointEmitter(ParticleSystem* psys); + + /** See ParticleEmitter. */ + void _initParticle(Particle* pParticle); + + /** See ParticleEmitter. */ + unsigned short _getEmissionCount(Real timeElapsed); + + + + + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgrePointEmitterFactory.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgrePointEmitterFactory.h new file mode 100644 index 00000000..ad20dac1 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgrePointEmitterFactory.h @@ -0,0 +1,67 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __PointEmitterFactory_H__ +#define __PointEmitterFactory_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleEmitterFactory.h" +#include "OgrePointEmitter.h" + + +namespace Ogre { + + /** Factory class for particle emitter of type "Point". + @remarks + Creates instances of PointEmitter to be used in particle systems. + */ + class _OgreParticleFXExport PointEmitterFactory : public ParticleEmitterFactory + { + protected: + + public: + /** See ParticleEmitterFactory */ + String getName() const + { + return "Point"; + } + + /** See ParticleEmitterFactory */ + ParticleEmitter* createEmitter(ParticleSystem* psys) + { + ParticleEmitter* emit = new PointEmitter(psys); + mEmitters.push_back(emit); + return emit; + } + + }; + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreQuake3Level.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreQuake3Level.h new file mode 100644 index 00000000..67917423 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreQuake3Level.h @@ -0,0 +1,168 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __Quake3Level_H__ +#define __Quake3Level_H__ + +#include "OgreBspPrerequisites.h" +#include "OgreQuake3Types.h" +#include "OgreDataStream.h" + + +namespace Ogre { + + /** Support for loading and extracting data from a Quake3 level file. + This class implements the required methods for opening Quake3 level files + and extracting the pertinent data within. Ogre supports BSP based levels + through it's own BspLevel class, which is not specific to any file format, + so this class is here to source that data from the Quake3 format.

      + Quake3 levels include far more than just data for rendering - typically the + leaves of the tree are used for rendering, and brushes, + are used to define convex hulls made of planes for collision detection. There are also + entities which define non-visual elements like player start + points, triggers etc and models which are used for movable + scenery like doors and platforms. Shaders meanwhile are textures + with extra effects and 'content flags' indicating special properties like + water or lava.

      + I will try to support as much of this as I can in Ogre, but I won't duplicate + the structure or necesarily use the same terminology. Quake3 is designed for a very specific + purpose and code structure, whereas Ogre is designed to be more flexible, + so for example I'm likely to separate game-related properties like surface flags + from the generics of materials in my implementation.

      + This is a utility class only - a single call to loadFromChunk should be + enough. You should not expect the state of this object to be consistent + between calls, since it uses pointers to memory which may no longer + be valid after the original call. This is why it has no accessor methods + for reading it's internal state. + */ + class Quake3Level + { + public: + Quake3Level(); + + /** Load just the header information from a Quake3 file. + @remarks + This method loads just the header information from the + Quake3 file, in order to estimate the loading time. + */ + void loadHeaderFromStream(DataStreamPtr& inStream); + + /** Reads Quake3 bsp data from a stream as read from the file. + Since ResourceManagers generally locate data in a variety of + places they typically manipulate them as a chunk of data, rather than + a file pointer since this is unsupported through compressed archives.

      + Quake3 files are made up of a header (which contains version info and + a table of the contents) and 17 'lumps' i.e. sections of data, + the offsets to which are kept in the table of contents. The 17 types + are predefined (You can find them in OgreQuake3Types.h) + + @param inStream Stream containing Quake3 data + */ + void loadFromStream(DataStreamPtr& inStream); + + /* Extracts the embedded lightmap texture data and loads them as textures. + Calling this method makes the lightmap texture data embedded in + the .bsp file available to the renderer. Lightmaps are extracted + and loaded as Texture objects (subclass specific to RenderSystem + subclass) and are named "@lightmap1", "@lightmap2" etc. + */ + void extractLightmaps(void) const; + + /** Utility function read the header and set up pointers. */ + void initialise(bool headerOnly = false); + /** Utility function read the header and set up counters. */ + void initialiseCounts(void); + /** Utility function read the header and set up pointers. */ + void initialisePointers(void); + + /** Utility function to return a pointer to a lump. */ + void* getLump(int lumpType); + int getLumpSize(int lumpType); + + /** Debug method. */ + void dumpContents(void); + + // Internal storage + // This is ALL temporary. Don't rely on it being static + MemoryDataStreamPtr mChunk; + + // NB no brushes, fog or local lightvolumes yet + bsp_header_t* mHeader; + unsigned char* mLumpStart; + + int* mElements; // vertex indexes for faces + int mNumElements; + + void* mEntities; + int mNumEntities; + + bsp_model_t* mModels; + int mNumModels; + + bsp_node_t* mNodes; + int mNumNodes; + + bsp_leaf_t* mLeaves; + int mNumLeaves; + + int* mLeafFaces; // Indexes to face groups by leaf + int mNumLeafFaces; + + bsp_plane_t* mPlanes; + int mNumPlanes; + + bsp_face_t* mFaces; // Groups of faces + int mNumFaces; + + bsp_vertex_t* mVertices; + int mNumVertices; + + bsp_shader_t* mShaders; + int mNumShaders; + + unsigned char* mLightmaps; + int mNumLightmaps; + + bsp_vis_t* mVis; + + bsp_brush_t* mBrushes; + int mNumBrushes; + + bsp_brushside_t* mBrushSides; + int mNumBrushSides; + + int* mLeafBrushes; // Groups of indexes to brushes by leaf + int mNumLeafBrushes; + + + + }; +} + + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreQuake3Shader.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreQuake3Shader.h new file mode 100644 index 00000000..41d8248f --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreQuake3Shader.h @@ -0,0 +1,120 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __QUAKE3SHADER_H__ +#define __QUAKE3SHADER_H__ + +#include "OgreResource.h" +#include "OgreBspPrerequisites.h" +#include "OgreQuake3Types.h" +#include "OgreCommon.h" +#include "OgreColourValue.h" +#include "OgreBlendMode.h" +#include "OgreTextureUnitState.h" + +namespace Ogre { + + + /** Class for recording Quake3 shaders. + This is a temporary holding area since shaders are actually converted into + Material objects for use in the engine proper. However, because we have to read + in shader definitions en masse (because they are stored in shared .shader files) + without knowing which will actually be used, we store their definitions here + temporarily since their instantiations as Materials would use precious resources + because of the automatic loading of textures etc. + */ + class Quake3Shader + { + protected: + String getAlternateName(const String& texName); + String mName; + + public: + + /** Default constructor - used by Quake3ShaderManager (do not call directly) */ + Quake3Shader(const String& name); + ~Quake3Shader(); + + /** Creates this shader as an OGRE material. + Creates a new material based on this shaders settings. + Material name shader#lightmap. + */ + MaterialPtr createAsMaterial(int lightmapNumber); + + struct Pass { + unsigned int flags; + String textureName; + TexGen texGen; + // Multitexture blend + LayerBlendOperation blend; + // Multipass blends (Quake3 only supports multipass?? Surely not?) + SceneBlendFactor blendSrc; + SceneBlendFactor blendDest; + bool customBlend; + CompareFunction depthFunc; + TextureUnitState::TextureAddressingMode addressMode; + // TODO - alphaFunc + GenFunc rgbGenFunc; + WaveType rgbGenWave; + Real rgbGenParams[4]; // base, amplitude, phase, frequency + Real tcModScale[2]; + Real tcModRotate; + Real tcModScroll[2]; + Real tcModTransform[6]; + bool tcModTurbOn; + Real tcModTurb[4]; + WaveType tcModStretchWave; + Real tcModStretchParams[4]; // base, amplitude, phase, frequency + CompareFunction alphaFunc; + unsigned char alphaVal; + + Real animFps; + unsigned int animNumFrames; + String frames[32]; + }; + + unsigned int flags; + int numPasses; + typedef std::vector PassList; + PassList pass; + bool farbox; // Skybox + String farboxName; + bool skyDome; + Real cloudHeight; // Skydome + DeformFunc deformFunc; + Real deformParams[5]; + ManualCullingMode cullMode; + + bool fog; + ColourValue fogColour; + Real fogDistance; + + }; +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreQuake3ShaderManager.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreQuake3ShaderManager.h new file mode 100644 index 00000000..f0b251ef --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreQuake3ShaderManager.h @@ -0,0 +1,126 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __QUAKE3SHADERMANAGER_H__ +#define __QUAKE3SHADERMANAGER_H__ + +#include "OgreBspPrerequisites.h" +#include "OgreSingleton.h" +#include "OgreResourceManager.h" +#include "OgreQuake3Shader.h" +#include "OgreBlendMode.h" + +namespace Ogre { + + + /** Class for managing Quake3 custom shaders. + Quake3 uses .shader files to define custom shaders, or Materials in Ogre-speak. + When a surface texture is mentioned in a level file, it includes no file extension + meaning that it can either be a standard texture image (+lightmap) if there is only a .jpg or .tga + file, or it may refer to a custom shader if a shader with that name is included in one of the .shader + files in the scripts/ folder. Because there are multiple shaders per file you have to parse all the + .shader files available to know if there is a custom shader available. This class is designed to parse + all the .shader files available and save their settings for future use.

      + I choose not to set up Material instances for shaders found since they may or may not be used by a level, + so it would be very wasteful to set up Materials since they load texture images for each layer (apart from the + lightmap). Once the usage of a shader is confirmed, a full Material instance can be set up from it.

      + Because this is a subclass of ScriptLoader, any files mentioned will be searched for in any path or + archive added to the ResourceGroupManager::WORLD_GROUP_NAME group. See ResourceGroupManager for details. + */ + class Quake3ShaderManager : public ScriptLoader, public Singleton + { + protected: + void parseNewShaderPass(DataStreamPtr& stream, Quake3Shader* pShader); + void parseShaderAttrib( const String& line, Quake3Shader* pShader); + void parseShaderPassAttrib( const String& line, Quake3Shader* pShader, Quake3Shader::Pass* pPass); + SceneBlendFactor convertBlendFunc( const String& q3func); + + typedef std::map Quake3ShaderMap; + Quake3ShaderMap mShaderMap; + StringVector mScriptPatterns; + + + public: + Quake3ShaderManager(); + virtual ~Quake3ShaderManager(); + + /** @copydoc ScriptLoader::getScriptPatterns */ + const StringVector& getScriptPatterns(void) const; + + /** @copydoc ScriptLoader::parseScript */ + void parseScript(DataStreamPtr& stream, const String& groupName); + + /** @copydoc ScriptLoader::parseScript */ + Real getLoadingOrder(void) const; + + /** Create implementation. */ + Quake3Shader* create(const String& name); + /** Clear all the current shaders */ + void clear(void); + /** Retrieve a Quake3Shader by name */ + Quake3Shader* getByName(const String& name); + + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static Quake3ShaderManager& getSingleton(void); + /** Override standard Singleton retrieval. + @remarks + Why do we do this? Well, it's because the Singleton + implementation is in a .h file, which means it gets compiled + into anybody who includes it. This is needed for the + Singleton template to work, but we actually only want it + compiled into the implementation of the class based on the + Singleton, not all of them. If we don't change this, we get + link errors when trying to use the Singleton-based class from + an outside dll. + @par + This method just delegates to the template version anyway, + but the implementation stays in this single compilation unit, + preventing link errors. + */ + static Quake3ShaderManager* getSingletonPtr(void); + + + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreQuake3Types.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreQuake3Types.h new file mode 100644 index 00000000..2c5afd6e --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreQuake3Types.h @@ -0,0 +1,250 @@ +// Quake 3 data definitions +// Copyright (C) 1999-2000 Id Software, Inc. +// +// This file must be identical in the quake and utils directories + +// contents flags are seperate bits +// a given brush can contribute multiple content bits + +// these definitions also need to be in q_shared.h! +#ifndef __Quake3Types_H__ +#define __Quake3Types_H__ + + +#define BSP_HEADER_ID (*(int*)"IBSP") +#define BSP_HEADER_VER (46) + +#define BSP_ENTITIES_LUMP (0) +#define BSP_SHADERS_LUMP (1) +#define BSP_PLANES_LUMP (2) +#define BSP_NODES_LUMP (3) +#define BSP_LEAVES_LUMP (4) +#define BSP_LFACES_LUMP (5) +#define BSP_LBRUSHES_LUMP (6) +#define BSP_MODELS_LUMP (7) +#define BSP_BRUSH_LUMP (8) +#define BSP_BRUSHSIDES_LUMP (9) +#define BSP_VERTICES_LUMP (10) +#define BSP_ELEMENTS_LUMP (11) +#define BSP_FOG_LUMP (12) +#define BSP_FACES_LUMP (13) +#define BSP_LIGHTMAPS_LUMP (14) +#define BSP_LIGHTVOLS_LUMP (15) +#define BSP_VISIBILITY_LUMP (16) + +#define BSP_LIGHTMAP_BANKSIZE (128*128*3) + + +#define CONTENTS_SOLID 1 // an eye is never valid in a solid +#define CONTENTS_LAVA 8 +#define CONTENTS_SLIME 16 +#define CONTENTS_WATER 32 +#define CONTENTS_FOG 64 + +#define CONTENTS_AREAPORTAL 0x8000 + +#define CONTENTS_PLAYERCLIP 0x10000 +#define CONTENTS_MONSTERCLIP 0x20000 +//bot specific contents types +#define CONTENTS_TELEPORTER 0x40000 +#define CONTENTS_JUMPPAD 0x80000 +#define CONTENTS_CLUSTERPORTAL 0x100000 +#define CONTENTS_DONOTENTER 0x200000 + +#define CONTENTS_ORIGIN 0x1000000 // removed before bsping an entity + +#define CONTENTS_BODY 0x2000000 // should never be on a brush, only in game +#define CONTENTS_CORPSE 0x4000000 +#define CONTENTS_DETAIL 0x8000000 // brushes not used for the bsp +#define CONTENTS_STRUCTURAL 0x10000000 // brushes used for the bsp +#define CONTENTS_TRANSLUCENT 0x20000000 // don't consume surface fragments inside +#define CONTENTS_TRIGGER 0x40000000 +#define CONTENTS_NODROP 0x80000000 // don't leave bodies or items (death fog, lava) + +#define SURF_NODAMAGE 0x1 // never give falling damage +#define SURF_SLICK 0x2 // effects game physics +#define SURF_SKY 0x4 // lighting from environment map +#define SURF_LADDER 0x8 +#define SURF_NOIMPACT 0x10 // don't make missile explosions +#define SURF_NOMARKS 0x20 // don't leave missile marks +#define SURF_FLESH 0x40 // make flesh sounds and effects +#define SURF_NODRAW 0x80 // don't generate a drawsurface at all +#define SURF_HINT 0x100 // make a primary bsp splitter +#define SURF_SKIP 0x200 // completely ignore, allowing non-closed brushes +#define SURF_NOLIGHTMAP 0x400 // surface doesn't need a lightmap +#define SURF_POINTLIGHT 0x800 // generate lighting info at vertexes +#define SURF_METALSTEPS 0x1000 // clanking footsteps +#define SURF_NOSTEPS 0x2000 // no footstep sounds +#define SURF_NONSOLID 0x4000 // don't collide against curves with this set +#define SURF_LIGHTFILTER 0x8000 // act as a light filter during q3map -light +#define SURF_ALPHASHADOW 0x10000 // do per-pixel light shadow casting in q3map +#define SURF_NODLIGHT 0x20000 // don't dlight even if solid (solid lava, skies) + +/* Shader flags */ +enum +{ + SHADER_NOCULL = 1 << 0, + SHADER_TRANSPARENT = 1 << 1, + SHADER_DEPTHWRITE = 1 << 2, + SHADER_SKY = 1 << 3, + SHADER_NOMIPMAPS = 1 << 4, + SHADER_NEEDCOLOURS = 1 << 5, + SHADER_DEFORMVERTS = 1 << 6 +}; + +/* Shaderpass flags */ +enum +{ + SHADER_LIGHTMAP = 1 << 0, + SHADER_BLEND = 1 << 1, + SHADER_ALPHAFUNC = 1 << 3, + SHADER_TCMOD = 1 << 4, + SHADER_ANIMMAP = 1 << 5, + SHADER_TCGEN_ENV = 1 << 6 +}; + +/* Transform functions */ +enum WaveType +{ + SHADER_FUNC_NONE = 0, + SHADER_FUNC_SIN = 1, + SHADER_FUNC_TRIANGLE = 2, + SHADER_FUNC_SQUARE = 3, + SHADER_FUNC_SAWTOOTH = 4, + SHADER_FUNC_INVERSESAWTOOTH = 5 +}; + +/* *Gen functions */ +enum GenFunc +{ + SHADER_GEN_IDENTITY = 0, + SHADER_GEN_WAVE = 1, + SHADER_GEN_VERTEX = 2 +}; + +enum TexGen +{ + TEXGEN_BASE = 0, // Coord set 0 + TEXGEN_LIGHTMAP = 1, // Coord set 1 + TEXGEN_ENVIRONMENT = 2 // Neither, generated +}; + +enum DeformFunc +{ + DEFORM_FUNC_NONE = 0, + DEFORM_FUNC_BULGE = 1, + DEFORM_FUNC_WAVE = 2, + DEFORM_FUNC_NORMAL = 3, + DEFORM_FUNC_MOVE = 4, + DEFORM_FUNC_AUTOSPRITE = 5, + DEFORM_FUNC_AUTOSPRITE2 = 6 + +}; +///////////////////////////////////////////////////////// +// +// bsp contents +// + +struct bsp_plane_t { + float normal[3]; + float dist; +}; + +struct bsp_model_t { + float bbox[6]; + int face_start; + int face_count; + int brush_start; + int brush_count; +}; + +struct bsp_node_t { + int plane; // dividing plane + //int children[2]; // left and right nodes, + // negative are leaves + int front; + int back; + int bbox[6]; +}; + +struct bsp_leaf_t { + int cluster; // visibility cluster number + int area; + int bbox[6]; + int face_start; + int face_count; + int brush_start; + int brush_count; +}; + +#define BSP_FACETYPE_NORMAL (1) +#define BSP_FACETYPE_PATCH (2) +#define BSP_FACETYPE_MESH (3) +#define BSP_FACETYPE_FLARE (4) + +struct bsp_face_t { + int shader; // shader ref + int unknown; + int type; // face type + int vert_start; + int vert_count; + int elem_start; + int elem_count; + int lm_texture; // lightmap + int lm_offset[2]; + int lm_size[2]; + float org[3]; // facetype_normal only + float bbox[6]; // facetype_patch only + float normal[3]; // facetype_normal only + int mesh_cp[2]; // patch control point dims +}; + +struct bsp_shader_t { + char name[64]; + int surface_flags; + int content_flags; +}; + +struct bsp_vertex_t { + float point[3]; + float texture[2]; + float lightmap[2]; + float normal[3]; + int color; +}; + +struct bsp_vis_t { + int cluster_count; + int row_size; + unsigned char data[1]; +}; + +// OGRE additions +struct bsp_lump_entry_t { + int offset; + int size; +}; +struct bsp_header_t { + char magic[4]; + int version; + bsp_lump_entry_t lumps[17]; +}; + +// +// Brushes sides in BSP tree +// +struct bsp_brushside_t { + int planenum; + int content; // ??shader?? +}; + + +// +// Brushes in BSP tree +// +struct bsp_brush_t { + int firstside; + int numsides; + int shaderIndex; +}; +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreRingEmitter.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreRingEmitter.h new file mode 100644 index 00000000..842aaa5c --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreRingEmitter.h @@ -0,0 +1,111 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright ) 2002 Tels based on BoxEmitter +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __RingEmitter_H__ +#define __RingEmitter_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreAreaEmitter.h" +#include "OgreMath.h" + +namespace Ogre { + + /** Particle emitter which emits particles randomly from points inside a ring (e.g. a tube). + @remarks + This particle emitter emits particles from a ring-shaped area. + The initial direction of these particles can either be a single + direction (i.e. a line), a random scattering inside a cone, or a random + scattering in all directions, depending the 'angle' parameter, which + is the angle across which to scatter the particles either side of the + base direction of the emitter. + */ + class _OgreParticleFXExport RingEmitter : public AreaEmitter + { + public: + // See AreaEmitter + /** Command object for inner size (see ParamCommand).*/ + class CmdInnerX : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + /** Command object for inner size (see ParamCommand).*/ + class CmdInnerY : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + RingEmitter(ParticleSystem* psys); + + /** See ParticleEmitter. */ + void _initParticle(Particle* pParticle); + + /** Sets the size of the clear space inside the area from where NO particles are emitted. + @param x,y,z + Parametric values describing the proportion of the shape which is hollow in each direction. + E.g. 0 is solid, 0.5 is half-hollow etc + */ + void setInnerSize(Real x, Real y); + + /** Sets the x component of the area inside the ellipsoid which doesn't emit particles. + @param x + Parametric value describing the proportion of the shape which is hollow in this direction. + E.g. 0 is solid, 0.5 is half-hollow etc + */ + void setInnerSizeX(Real x); + /** Sets the y component of the area inside the ellipsoid which doesn't emit particles. + @param y + Parametric value describing the proportion of the shape which is hollow in this direction. + E.g. 0 is solid, 0.5 is half-hollow etc + */ + void setInnerSizeY(Real y); + /** Gets the x component of the area inside the ellipsoid which doesn't emit particles. */ + Real getInnerSizeX(void) const; + /** Gets the y component of the area inside the ellipsoid which doesn't emit particles. */ + Real getInnerSizeY(void) const; + + protected: + // See ParticleEmitter + static CmdInnerX msCmdInnerX; + static CmdInnerY msCmdInnerY; + + /// Size of 'clear' center area (> 0 and < 1.0) + Real mInnerSizex; + Real mInnerSizey; + + + + }; + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreRingEmitterFactory.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreRingEmitterFactory.h new file mode 100644 index 00000000..b8e1674b --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreRingEmitterFactory.h @@ -0,0 +1,67 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright ) 2002 Tels >http://bloodgate.com> based on BoxEmitter +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __RingEmitterFactory_H__ +#define __RingEmitterFactory_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleEmitterFactory.h" +#include "OgreRingEmitter.h" + + +namespace Ogre { + + /** Factory class for particle emitter of type "Ring". + @remarks + Creates instances of RingEmitter to be used in particle systems. + */ + class _OgreParticleFXExport RingEmitterFactory : public ParticleEmitterFactory + { + protected: + + public: + /** See ParticleEmitterFactory */ + String getName() const + { + return "Ring"; + } + + /** See ParticleEmitterFactory */ + ParticleEmitter* createEmitter(ParticleSystem* psys) + { + ParticleEmitter* emit = new RingEmitter(psys); + mEmitters.push_back(emit); + return emit; + } + + }; + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreRotationAffector.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreRotationAffector.h new file mode 100644 index 00000000..fb1f7caa --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreRotationAffector.h @@ -0,0 +1,152 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __RotationAffector_H__ +#define __RotationAffector_H__ + +#include "OgreMath.h" +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleAffector.h" +#include "OgreStringInterface.h" + +namespace Ogre { + + + /** This plugin subclass of ParticleAffector allows you to alter the rotation of particles. + @remarks + This class supplies the ParticleAffector implementation required to make the particle expand + or contract in mid-flight. + */ + class _OgreParticleFXExport RotationAffector : public ParticleAffector + { + public: + /// Command object for particle emitter - see ParamCommand + class CmdRotationSpeedRangeStart : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /// Command object for particle emitter - see ParamCommand + class CmdRotationSpeedRangeEnd : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /// Command object for particle emitter - see ParamCommand + class CmdRotationRangeStart : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /// Command object for particle emitter - see ParamCommand + class CmdRotationRangeEnd : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Default constructor. */ + RotationAffector(ParticleSystem* psys); + + /** See ParticleAffector. */ + void _initParticle(Particle* pParticle); + + /** See ParticleAffector. */ + void _affectParticles(ParticleSystem* pSystem, Real timeElapsed); + + + + /** Sets the minimum rotation speed of particles to be emitted. */ + void setRotationSpeedRangeStart(const Radian& angle); +#ifndef OGRE_FORCE_ANGLE_TYPES + inline void setRotationSpeedRangeStart(Real angle) { + setRotationSpeedRangeStart(Angle(angle)); + } +#endif//OGRE_FORCE_ANGLE_TYPES + /** Sets the maximum rotation speed of particles to be emitted. */ + void setRotationSpeedRangeEnd(const Radian& angle); +#ifndef OGRE_FORCE_ANGLE_TYPES + inline void setRotationSpeedRangeEnd(Real angle) { + setRotationSpeedRangeEnd(Angle(angle)); + } +#endif//OGRE_FORCE_ANGLE_TYPES + /** Gets the minimum rotation speed of particles to be emitted. */ + const Radian& getRotationSpeedRangeStart(void) const; + /** Gets the maximum rotation speed of particles to be emitted. */ + const Radian& getRotationSpeedRangeEnd(void) const; + + + /** Sets the minimum rotation angle of particles to be emitted. */ + void setRotationRangeStart(const Radian& angle); +#ifndef OGRE_FORCE_ANGLE_TYPES + inline void setRotationRangeStart(Real angle) { + setRotationRangeStart(Angle(angle)); + } +#endif//OGRE_FORCE_ANGLE_TYPES + /** Sets the maximum rotation angle of particles to be emitted. */ + void setRotationRangeEnd(const Radian& angle); +#ifndef OGRE_FORCE_ANGLE_TYPES + inline void setRotationRangeEnd(Real angle) { + setRotationRangeEnd(Angle(angle)); + } +#endif//OGRE_FORCE_ANGLE_TYPES + /** Gets the minimum rotation of particles to be emitted. */ + const Radian& getRotationRangeStart(void) const; + /** Gets the maximum rotation of particles to be emitted. */ + const Radian& getRotationRangeEnd(void) const; + + static CmdRotationSpeedRangeStart msRotationSpeedRangeStartCmd; + static CmdRotationSpeedRangeEnd msRotationSpeedRangeEndCmd; + static CmdRotationRangeStart msRotationRangeStartCmd; + static CmdRotationRangeEnd msRotationRangeEndCmd; + + protected: + /// Initial rotation speed of particles (range start) + Radian mRotationSpeedRangeStart; + /// Initial rotation speed of particles (range end) + Radian mRotationSpeedRangeEnd; + /// Initial rotation angle of particles (range start) + Radian mRotationRangeStart; + /// Initial rotation angle of particles (range end) + Radian mRotationRangeEnd; + + }; + + +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreRotationAffectorFactory.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreRotationAffectorFactory.h new file mode 100644 index 00000000..a9dd7ab9 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreRotationAffectorFactory.h @@ -0,0 +1,57 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __RotationAffectorFactory_H__ +#define __RotationAffectorFactory_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleAffectorFactory.h" +#include "OgreRotationAffector.h" + +namespace Ogre { + + /** Factory class for RotationAffector. */ + class _OgreParticleFXExport RotationAffectorFactory : public ParticleAffectorFactory + { + /** See ParticleAffectorFactory */ + String getName() const { return "Rotator"; } + + /** See ParticleAffectorFactory */ + ParticleAffector* createAffector(ParticleSystem* psys) + { + ParticleAffector* p = new RotationAffector(psys); + mAffectors.push_back(p); + return p; + } + }; + + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreScaleAffector.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreScaleAffector.h new file mode 100644 index 00000000..079e131a --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreScaleAffector.h @@ -0,0 +1,85 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ScaleAffector_H__ +#define __ScaleAffector_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleAffector.h" +#include "OgreStringInterface.h" + +namespace Ogre { + + + /** This plugin subclass of ParticleAffector allows you to alter the scale of particles. + @remarks + This class supplies the ParticleAffector implementation required to make the particle expand + or contract in mid-flight. + */ + class _OgreParticleFXExport ScaleAffector : public ParticleAffector + { + public: + + /** Command object for scale adjust (see ParamCommand).*/ + class CmdScaleAdjust : public ParamCommand + { + public: + String doGet(const void* target) const; + void doSet(void* target, const String& val); + }; + + /** Default constructor. */ + ScaleAffector(ParticleSystem* psys); + + /** See ParticleAffector. */ + void _affectParticles(ParticleSystem* pSystem, Real timeElapsed); + + /** Sets the scale adjustment to be made per second to particles. + @param Rate + Sets the adjustment to be made to the x and y scale components per second. These + values will be added to the scale of all particles every second, scaled over each frame + for a smooth adjustment. + */ + void setAdjust( Real rate ); + + /** Gets the scale adjustment to be made per second to particles. */ + Real getAdjust(void) const; + + static CmdScaleAdjust msScaleCmd; + + protected: + Real mScaleAdj; + + }; + + +} + + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreScaleAffectorFactory.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreScaleAffectorFactory.h new file mode 100644 index 00000000..e1662719 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreScaleAffectorFactory.h @@ -0,0 +1,57 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE + (Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __ScaleAffectorFactory_H__ +#define __ScaleAffectorFactory_H__ + +#include "OgreParticleFXPrerequisites.h" +#include "OgreParticleAffectorFactory.h" +#include "OgreScaleAffector.h" + +namespace Ogre { + + /** Factory class for ScaleAffector. */ + class _OgreParticleFXExport ScaleAffectorFactory : public ParticleAffectorFactory + { + /** See ParticleAffectorFactory */ + String getName() const { return "Scaler"; } + + /** See ParticleAffectorFactory */ + ParticleAffector* createAffector(ParticleSystem* psys) + { + ParticleAffector* p = new ScaleAffector(psys); + mAffectors.push_back(p); + return p; + } + }; + + +} + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreTerrainPage.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreTerrainPage.h new file mode 100644 index 00000000..d5e02c41 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreTerrainPage.h @@ -0,0 +1,94 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +#ifndef __TerrainPage_H__ +#define __TerrainPage_H__ + +#include "OgreTerrainPrerequisites.h" +#include "OgreRenderQueue.h" + +namespace Ogre { + + /** Groups a number of TerrainRenderables (tiles) into a page, which is + the unit of loading / unloading. + @remarks + Note that this class, whilst holding onto TerrainRenderable instances, + does not actually process or initialise them itself - this is + intentional so the TerrainPageSource which is providing the tiles + is able to load and prepare each renderable incrementally if required, + thus avoiding any 'single hit' load methods for the page. + @par + All this class does do is pre-create a 2D vector of 'slots' in which + to place the TerrainRenderable pointers, which it does on + construction. Note that this structure is public to allow completely + free access to users of this class. + */ + class _OgreOctreePluginExport TerrainPage + { + public: + typedef std::vector < TerrainRenderable * > TerrainRow; + typedef std::vector < TerrainRow > Terrain2D; + + /// 2-dimensional vector of tiles, pre-allocated to the correct size + Terrain2D tiles; + /// The number of tiles across a page + unsigned short tilesPerPage; + /// The scene node to which all the tiles for this page are attached + SceneNode* pageSceneNode; + + /** The main constructor. + @param numTiles The number of terrain tiles (TerrainRenderable) + across (and down) a page + */ + TerrainPage(unsigned short numTiles); + + /** Destructor, will organise the deletion of pages + */ + virtual ~TerrainPage(); + /** After TerrainRenderables have been populated, this method + adds the neighbour links. + @remarks + Should be called before adding the page to the scene manager. + */ + void linkNeighbours(void); + + /** Returns the TerrainRenderable that contains the given pt. + If no tile exists at the point, it returns 0; + */ + TerrainRenderable * getTerrainTile( const Vector3 & pt ); + + /** Sets the render queue group which the tiles should be rendered in. */ + void setRenderQueue(uint8 qid); + + + }; + + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreTerrainPageSource.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreTerrainPageSource.h new file mode 100644 index 00000000..bfd4bb67 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreTerrainPageSource.h @@ -0,0 +1,258 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __TerrainPageSource_H__ +#define __TerrainPageSource_H__ + +#include "OgreTerrainPrerequisites.h" +#include "OgreSingleton.h" + +namespace Ogre { + + typedef std::pair TerrainPageSourceOption; + typedef std::vector TerrainPageSourceOptionList; + + /** Abstract class which classes can override to receive notifications + when a page is ready to be added to the terrain manager. + */ + class _OgreOctreePluginExport TerrainPageSourceListener + { + public: + /** Listener method called when a new page is about to be constructed. + @param manager The manager in question + @param pagex, pagez The index of the page being constructed + @param heightData Array of normalised height data (0..1). The size of + this buffer will conform to the scene manager page size. The listener + may modify the data if it wishes. + */ + virtual void pageConstructed(TerrainSceneManager* manager, size_t pagex, size_t pagez, Real* heightData) = 0; + }; + + /** Simple manager class to hold onto a list of page source listeners + across all sources. + */ + class _OgreOctreePluginExport TerrainPageSourceListenerManager : + public Singleton + { + protected: + typedef std::vector PageSourceListenerList; + PageSourceListenerList mPageSourceListeners; + public: + TerrainPageSourceListenerManager() {} + ~TerrainPageSourceListenerManager() {} + + /** Register a class which will be called back whenever a new page is + available. + @remarks + Since this method is static, it applies to any page source which + is in active use; there is no need to register one per source. + */ + void addListener(TerrainPageSourceListener* pl); + /** Unregister a class which will be called back whenever a new page is + available. + */ + void removeListener(TerrainPageSourceListener* pl); + + /// Fire pageContructed events + void firePageConstructed(TerrainSceneManager* manager, size_t pagex, size_t pagez, Real* heightData); + + /** Override standard Singleton retrieval. + */ + static TerrainPageSourceListenerManager& getSingleton(void); + /** Override standard Singleton retrieval. + */ + static TerrainPageSourceListenerManager* getSingletonPtr(void); + + }; + + + /** Abstract class which describes the interface which a source of terrain + pages must implement. + @remarks + The TerrainSceneManager can accept external classes as providers of + terrain data, to allow terrain height data to come from anywhere the + user application may choose, and additionally to support on-demand + loading an unloading of terrain data. Providers must suclass this class, + and implement the abstract methods (details are described within each method) + @par + The overall sequence of events is this: +
        +
      1. TerrainSceneManager is created as usual, and options such as tile + size etc are set.
      2. +
      3. CustomTerrainPageSource is registered with TerrainSceneManager by + calling registerPageSource(), registering a particular named type of source + data with this tile source.
      4. +
      5. TerrainSceneManager::setWorldGeometry is called. Depending on the + configuration, this will call one of the page source classes + initialise methods, when the scene manager will communicate it's + preferred options. It does not have to load anything immediately on this + call (especially if the terrain options include paging). It will + also set this tile source as the primary.
      6. +
      7. As and when TerrainSceneManager requires more tiles (and this will + either be done all up-front, or progressively depending on paging settings) + it will call the primary tile source's requestPage() method, with the + page it requires.
      8. +
      9. It is then the responsibility of the tile source to prepare + TerrainRenderable instances for the page(s) requested, and to attach them + to the TerrainSceneManager. Note that preparing the tiles does not + involve modifying any shared data so may be done in an alternate thread, + if required. Attaching them must be done synchronously though. +
      10. When paging, the TerrainSceneManager will request tiles in advance, + within it's 'buffer zone' so some delay in loading is acceptable. It + will also indicate when tiles are no longer required (and will detach + them); it is up to the tile source whether that memory is actually freed + or held for a while longer. +
      + @note The comments on paging above are in principle, the implementation of + paging in this manager is not present yet but the system is designed to + extend to it. For now, all tiles are requested up-front. + */ + class _OgreOctreePluginExport TerrainPageSource + { + protected: + /// Link back to parent manager + TerrainSceneManager* mSceneManager; + /// Has asynchronous loading been requested? + bool mAsyncLoading; + /// The expected size of the page in number of vertices + unsigned short mPageSize; + /// The expected size of a tile in number of vertices + unsigned short mTileSize; + + /// Internal method for firing pageContructed events + void firePageConstructed(size_t pagex, size_t pagez, Real* heightData); + + /** Utility method for building a page of tiles based on some source + data, wherever that may have come from. + @remarks + It is expected that this height data is represented in the range + [0..1], which will be duly scaled by the TerrainRenderables it + creates. + */ + virtual TerrainPage* buildPage(Real* heightData, const MaterialPtr& pMaterial); + + + public: + TerrainPageSource(); + virtual ~TerrainPageSource() { shutdown(); } + + /** Initialise this tile source based on a series of options as + dictated by the scene manager. + @param tsm The TerrainSceneManager doing the initialising. This should be + allowed NULL, for use by external tools if they want to read data + generically without necessarily having a real scene manager involved + @param tileSize The number of horizontal (and hence also vertical) + vertices in a single tile (which is a TerrainRenderable). This will + always be (2^n)+1. + @param pageSize The number of horizontal (and hence also vertical) + vertices in a single page. This will always be (2^n)+1. + @param asyncLoading + True if the scene manager would like the tile source to load tiles + asynchronously. It does not have to do this, although if it does not + when requested, it will likely result in stalls in the terrain rendering. + @param optionList + A list of name/value pairs describing custom options for this particular + page source. The expected convention for option names is + "TypeName.OptionName", where TypeName is the type under which this + page source has been registered. + */ + virtual void initialise(TerrainSceneManager* tsm, + ushort tileSize, ushort pageSize, bool asyncLoading, + TerrainPageSourceOptionList& optionList) + { + mSceneManager = tsm; + mTileSize = tileSize; + mPageSize = pageSize; + mAsyncLoading = asyncLoading; + } + /** Shut down this tile source, freeing all it's memory ready for + decommissioning. + @remarks + This method will normally just be called on destruction; however + it may also be called by the TerrainSceneManager if another source + is provided for the same type of tile source. + */ + virtual void shutdown(void) {} + + /** Requests a new page of tiles from the source. + @remarks + The TerrainSceneManager will call this method when it needs new tiles. + In response, this class must prepare TerrainRenderable instances for + the page requested and attach the entire page when ready using + TerrainSceneManager::attachTerrainPage. + @par + Now, the tile source does not necessarily need to do all that before the + return of this method. If it likes, and particularly if asynchronous + loading is enabled, it can merely queue this request, and process it + either in another thread, or over a series of frames. The key thing + is that attaching the new page has to be done synchronously with + the main rendering loop in order to avoid concurrency issues; + other than that, you are free to load and prepare new tiles in + a concurrent fashion if you like. + @par + Typically the scene manager will request at least one page up-front, + with the possibility of requesting more if paging is enabled. + @param x The x index of the page requested + @param z The z index of the page requested + */ + virtual void requestPage(ushort x, ushort z) = 0; + /** This notifies the tile source that the specified page of tiles + has been automatically detached. + @remarks + When paging is enabled, tiles go out of scope and the TerrainSceneManager + detaches them automatically, notifying the TerrainPageSource that + this has happened. The tile source can choose to either keep these + tiles in memory (incase they are requested again) or can delete them + if it wishes to free memory. This freeing does not need to be done + before the return of this method - like requesting tiles, the + freeing of them can be done in another thread or across many frames + if required, since the shared data in TerrainSceneManager has already + been updated synchronously when the page was detached. + @param x The x index of the page expired + @param z The z index of the page expired + */ + virtual void expirePage(ushort x, ushort z) = 0; + + /** Register a class which will be called back whenever a new page is + available. + @remarks + Since this method is static, it applies to any page source which + is in active use; there is no need to register one per source. + */ + static void addListener(TerrainPageSourceListener* pl); + /** Unregister a class which will be called back whenever a new page is + available. + */ + static void removeListener(TerrainPageSourceListener* pl); + + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreTerrainPrerequisites.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreTerrainPrerequisites.h new file mode 100644 index 00000000..267c329d --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreTerrainPrerequisites.h @@ -0,0 +1,67 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __TerrainPrerequisites_H__ +#define __TerrainPrerequisites_H__ + +#include "OgrePrerequisites.h" + +//----------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------- + +namespace Ogre +{ + class TerrainSceneManager; + class TerrainPageSource; + class TerrainRenderable; + class TerrainPage; +} +//----------------------------------------------------------------------- +// Windows Settings +//----------------------------------------------------------------------- + +#if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32 ) && !defined(OGRE_STATIC_LIB) +# ifdef OGRE_TERRAINPLUGIN_EXPORTS +# define _OgreOctreePluginExport __declspec(dllexport) +# else +# if defined( __MINGW32__ ) +# define _OgreOctreePluginExport +# else +# define _OgreOctreePluginExport __declspec(dllimport) +# endif +# endif +#elif defined ( OGRE_GCC_VISIBILITY ) +# define _OgreOctreePluginExport __attribute__ ((visibility("default"))) +#else +# define _OgreOctreePluginExport +#endif + +#endif + diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreTerrainRenderable.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreTerrainRenderable.h new file mode 100644 index 00000000..1c60d6db --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreTerrainRenderable.h @@ -0,0 +1,415 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +/*************************************************************************** +terrainrenderable.h - description +------------------- +begin : Sat Oct 5 2002 +copyright : (C) 2002 by Jon Anderson +email : janders@users.sf.net + +Enhancements 2003 - 2004 (C) The OGRE Team + +***************************************************************************/ + +#ifndef TERRAINRENDERABLE_H +#define TERRAINRENDERABLE_H + +#include "OgreTerrainPrerequisites.h" +#include +#include +#include +#include +#include + +#include + +#define MORPH_CUSTOM_PARAM_ID 77 + +namespace Ogre +{ + + typedef std::map IndexMap; + typedef std::vector < IndexData* > IndexArray; + typedef std::vector < IndexMap* > LevelArray; + + /** + * A cache of TerrainIndexBuffers. Used to keep track of the buffers, and + * delete them when the program finishes. + */ + class TerrainBufferCache + { + public: + void shutdown(void) + { + for( size_t i=0; i y ) ? x : y; + } + + /** A simple class for encapsulating parameters which are commonly needed by + both TerrainSceneManager and TerrainRenderable. + */ + class TerrainOptions + { + public: + TerrainOptions() + { + pageSize = 0; + tileSize = 0; + tilesPerPage = 0; + maxGeoMipMapLevel = 0; + scale = Vector3::UNIT_SCALE; + maxPixelError = 4; + detailTile = 1; + lit = false; + coloured = false; + lodMorph = false; + lodMorphStart = 0.5; + useTriStrips = false; + primaryCamera = 0; + terrainMaterial.setNull(); + }; + /// The size of one edge of a terrain page, in vertices + size_t pageSize; + /// The size of one edge of a terrain tile, in vertices + size_t tileSize; + /// Precalculated number of tiles per page + size_t tilesPerPage; + /// The primary camera, used for error metric calculation and page choice + const Camera* primaryCamera; + /// The maximum terrain geo-mipmap level + size_t maxGeoMipMapLevel; + /// The scale factor to apply to the terrain (each vertex is 1 unscaled unit + /// away from the next, and height is from 0 to 1) + Vector3 scale; + /// The maximum pixel error allowed + size_t maxPixelError; + /// Whether we should use triangle strips + bool useTriStrips; + /// The number of times to repeat a detail texture over a tile + size_t detailTile; + /// Whether LOD morphing is enabled + bool lodMorph; + /// At what point (parametric) should LOD morphing start + Real lodMorphStart; + /// Whether dynamic lighting is enabled + bool lit; + /// Whether vertex colours are enabled + bool coloured; + /// Pointer to the material to use to render the terrain + MaterialPtr terrainMaterial; + + }; + +#define STITCH_NORTH_SHIFT 0 +#define STITCH_SOUTH_SHIFT 8 +#define STITCH_WEST_SHIFT 16 +#define STITCH_EAST_SHIFT 24 + +#define STITCH_NORTH 128 << STITCH_NORTH_SHIFT +#define STITCH_SOUTH 128 << STITCH_SOUTH_SHIFT +#define STITCH_WEST 128 << STITCH_WEST_SHIFT +#define STITCH_EAST 128 << STITCH_EAST_SHIFT + + /** + Represents a terrain tile. + @remarks + A TerrainRenderable represents a tile used to render a block of terrain using the geomipmap approach + for LOD. + *@author Jon Anderson + */ + + class _OgreOctreePluginExport TerrainRenderable : public Renderable, public MovableObject + { + public: + + TerrainRenderable(const String& name, TerrainSceneManager* tsm); + ~TerrainRenderable(); + + void deleteGeometry(); + + enum Neighbor + { + NORTH = 0, + SOUTH = 1, + EAST = 2, + WEST = 3, + HERE = 4 + }; + + /** Initializes the TerrainRenderable. + @param startx, startz + The starting points of the top-left of this tile, in terms of the + number of vertices. + @param pageHeightData The source height data for the entire parent page + */ + void initialise(int startx, int startz, Real* pageHeightData); + + //movable object methods + + /** Returns the type of the movable. */ + virtual const String& getMovableType( void ) const + { + return mType; + }; + + /** Returns the bounding box of this TerrainRenderable */ + const AxisAlignedBox& getBoundingBox( void ) const + { + return mBounds; + }; + + /** Updates the level of detail to be used for rendering this TerrainRenderable based on the passed in Camera */ + virtual void _notifyCurrentCamera( Camera* cam ); + + virtual void _updateRenderQueue( RenderQueue* queue ); + + /** + Constructs a RenderOperation to render the TerrainRenderable. + @remarks + Each TerrainRenderable has a block of vertices that represent the terrain. Index arrays are dynamically + created for mipmap level, and then cached. + */ + virtual void getRenderOperation( RenderOperation& rend ); + + virtual const MaterialPtr& getMaterial( void ) const + { + return mMaterial; + }; + + virtual void getWorldTransforms( Matrix4* xform ) const; + + virtual const Quaternion& getWorldOrientation(void) const; + virtual const Vector3& getWorldPosition(void) const; + + /** Returns the mipmap level that will be rendered for this frame */ + inline int getRenderLevel() const + { + return mRenderLevel; + }; + + /** Forces the LOD to the given level from this point on */ + inline void setForcedRenderLevel( int i ) + { + mForcedRenderLevel = i; + } + + /** Calculates the normal at the given location */ + void _getNormalAt( float x, float y, Vector3 * result ); + + /** Returns the terrain height at the given coordinates */ + float getHeightAt( float x, float y ); + + /** Intersects the segment witht he terrain tile + */ + bool intersectSegment( const Vector3 & start, const Vector3 & end, Vector3 * result ); + + /** Sets the appropriate neighbor for this TerrainRenderable. Neighbors are necessary + to know when to bridge between LODs. + */ + void _setNeighbor( Neighbor n, TerrainRenderable *t ) + { + mNeighbors[ n ] = t; + }; + + /** Returns the neighbor TerrainRenderable + */ + TerrainRenderable * _getNeighbor( Neighbor n ) + { + return mNeighbors[ n ]; + } + + + void setMaterial(const MaterialPtr& m ) + { + mMaterial = m; + }; + + /** Calculates static normals for lighting the terrain */ + void _calculateNormals(); + + + + + /** Generates terrain shadows and lighting using vertex colors + */ + void _generateVertexLighting( const Vector3 &sunlight, ColourValue ambient ); + + + /** Overridden, see Renderable */ + Real getSquaredViewDepth(const Camera* cam) const; + + /** Overridden from MovableObject */ + Real getBoundingRadius(void) const { return mBoundingRadius; } + + /** @copydoc Renderable::getLights */ + const LightList& getLights(void) const; + + /// Overridden from Renderable to allow the morph LOD entry to be set + void _updateCustomGpuParameter( + const GpuProgramParameters::AutoConstantEntry& constantEntry, + GpuProgramParameters* params) const; + /// @see MovableObject + uint32 getTypeFlags(void) const; + protected: + /// Parent SceneManager + TerrainSceneManager* mSceneManager; + /// Link to shared options + const TerrainOptions* mOptions; + + /** Returns the index into the height array for the given coords. */ + inline size_t _index( int x, int z ) const + { + return ( x + z * mOptions->tileSize ); + }; + + /** Returns the vertex coord for the given coordinates */ + inline float _vertex( int x, int z, int n ) + { + return mPositionBuffer[x * 3 + z * mOptions->tileSize * 3 + n]; + }; + + + inline int _numNeighbors() const + { + int n = 0; + + for ( int i = 0; i < 4; i++ ) + { + if ( mNeighbors[ i ] != 0 ) + n++; + } + + return n; + } + + inline bool _hasNeighborRenderLevel( int i ) const + { + for ( int j = 0; j < 4; j++ ) + { + if ( mNeighbors[ j ] != 0 && mNeighbors[ j ] ->mRenderLevel == i ) + return true; + } + + return false; + + } + + void _adjustRenderLevel( int i ); + + bool _checkSize( int n ); + + void _calculateMinLevelDist2( Real C ); + + Real _calculateCFactor(); + + VertexData* mTerrain; + + /// The current LOD level + int mRenderLevel; + /// The previous 'next' LOD level down, for frame coherency + int mLastNextLevel; + /// The morph factor between this and the next LOD level down + Real mLODMorphFactor; + /// List of squared distances at which LODs change + Real *mMinLevelDistSqr; + /// Connection to tiles four neighbours + TerrainRenderable *mNeighbors [ 4 ]; + /// Whether light list need to re-calculate + mutable bool mLightListDirty; + /// Cached light list + mutable LightList mLightList; + /// The bounding radius of this tile + Real mBoundingRadius; + /// Bounding box of this tile + AxisAlignedBox mBounds; + /// The center point of this tile + Vector3 mCenter; + /// The MovableObject type + static String mType; + /// Current material used by this tile + MaterialPtr mMaterial; + /// Whether this tile has been initialised + bool mInit; + /// The buffer with all the renderable geometry in it + HardwareVertexBufferSharedPtr mMainBuffer; + /// Optional set of delta buffers, used to morph from one LOD to the next + HardwareVertexBufferSharedPtr* mDeltaBuffers; + /// System-memory buffer with just positions in it, for CPU operations + float* mPositionBuffer; + /// Forced rendering LOD level, optional + int mForcedRenderLevel; + /// Array of LOD indexes specifying which LOD is the next one down + /// (deals with clustered error metrics which cause LODs to be skipped) + int mNextLevelDown[10]; + /// Gets the index data for this tile based on current settings + IndexData* getIndexData(void); + /// Internal method for generating stripified terrain indexes + IndexData* generateTriStripIndexes(unsigned int stitchFlags); + /// Internal method for generating triangle list terrain indexes + IndexData* generateTriListIndexes(unsigned int stitchFlags); + /** Utility method to generate stitching indexes on the edge of a tile + @param neighbor The neighbor direction to stitch + @param hiLOD The LOD of this tile + @param loLOD The LOD of the neighbor + @param omitFirstTri Whether the first tri of the stitch (always clockwise + relative to the centre of this tile) is to be omitted because an + adjoining edge is also being stitched + @param omitLastTri Whether the last tri of the stitch (always clockwise + relative to the centre of this tile) is to be omitted because an + adjoining edge is also being stitched + @param pIdx Pointer to a pointer to the index buffer to push the results + into (this pointer will be updated) + @returns The number of indexes added + */ + int stitchEdge(Neighbor neighbor, int hiLOD, int loLOD, + bool omitFirstTri, bool omitLastTri, unsigned short** ppIdx); + + /// Create a blank delta buffer for usein morphing + HardwareVertexBufferSharedPtr createDeltaBuffer(void); + + }; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreTerrainSceneManager.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreTerrainSceneManager.h new file mode 100644 index 00000000..505d9993 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreTerrainSceneManager.h @@ -0,0 +1,435 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ +/*************************************************************************** +terrainscenemanager.h - description +--------------------- + begin : Mon Sep 23 2002 + copyright : (C) 2002 by Jon Anderson + email : janders@users.sf.net + + Enhancements 2003 - 2004 (C) The OGRE Team + +***************************************************************************/ + +#ifndef TERRAINSCENEMANAGER_H +#define TERRAINSCENEMANAGER_H + +#include "OgreTerrainPrerequisites.h" +#include "OgreOctreeSceneManager.h" +#include "OgreOctreeSceneQuery.h" +#include "OgreTerrainRenderable.h" +#include "OgreTerrainPageSource.h" +#include "OgreIteratorWrappers.h" + + +namespace Ogre +{ + +class Image; + +typedef std::vector < TerrainPage * > TerrainPageRow; +typedef std::vector < TerrainPageRow > TerrainPage2D; + +/** Default implementation of RaySceneQuery. */ +class _OgreOctreePluginExport TerrainRaySceneQuery : public OctreeRaySceneQuery +{ +protected: + WorldFragment mWorldFrag; +public: + TerrainRaySceneQuery(SceneManager* creator); + ~TerrainRaySceneQuery(); + + /** See RayScenQuery. */ + void execute(RaySceneQueryListener* listener); +}; + + + +/** This is a basic SceneManager for organizing TerrainRenderables into a total landscape. + * It loads a terrain from a .cfg file that specifices what textures/scale/mipmaps/etc to use. + *@author Jon Anderson + */ + +class _OgreOctreePluginExport TerrainSceneManager : public OctreeSceneManager +{ +public: + TerrainSceneManager(const String& name); + virtual ~TerrainSceneManager( ); + + /// @copydoc SceneManager::getTypeName + const String& getTypeName(void) const; + + /** Loads the terrain using parameters int he given config file. */ + void setWorldGeometry( const String& filename ); + /** Loads the terrain using parameters in the given config file (contained + in a stream). */ + virtual void setWorldGeometry(DataStreamPtr& stream, + const String& typeName = StringUtil::BLANK); + + /** Aligns TerrainRenderable neighbors, and renders them. */ + virtual void _renderVisibleObjects( void ); + + /** Returns the height at the given terrain coordinates. */ + float getHeightAt( float x, float y ); + + + bool intersectSegment( const Vector3 & start, const Vector3 & end, Vector3 * result ); + + /** Sets the texture to use for the main world texture. */ + void setWorldTexture(const String& textureName); + /** Sets the texture to use for the detail texture. */ + void setDetailTexture(const String& textureName); + /** Sets the number of times per tile the detail texture should be repeated. */ + void setDetailTextureRepeat(int repeat); + /** Sets the dimensions of each tile (must be power of 2 + 1) */ + void setTileSize(int size); + /** Sets the dimensions of each page (must be power of 2 + 1) */ + void setPageSize(int size); + /** Sets the maximum screen space pixel error. */ + void setMaxPixelError(int pixelError); + /** Sets how to scale the terrain data. */ + void setScale(const Vector3& scale); + /** Sets the maximum geomipmap level to allow. */ + void setMaxGeoMipMapLevel(int maxMip); + + /** Gets the texture to use for the main world texture. */ + const String& getWorldTexture(void) { return mWorldTextureName; } + /** Gets the texture to use for the detail texture. */ + const String& getDetailTexture(void) { return mDetailTextureName; } + /** Gets the number of times per tile the detail texture should be repeated. */ + int getDetailTextureRepeat(void); + /** Gets the dimensions of each tile (must be power of 2 + 1) */ + int getTileSize(void); + /** Gets the dimensions of each page (must be power of 2 + 1) */ + int getPageSize(void); + /** Gets the maximum screen space pixel error. */ + int getMaxPixelError(void); + /** Gets how to scale the terrain data. */ + const Vector3& getScale(void); + /** Gets the maximum geomipmap level to allow. */ + int getMaxGeoMipMapLevel(void); + + + + /** Sets whether the terrain should use triangle strips or not. + @remarks + The default is not, in which case it uses triangle lists. + */ + void setUseTriStrips(bool useStrips); + /** Sets whether or not terrain tiles should be morphed between LODs + (NB requires vertex program support). */ + void setUseLODMorph(bool useMorph); + /** Sets whether vertex normals will be generated for the terrain. */ + void setUseVertexNormals(bool useNormals); + /** Sets whether vertex colours will be used. */ + void setUseVertexColours(bool useColours); + + /** Sets the name of a custom material to use to shade the landcape. + @remarks + This method allows you to provide a custom material which will be + used to render the landscape instead of the standard internal + material. This gives you a great deal of flexibility and allows you + to perform special effects if you wish. Note that because you determine + every aspect of the material, this setting makes the use of setWorldTexture + and setDetailTexture redundant. + @par + In your custom material, you can use all the usual features of Ogre's + materials, including multiple passes if you wish. You can also use + the programmable pipeline to hook vertex and fragment programs into the + terrain rendering. The plugin provides the following vertex components: +
        +
      • positions
      • +
      • 2 sets of texture coordinates (index 0 is world texture, + index 1 is detail texture)
      • +
      • Normals, if enabled
      • +
      • Per-vertex delta values, for morphing a higher LOD tile into + a lower LOD tile. This is one float per vertex bound as 'blend + weight'. If you want to use this you also have to provide the + name or index of the parameter you wish to receive the morph factor + (@see setCustomMaterialMorphFactorParam)
      • +
      + */ + void setCustomMaterial(const String& materialName); + /** Sets the name of the vertex program parameter to which to pass the + LOD morph factor. + @remarks + When LOD morphing is enabled, and you are using a custom material to + shade the terrain, you need to inform this class of the parameter you + wish the current LOD morph factor to be passed to. This is a simple + float parameter value that the plugin will set from 0 to 1, depending on + the morph stage of a tile. 0 represents no morphing, ie the vertices are + all in the original position. 1 represents a complete morph such that + the height of the vertices is the same as they are at the next lower LOD + level. The vertex program must use this factor, in conjunction with the + per-vertex height delta values (bound as 'blend weight'), to displace + vertices. + @note This version of the method lets you specify a parameter name, compatible + with high-level vertex programs. There is an alternative signature method + which allows you to set the parameter index for low-level assembler programs. + @param paramName The name of the parameter which will receive the morph factor + */ + void setCustomMaterialMorphFactorParam(const String& paramName); + /** Sets the index of the vertex program parameter to which to pass the + LOD morph factor. + @remarks + When LOD morphing is enabled, and you are using a custom material to + shade the terrain, you need to inform this class of the parameter you + wish the current LOD morph factor to be passed to. This is a simple + float parameter value that the plugin will set from 0 to 1, depending on + the morph stage of a tile. 0 represents no morphing, ie the vertices are + all in the original position. 1 represents a complete morph such that + the height of the vertices is the same as they are at the next lower LOD + level. The vertex program must use this factor, in conjunction with the + per-vertex height delta values (bound as 'blend weight'), to displace + vertices. + @note This version of the method lets you specify a parameter index, compatible + with low-level assembler vertex programs. There is an alternative signature method + which allows you to set the parameter name for high-level programs. + @param paramName The name of the parameter which will receive the morph factor + */ + void setCustomMaterialMorphFactorParam(size_t paramIndex); + /** Sets the distance at which the LOD will start to morph downwards, as + a proportion of the distance between the LODs. */ + void setLODMorphStart(Real morphStart); + + /** Returns the TerrainRenderable that contains the given pt. + If no tile exists at the point, it returns 0; + */ + virtual TerrainRenderable * getTerrainTile( const Vector3 & pt ); + + /** Returns the TerrainPage that contains the given pt. + If no page exists at the point, it returns 0; + */ + virtual TerrainPage* getTerrainPage( const Vector3 & pt ); + + /** Creates a RaySceneQuery for this scene manager. + @remarks + This method creates a new instance of a query object for this scene manager, + looking for objects which fall along a ray. See SceneQuery and RaySceneQuery + for full details. + @par + The instance returned from this method must be destroyed by calling + SceneManager::destroyQuery when it is no longer required. + @param ray Details of the ray which describes the region for this query. + @param mask The query mask to apply to this query; can be used to filter out + certain objects; see SceneQuery for details. + */ + RaySceneQuery* + createRayQuery(const Ray& ray, unsigned long mask = 0xFFFFFFFF); + + /** Overridden in order to store the first camera created as the primary + one, for determining error metrics and the 'home' terrain page. + */ + Camera* createCamera( const String &name ); + /// Gets the terrain options + const TerrainOptions& getOptions(void) { return mOptions; } + + /** Sets the given option for the SceneManager. + @remarks + Options are (in addition to those supported by superclasses): + "PageSize", int*; + "TileSize", int*; + "PrimaryCamera, Camera*; + "MaxMipMapLevel", int*; + "Scale", Vector3 *; + "MaxPixelError", int*; + "UseTriStrips", bool*; + "VertexProgramMorph", bool*; + "DetailTile", int*; + "LodMorphStart", Real*; + "VertexNormals", bool*; + "VertexColours", bool*; + "MorphLODFactorParamName", String*; + "MorphLODFactorParamIndex", size_t*; + "CustomMaterialName", String*; + "WorldTexture", String*; + "DetailTexture", String*; + */ + virtual bool setOption( const String &, const void * ); + + /** Sets the 'primary' camera, i.e. the one which will be used to determine + the 'home' terrain page, and to calculate the error metrics. + */ + virtual void setPrimaryCamera(const Camera* cam); + /// Internal map of page source name to page source + typedef std::map PageSourceMap; + + /// Iterator over all page sources + typedef ConstMapIterator PageSourceIterator; + /// Get an iterator over all page sources + PageSourceIterator getPageSourceIterator(void); + /** Registers a TerrainPageSource class and associates it with a named type + of source. + @remarks + This function allows external classes to register themselves as providers + of terrain pages of a particular type. Only one page source can be + active at once, and the active one is selected by calling + selectPageSource(typeName), which is part of plugin configuration. + @note The terrain engine comes with a default page source which loads + greyscale heightmap images, registered under the type name "Heightmap". + @param typeName A unique String to associate with this type of source + @param source Pointer to the class which will implement this source. + */ + virtual void registerPageSource(const String& typeName, TerrainPageSource* source); + /** Selects a given page source based on its type name. + @remarks + This method activates a single page source based on its typename, + e.g. "Heightmap". It also passes to it a number of custom options + which the source is able to interpret however it likes. + @param typeName The type name of the page source to activate + @param optionList A list of string parameters, which are expected to begin + with 'typeName.' (e.g. "Heightmap.image"), with their appropriate + values. + */ + virtual void selectPageSource(const String& typeName, + TerrainPageSourceOptionList& optionList); + + /** Attaches a previously built page to the list of available pages. + @remarks + TerrainPageSource subclasses will call this method once they have + pages available to be added to the working set. Note that whilst you + can build TerrainPage instances in another thread if you like, this + method must be called in the same thread as the main rendering loop + in order to avoid concurrency issues. + @param pageX, pageZ The page index at which to attach the page + @param page The page to attach + */ + virtual void attachPage(ushort pageX, ushort pageZ, TerrainPage* page); + /// Get a pointer to the material being used for the terrain + MaterialPtr& getTerrainMaterial(void); + // Overridden from basic scene manager + void _renderScene(Camera *cam, Viewport *vp, bool includeOverlays); + + /// Get the SceneNode under which all terrain nodes are attached. + SceneNode* getTerrainRootNode(void) const { return mTerrainRoot; } + /** Overridden from SceneManager */ + void clearScene(void); + /** Overridden from SceneManager */ + void setWorldGeometryRenderQueue(uint8 qid); + + /// Get the shared list of indexes cached (internal use only) + TerrainBufferCache& _getIndexCache(void) {return mIndexCache;} + + /// Get the shared level index list (internal use only) + LevelArray& _getLevelIndex(void) { return mLevelIndex; } + + /// Get the current page count (internal use only) + size_t _getPageCount(void) { return mTerrainPages.size(); } + + /// Shutdown cleanly before we get destroyed + void shutdown(void); + + +protected: + + /// Validates that the size picked for the terrain is acceptable + bool _checkSize( int s ) + { + for ( int i = 0; i < 16; i++ ) + { + printf( "Checking...%d\n", ( 1 << i ) + 1 ); + + if ( s == ( 1 << i ) + 1 ) + return true; + } + + return false; + + } + + /// The node to which all terrain tiles are attached + SceneNode * mTerrainRoot; + /// Terrain size, detail etc + TerrainOptions mOptions; + /// Should we use an externally-defined custom material? + bool mUseCustomMaterial; + /// The name of the custom material to use + String mCustomMaterialName; + /// The name of the world texture + String mWorldTextureName; + /// The name of the detail texture + String mDetailTextureName; + /// Are we using a named parameter to hook up LOD morph? + bool mUseNamedParameterLodMorph; + /// The name of the parameter to send the LOD morph to + String mLodMorphParamName; + /// The index of the parameter to send the LOD morph to + size_t mLodMorphParamIndex; + /// Whether paging is enabled, or whether a single page will be used + bool mPagingEnabled; + /// The number of pages to render outside the 'home' page + unsigned short mLivePageMargin; + /// The number of pages to keep loaded outside the 'home' page + unsigned short mBufferedPageMargin; + /// Grid of buffered pages + TerrainPage2D mTerrainPages; + //-- attributes to share across tiles + /// Shared list of index buffers + TerrainBufferCache mIndexCache; + /// Shared array of IndexData (reuse indexes across tiles) + LevelArray mLevelIndex; + + /// Internal method for loading configurations settings + void loadConfig(DataStreamPtr& stream); + + /// Sets up the terrain material + void setupTerrainMaterial(void); + /// Sets up the terrain page slots + void setupTerrainPages(void); + /// Initialise level indexes + void initLevelIndexes(void); + /// Destroy level indexes + void destroyLevelIndexes(void); + + + /// Map of source type -> TerrainPageSource + PageSourceMap mPageSources; + /// The currently active page source + TerrainPageSource* mActivePageSource; + +}; +/// Factory for TerrainSceneManager +class TerrainSceneManagerFactory : public SceneManagerFactory +{ +protected: + typedef std::vector TerrainPageSources; + TerrainPageSources mTerrainPageSources; + void initMetaData(void) const; +public: + TerrainSceneManagerFactory(); + ~TerrainSceneManagerFactory(); + /// Factory type name + static const String FACTORY_TYPE_NAME; + SceneManager* createInstance(const String& instanceName); + void destroyInstance(SceneManager* instance); +}; + +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/opt/OgreTerrainVertexProgram.h b/school/informatik/verkerhssimulation/src/ogre/opt/OgreTerrainVertexProgram.h new file mode 100644 index 00000000..3d7bc703 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/opt/OgreTerrainVertexProgram.h @@ -0,0 +1,226 @@ +/* +----------------------------------------------------------------------------- +This source file is part of OGRE +(Object-oriented Graphics Rendering Engine) +For the latest info, see http://www.ogre3d.org/ + +Copyright (c) 2000-2006 Torus Knot Software Ltd +Also see acknowledgements in Readme.html + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. + +You may alternatively use this source under the terms of a specific version of +the OGRE Unrestricted License provided you have obtained such a license from +Torus Knot Software Ltd. +----------------------------------------------------------------------------- +*/ + +#ifndef __TERRAINVERTEXPROGRAM_H__ +#define __TERRAINVERTEXPROGRAM_H__ + +#include "OgrePrerequisites.h" +#include "OgreCommon.h" +#include "OgreString.h" + +namespace Ogre { + + /* + Static class containing the source to vertex programs used to + morph the terrain LOD levels. The programs are generated from + the following Cg: + @code + // No fog morphing terrain + void terrain_vp( + float4 position : POSITION, + float2 uv1 : TEXCOORD0, + float2 uv2 : TEXCOORD1, + float delta : BLENDWEIGHT, + + out float4 oPosition : POSITION, + out float2 oUv1 : TEXCOORD0, + out float2 oUv2 : TEXCOORD1, + out float4 colour : COLOR, + uniform float4x4 worldViewProj, + uniform float morphFactor + ) + { + // Apply morph + position.y = position.y + (delta.x * morphFactor); + // world / view / projection + oPosition = mul(worldViewProj, position); + // Main texture coords + oUv1 = uv1; + // Detail texture coords + oUv2 = uv2; + // Full bright (no lighting) + colour = float4(1,1,1,1); + } + + + // Linear fogged morphing terrain + void terrain_vp_linear( + float4 position : POSITION, + float2 uv1 : TEXCOORD0, + float2 uv2 : TEXCOORD1, + float delta : BLENDWEIGHT, + + out float4 oPosition : POSITION, + out float2 oUv1 : TEXCOORD0, + out float2 oUv2 : TEXCOORD1, + out float4 colour : COLOR, + out float fog : FOG, + uniform float4x4 worldViewProj, + uniform float morphFactor + ) + { + // Apply morph + position.y = position.y + (delta.x * morphFactor); + // world / view / projection + oPosition = mul(worldViewProj, position); + // Main texture coords + oUv1 = uv1; + // Detail texture coords + oUv2 = uv2; + // Full bright (no lighting) + colour = float4(1,1,1,1); + // Fog + // f = end - camz / end - start + // when start / end has been set, fog value is distance + fog = oPosition.z; + } + + + // Exp fogged morphing terrain + void terrain_vp_exp( + float4 position : POSITION, + float2 uv1 : TEXCOORD0, + float2 uv2 : TEXCOORD1, + float delta : BLENDWEIGHT, + + out float4 oPosition : POSITION, + out float2 oUv1 : TEXCOORD0, + out float2 oUv2 : TEXCOORD1, + out float4 colour : COLOR, + out float fog : FOG, + uniform float4x4 worldViewProj, + uniform float morphFactor, + uniform float fogDensity) + { + // Apply morph + position.y = position.y + (delta.x * morphFactor); + // world / view / projection + oPosition = mul(worldViewProj, position); + // Main texture coords + oUv1 = uv1; + // Detail texture coords + oUv2 = uv2; + // Full bright (no lighting) + colour = float4(1,1,1,1); + // Fog + // f = 1 / e ^ (camz x density) + // note pow = exp(src1 * log(src0)). + fog = 1 / (exp((oPosition.z * fogDensity) * log(2.718281828))); + } + + + // Exp2 fogged morphing terrain + void terrain_vp_exp2( + float4 position : POSITION, + float2 uv1 : TEXCOORD0, + float2 uv2 : TEXCOORD1, + float delta : BLENDWEIGHT, + + out float4 oPosition : POSITION, + out float2 oUv1 : TEXCOORD0, + out float2 oUv2 : TEXCOORD1, + out float4 colour : COLOR, + out float fog : FOG, + uniform float4x4 worldViewProj, + uniform float morphFactor, + uniform float fogDensity) + { + // Apply morph + position.y = position.y + (delta.x * morphFactor); + // world / view / projection + oPosition = mul(worldViewProj, position); + // Main texture coords + oUv1 = uv1; + // Detail texture coords + oUv2 = uv2; + // Full bright (no lighting) + colour = float4(1,1,1,1); + // Fog + // f = 1 / e ^ (camz x density)^2 + // note pow = exp(src1 * log(src0)). + float src1 = oPosition.z * 0.002; + fog = 1 / (exp((src1*src1) * log(2.718281828f))); + } + + // Shadow receiver vertex program + void terrain_shadow_receiver_vp( + float4 position : POSITION, + float2 uv1 : TEXCOORD0, + float2 uv2 : TEXCOORD1, + float delta : BLENDWEIGHT, + + out float4 oPosition : POSITION, + out float2 oUv1 : TEXCOORD0, + out float4 colour : COLOR, + uniform float4x4 worldViewProj, + uniform float4x4 world, + uniform float4x4 textureViewProj, + uniform float morphFactor + ) + { + // Apply morph + position.y = position.y + (delta.x * morphFactor); + // world / view / projection + oPosition = mul(worldViewProj, position); + + // Main texture coords + float4 worldpos = mul(world, position); + float4 projuv = mul(textureViewProj, worldpos); + oUv1.xy = projuv.xy / projuv.w; + // Full bright (no lighting) + colour = float4(1,1,1,1); + } + + @endcode + */ + class TerrainVertexProgram + { + private: + static String mNoFogArbvp1; + static String mLinearFogArbvp1; + static String mExpFogArbvp1; + static String mExp2FogArbvp1; + static String mShadowReceiverArbvp1; + + static String mNoFogVs_1_1; + static String mLinearFogVs_1_1; + static String mExpFogVs_1_1; + static String mExp2FogVs_1_1; + static String mShadowReceiverVs_1_1; + + public: + /// General purpose method to get any of the program sources + static const String& getProgramSource(FogMode fogMode, + const String syntax, bool shadowReceiver = false); + + + }; +} + +#endif diff --git a/school/informatik/verkerhssimulation/src/ogre/stl_user_config.h b/school/informatik/verkerhssimulation/src/ogre/stl_user_config.h new file mode 100644 index 00000000..db0d2f70 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/ogre/stl_user_config.h @@ -0,0 +1,204 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* + * Purpose of this file : + * + * To hold user-definable portion of STLport settings which may be overridden + * on per-project basis. + * Please note that if you use STLport iostreams (compiled library) then you have + * to use consistent settings when you compile STLport library and your project. + * Those settings are defined in _site_config.h and have to be the same for a given + * STLport installation. + * + */ + + +//========================================================== +// User-settable macros that control compilation: +// Features selection +//========================================================== + +/* _STLP_NO_OWN_IOSTREAMS: + * __STL_NO_SGI_IOSTREAMS (in older versions) + * This is major configuration switch. + * Turn it on to disable use of SGI iostreams and use wrappers + * around your compiler's iostreams, like before. + * Keep it off if you want to use SGI iostreams + * (Note that in this case you have to compile library in ../src + * and supply resulting library at link time). + * + */ + +// # define _STLP_NO_OWN_IOSTREAMS 1 + + +/* + * This macro only works in non-SGI iostreams mode. + * + * Uncomment to suppress using new-style streams even if they are + * available. + * Beware - _STLP_USE_OWN_NAMESPACE depends on this macro, too. + * Do that only if you are absolutely sure backwards-compatible + * is not actually a wrapper with + * Hint : In VC++ 6.x, they are not. + */ + +// #define _STLP_NO_NEW_IOSTREAMS 1 + +/* + * Use this switch for embedded systems where no iostreams are available + * at all. STLport own iostreams will also get disabled automatically then. + */ +// # define _STLP_NO_IOSTREAMS 1 + +/* + * Set _STLP_DEBUG to turn the "Debug Mode" on. + * That gets you checked iterators/ranges in the manner + * of "Safe STL". Very useful for debugging. Thread-safe. + * Please do not forget to link proper STLport library flavor + * (e.g libstlport_gcc_stldebug.a) when you set this flag in STLport iostreams mode. + */ +#ifdef _DEBUG + #define _STLP_DEBUG 1 +#endif + + +/* + * + * _STLP_NO_CUSTOM_IO : define this if you do not instantiate basic_xxx iostream classes with custom types (which is most likely the case). + * Custom means types other than char, wchar and char_traits<>, + * like basic_ostream > + * When this option is on, most non-inline template functions definitions for iostreams are not seen by the client. + * Default is off, just not to break compilation for those who do use those types. + * which saves a lot of compile time for most compilers, also object and executable size for some. + * That also guarantees that you still use optimized standard i/o when you compile your program without optimization. + * Option does not affect STLport library build; you may use the same binary library with and without this option, + * on per-project basis. + * + */ +//#define _STLP_NO_CUSTOM_IO + + +/* + * _STLP_NO_RELOPS_NAMESPACE: if defined, don't put the relational + * operator templates (>, <=. >=, !=) in namespace std::rel_ops, even + * if the compiler supports namespaces. + * Note : if the compiler do not support namespaces, those operators are not be provided by default, + * to simulate hiding them into rel_ops. This was proved to resolve many compiler bugs with ambiguity. + */ + +// #define _STLP_NO_RELOPS_NAMESPACE 1 + + +/* + * If _STLP_USE_OWN_NAMESPACE is in effect, STLport by default will not try + * to rename std:: for the user + * to _STL::. If you do want this feature, please define the following switch : + */ +// # define _STLP_REDEFINE_STD 1 + + +/* + * _STLP_WHOLE_NATIVE_STD : only meaningful in _STLP_USE_OWN_NAMESPACE mode. + * Normally, STLport only imports necessary components from native std:: namespace - + * those not yet provided by STLport (, , etc.) + * and their dependencies (, ). + * You might want everything from std:: being available in std:: namespace when you + * include corresponding STLport header (like STLport provides std::map as well, etc.), + * if you are going to use both stlport:: and std:: components in your code. + * Otherwise this option is not recommended as it increases the size of your object files + * and slows down compilation. + */ +// # define _STLP_WHOLE_NATIVE_STD + + +/* + * Use this option to catch uninitialized members in your classes. + * When it is set, construct() and destroy() fill the class storage + * with _STLP_SHRED_BYTE (see below). + * Note : _STLP_DEBUG and _STLP_DEBUG_ALLOC don't set this option automatically. + */ + +// # define _STLP_DEBUG_UNINITIALIZED 1 + +/* + * Uncomment and provide a definition for the byte with which raw memory + * will be filled if _STLP_DEBUG_ALLOC or _STLP_DEBUG_UNINITIALIZED is defined. + * Choose a value which is likely to cause a noticeable problem if dereferenced + * or otherwise abused. A good value may already be defined for your platform; see + * stl_config.h + */ +// #define _STLP_SHRED_BYTE 0xA3 + +/* + * This option is for gcc users only and only affects systems where native linker + * does not let gcc to implement automatic instantiation of static template data members/ + * It is being put in this file as there is no way to check if we are using GNU ld automatically, + * so it becomes user's responsibility. + * + */ + +// #define _STLP_GCC_USES_GNU_LD + + +//========================================================== +// Compatibility section +//========================================================== + +/* + * Define this macro to disable anachronistic constructs (like the ones used in HP STL and + * not included in final standard, etc. + */ +// define _STLP_NO_ANACHRONISMS 1 + +/* + * Define this macro to disable STLport extensions (for example, to make sure your code will + * compile with some other implementation ) + */ +// define _STLP_NO_EXTENSIONS 1 + + +/* + * You should define this macro if compiling with MFC - STLport + * then include instead of to get synchronisation primitives + * + */ + +// # define _STLP_USE_MFC 1 + + +// boris : this setting is here as we cannot detect precense of new Platform SDK automatically +// If you are using new PSDK with VC++ 6.0 or lower, please define this to get correct prototypes for InterlockedXXX functions +//# define _STLP_NEW_PLATFORM_SDK 1 + +/* + * Use minimum set of default arguments on template classes that have more + * than one - for example map<>, set<>. + * This has effect only if _STLP_LIMITED_DEFAULT_TEMPLATES is on. + * If _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS is set, you'll be able to compile + * set with those compilers, but you'll have to use __set__> + * + * Affects : map<>, multimap<>, set<>, multiset<>, hash_*<>, + * queue<>, priority_queue<>, stack<>, istream_iterator<> + */ + +// # define _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS 1 + +//========================================================== + +// Local Variables: +// mode:C++ +// End: diff --git a/school/informatik/verkerhssimulation/src/thunks/thunks.h b/school/informatik/verkerhssimulation/src/thunks/thunks.h new file mode 100644 index 00000000..45417021 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/thunks/thunks.h @@ -0,0 +1,69 @@ +#pragma once +#ifndef _THUNKS_H__ +#define _THUNKS_H__ + +// This was introduced to me by Maximilian Hänel in his WTL port. Cool, eh? +//////////////////////////////////////////////////////////////////////////////// +// The class _ThunkImpl is a renamed version of Andrew Nosenko CAuxThunk implementation. +// Thanks Andrew, it's a fantastic class! +// +// Copyright (c) 1997-2001 by Andrew Nosenko , +// (c) 1997-1998 by Computer Multimedia System, Inc., +// (c) 1998-2001 by Mead & Co Limited +// +// http://www.nozillium.com/atlaux/ +// Version: 1.10.0021 +// +#ifndef _M_IX86 +// #pragma message("_ThunkImpl is implemented for X86 only!") + #error _ThunkImpl is implemented for X86 only! +#endif + +#pragma pack(push, 1) + +template +class _ThunkImpl +{ +private: + + typedef struct{ + BYTE m_mov; // mov ecx, %pThis + DWORD m_this; // + BYTE m_jmp; // jmp func + DWORD m_relproc; // relative jmp + } CODETHUNK; + + CODETHUNK* m_pCodeThunk; +public: + typedef void (T::*TMFP)(); + + _ThunkImpl(TMFP method, const T* pThis) + { + m_pCodeThunk = (CODETHUNK*)VirtualAlloc (NULL, sizeof(CODETHUNK), MEM_COMMIT, PAGE_READWRITE); + union { DWORD func; TMFP method; } addr; + addr.method = (TMFP)method; + m_pCodeThunk->m_mov = 0xB9; + m_pCodeThunk->m_this = (DWORD)pThis; + m_pCodeThunk->m_jmp = 0xE9; + m_pCodeThunk->m_relproc = addr.func - (DWORD)(m_pCodeThunk+1); + + DWORD dwOldProtect; + VirtualProtect( m_pCodeThunk, sizeof(CODETHUNK), PAGE_EXECUTE, &dwOldProtect ); + + ::FlushInstructionCache(GetCurrentProcess(), m_pCodeThunk, sizeof(CODETHUNK)); + } + + ~_ThunkImpl() + { + VirtualFree( m_pCodeThunk, 0, MEM_RELEASE ); + } + + FARPROC GetThunk() const + { + //_ASSERTE(m_mov == 0xB9); + return (FARPROC)m_pCodeThunk; + } +}; +#pragma pack(pop) // _ThunkImpl + +#endif // _THUNKS_H__ \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/u_path_operations/u_path_operations.cpp b/school/informatik/verkerhssimulation/src/u_path_operations/u_path_operations.cpp new file mode 100644 index 00000000..c29f28a4 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/u_path_operations/u_path_operations.cpp @@ -0,0 +1,64 @@ +#include "u_path_operations.h" + +string getExeName() +{ + return extractFileName(getExePathName()); +} + +string getExePath() +{ + return extractPath(getExePathName()); +} + +string getExePathName() +{ + char szAppPath[MAX_PATH] = ""; + ::GetModuleFileName(0, szAppPath, MAX_PATH); + + return szAppPath; +} + +string extractPath(string filepath) +{ + return filepath.substr(0,filepath.rfind("\\") +1); +} + +string extractFileName(string filepath) +{ + return filepath.substr(filepath.rfind("\\") + 1); +} + +string getUpperPath(string path) +{ + //Überprüfen ob ein \ am Ende ist + if(path.substr(0,path.rfind("\\") +1) == path) path=path.substr(0,path.length()-1); + + return path.substr(0,path.rfind("\\") +1); +} + +string getAbsolutPath(string relativpath, string relativto) +{ + bool b = true; + + while(b == true) + { + if(relativpath.substr(0,1) == "/" || relativpath.substr(0,1) == "\\" ) relativpath = relativpath.substr(1,relativpath.length()-1); + if(relativpath.substr(0,2) == "//" ) relativpath = relativpath.substr(2,relativpath.length()-2); + + if(relativpath.substr(0,2) == "..") + { + relativpath = relativpath.substr(2,relativpath.length()-2); + relativto = getUpperPath(relativto); + } else b = false; + } + + //Überprüfen ob ein \ am Ende ist + if(relativto.substr(0,relativto.rfind("\\") +1) == relativto){} else relativto=relativto + "\\"; + + return relativto + relativpath; +} + +string getAbsolutPathToExe(string relativpath) +{ + return getAbsolutPath(relativpath, getExePath()); +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/u_path_operations/u_path_operations.h b/school/informatik/verkerhssimulation/src/u_path_operations/u_path_operations.h new file mode 100644 index 00000000..b9511491 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/u_path_operations/u_path_operations.h @@ -0,0 +1,18 @@ +#pragma once + +#include +#include "windows.h" + +using namespace std; + +string getExeName(); +string getExePath(); +string getExePathName(); + +string extractPath(string filepath); +string extractFileName(string filepath); + +string getUpperPath(string path); + +string getAbsolutPath(string relativpath, string relativto); +string getAbsolutPathToExe(string relativpath); \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/u_stringoperations/u_stringoperations.cpp b/school/informatik/verkerhssimulation/src/u_stringoperations/u_stringoperations.cpp new file mode 100644 index 00000000..9a3fc0ac --- /dev/null +++ b/school/informatik/verkerhssimulation/src/u_stringoperations/u_stringoperations.cpp @@ -0,0 +1,80 @@ +#include "u_stringoperations.h" + +string LowerCase(string str) +{ + for (int i = 0; i <= int(str.size()); ++i) str[i] = tolower(str[i]); + + return str; +} + +bool isStringIncluded(string SourceString, string SearchString,string DivideParam) +{ + + for(int i=0;i<=getStringParts(SourceString,DivideParam);i++) { + if(PartAString(SourceString,DivideParam,i) == SearchString) return true; } + + return false; + +} + +bool isStringIncluded(string SourceString, string SearchString) +{ + + return isStringIncluded(SourceString,SearchString,StringDivideParam); + +} + +string PartAString(string SourceString, string DivideParam, int Position) +{ + + if( getStringParts(SourceString,DivideParam)<=0 ) return ""; + + int lastDivide = 1; + int dividecount = 0; + + for(int i=0;i<=int(SourceString.length());i++) + { + if(LowerCase(SourceString.substr(i,DivideParam.length())) == LowerCase(DivideParam)) + { + dividecount++; + if(Position == dividecount) return SourceString.substr(lastDivide,i-lastDivide); + } + + lastDivide = i+int(DivideParam.length()); + } + + if(dividecount>=Position-1) return SourceString.substr(lastDivide,SourceString.length()); + + return ""; + +} + +string PartAString(string SourceString, int Position) +{ + + return PartAString(SourceString,StringDivideParam,Position); + +} + +int getStringParts(string SourceString, string DivideParam) +{ + + if(SourceString.length() <= 0) return 0; + + int result = 0; + + for(int i=0;i<=int(SourceString.length());i++) + if(LowerCase(SourceString.substr(i,DivideParam.length()))==LowerCase(DivideParam)) result++; + + if(LowerCase(SourceString.substr(SourceString.length()-DivideParam.length()+1,DivideParam.length())) == LowerCase(DivideParam)){} else result++; + + return result; + +} + +int getStringParts(string SourceString) +{ + + return getStringParts(SourceString,StringDivideParam); + +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/u_stringoperations/u_stringoperations.h b/school/informatik/verkerhssimulation/src/u_stringoperations/u_stringoperations.h new file mode 100644 index 00000000..2b47fede --- /dev/null +++ b/school/informatik/verkerhssimulation/src/u_stringoperations/u_stringoperations.h @@ -0,0 +1,23 @@ +#pragma once + +#include + +using namespace std; + +//Konstanten +#define StringDivideParam ";" //for all string operations where the Divideparam is not a requried Param +//const string StringDivideParam = ";"; + +string LowerCase(string str); + +bool isStringIncluded(string SourceString, string SearchString,string DivideParam); +bool isStringIncluded(string SourceString, string SearchString); + +string PartAString(string SourceString, string DivideParam, int Position); +string PartAString(string SourceString, int Position); + +int getStringParts(string SourceString, string DivideParam); +int getStringPart(string SourceString); + +string delStringPart(string Sourcestring, string DivideParam, int Position); +string delStringPart(string Sourcestring, int Position); \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/u_typecasts/u_typecasts.cpp b/school/informatik/verkerhssimulation/src/u_typecasts/u_typecasts.cpp new file mode 100644 index 00000000..06977a29 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/u_typecasts/u_typecasts.cpp @@ -0,0 +1,12 @@ +#include "u_typecasts.h" + +string inttostr(int i) +{ + string s; + + stringstream sstr; + sstr << i; + sstr >> s; + + return s; +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/u_typecasts/u_typecasts.h b/school/informatik/verkerhssimulation/src/u_typecasts/u_typecasts.h new file mode 100644 index 00000000..99e08a5f --- /dev/null +++ b/school/informatik/verkerhssimulation/src/u_typecasts/u_typecasts.h @@ -0,0 +1,7 @@ +#include +#include +#pragma once + +using namespace std; + +string inttostr(int i); \ No newline at end of file diff --git a/.DS_Store b/school/informatik/verkerhssimulation/src/verkehrssimulation/._u_physics.cpp similarity index 60% rename from .DS_Store rename to school/informatik/verkerhssimulation/src/verkehrssimulation/._u_physics.cpp index 2e35da07..dcf23170 100644 Binary files a/.DS_Store and b/school/informatik/verkerhssimulation/src/verkehrssimulation/._u_physics.cpp differ diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/backup/c_physics.cpp b/school/informatik/verkerhssimulation/src/verkehrssimulation/backup/c_physics.cpp new file mode 100644 index 00000000..52d4fce6 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/backup/c_physics.cpp @@ -0,0 +1,156 @@ +CPhysics::CPhysics() +{ +} + +CPhysics::~CPhysics() +{ +} + + +// main function to calculate the new positions of the cars +int CPhysics::calculate(int ticks) +{ + //dummy + return 0; +} + + +float CPhysics::angle( float ax, float ay, float bx, float by) +{ + return ((ax*bx+ay*by) / sqrt(pow(ax, 2)+pow(ay, 2)) * sqrt(pow(bx, 2)+pow(by, 2))); +} + + +void CPhysics::collisionDetection(CCar *car) +{ + + CCar *frontcar; // Represents the car in front + float distanceFC; + bool frontcarset = false; + + // look for the frontcar + for (int i=0; istreetType && &data.cars[i] == car) + { + if ( sqrt( pow( (data.cars[i].posx - car->posx), 2) + pow( (data.cars[i].posy - car->posy), 2) ) < distanceFC ) + { + if ( abs( angle(car->directiony, car->directionx, data.cars[i].posx - car->posx, data.cars[i].posy - car->posy) ) < 20) + { + frontcar = &(data.cars[i]); + distanceFC = sqrt( pow( (data.cars[i].posx - car->posx), 2) + pow( (data.cars[i].posy - car->posy), 2) ); + frontcarset = true; + } + } + } + } + + + // calculate a new acceleration for the previously calculated distance + if (frontcarset == true) + { + // !!!!! Constant 20 has to be set so a suitible value + car->acceleration = sqrt(distanceFC) - 20 * car->aggressiveness * car->risk * car->velocity; + } + + // decide whether the car wants to override + if (distanceFC < 20 * car->risk * car->aggressiveness && frontcar->velocity < car->maxvelocity - 30) + { + // Mark that the car wants to overtake + car->driverState = 4; + } + + + + +} + + +int CPhysics::checkForGap (CCar *car, int streetlane) +{ + // calculate the number of StreetPoints for the length of the needed gap + + int n = (int) ((1/(car->risk * car->aggressiveness)) * car->velocity + 2); + + // look for nearest streetpoint on streetlane for the car (othogonal) + float streetx, streety, distanceCS = 10e10; + + //dummy + int j; + + for (int i=0; iposx - data.streetsections[j].StreetPoints[i].x), 2) + pow( (car->posy - data.streetsections[j].StreetPoints[i].y), 2) ) < distanceCS ) + { + streetx = data.streetsections[j].StreetPoints[i].x; + streety = data.streetsections[j].StreetPoints[i].y; + distanceCS = sqrt( pow( (car->posx - data.streetsections[j].StreetPoints[i].x), 2) + pow( (car->posy - data.streetsections[j].StreetPoints[i].y), 2) ); + } + } + } + + + // check for free points on the streetlane and behind the car + float px, py, distanceSP = 10e10; + for (int i=0; idirectionx, car->directiony)) > 0.9) + { + px = data.streetsections[j].StreetPoints[i].x; + py = data.streetsections[j].StreetPoints[i].y; + distanceSP = sqrt( pow( streetx-data.streetsections[j].StreetPoints[i].x, 2) + pow( streety-data.streetsections[j].StreetPoints[i].y, 2) ); + } + } + } + + +} + + + +void CPhysics::calculateVelocity(int carnumber) +{ + data.cars[carnumber].velocity = data.cars[carnumber].velocity + data.cars[carnumber].acceleration / systicks; + if (data.cars[carnumber].velocity > data.cars[carnumber].maxvelocity) + { + data.cars[carnumber].velocity = data.cars[carnumber].maxvelocity; + } +} + + +void CPhysics::checkAcceleration(int carnumber) +{ + if (data.cars[carnumber].acceleration > data.cars[carnumber].maxacceleration) + { + //No Effect + // data.cars[carnumber].acceleration > data.cars[carnumber].maxacceleration; + } + if (data.cars[carnumber].acceleration < data.cars[carnumber].maxbrake) + { + //No Effect + // data.cars[carnumber].acceleration < data.cars[carnumber].maxbrake; + } + if (data.cars[carnumber].acceleration < 0) + { + data.cars[carnumber].brakelight = 1; + } + else + { + data.cars[carnumber].brakelight = 0; + } +} + + +void CPhysics::calculatePosition(int carnumber) +{ + //Läuft nicht + //data.cars[carnumber].posx = data.cars[carnumber].posx + (data.cars[carnumber].velocity / systicks) * data.cars[carnumber].directionx; + //data.cars[carnumber].posy = data.cars[carnumber].posy + (data.cars[carnumber].velocity / systicks) * data.cars[carnumber].directiony; +} + diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/backup/c_physics.h b/school/informatik/verkerhssimulation/src/verkehrssimulation/backup/c_physics.h new file mode 100644 index 00000000..a4801c91 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/backup/c_physics.h @@ -0,0 +1,30 @@ +#include "verkehrssimulation.h" + +//Physik-Funktionen +#define systicks 100; + +class CPhysics +{ + +public: + CData data; + + CPhysics(); + ~CPhysics(); + + static int calculate(int ticks); + + void collisionDetection(CCar *car); + void calculateVelocity(int carnumber); + void checkAcceleration(int carnumber); + void calculatePosition(int carnumber); + // check if there is a gap for overtaking etc. + // returns: + // 1: there is a gap + // 0: there is no gap + int checkForGap (CCar *car, int streettype); + + float angle( float ax, float ay, float bx, float by); + + +}; \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/c_OgreFrameListener.cpp b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_OgreFrameListener.cpp new file mode 100644 index 00000000..e6c05059 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_OgreFrameListener.cpp @@ -0,0 +1,299 @@ +#include "verkehrssimulation.h" +#include "c_ogreframelistener.h" + +void COgreFrameListener::updateStats(void) +{ + static String currFps = "Momentane FPS: "; + static String avgFps = "Durchschnittliche FPS: "; + static String bestFps = "Beste FPS: "; + static String worstFps = "Schlechteste FPS: "; + static String tris = "Anzahl der Dreiecke: "; + static String batches = "Anzahl der Stapel: "; + + // update stats when necessary + try + { + OverlayElement* guiAvg = OverlayManager::getSingleton().getOverlayElement("Core/AverageFps"); + OverlayElement* guiCurr = OverlayManager::getSingleton().getOverlayElement("Core/CurrFps"); + OverlayElement* guiBest = OverlayManager::getSingleton().getOverlayElement("Core/BestFps"); + OverlayElement* guiWorst = OverlayManager::getSingleton().getOverlayElement("Core/WorstFps"); + + const RenderTarget::FrameStats& stats = mWindow->getStatistics(); + guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS)); + guiCurr->setCaption(currFps + StringConverter::toString(stats.lastFPS)); + guiBest->setCaption(bestFps + StringConverter::toString(stats.bestFPS)+" "+StringConverter::toString(stats.bestFrameTime)+" ms"); + guiWorst->setCaption(worstFps + StringConverter::toString(stats.worstFPS)+" "+StringConverter::toString(stats.worstFrameTime)+" ms"); + + OverlayElement* guiTris = OverlayManager::getSingleton().getOverlayElement("Core/NumTris"); + guiTris->setCaption(tris + StringConverter::toString(stats.triangleCount)); + + OverlayElement* guiBatches = OverlayManager::getSingleton().getOverlayElement("Core/NumBatches"); + guiBatches->setCaption(batches + StringConverter::toString(stats.batchCount)); + + OverlayElement* guiDbg = OverlayManager::getSingleton().getOverlayElement("Core/DebugText"); + guiDbg->setCaption(mDebugText); + }catch(...) { /* ignore */ } +} + +void COgreFrameListener::windowResized(RenderWindow* rw) +{ + unsigned int width, height, depth; + int left, top; + rw->getMetrics(width, height, depth, left, top); + + const OIS::MouseState &ms = mMouse->getMouseState(); + ms.width = width; + ms.height = height; +} + +void COgreFrameListener::windowClosed(RenderWindow* rw) +{ + //Only close for window that created OIS (the main window in these demos) + if( rw == mWindow ) + { + if( mInputManager ) + { + mInputManager->destroyInputObject( mMouse ); + mInputManager->destroyInputObject( mKeyboard ); + mInputManager->destroyInputObject( mJoy ); + + OIS::InputManager::destroyInputSystem(mInputManager); + mInputManager = 0; + } + } +} + +COgreFrameListener::COgreFrameListener(RenderWindow* win, Camera* cam, bool bufferedKeys, bool bufferedMouse, bool bufferedJoy): + mCamera(cam), mTranslateVector(Vector3::ZERO), mWindow(win), mStatsOn(true), mNumScreenShots(0), + mMoveScale(0.0f), mRotScale(0.0f), mTimeUntilNextToggle(0), mFiltering(TFO_BILINEAR), + mAniso(1), mSceneDetailIndex(0), mMoveSpeed(100), mRotateSpeed(36), mDebugOverlay(0), + mInputManager(0), mMouse(0), mKeyboard(0), mJoy(0) + { + frameend = NULL; + framestart = NULL; + + using namespace OIS; + + mDebugOverlay = OverlayManager::getSingleton().getByName("Core/DebugOverlay"); + + LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***"); + ParamList pl; + size_t windowHnd = 0; + std::ostringstream windowHndStr; + + win->getCustomAttribute("WINDOW", &windowHnd); + windowHndStr << windowHnd; + pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); + + mInputManager = InputManager::createInputSystem( pl ); + + //Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse) + mKeyboard = static_cast(mInputManager->createInputObject( OISKeyboard, bufferedKeys )); + mMouse = static_cast(mInputManager->createInputObject( OISMouse, bufferedMouse )); + try {mJoy = static_cast(mInputManager->createInputObject( OISJoyStick, bufferedJoy ));}catch(...) {mJoy = 0;} + + //Set initial mouse clipping size + windowResized(mWindow); + + showDebugOverlay(true); + + //Register as a Window listener + WindowEventUtilities::addWindowEventListener(mWindow, this); + } + +COgreFrameListener::~COgreFrameListener() +{ + //Remove ourself as a Window listener + WindowEventUtilities::removeWindowEventListener(mWindow, this); + windowClosed(mWindow); +} + +bool COgreFrameListener::processUnbufferedKeyInput(const FrameEvent& evt) +{ + using namespace OIS; + + if(mKeyboard->isKeyDown(KC_A)) mTranslateVector.x = -mMoveScale; // Move camera left + + if(mKeyboard->isKeyDown(KC_D)) mTranslateVector.x = mMoveScale; // Move camera RIGHT + + if(mKeyboard->isKeyDown(KC_UP) || mKeyboard->isKeyDown(KC_W) ) mTranslateVector.z = -mMoveScale; // Move camera forward + + if(mKeyboard->isKeyDown(KC_DOWN) || mKeyboard->isKeyDown(KC_S) ) mTranslateVector.z = mMoveScale; // Move camera backward + + if(mKeyboard->isKeyDown(KC_PGUP)) mTranslateVector.y = mMoveScale; // Move camera up + + if(mKeyboard->isKeyDown(KC_PGDOWN)) mTranslateVector.y = -mMoveScale; // Move camera down + + if(mKeyboard->isKeyDown(KC_RIGHT)) mCamera->yaw(-mRotScale); + + if(mKeyboard->isKeyDown(KC_LEFT)) mCamera->yaw(mRotScale); + + if(mKeyboard->isKeyDown(KC_ESCAPE)) return false; + + if( mKeyboard->isKeyDown(KC_F) && mTimeUntilNextToggle <= 0 ) + { + mStatsOn = !mStatsOn; + showDebugOverlay(mStatsOn); + mTimeUntilNextToggle = 1; + } + + if( mKeyboard->isKeyDown(KC_T) && mTimeUntilNextToggle <= 0 ) + { + switch(mFiltering) + { + case TFO_BILINEAR: + mFiltering = TFO_TRILINEAR; + mAniso = 1; + break; + case TFO_TRILINEAR: + mFiltering = TFO_ANISOTROPIC; + mAniso = 8; + break; + case TFO_ANISOTROPIC: + mFiltering = TFO_BILINEAR; + mAniso = 1; + break; + default: break; + } + + MaterialManager::getSingleton().setDefaultTextureFiltering(mFiltering); + MaterialManager::getSingleton().setDefaultAnisotropy(mAniso); + + showDebugOverlay(mStatsOn); + mTimeUntilNextToggle = 1; + } + + if(mKeyboard->isKeyDown(KC_SYSRQ) && mTimeUntilNextToggle <= 0) + { + std::ostringstream ss; + ss << "screenshot_" << ++mNumScreenShots << ".png"; + mWindow->writeContentsToFile(ss.str()); + mTimeUntilNextToggle = 0.5; + mDebugText = "Saved: " + ss.str(); + } + + /*if(mKeyboard->isKeyDown(KC_R) && mTimeUntilNextToggle <=0) + { + mSceneDetailIndex = (mSceneDetailIndex+1)%3 ; + switch(mSceneDetailIndex) { + case 0 : mCamera->setPolygonMode(PM_SOLID); break; + case 1 : mCamera->setPolygonMode(PM_WIREFRAME); break; + case 2 : mCamera->setPolygonMode(PM_POINTS); break; + } + mTimeUntilNextToggle = 0.5; + }*/ + + static bool displayCameraDetails = false; + if(mKeyboard->isKeyDown(KC_P) && mTimeUntilNextToggle <= 0) + { + displayCameraDetails = !displayCameraDetails; + mTimeUntilNextToggle = 0.5; + if (!displayCameraDetails)mDebugText = ""; + } + + // Print camera details + if(displayCameraDetails) + mDebugText = "P: " + StringConverter::toString(mCamera->getDerivedPosition()) + + " " + "O: " + StringConverter::toString(mCamera->getDerivedOrientation()); + + // Return true to continue rendering + return true; +} + +bool COgreFrameListener::processUnbufferedMouseInput(const FrameEvent& evt) +{ + using namespace OIS; + + // Rotation factors, may not be used if the second mouse button is pressed + // 2nd mouse button - slide, otherwise rotate + const MouseState &ms = mMouse->getMouseState(); + if( ms.buttonDown( MB_Right ) ) + { + mTranslateVector.x += ms.X.rel * 0.13; + mTranslateVector.y -= ms.Y.rel * 0.13; + } + else + { + mRotX = Degree(-ms.X.rel * 0.13); + mRotY = Degree(-ms.Y.rel * 0.13); + } + + return true; +} + +void COgreFrameListener::moveCamera() +{ + // Make all the changes to the camera + // Note that YAW direction is around a fixed axis (freelook style) rather than a natural YAW + //(e.g. airplane) + mCamera->yaw(mRotX); + mCamera->pitch(mRotY); + mCamera->moveRelative(mTranslateVector); +} + +void COgreFrameListener::showDebugOverlay(bool show) +{ + if (mDebugOverlay) + if (show) mDebugOverlay->show(); else mDebugOverlay->hide(); +} + +bool COgreFrameListener::frameStarted(const FrameEvent& evt) +{ + using namespace OIS; + + if(!framestart == NULL) framestart(); + + if(mWindow->isClosed()) return false; + + //Need to capture/update each device + mKeyboard->capture(); + mMouse->capture(); + if( mJoy ) mJoy->capture(); + + bool buffJ = (mJoy) ? mJoy->buffered() : true; + + //Check if one of the devices is not buffered + if( !mMouse->buffered() || !mKeyboard->buffered() || !buffJ ) + { + // one of the input modes is immediate, so setup what is needed for immediate movement + if (mTimeUntilNextToggle >= 0) mTimeUntilNextToggle -= evt.timeSinceLastFrame; + + // If this is the first frame, pick a speed + if (evt.timeSinceLastFrame == 0) + { + mMoveScale = 1; + mRotScale = 0.1; + } + // Otherwise scale movement units by time passed since last frame + else + { + // Move about 100 units per second, + mMoveScale = mMoveSpeed * evt.timeSinceLastFrame; + // Take about 10 seconds for full rotation + mRotScale = mRotateSpeed * evt.timeSinceLastFrame; + } + + mRotX = 0; + mRotY = 0; + mTranslateVector = Ogre::Vector3::ZERO; + } + + //Check to see which device is not buffered, and handle it + if( !mKeyboard->buffered() ) + if( processUnbufferedKeyInput(evt) == false ) return false; + if( !mMouse->buffered() ) + if( processUnbufferedMouseInput(evt) == false ) return false; + + if( !mMouse->buffered() || !mKeyboard->buffered() || !buffJ ) moveCamera(); + + return true; +} + +bool COgreFrameListener::frameEnded(const FrameEvent& evt) +{ + //int result = (*this.*frmend)(0); + if(!frameend == NULL) frameend(0); + + updateStats(); + return true; +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/c_OgreFrameListener.h b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_OgreFrameListener.h new file mode 100644 index 00000000..570d6126 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_OgreFrameListener.h @@ -0,0 +1,64 @@ +#include "verkehrssimulation.h" +#pragma once + +class COgreFrameListener: public FrameListener, public WindowEventListener +{ +public: + Camera* mCamera; + + Vector3 mTranslateVector; + RenderWindow* mWindow; + bool mStatsOn; + + std::string mDebugText; + + unsigned int mNumScreenShots; + float mMoveScale; + Degree mRotScale; + // just to stop toggles flipping too fast + Real mTimeUntilNextToggle ; + Radian mRotX, mRotY; + TextureFilterOptions mFiltering; + int mAniso; + + int mSceneDetailIndex ; + Real mMoveSpeed; + Degree mRotateSpeed; + Overlay* mDebugOverlay; + + //OIS Input devices + OIS::InputManager* mInputManager; + OIS::Mouse* mMouse; + OIS::Keyboard* mKeyboard; + OIS::JoyStick* mJoy; + + int (*frameend)(int fps); + int (*framestart)(); + + void updateStats(void); + + // Constructor takes a RenderWindow because it uses that to determine input context + COgreFrameListener(){}; + COgreFrameListener(RenderWindow* win, Camera* cam, bool bufferedKeys = false, bool bufferedMouse = false, bool bufferedJoy = false); + + //Adjust mouse clipping area + virtual void windowResized(RenderWindow* rw); + + //Unattach OIS before window shutdown (very important under Linux) + virtual void windowClosed(RenderWindow* rw); + + virtual ~COgreFrameListener(); + + virtual bool processUnbufferedKeyInput(const FrameEvent& evt); + + bool processUnbufferedMouseInput(const FrameEvent& evt); + + void moveCamera(); + + void showDebugOverlay(bool show); + + // Override frameStarted event to process that (don't care about frameEnded) + bool frameStarted(const FrameEvent& evt); + + bool frameEnded(const FrameEvent& evt); +}; diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/c_OgreWindow.cpp b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_OgreWindow.cpp new file mode 100644 index 00000000..f1183985 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_OgreWindow.cpp @@ -0,0 +1,143 @@ +#include "verkehrssimulation.h" +#include "c_ogrewindow.h" + +COgreWindow::COgreWindow() +{ + mFrameListener = 0; + mRoot = 0; + mResourcePath = getExePath() + "resources.cfg"; + mOgreCfgPath = getExePath() + "ogre.cfg"; + mOgreLogPath = getExePath() + "ogre.log"; + mPluginPath = getExePath() + "plugins.cfg"; +} + +COgreWindow::~COgreWindow() +{ + if (mFrameListener) delete mFrameListener; + if (mRoot) delete mRoot; +} + +void COgreWindow::go(void) +{ + if (!setup())return; + + mRoot->startRendering(); + + // clean up + destroyScene(); +} + +bool COgreWindow::setup(void) +{ +// String pluginsPath; + + // only use plugins.cfg if not static +// #ifndef OGRE_STATIC_LIB +// pluginsPath = mResourcePath + "plugins.cfg"; +// #endif + + mRoot = new Root(mPluginPath, mOgreCfgPath, mOgreLogPath); + + setupResources(); + + bool carryOn = configure(); + if (!carryOn) return false; + + chooseSceneManager(); + createCamera(); + createViewports(); + + // Set default mipmap level (NB some APIs ignore this) + TextureManager::getSingleton().setDefaultNumMipmaps(5); + + // Create any resource listeners (for loading screens) + createResourceListener(); + // Load resources + loadResources(); + + // Create the scene + createScene(); + + createFrameListener(); + + return true; +} + +void COgreWindow::setupResources(void) +{ + // Load resource paths from config file + ConfigFile cf; + cf.load(mResourcePath); + + // Go through all sections & settings in the file + ConfigFile::SectionIterator seci = cf.getSectionIterator(); + String secName, typeName, archName; + while (seci.hasMoreElements()) + { + secName = seci.peekNextKey(); + ConfigFile::SettingsMultiMap *settings = seci.getNext(); + ConfigFile::SettingsMultiMap::iterator i; + for (i = settings->begin(); i != settings->end(); ++i) + { + typeName = i->first; + archName = i->second; + ResourceGroupManager::getSingleton().addResourceLocation(getAbsolutPathToExe(archName), typeName, secName); + } + } +} + +bool COgreWindow::configure(void) +{ + // Show the configuration dialog and initialise the system + // You can skip this and use root.restoreConfig() to load configuration + // settings if you were sure there are valid ones saved in ogre.cfg + if(mRoot->showConfigDialog()) + { + // If returned true, user clicked OK so initialise + // Here we choose to let the system create a default rendering window by passing 'true' + mWindow = mRoot->initialise(true); + return true; + } else return false; +} + +void COgreWindow::chooseSceneManager(void) +{ + // Create the SceneManager, in this case a generic one + mSceneMgr = mRoot->createSceneManager(ST_GENERIC, "ExampleSMInstance"); +} + +void COgreWindow::createCamera(void) +{ + // Create the camera + mCamera = mSceneMgr->createCamera("PlayerCam"); + + // Position it at 500 in Z direction + mCamera->setPosition(Vector3(0,0,500)); + // Look back along -Z + mCamera->lookAt(Vector3(0,0,-300)); + mCamera->setNearClipDistance(5); + +} + +void COgreWindow::createFrameListener(void) +{ + mFrameListener= new COgreFrameListener(mWindow, mCamera); + mFrameListener->showDebugOverlay(true); + mRoot->addFrameListener(mFrameListener); +} + +void COgreWindow::createViewports(void) +{ + // Create one viewport, entire window + Viewport* vp = mWindow->addViewport(mCamera); + vp->setBackgroundColour(ColourValue(0,0,0)); + + // Alter the camera aspect ratio to match the viewport + mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight())); +} + +void COgreWindow::loadResources(void) +{ + // Initialise, parse scripts etc + ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/c_OgreWindow.h b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_OgreWindow.h new file mode 100644 index 00000000..599054c7 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_OgreWindow.h @@ -0,0 +1,62 @@ +#include "verkehrssimulation.h" +#include "c_OgreFrameListener.h" +#pragma once + +class COgreWindow:public COgreFrameListener +{ +protected: + Root *mRoot; + Camera* mCamera; + SceneManager* mSceneMgr; + COgreFrameListener* mFrameListener; + RenderWindow* mWindow; + + Ogre::String mResourcePath; + Ogre::String mOgreCfgPath; + Ogre::String mOgreLogPath; + Ogre::String mPluginPath; + +public: + COgreWindow(); + ~COgreWindow(); + + // Start the Graphic-Thing + virtual void go(void); + + // These internal methods package up the stages in the startup process + // Sets up the application - returns false if the user chooses to abandon configuration. + virtual bool setup(void); + + // Optional to override this + virtual void destroyScene(void){}; + + // Method which will define the source of resources (other than current folder) + virtual void setupResources(void); + + /** Configures the application - returns false if the user chooses to abandon configuration. */ + virtual bool configure(void); + + virtual void chooseSceneManager(void); + + virtual void createCamera(void); + + virtual void createFrameListener(void); + + // pure virtual - this has to be overridden + virtual void createScene(void) = 0; + + virtual void createViewports(void); + + /// Optional override method where you can create resource listeners (e.g. for loading screens) + virtual void createResourceListener(void){} + + //Optional override method where you can perform resource group loading + // Must at least do ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); + virtual void loadResources(void); + + //void drawStreet() + + //void getCarModel(int id); + //void getCarTexture(int id); + +}; \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/c_car.cpp b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_car.cpp new file mode 100644 index 00000000..fb9d299d --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_car.cpp @@ -0,0 +1,46 @@ +#include "c_car.h" + +CCar::CCar(SceneNode* snode) +{ + node = snode; +} + +CCar::~CCar() +{ +} + +float CCar::getPosX() +{ + return posx; +} + +float CCar::getPosY() +{ + return posy; +} + +float CCar::getVelocity() +{ + return velocity; +} + +float CCar::getOrientation() +{ + return (directiony/directionx); +} + +char CCar::getBrakeLight() +{ + return brakelight; +} + +signed char CCar::getIndicatorLight() +{ + return indicatorlight; +} + +int CCar::getCartype() +{ + return cartype; +} + diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/c_car.h b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_car.h new file mode 100644 index 00000000..f8cc64d6 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_car.h @@ -0,0 +1,76 @@ +#include "verkehrssimulation.h" +#pragma once + +class CCar +{ + +public: + + //CCar(){}; + CCar(SceneNode* snode); + ~CCar(); + SceneNode* node; + +// basic car properties + float posx, posy; + float velocity; + float directionx, directiony; // where is the car looking? !!!! Einheitsvektor + + +// describes the actual type of street where the car is on + int streetType; + +/* + +describes the current state of the driver - eg. when overtaking or on the driveway to the motorway + +0 - driving on the current lane +1 - overtaking +2 - reeving after having overtaken a car / cars +3 - on the driveway +4 - + + +*/ + int driverState; + + + +// car physics + float acceleration; + + float maxbrake; // negative value for max. brake acceleration + float maxacceleration; + float maxvelocity; + +// lights + char brakelight; + signed char indicatorlight; + +// driver + float risk; + float aggressiveness; + + +// graphics + int cartype; + string numberPlate; + + + +// access functions for graphic functions + + + float getPosX(); + float getPosY(); + float getVelocity(); + float getOrientation(); + + // char getBrakeLight(); + //signed char getIndicatorLight(); + //int getCartype(); + + + + +}; \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/c_data.cpp b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_data.cpp new file mode 100644 index 00000000..acf10fff --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_data.cpp @@ -0,0 +1,71 @@ +#include "c_data.h" +#pragma once + +CData::CData() +{ + if(InstancePointer!=0) + { + //error--throw exception + } + + InstancePointer=this; +} + +CData::~CData() +{ +} + +void CData::addCar(CCar* car) +{ + //.\verkehrssimulation\c_data.cpp(21) : error C2664: 'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'CCar **__w64 ' to 'const CCar &' + //cars.push_back(car); + +} + +void CData::addStreetSection(CStreetSection strsec) +{ + InstancePointer->streetsections.push_back(strsec); +} + +CCar* CData::getCar(int id) +{ + if(InstancePointer->countCars()>id) return &InstancePointer->cars[id]; + + return NULL; +} + +CStreetSection* CData::getStreetSection(int id) +{ + if(InstancePointer->countStreetsections()>id) return &InstancePointer->streetsections[id]; + + return NULL; +} + +int CData::countCars() +{ + return int(InstancePointer->cars.size()); +} + +int CData::countStreetsections() +{ + return int(InstancePointer->streetsections.size()); +} + +int CData::calculate(int ticks) +{ +// CData* self = getInstance(); + for(int i=0;i<=InstancePointer->countCars();i++) + { + //Dummy + InstancePointer->cars[i].posx += 1; + } + + //dummy + return 0; +} + +bool CData::loadFromFile(string path) +{ + //dummy + return true; +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/c_data.h b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_data.h new file mode 100644 index 00000000..27733cfe --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_data.h @@ -0,0 +1,32 @@ +#include "c_street.h" +#include "c_car.h" +#pragma once + +class CData +{ + //CData* getInstance(); + + static CData* InstancePointer; + +public: + vector cars; + // Street Sections are managed in an Array + vector streetsections; + + CData(); + ~CData(); + + inline static CData* GetInstancePointer(){return(InstancePointer);} + + //Calculate!!! + static int calculate(int ticks); + + static void addCar(CCar* car); + static void addStreetSection(CStreetSection strsec); + static CCar* getCar(int id); + static CStreetSection* getStreetSection(int id); + static int countCars(); + static int countStreetsections(); + static bool loadFromFile(string path); + +}; \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/c_parameters.cpp b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_parameters.cpp new file mode 100644 index 00000000..1d99f87f --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_parameters.cpp @@ -0,0 +1,96 @@ +#include "..\u_stringoperations\u_stringoperations.h" +#include "c_parameters.h" + +void CParameter::clear() +{ + name = ""; + value = ""; +} + +string CParameter::getValue() +{ + return value; +} + +string CParameter::getName() +{ + return name; +} + +void CParameters::clear() +{ + for(int i=0;i<=99;i++) params[i].clear(); +} + +bool CParameters::getParamName(int id, string *name) +{ + if(id <= 99) + { + *name = *(¶ms[id].getName()); + if(params[id].getName() == "") return false; else return true; + } return false; +} + +bool CParameters::getParamValue(string name, string *value) +{ + for(int i=0;i<=99;i++) + if(LowerCase(params[i].getName()) == LowerCase(name)) + { + *value = *(¶ms[i].getValue()); + return true; + } + + return false; +} + +bool CParameters::addParam(string name, string value) +{ + for(int i=0;i<=99;i++) + { + if(params[i].name == "") + { + params[i].name = name; + params[i].value = value; + return true; + } + } + + return false; +} + +void CParameters::parseParamStr(string paramstr, string separator_) +{ + clear(); + + separator = separator_; + + bool b = true, b2; + string temps,pname,pvalue; + + while(b == true) + { + if(paramstr.substr(0,1) == " ") paramstr = paramstr.substr(1,paramstr.length()); + if(paramstr.substr(0,separator.length()) == separator) + { + paramstr = paramstr.substr(separator.length(),paramstr.length()); + temps = paramstr.substr(0,paramstr.find(separator)); + paramstr = paramstr.substr(temps.length(),paramstr.length()); + + pname = ""; + pvalue = ""; + + b2 = true; + + for(int i=0;i<=int(temps.length());i++) + { + if(temps.substr(i,1) == " " && b2 == true) b2 = false; else + if(b2) pname +=temps.substr(i,1); else pvalue += temps.substr(i,1); + } + + addParam(pname,pvalue); + } else + if(separator.length() < paramstr.length()) paramstr = paramstr.substr(separator.length(),paramstr.length()); else paramstr = ""; + + if(paramstr.length() == 0) b = false; + } +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/c_parameters.h b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_parameters.h new file mode 100644 index 00000000..7eda42a2 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_parameters.h @@ -0,0 +1,32 @@ +#pragma once + +#include + +using namespace std; + +class CParameter +{ + +public: + string name; + string value; + void clear(); + string getValue(); + string getName(); + +}; + +class CParameters +{ + CParameter params[100]; + string separator; + +public: + + bool getParamName(int id, string *name); + bool getParamValue(string name, string *value); + void parseParamStr(string paramstr, string separator_); + bool addParam(string name, string value); + void clear(); + +}; \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/c_simulation.cpp b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_simulation.cpp new file mode 100644 index 00000000..7fc1b6b8 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_simulation.cpp @@ -0,0 +1,228 @@ +#include "verkehrssimulation.h" +#include "c_simulation.h" +#pragma once + +CSimulation::CSimulation(LPSTR strCmdLine) +{ + if(InstancePointer!=0) + { + //error--throw exception + } + InstancePointer=this; + + //Std-Config true; + m_ErrorExceptions = true; + m_CmdLineExceptions = true; + + //Cmd-Line auslesen + m_Parameters.parseParamStr(strCmdLine,"-"); + interpretParameters(); + + //Load Data + m_data.loadFromFile("maps\\motorway\\motorway.ini"); + + //Dummy + for(int i=0;i<=4;i++) + { + Entity *ent = mSceneMgr->createEntity( "Ninja"+inttostr(i), "ninja.mesh" ); + SceneNode *snode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "NinjaNode"+inttostr(i), Vector3( 0, 0, 100 ) ); + snode->attachObject( ent ); + snode->yaw( Degree( 180 ) ); + snode->scale( 0.25, 0.25, 0.25 ); + + CCar* car = new CCar(snode); + + m_data.addCar(car); + } + +} + +CSimulation::~CSimulation() +{ +} + +void CSimulation::go(void) +{ + if (!setup())return; + + mFrameListener->frameend = &m_data.calculate; + + mRoot->startRendering(); + + // clean up + destroyScene(); + +} + +void CSimulation::interpretParameters() +{ + string temps; + bool b; + + for(int i=0;i<=99;i++) + { + temps = ""; + if(m_Parameters.getParamName(i,&temps)) + { + b = true; + + string pvalue; + m_Parameters.getParamValue(temps,&pvalue); + + if(LowerCase(temps) == "ne") + { + m_ErrorExceptions = false; + + b = false; + } + + if(LowerCase(temps) == "ncle") + { + m_CmdLineExceptions = false; + + b = false; + } + + temps = "Unknown Cmd-Line Cmd: \""+temps+"\""; + if(b) if(m_ErrorExceptions && m_CmdLineExceptions) MessageBox( NULL, temps.c_str(), "Unknown Cmd-Line Cmd", MB_OK | MB_ICONWARNING | MB_TASKMODAL); + } + } +} + +void CSimulation::createScene(void) +{ + mSceneMgr->setAmbientLight( ColourValue( 0, 0, 0 ) ); + mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE); + //mSceneMgr->setShadowTechnique(SHADOWTYPE_TEXTURE_MODULATIVE); + //mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_MODULATIVE); + + + //Entity *ent1 = mSceneMgr->createEntity( "Robot", "robot.mesh" ); + //SceneNode *node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode", Vector3( -100, 0, 0 ) ); + //node1->attachObject( ent1 ); + //node1->yaw( Degree( -90 ) ); + + //Entity *ent2 = mSceneMgr->createEntity( "Robot2", "robot.mesh" ); + //SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode2", Vector3( 0, 0, 0 ) ); + //node2->attachObject( ent2 ); + //node2->yaw( Degree( -90 ) ); + //node2->scale( 0.5, 1.5, 1 ); + + //Entity *ent3 = mSceneMgr->createEntity( "Robot3", "robot.mesh" ); + //SceneNode *node3 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode3", Vector3( 100, 0, 0 ) ); + //node3->attachObject( ent3 ); + //node3->yaw( Degree( -90 ) ); + //node3->scale( 1.5, 0.5, 2 ); + + //Entity *ent4 = mSceneMgr->createEntity( "Ninja1", "ninja.mesh" ); + //SceneNode *node4 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "NinjaNode1", Vector3( 0, 0, 100 ) ); + //node4->attachObject( ent4 ); + //node4->yaw( Degree( 180 ) ); + //node4->scale( 0.25, 0.25, 0.25 ); + + Plane plane(Vector3::UNIT_Y, 0); + MeshManager::getSingleton().createPlane("ground",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,1500,1500,20,20,true,1,5,5,Vector3::UNIT_Z); + Entity *ent5 = mSceneMgr->createEntity("GroundEntity", "ground"); + mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent5); + ent5->setMaterialName("Examples/BumpyMetal"); + ent5->setCastShadows(false); + + Light *light1 = mSceneMgr->createLight("Light1"); + light1->setType(Light::LT_POINT); + light1->setPosition(Vector3(0, 150, 250)); + light1->setDiffuseColour(0.30, 0.30, 0.30); + light1->setSpecularColour(0.1, 0.1, 0.1); + + Light *light2 = mSceneMgr->createLight("Light2"); + light2->setType(Light::LT_DIRECTIONAL); + light2->setDiffuseColour(ColourValue(0.05, 0.05, 0.35)); + light2->setSpecularColour(ColourValue(0.25, 0.25, 0.25)); + light2->setDirection(Vector3( 0, -1, 1 )); + + Light *light3 = mSceneMgr->createLight("Light3"); + light3->setType(Light::LT_SPOTLIGHT); + light3->setDiffuseColour(0, 0, 1.0); + light3->setSpecularColour(0, 0, 1.0); + light3->setDirection(-1, -1, 1); + light3->setPosition(Vector3(100, 100, 0)); + light3->setSpotlightRange(Degree(35), Degree(50)); + + //mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox"); + + //mSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 12); + + //Plane plane2; + //plane2.d = 1000; + //plane2.normal = Vector3::NEGATIVE_UNIT_Y; + //mSceneMgr->setSkyPlane(true, plane2, "Examples/SpaceSkyPlane", 1500, 75); + + //ColourValue fadeColour(0.9, 0.9, 0.9); + //mWindow->getViewport(0)->setBackgroundColour(fadeColour); + + //mSceneMgr->setFog(FOG_LINEAR, fadeColour, 0.0, 50, 500); + //mSceneMgr->setFog(FOG_EXP, fadeColour, 0.005); + //mSceneMgr->setFog(FOG_EXP2, fadeColour, 0.009); + + //mSceneMgr->setWorldGeometry("terrain.cfg"); + + ColourValue fadeColour(0.9, 0.9, 0.9); + mSceneMgr->setFog(FOG_LINEAR, fadeColour, 0.0, 0, 1000); + mWindow->getViewport(0)->setBackgroundColour(fadeColour); + + Plane plane3; + plane3.d = 100; + plane3.normal = Vector3::NEGATIVE_UNIT_Y; + + //mSceneMgr->setWorldGeometry("terrain.cfg"); + + mSceneMgr->setSkyPlane(true, plane3, "Examples/CloudySky", 500, 20, true, 0.5, 150, 150); + + // Create the scene node + SceneNode *node4 = mSceneMgr->getRootSceneNode()->createChildSceneNode("CamNode1", Vector3(-400, 200, 400)); + node4->yaw(Degree(-45)); + node4->attachObject(mCamera); + + // create the second camera node + node4 = mSceneMgr->getRootSceneNode()->createChildSceneNode("CamNode2", Vector3(0, 200, 400)); + + //ptr +} + +void CSimulation::createCamera(void) +{ + // create the camera + mCamera = mSceneMgr->createCamera("PlayerCam"); + + // set its position, direction + //mCamera->setPosition(Vector3(1000,10,1000)); + mCamera->setPosition(Vector3(0,10,0)); + //mCamera->lookAt(Vector3(0,0,0)); + + //Viewdistance + mCamera->setNearClipDistance(5); + mCamera->setFarClipDistance(5); +} + +void CSimulation::createViewports(void) +{ + // Create one viewport, entire window + Viewport* vp = mWindow->addViewport(mCamera); + vp->setBackgroundColour(ColourValue(0.1,0.1,0.1)); + + // Alter the camera aspect ratio to match the viewport + mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight())); + +} + +void CSimulation::chooseSceneManager(void) +{ + // Create the SceneManager, in this case a generic one + mSceneMgr = mRoot->createSceneManager(ST_EXTERIOR_CLOSE, "SMInstance"); + + ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); +} + +int CSimulation::framestart() +{ + for(int i=0;i<=InstancePointer->m_data.countCars() +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/c_simulation.h b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_simulation.h new file mode 100644 index 00000000..6312b2c8 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_simulation.h @@ -0,0 +1,34 @@ +#include "c_data.h" +#include "c_parameters.h" +#include "c_OgreWindow.h" +#pragma once + +class CSimulation:public COgreWindow +{ + CData m_data; + CParameters m_Parameters; + + static CSimulation* InstancePointer; + + static virtual void createScene(void); //Has to be overwritten + static virtual void createCamera(void); + static virtual void createViewports(void); + static virtual void chooseSceneManager(void); + + static int framestart(); + + static void interpretParameters(); + +public: + + static virtual void go(void); + + inline static CSimulation* GetInstancePointer(){return(InstancePointer);} + + bool m_CmdLineExceptions; + bool m_ErrorExceptions; + + CSimulation(LPSTR strCmdLine); + ~CSimulation(); + +}; \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/c_street.cpp b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_street.cpp new file mode 100644 index 00000000..09d25f80 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/c_street.cpp @@ -0,0 +1,35 @@ +#include "verkehrssimulation.h" +#include "c_street.h" + +CStreetSection::CStreetSection() +{ + + for (int i=0; i +#include +#include +#include +#include "c_street.h" + +int loadpng (char *filename, CStreetSection *output) +{ +//Redeclaration of filename +// const char* filename = argc > 1 ? argv[1] : "test.png"; + + //load and decode + std::vector buffer, image; + loadFile(buffer, filename); //load the image file with given filename + unsigned long w, h; + int error = decodePNG(image, w, h, buffer.empty() ? 0 : &buffer[0], (unsigned long)buffer.size()); //decode the png + + //if there's an error, display it, otherwise display information about the image + if(error != 0) + { + std::cout << "error: " << error << std::endl; + } + + + // Image data should now be in the vector image + + for (unsigned long height = 0; heightStreetPoints[height*w + width]->x = width; + //output->StreetPoints[height*w + width]->y = heigth; + unsigned int r = image[height*w*4 + width*4 + 0]; //red + unsigned int g = image[height*w*4 + width*4 + 1]; //green + unsigned int b = image[height*w*4 + width*4 + 2]; //blue + unsigned int a = image[height*w*4 + width*4 + 3]; //alpha + +//#### Example ##### + //if (r==0 && g==0 && b==0 && a==0) output->StreetPoints[height*w + width]->lane = 676; + + //output->StreetPoints[height*w + width]->direction = 1; + //if ( output->StreetPoints[height*w + width]->lane < 0) output->StreetPoints[height*w + width]->direction = -1; + //output->StreetPoints[height*w + width]->occupied = false; + + + } + } + + +} + diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/u_loadbitmap.h b/school/informatik/verkerhssimulation/src/verkehrssimulation/u_loadbitmap.h new file mode 100644 index 00000000..b28b04f6 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/u_loadbitmap.h @@ -0,0 +1,3 @@ + + + diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/u_physics.cpp b/school/informatik/verkerhssimulation/src/verkehrssimulation/u_physics.cpp new file mode 100644 index 00000000..5787c8a8 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/u_physics.cpp @@ -0,0 +1,147 @@ +#include "u_physics.h" +//#include "c_car.h" +//#include "c_data.h" +#pragma once + +float angle( float ax, float ay, float bx, float by) +{ + return ((ax*bx+ay*by) / sqrt(pow(ax, 2)+pow(ay, 2)) * sqrt(pow(bx, 2)+pow(by, 2))); +} + +void collisionDetection(CCar* car, CData* data) +{ + + CCar *frontcar; // Represents the car in front + float distanceFC; + bool frontcarset = false; + + // look for the frontcar + for (int i=0; icars[i].streetType == car->streetType && &data->cars[i] == car) + { + if ( sqrt( pow( (data->cars[i].posx - car->posx), 2) + pow( (data->cars[i].posy - car->posy), 2) ) < distanceFC ) + { + if ( abs( angle(car->directiony, car->directionx, data->cars[i].posx - car->posx, data->cars[i].posy - car->posy) ) < 20) + { + frontcar = &(data->cars[i]); + distanceFC = sqrt( pow( (data->cars[i].posx - car->posx), 2) + pow( (data->cars[i].posy - car->posy), 2) ); + frontcarset = true; + } + } + } + } + + + // calculate a new acceleration for the previously calculated distance + if (frontcarset == true) + { + // !!!!! Constant 20 has to be set so a suitible value + car->acceleration = sqrt(distanceFC) - 20 * car->aggressiveness * car->risk * car->velocity; + } + + // decide whether the car wants to override + if (distanceFC < 20 * car->risk * car->aggressiveness && frontcar->velocity < car->maxvelocity - 30) + { + // Mark that the car wants to overtake + car->driverState = 4; + } +} + +int checkForGap (CCar *car, int streetlane, CData* data) +{ + // calculate the number of StreetPoints for the length of the needed gap + + int n = (int) ((1/(car->risk * car->aggressiveness)) * car->velocity + 2); + + // look for nearest streetpoint on streetlane for the car (othogonal) + float streetx, streety, distanceCS = 10e10; + + //dummy + int j; + + for (int i=0; istreetsections[j].StreetPoints[i].lane == streetlane) + { + if ( sqrt( pow( (car->posx - data->streetsections[j].StreetPoints[i].x), 2) + pow( (car->posy - data->streetsections[j].StreetPoints[i].y), 2) ) < distanceCS ) + { + streetx = data->streetsections[j].StreetPoints[i].x; + streety = data->streetsections[j].StreetPoints[i].y; + distanceCS = sqrt( pow( (car->posx - data->streetsections[j].StreetPoints[i].x), 2) + pow( (car->posy - data->streetsections[j].StreetPoints[i].y), 2) ); + } + } + } + + + // check for free points on the streetlane and behind the car + float px, py, distanceSP = 10e10; + for (int i=0; istreetsections[j].StreetPoints[i].lane == streetlane) + { + if ( sqrt( pow( streetx-data->streetsections[j].StreetPoints[i].x, 2) + pow( streety-data->streetsections[j].StreetPoints[i].y, 2) ) < distanceSP) + if (streetx != data->streetsections[j].StreetPoints[i].x && streety != data->streetsections[j].StreetPoints[i].y) // not the same point as nearest point to car + if ( abs(angle(streetx-data->streetsections[j].StreetPoints[i].x, streety-data->streetsections[j].StreetPoints[i].y, car->directionx, car->directiony)) > 0.9) + { + px = data->streetsections[j].StreetPoints[i].x; + py = data->streetsections[j].StreetPoints[i].y; + distanceSP = sqrt( pow( streetx-data->streetsections[j].StreetPoints[i].x, 2) + pow( streety-data->streetsections[j].StreetPoints[i].y, 2) ); + } + } + } +} + +void calculateVelocity(int carnumber, CData* data) +{ + data->cars[carnumber].velocity = data->cars[carnumber].velocity + data->cars[carnumber].acceleration / systicks; + if (data->cars[carnumber].velocity > data->cars[carnumber].maxvelocity) + { + data->cars[carnumber].velocity = data->cars[carnumber].maxvelocity; + } +} + +void checkAcceleration(int carnumber, CData *data) +{ + if (data->cars[carnumber].acceleration > data->cars[carnumber].maxacceleration) + { + data->cars[carnumber].acceleration = data->cars[carnumber].maxacceleration; + } + if (data->cars[carnumber].acceleration < data->cars[carnumber].maxbrake) + { + data->cars[carnumber].acceleration = data->cars[carnumber].maxbrake; + } + if (data->cars[carnumber].acceleration < 0) + { + data->cars[carnumber].brakelight = 1; + } + else + { + data->cars[carnumber].brakelight = 0; + } +} + + + +void checkVelocity(int carnumber, CData *data) +{ + if (data->cars[carnumber].velocity > data->cars[carnumber].maxvelocity) + { + data->cars[carnumber].velocity = data->cars[carnumber].maxvelocity; + } + if (data->cars[carnumber].velocity < 0) + { + data->cars[carnumber].velocity = 0; + } +} + + +void calculatePosition(int carnumber, CData *data) +{ + data->cars[carnumber].posx = data->cars[carnumber].posx + (data->cars[carnumber].velocity / systicks) * data->cars[carnumber].directionx ; + data->cars[carnumber].posy = data->cars[carnumber].posy + (data->cars[carnumber].velocity / systicks) * data->cars[carnumber].directiony ; +} + + + + diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/u_physics.h b/school/informatik/verkerhssimulation/src/verkehrssimulation/u_physics.h new file mode 100644 index 00000000..d22a05b1 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/u_physics.h @@ -0,0 +1,13 @@ +#include "c_car.h" +#include "c_data.h" + +#pragma once +#define systicks 100.0 + +float angle( float ax, float ay, float bx, float by); +void collisionDetection(CCar* car, CData* data); +int checkForGap (CCar *car, int streetlane, CData* data); +void calculateVelocity(int carnumber, CData* data); +void checkAcceleration(int carnumber, CData* data); +void checkVelocity(int carnumber, CData *data); +void calculatePosition(int carnumber, CData* data); \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/verkehrssimulation.cpp b/school/informatik/verkerhssimulation/src/verkehrssimulation/verkehrssimulation.cpp new file mode 100644 index 00000000..42e4de99 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/verkehrssimulation.cpp @@ -0,0 +1,19 @@ +#include "verkehrssimulation.h" +#include "c_simulation.h" + +//Windows only +#define WIN32_LEAN_AND_MEAN +#include "windows.h" + +int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR strCmdLine, INT nCmdShow) +{ + CSimulation m_simulation(strCmdLine); + + //Start the Application and catch Errors + try{ m_simulation.go();} catch( Exception& e ) + { + if(m_simulation.m_ErrorExceptions) MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL); + } + + return 1; +} \ No newline at end of file diff --git a/school/informatik/verkerhssimulation/src/verkehrssimulation/verkehrssimulation.h b/school/informatik/verkerhssimulation/src/verkehrssimulation/verkehrssimulation.h new file mode 100644 index 00000000..706dc8e2 --- /dev/null +++ b/school/informatik/verkerhssimulation/src/verkehrssimulation/verkehrssimulation.h @@ -0,0 +1,31 @@ +//Hier kommen die Includes hinein. + +//Verhindern des Loopbacks +#pragma once + +//Ogre +#include +#include +#include +#include + +//Use this define to signify OIS will be used as a DLL +//(so that dll import/export macros are in effect) +#define OIS_DYNAMIC_LIB +#include + +//system +#include +#include + +//Namespaces +using namespace Ogre; +using namespace std; + +//Units +#include "..\u_stringoperations\u_stringoperations.h" +#include "..\u_path_operations\u_path_operations.h" +#include "..\u_typecasts\u_typecasts.h" + +//Main Function +int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR strCmdLine, INT nCmdShow); \ No newline at end of file diff --git a/school/informatik/ycfg/docu/ycfg.txt b/school/informatik/ycfg/docu/ycfg.txt new file mode 100644 index 00000000..e69de29b diff --git a/school/informatik/ycfg/old/ycfg 1.x/ycfg.pas b/school/informatik/ycfg/old/ycfg 1.x/ycfg.pas new file mode 100644 index 00000000..d1720aca --- /dev/null +++ b/school/informatik/ycfg/old/ycfg 1.x/ycfg.pas @@ -0,0 +1,616 @@ +unit ycfg; + +//v.1.015 + +interface + +uses sysutils,classes; + +//strings +function guckenobzeichenenthaltenist(infostring,searchstring,divideparam:String):boolean; +function dividestring(str,platzhalter:string;stellenzeiger:integer):string; +function getnumberofdivides(str,platzhalter:string):integer; + +//Wert + //get + +function getYcfgStr(Filename,info,platzhalter:string):string; overload; +function getYcfgStr(Filename,info:string):string; overload; +function getYcfgStr(StringlistWithFile:Tstringlist;info,platzhalter:string):string; overload; +function getYcfgStr(StringlistWithFile:Tstringlist;info:string):string; overload; + +function getYcfgInt(Filename,info,platzhalter:string;defaultint:integer):integer; overload; +function getYcfgInt(Filename,info:string;defaultint:integer):integer; overload; +function getYcfgInt(Filename,info:string):integer; overload; +function getYcfgInt(Filename:TStringlist;info,platzhalter:string;defaultint:integer):integer;overload; +function getYcfgInt(Filename:TStringlist;info:string;defaultint:integer):integer;overload; +function getYcfgInt(Filename:TStringlist;info:string):integer;overload; + +function getYcfgBool(Filename,info,platzhalter:string):boolean; overload; +function getYcfgBool(Filename,info:string):boolean; overload; +function getYcfgBool(StringlistWithFile:Tstringlist;info,platzhalter:string):boolean; overload; +function getYcfgBool(StringlistWithFile:Tstringlist;info:string):boolean; overload; + + //set +procedure setYcfgStr(Filename,info,wert,platzhalter:string);overload; +procedure setYcfgStr(Filename,info,wert:string);overload; +function setYcfgStr(StringlistWithFile:TStringlist;info,wert,platzhalter:string):TStringlist;overload; +function setYcfgStr(StringlistWithFile:TStringlist;info,wert:string):TStringlist;overload; + +procedure setYcfgInt(Filename,info,platzhalter:string;wert:integer);overload; +procedure setYcfgInt(Filename,info:string;wert:integer);overload; +function setYcfgInt(Filename:TStringlist;info,platzhalter:string;wert:integer):Tstringlist;overload; +function setYcfgInt(Filename:TStringlist;info:string;wert:integer):Tstringlist;overload; + +procedure setYcfgBool(Filename,info,platzhalter:string;wert,writtentrue:boolean);overload; +procedure setYcfgBool(Filename,info:string;wert,writtentrue:boolean);overload; +procedure setYcfgBool(Filename,info:string;wert:boolean);overload; +function setYcfgBool(StringlistWithFile:TStringlist;info,platzhalter:string;wert,writtentrue:boolean):TStringlist;overload; +function setYcfgBool(StringlistWithFile:TStringlist;info:string;wert,writtentrue:boolean):TStringlist;overload; +function setYcfgBool(StringlistWithFile:TStringlist;info:string;wert:boolean):TStringlist;overload; + +//Liste + //get +function getYcfgListe(filepath,divideparam,ignorelist,platzhalter:string):TStringlist; overload; +function getYcfgListe(StringlistWithFile:TStringlist;divideparam,ignorelist,platzhalter:string):TStringlist; overload; + +implementation + +function guckenobzeichenenthaltenist(infostring,searchstring,divideparam:String):boolean; +var count1:integer; +begin +//bsp: +// +// Rückgabewert von guckenobzeichenenthaltenist('1,2,3,4,5,6,7,8,9','1',',') ist true +// Dagegen ist guckenobzeichenenthaltenist('1,2,3,4,5,6,7,8,9','10',',') false + + result:=false; + count1:=getnumberofdivides(infostring,divideparam); + if count1>0 then + begin + repeat + if dividestring(infostring,divideparam,count1)=searchstring then result:=true; + count1:=count1-1; + until count1<=0; + end; + +end; + +function getycfgliste(StringlistWithFile:TStringlist;divideparam,ignorelist,platzhalter:string):TStringlist; overload; +var output:TStringlist; + count1,count2:integer; + test1,ende:boolean; +begin + +//Bsp: +// +// Textfile: +// ... +// //Foren +// ---Forum--- //Achtung neue function +// //Forumname;Forumkonfigdatei;infofile;guest;icon; +// Testenisscheiße +// +// ---Forum--- +// ... +// +// temp:=divideycfgfile(wheredistextfileare,'---Forum---','#;##;(*;//',';'); +// +// Das Ergebnis der function wäre in diesem Falle: "Testenisscheiße", weil alle +// leeren Zeilen und alle Zeilen mit #,##,(* und // am Anfang ignoriert werden. +// Außerdem alle leeren Zeilen. Es wird nur zwischen "---Forum---" gesucht. +// Der Letzte Parameter (platzhalter) (in diesem Falle ";") steht für den "Trenner" +// zu ignorierenden Zeilenanfängen! + + output:=TStringlist.create; + + ende:=false; + + if StringlistWithFile.count>0 then + begin + count1:=0; + repeat + if copy(StringlistWithFile.strings[count1],1,length(divideparam))=divideparam then + begin + count1:=count1+1; + repeat + if copy(StringlistWithFile.strings[count1],1,length(divideparam))=divideparam then ende:=true else + begin + if ende=false then + begin + count2:=1; + test1:=false; + + if getnumberofdivides(ignorelist,platzhalter)<>0 then + begin + repeat + if copy(StringlistWithFile.strings[count1],1,length(dividestring(ignorelist,platzhalter,count2)))= dividestring(ignorelist,platzhalter,count2) then test1:=true; + if StringlistWithFile.Strings[count1]='' then test1:=true; + count2:=count2+1; + until count2>=getnumberofdivides(ignorelist,platzhalter); + end; + + if test1=false then output.Add(StringlistWithFile.strings[count1]); + end; + end; + count1:=count1+1; + until count1>=StringlistWithFile.count; + end; + count1:=count1+1; + until count1>=StringlistWithFile.count-1; + end; + + result:=output; + + +end; + +function getycfgliste(filepath,divideparam,ignorelist,platzhalter:string):TStringlist; overload; +var temp,output:TStringlist; + count1,count2:integer; + test1,ende:boolean; +begin + +//Bsp: +// +// Textfile: +// ... +// //Foren +// ---Forum--- //Achtung neue function +// //Forumname;Forumkonfigdatei;infofile;guest;icon; +// Testenisscheiße +// +// ---Forum--- +// ... +// +// temp:=divideycfgfile(wheredistextfileare,'---Forum---','#;##;(*;//',';'); +// +// Das Ergebnis der function wäre in diesem Falle: "Testenisscheiße", weil alle +// leeren Zeilen und alle Zeilen mit #,##,(* und // am Anfang ignoriert werden. +// Außerdem alle leeren Zeilen. Es wird nur zwischen "---Forum---" gesucht. +// Der Letzte Parameter (platzhalter) (in diesem Falle ";") steht für den "Trenner" +// zu ignorierenden Zeilenanfängen! + + if fileexists(filepath) then + begin + temp:=TStringlist.create; + output:=TStringlist.create; + temp.loadfromfile(filepath); + + ende:=false; + + if temp.count>0 then + begin + count1:=0; + repeat + if copy(temp.strings[count1],1,length(divideparam))=divideparam then + begin + count1:=count1+1; + repeat + if copy(temp.strings[count1],1,length(divideparam))=divideparam then ende:=true else + begin + if ende=false then + begin + count2:=1; + test1:=false; + + if getnumberofdivides(ignorelist,platzhalter)<>0 then + begin + repeat + if copy(temp.strings[count1],1,length(dividestring(ignorelist,platzhalter,count2)))= dividestring(ignorelist,platzhalter,count2) then test1:=true; + if temp.Strings[count1]='' then test1:=true; + count2:=count2+1; + until count2>=getnumberofdivides(ignorelist,platzhalter); + end; + + if test1=false then output.Add(temp.strings[count1]); + end; + end; + count1:=count1+1; + until count1>=temp.count; + end; + count1:=count1+1; + until count1>=temp.count-1; + end; + temp.free; + end; + + result:=output; + + +end; + +function getnumberofdivides(str,platzhalter:string):integer; +var count1,divides:integer; +begin + +//Bsp: +// +// Diese function stellt fest, wie oft der string unterteilt +// worden ist mit dem Trenner "platzhalter". +// +// getnumberofdivides('test1;test2;test3;',';') gibt den Wert 3 aus. +// getnumberofdivides('test1;test2;test3',';') gibt auch den Wert 3 aus. + + if str='' then + begin + result:=0; + exit; + end; + + divides:=0; + count1:=1; + repeat + if copy(str,count1,1)=platzhalter then divides:=divides+1; + count1:=count1+1; + until count1>length(str); + + if copy(str,length(str),1)<>platzhalter then divides:=divides+1; + + result:=divides; + +end; + +function dividestring(str,platzhalter:string;stellenzeiger:integer):string; +var text1:string; + count1:integer; +begin + +//Bsp: text1;text2;text3 ... jetzt hast du diesen String... Die Function +// kann jetzt den string aufteilen in die drei +// Teile: +// +// dividestring('text1;text2;text3;',';',1) +// Das Ergebnis ist "text1" + + if length(str)>0 then + begin + + count1:=1; + text1:=''; + repeat + if copy(str,count1,1)=platzhalter then + begin + stellenzeiger:=stellenzeiger-1; + if stellenzeiger<=0 then + begin + result:=text1; + exit; + end; + text1:=''; + end else text1:=text1+copy(str,count1,1); + if count1=length(str) then + begin + result:=text1; + exit; + end; + count1:=count1+1; + until count1>length(str); + + end; + +end; + +function getYcfgStr(Filename,info:string):string; overload; +begin + + result:=getYcfgStr(Filename,info,'='); + +end; + +function getycfgStr(Filename,info,platzhalter:string):string; overload; +var text1:string; + count1,count2:integer; + test1:boolean; + ycfg:TStringlist; +begin +//Bsp: in einer textdatei filename steht der string test=123 , dann ist die rückgabe von getycfgwert(Filename,'test','=') = '123' + + if fileexists(filename) then + begin + ycfg:=TStringlist.create; + ycfg.LoadFromFile(filename); + + if ycfg.Count>0 then + begin + count1:=0; + repeat + text1:=''; + test1:=false; + count2:=1; + repeat + if copy(ycfg.Strings[count1],count2,1)<>platzhalter then text1:=text1+copy(ycfg.Strings[count1],count2,1) else test1:=true; + if count2>=length(ycfg.Strings[count1]) then test1:=true; + count2:=count2+1; + until test1=true; + + if lowercase(text1)=lowercase(info) then result:=copy(ycfg.Strings[count1],length(text1)+2,length(ycfg.strings[count1])); + count1:=count1+1; + until count1>=ycfg.Count; + end; + end; + +end; + +function getYcfgStr(StringlistWithFile:Tstringlist;info:string):string; overload; +begin + + result:=getYcfgStr(StringlistWithFile,info,'='); + +end; + +function getycfgStr(StringlistWithFile:Tstringlist;info,platzhalter:string):string; overload; +var text1:string; + count1,count2:integer; + test1:boolean; +begin + + if StringlistWithFile.Count>0 then + begin + count1:=0; + repeat + text1:=''; + test1:=false; + count2:=1; + repeat + if copy(StringlistWithFile.Strings[count1],count2,1)<>platzhalter then text1:=text1+copy(StringlistWithFile.Strings[count1],count2,1) else test1:=true; + if count2>=length(StringlistWithFile.Strings[count1]) then test1:=true; + count2:=count2+1; + until test1=true; + + if lowercase(text1)=lowercase(info) then result:=copy(StringlistWithFile.Strings[count1],length(text1)+2,length(StringlistWithFile.strings[count1])); + + count1:=count1+1; + until count1>=StringlistWithFile.Count; + end; + +end; + +function getYcfgInt(Filename,info:string):integer; overload; +begin + + result:=getYcfgInt(filename,info,'=',-1); + +end; + +function getYcfgInt(Filename,info:string;defaultint:integer):integer; overload; +begin + + result:=getYcfgInt(filename,info,'=',defaultint); + +end; + +function getycfgInt(Filename,info,platzhalter:string;defaultint:integer):integer; overload; +begin + + result:=strtointdef(getycfgStr(Filename,info,platzhalter),defaultint); + +end; + +function getYcfgInt(Filename:TStringlist;info:string):integer;overload; +begin + + result:=getYcfgInt(filename,info,'=',-1); + +end; + +function getYcfgInt(Filename:TStringlist;info:string;defaultint:integer):integer;overload; +begin + + result:=getYcfgInt(filename,info,'=',defaultint); + +end; + +function getycfgInt(Filename:TStringlist;info,platzhalter:string;defaultint:integer):integer; overload; +begin + + result:=strtointdef(getycfgStr(Filename,info,platzhalter),defaultint); + +end; + +function getYcfgBool(Filename,info:string):boolean; overload; +begin + + result:=getYcfgBool(filename,info,'='); + +end; + +function getYcfgBool(Filename,info,platzhalter:string):boolean; overload; +begin + + if (getycfgStr(filename,info,platzhalter)='1') or (lowercase(getycfgStr(filename,info,platzhalter))='true') then result:=true else result:=false; + +end; + +function getYcfgBool(StringlistWithFile:Tstringlist;info:string):boolean; overload; +begin + + result:=getYcfgBool(StringlistWithFile,info,'='); + +end; + +function getYcfgBool(StringlistWithFile:Tstringlist;info,platzhalter:string):boolean; overload; +begin + + if (getycfgStr(StringlistWithFile,info,platzhalter)='1') or (lowercase(getycfgStr(StringlistWithFile,info,platzhalter))='true') then result:=true else result:=false; + +end; + +procedure setYcfgStr(Filename,info,wert:string);overload; +begin + + setycfgstr(filename,info,wert,'='); + +end; + +procedure setycfgStr(Filename,info,wert,platzhalter:string); +var text1:string; + count1,count2:integer; + test1,test2:boolean; + ycfg:TSTringlist; +begin + + ycfg:=TStringlist.create; + + test2:=false; + if fileexists(filename) then + begin + ycfg.LoadFromFile(filename); + + if ycfg.Count>0 then + begin + count1:=0; + repeat + text1:=''; + test1:=false; + count2:=1; + repeat + if copy(ycfg.Strings[count1],count2,1)<>platzhalter then text1:=text1+copy(ycfg.Strings[count1],count2,1) else test1:=true; + if count2>=length(ycfg.Strings[count1]) then test1:=true; + count2:=count2+1; + until test1=true; + + if lowercase(text1)=lowercase(info) then + begin + test2:=true; + ycfg.Strings[count1]:=info+platzhalter+wert; + end; + + count1:=count1+1; + until count1>=ycfg.Count; + end; + end; + + if test2=false then ycfg.Add(info+platzhalter+wert); + + ycfg.SaveToFile(filename); + + ycfg.Free; + +end; + +function setYcfgStr(StringlistWithFile:TStringlist;info,wert:string):TStringlist;overload; +begin + + result:=setycfgstr(StringlistWithFile,info,wert,'='); + +end; + +function setycfgStr(StringlistWithFile:TStringlist;info,wert,platzhalter:string):TStringlist; +var text1:string; + count1,count2:integer; + test1,test2:boolean; +begin + + test2:=false; + if StringlistWithFile.Count>0 then + begin + count1:=0; + repeat + text1:=''; + test1:=false; + count2:=1; + repeat + if copy(StringlistWithFile.Strings[count1],count2,1)<>platzhalter then text1:=text1+copy(StringlistWithFile.Strings[count1],count2,1) else test1:=true; + if count2>=length(StringlistWithFile.Strings[count1]) then test1:=true; + count2:=count2+1; + until test1=true; + + if lowercase(text1)=lowercase(info) then + begin + test2:=true; + StringlistWithFile.Strings[count1]:=info+platzhalter+wert; + end; + + count1:=count1+1; + until count1>=StringlistWithFile.Count; + end; + + if test2=false then StringlistWithFile.Add(info+platzhalter+wert); + + result:=StringlistWithFile; +end; + +procedure setYcfgInt(Filename,info:string;wert:integer);overload; +begin + + setYcfgInt(filename,info,'=',wert); + +end; + +procedure setycfgInt(Filename,info,platzhalter:string;wert:integer);overload; +begin + + setycfgStr(Filename,info,inttostr(wert),platzhalter); + +end; + +function setYcfgInt(Filename:TStringlist;info:string;wert:integer):Tstringlist;overload; +begin + + result:=setYcfgInt(filename,info,'=',wert); + +end; + +function setycfgInt(Filename:TStringlist;info,platzhalter:string;wert:integer):TStringlist; overload +begin + + result:=setycfgStr(Filename,info,inttostr(wert),platzhalter); + +end; + +procedure setYcfgBool(Filename,info:string;wert:boolean);overload; +begin + + setYcfgBool(filename,info,'=',wert,false); + +end; + +procedure setYcfgBool(Filename,info:string;wert,writtentrue:boolean);overload; +begin + + setYcfgBool(filename,info,'=',wert,writtentrue); + +end; + +procedure setYcfgBool(Filename,info,platzhalter:string;wert,writtentrue:boolean);overload; +begin + + if wert then + begin + if writtentrue then setycfgStr(Filename,info,'true',platzhalter) else setycfgStr(Filename,info,'1',platzhalter); + end else + begin + if writtentrue then setycfgStr(Filename,info,'false',platzhalter) else setycfgStr(Filename,info,'0',platzhalter); + end; + +end; + +function setYcfgBool(StringlistWithFile:TStringlist;info:string;wert:boolean):TStringlist;overload; +begin + + result:=setYcfgBool(StringlistWithFile,info,'=',wert,false); + +end; + +function setYcfgBool(StringlistWithFile:TStringlist;info:string;wert,writtentrue:boolean):TStringlist;overload; +begin + + result:=setYcfgBool(StringlistWithFile,info,'=',wert,writtentrue); + +end; + +function setYcfgBool(StringlistWithFile:TStringlist;info,platzhalter:string;wert,writtentrue:boolean):TStringlist;overload; +begin + + if wert then + begin + if writtentrue then result:=setycfgStr(StringlistWithFile,info,'true',platzhalter) else result:=setycfgStr(StringlistWithFile,info,'1',platzhalter); + end else + begin + if writtentrue then result:=setycfgStr(StringlistWithFile,info,'false',platzhalter) else result:=setycfgStr(StringlistWithFile,info,'0',platzhalter); + end; + +end; + +end. diff --git a/school/informatik/ycfg/old/ycfg 2.x/Demo/YCFGDemo.cfg b/school/informatik/ycfg/old/ycfg 2.x/Demo/YCFGDemo.cfg new file mode 100644 index 00000000..18840108 --- /dev/null +++ b/school/informatik/ycfg/old/ycfg 2.x/Demo/YCFGDemo.cfg @@ -0,0 +1,35 @@ +-$A8 +-$B- +-$C+ +-$D+ +-$E- +-$F- +-$G+ +-$H+ +-$I+ +-$J- +-$K- +-$L+ +-$M- +-$N+ +-$O+ +-$P+ +-$Q- +-$R- +-$S- +-$T- +-$U- +-$V+ +-$W- +-$X+ +-$YD +-$Z1 +-cg +-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; +-H+ +-W+ +-M +-$M16384,1048576 +-K$00400000 +-LE"c:\programme\delphi\delphi 6\Projects\Bpl" +-LN"c:\programme\delphi\delphi 6\Projects\Bpl" diff --git a/school/informatik/ycfg/old/ycfg 2.x/Demo/YCFGDemo.dof b/school/informatik/ycfg/old/ycfg 2.x/Demo/YCFGDemo.dof new file mode 100644 index 00000000..c6d31c04 --- /dev/null +++ b/school/informatik/ycfg/old/ycfg 2.x/Demo/YCFGDemo.dof @@ -0,0 +1,83 @@ +[FileVersion] +Version=6.0 +[Compiler] +A=8 +B=0 +C=1 +D=1 +E=0 +F=0 +G=1 +H=1 +I=1 +J=0 +K=0 +L=1 +M=0 +N=1 +O=1 +P=1 +Q=0 +R=0 +S=0 +T=0 +U=0 +V=1 +W=0 +X=1 +Y=1 +Z=1 +ShowHints=1 +ShowWarnings=1 +UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; +[Linker] +MapFile=0 +OutputObjs=0 +ConsoleApp=1 +DebugInfo=0 +RemoteSymbols=0 +MinStackSize=16384 +MaxStackSize=1048576 +ImageBase=4194304 +ExeDescription= +[Directories] +OutputDir= +UnitOutputDir= +PackageDLLOutputDir= +PackageDCPOutputDir= +SearchPath= +Packages= +Conditionals= +DebugSourceDirs= +UsePackages=0 +[Parameters] +RunParams= +HostApplication= +Launcher= +UseLauncher=0 +DebugCWD= +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1031 +CodePage=1252 +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= diff --git a/school/informatik/ycfg/old/ycfg 2.x/Demo/YCFGDemo.dpr b/school/informatik/ycfg/old/ycfg 2.x/Demo/YCFGDemo.dpr new file mode 100644 index 00000000..d6334cd4 --- /dev/null +++ b/school/informatik/ycfg/old/ycfg 2.x/Demo/YCFGDemo.dpr @@ -0,0 +1,13 @@ +program YCFGDemo; + +uses + Forms, + uycfgdemo in 'uycfgdemo.pas' {fMain}; + +{$R *.res} + +begin + Application.Initialize; + Application.CreateForm(TfMain, fMain); + Application.Run; +end. diff --git a/school/informatik/ycfg/old/ycfg 2.x/Demo/YCFGDemo.exe b/school/informatik/ycfg/old/ycfg 2.x/Demo/YCFGDemo.exe new file mode 100644 index 00000000..3f0e8250 Binary files /dev/null and b/school/informatik/ycfg/old/ycfg 2.x/Demo/YCFGDemo.exe differ diff --git a/school/informatik/ycfg/old/ycfg 2.x/Demo/uycfgdemo.ddp b/school/informatik/ycfg/old/ycfg 2.x/Demo/uycfgdemo.ddp new file mode 100644 index 00000000..cdc0ee8c Binary files /dev/null and b/school/informatik/ycfg/old/ycfg 2.x/Demo/uycfgdemo.ddp differ diff --git a/school/informatik/ycfg/old/ycfg 2.x/Demo/uycfgdemo.dfm b/school/informatik/ycfg/old/ycfg 2.x/Demo/uycfgdemo.dfm new file mode 100644 index 00000000..143cf196 --- /dev/null +++ b/school/informatik/ycfg/old/ycfg 2.x/Demo/uycfgdemo.dfm @@ -0,0 +1,332 @@ +object fMain: TfMain + Left = 317 + Top = 230 + Width = 870 + Height = 640 + Caption = 'YCFG DEMO' + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + OldCreateOrder = False + PixelsPerInch = 96 + TextHeight = 13 + object PageControl1: TPageControl + Left = 0 + Top = 0 + Width = 862 + Height = 613 + ActivePage = TabSheet1 + Align = alClient + TabIndex = 0 + TabOrder = 0 + object TabSheet1: TTabSheet + Caption = 'Einleitung' + object Memo1: TMemo + Left = 0 + Top = 0 + Width = 854 + Height = 585 + Align = alClient + BevelInner = bvNone + BevelOuter = bvNone + BorderStyle = bsNone + Color = cl3DLight + Lines.Strings = ( + '' + 'YCFG Demo' + 'by Rylon t.H.D. a member of Yeminy' + '' + 'Diese Demo zeigt die Funktionen der ycfg unit auf.' + '' + + 'Die ycfg unit ist zum auslesen von configfiles '#228'hnlich den ini f' + + 'iles entwickelt worden.' + 'um sie einzubinden muss sie in den uses vermerkt werden:' + '' + 'Bsp:' + 'uses' + + ' Windows, Messages, SysUtils, Variants, Classes, Graphics, Cont' + + 'rols, Forms,' + ' Dialogs, ComCtrls, {!}ycfg{!}, StdCtrls;' + '' + + 'Au'#223'erdem muss sie sich auf dem Suchpfad befinden. Bzw im Program' + + 'mordner' + '' + 'Nun zum Praktischen: Bl'#228'tere eine Seite Weiter!') + TabOrder = 0 + end + end + object TabSheet2: TTabSheet + Caption = 'Strings' + ImageIndex = 1 + object Label1: TLabel + Left = 96 + Top = 275 + Width = 151 + Height = 13 + Caption = 'dividestring(Ausgangsstring.text,' + Color = clGray + Font.Charset = DEFAULT_CHARSET + Font.Color = clRed + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentColor = False + ParentFont = False + Transparent = True + end + object Label2: TLabel + Left = 520 + Top = 275 + Width = 6 + Height = 13 + Caption = ');' + Color = clGray + Font.Charset = DEFAULT_CHARSET + Font.Color = clRed + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentColor = False + ParentFont = False + Transparent = True + end + object Label3: TLabel + Left = 387 + Top = 275 + Width = 3 + Height = 13 + Caption = ',' + Color = clGray + Font.Charset = DEFAULT_CHARSET + Font.Color = clRed + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentColor = False + ParentFont = False + Transparent = True + end + object Label4: TLabel + Left = 8 + Top = 232 + Width = 482 + Height = 20 + Caption = + 'function dividestring(str,platzhalter:string;stellenzeiger:integ' + + 'er):string;' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentFont = False + end + object Label5: TLabel + Left = 8 + Top = 328 + Width = 406 + Height = 20 + Caption = 'function getnumberofdivides(str,platzhalter:string):integer;' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentFont = False + end + object Label6: TLabel + Left = 96 + Top = 371 + Width = 190 + Height = 13 + Caption = 'getnumberofdivides(Ausgangsstring.text,' + Color = clGray + Font.Charset = DEFAULT_CHARSET + Font.Color = clRed + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentColor = False + ParentFont = False + Transparent = True + end + object Label7: TLabel + Left = 424 + Top = 371 + Width = 6 + Height = 13 + Caption = ');' + Color = clGray + Font.Charset = DEFAULT_CHARSET + Font.Color = clRed + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentColor = False + ParentFont = False + Transparent = True + end + object ausgangsstring: TLabeledEdit + Left = 8 + Top = 192 + Width = 441 + Height = 21 + EditLabel.Width = 92 + EditLabel.Height = 13 + EditLabel.Caption = 'Der Ausgangsstring' + LabelPosition = lpAbove + LabelSpacing = 3 + TabOrder = 0 + Text = 'adam;eva;m'#252'ller;hallo;test;nochnezeichenfolge;' + end + object Memo3: TMemo + Left = 0 + Top = 496 + Width = 854 + Height = 89 + Align = alBottom + BevelInner = bvNone + BevelOuter = bvNone + BorderStyle = bsNone + Color = cl3DLight + Lines.Strings = ( + 'In der Praxis sieht das dann so aus:' + '' + 'temps ist eine string variable' + 'eineconfigvariable ist eine config variable' + '' + 'eineconfigvariable:=dividestring(temps,'#39';'#39',1);') + TabOrder = 1 + end + object Button1: TButton + Left = 8 + Top = 272 + Width = 75 + Height = 25 + Caption = 'Mache es' + TabOrder = 2 + OnClick = Button1Click + end + object Platzhalter: TLabeledEdit + Left = 264 + Top = 272 + Width = 121 + Height = 21 + EditLabel.Width = 49 + EditLabel.Height = 13 + EditLabel.Caption = 'Platzhalter' + LabelPosition = lpAbove + LabelSpacing = 3 + TabOrder = 3 + Text = ';' + end + object Stellenanzeige: TLabeledEdit + Left = 392 + Top = 272 + Width = 121 + Height = 21 + EditLabel.Width = 69 + EditLabel.Height = 13 + EditLabel.Caption = 'Stellenanzeige' + LabelPosition = lpAbove + LabelSpacing = 3 + TabOrder = 4 + Text = '3' + end + object Memo4: TMemo + Left = 0 + Top = 0 + Width = 854 + Height = 153 + Align = alTop + BevelInner = bvNone + BevelOuter = bvNone + BorderStyle = bsNone + Color = cl3DLight + Lines.Strings = ( + 'Strings k'#246'nnen mit der ycfg unit geteilt werden' + '' + + 'Solte der String nicht lang genug sein, wie die angegebene Stell' + + 'enanzeige, dann wird die lezte ausgegeben.' + '' + 'Bsp:' + '' + 'showmessage(devidestring(Ausgangsstring.text,'#39';'#39',8234395));' + '' + 'Die schowmessage w'#252'rde "nochnezeichenfolge" lauten. ' + '' + + 'Au'#223'erdem ist es nicht n'#246'tig am ende nocheinmal ein ";" zu setzen' + + ' - Probiers aus!') + TabOrder = 5 + end + object Button2: TButton + Left = 8 + Top = 368 + Width = 75 + Height = 25 + Caption = 'Mach es' + TabOrder = 6 + OnClick = Button2Click + end + object Platzhalter2: TLabeledEdit + Left = 296 + Top = 368 + Width = 121 + Height = 21 + EditLabel.Width = 49 + EditLabel.Height = 13 + EditLabel.Caption = 'Platzhalter' + LabelPosition = lpAbove + LabelSpacing = 3 + TabOrder = 7 + Text = ';' + end + end + object TabSheet3: TTabSheet + Caption = 'Config: Werte auslesen' + ImageIndex = 2 + end + object TabSheet4: TTabSheet + Caption = 'Config: Werte schreiben' + ImageIndex = 3 + end + object TabSheet5: TTabSheet + Caption = 'Config: Liste auslesen' + ImageIndex = 4 + end + object TabSheet6: TTabSheet + Caption = 'Config: Liste schreiben' + ImageIndex = 5 + end + object TabSheet7: TTabSheet + Caption = 'Contact' + ImageIndex = 6 + object Memo2: TMemo + Left = 0 + Top = 0 + Width = 854 + Height = 585 + Align = alClient + BevelInner = bvNone + BevelOuter = bvNone + BorderStyle = bsNone + Color = cl3DLight + Lines.Strings = ( + 'Contact:' + '' + + 'Du kannst mich '#252'ber rylon@web.de erreichen, soltlen Fragen oder ' + + 'Probleme auftreten.') + TabOrder = 0 + end + end + end +end diff --git a/school/informatik/ycfg/old/ycfg 2.x/Demo/uycfgdemo.pas b/school/informatik/ycfg/old/ycfg 2.x/Demo/uycfgdemo.pas new file mode 100644 index 00000000..fb3ee94e --- /dev/null +++ b/school/informatik/ycfg/old/ycfg 2.x/Demo/uycfgdemo.pas @@ -0,0 +1,65 @@ +unit uycfgdemo; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, ComCtrls, ycfg, StdCtrls, ExtCtrls; + +type + TfMain = class(TForm) + PageControl1: TPageControl; + TabSheet1: TTabSheet; + Memo1: TMemo; + TabSheet2: TTabSheet; + TabSheet3: TTabSheet; + TabSheet4: TTabSheet; + TabSheet5: TTabSheet; + TabSheet6: TTabSheet; + TabSheet7: TTabSheet; + Memo2: TMemo; + ausgangsstring: TLabeledEdit; + Memo3: TMemo; + Label1: TLabel; + Button1: TButton; + Platzhalter: TLabeledEdit; + Stellenanzeige: TLabeledEdit; + Label2: TLabel; + Label3: TLabel; + Memo4: TMemo; + Label4: TLabel; + Label5: TLabel; + Button2: TButton; + Label6: TLabel; + Platzhalter2: TLabeledEdit; + Label7: TLabel; + procedure Button1Click(Sender: TObject); + procedure Button2Click(Sender: TObject); + private + { Private declarations } + public + { Public declarations } + end; + +var + fMain: TfMain; + +implementation + +{$R *.dfm} + +procedure TfMain.Button1Click(Sender: TObject); +begin + + showmessage({aus der ycfg unit ->}divideAstring(ausgangsstring.text,platzhalter.text{Daslabeled edit},strtointdef(stellenanzeige.text,1))); + +end; + +procedure TfMain.Button2Click(Sender: TObject); +begin + + showmessage(inttostr(getStringDivides(ausgangsstring.Text,platzhalter2.text))); + +end; + +end. diff --git a/school/informatik/ycfg/old/ycfg 2.x/ycfg.pas b/school/informatik/ycfg/old/ycfg 2.x/ycfg.pas new file mode 100644 index 00000000..c1765514 --- /dev/null +++ b/school/informatik/ycfg/old/ycfg 2.x/ycfg.pas @@ -0,0 +1,2167 @@ +{ + + **************************************************************************** + | YCFG Unit Version 2.00 | + | | + | Copyright (c) 2006 by Yeminy | + | Copyright (c) 2006 by Rylon | + | | + | 165 Function/Procedures | + | | + | 165 Done : 0 ToDo >>> 100,00% Done : 0,00% ToDO | + | | + | 0 Tested : 165 ToDo >>> 0,00% Done : 100,00% ToDo | + | | + **************************************************************************** + + **************************************************************************** + | License: | + | | + **************************************************************************** + + **************************************************************************** + | ToDo: Falls es viele Keys gibt, alle in einer Liste ausgeben | + | Bsp: test=2135123 | + | test=213ds435dsf | + | | + | Comments automatisch löschen und immer eine Funktion um das zu | + | unterbinden | + | | + | Leerezeile einfügen | + | | + | get Section/List text (ohne Header) | + | | + | setYcfgSection -> text hinzufügen | + | | + **************************************************************************** + + **************************************************************************** + | ChangeLog: | + | -started project ycfg 2 | + **************************************************************************** + +} + +unit ycfg; + +interface + +uses SysUtils, Classes, windows, Graphics, ycode, dialogs; + +// OTHER***************************************************************************************************************************** //-- + //-- +//strings //-- +function isStringIncluded(SourceString,SearchString,DivideParam:String):boolean; overload; //w +function isStringIncluded(SourceString,SearchString:String):boolean; overload; //w + //-- +//function delStringPart(Sourcestring,DivideParam:string;Position:integer):string; // +//function delStringPart(Sourcestring:string;Position:integer):string; // +//function delStringPart(Sourcestring,Searchstring,DivideParam:string):string; // +//function delStringPart(Sourcestring,Searchstring:string):string; // + //-- +function DivideAString(SourceString,DivideParam:string;Position:integer):string; overload; //wt +function DivideAString(SourceString:string;Position:integer):string; overload; //wt + //-- +function getStringDivides(SourceString,DivideParam:string):integer; overload; //wt +function getStringDivides(SourceString:string):integer; overload; //wt + //-- +//sections //-- +procedure delYcfgSection(YcfgFile,Section:string); overload; //w +procedure delYcfgSection(var YcfgFile:TStringlist;Section:string); overload; //w + //-- +procedure createYcfgSection(YcfgFile,Section:string); overload; //w +procedure createYcfgSection(var YcfgFile:TStringlist;Section:string); overload; //w + //-- +procedure clearYcfgSection(YcfgFile,Section:string); overload; //w +procedure clearYcfgSection(var YcfgFile:TStringlist;Section:string); overload; //w + //-- +function YcfgSectionExists(YcfgFile,Section:string):boolean; overload; //w +function YcfgSectionExists(var YcfgFile:TStringlist;Section:string):boolean; overload; //w + //-- +//Ycfg File //-- + //-- +//function delComments(YcfgFile:string):boolean; overload; // +//function delComments(YcfgFile:TStringlist):boolean; overload; // + //-- +function checkYcfgHeader(YcfgFile:string):boolean; overload; //w +function checkYcfgHeader(YcfgFile:TStringlist):boolean; overload; //w + //-- +procedure writeYcfgHeader(YcfgFile:string); overload; //w +procedure writeYcfgHeader(YcfgFile:TStringlist); overload; //w + //-- +function readYcfgHeader(YcfgFile:string):string; overload; //w +function readYcfgHeader(YcfgFile:TStringlist):string; overload; //w + //-- +//Ycfg Unit //-- + //-- +function getYcfgVersion:string; //w + //-- +// GET******************************************************************************************************************************* //-- + //-- +//sections //-- +function getYcfgSections(YcfgFile:string):TStringList; overload; //w +function getYcfgSections(YcfgFile:TStringlist):TStringList; overload; //w + //-- +function getYcfgSection(YcfgFile,Section:string):TStringList; overload; //wt +function getYcfgSection(YcfgFile:TStringlist;Section:string):TStringList; overload; //wt + //-- +function getYcfgSectionKeys(YcfgFile,Section,DivideParam:string):TStringList; overload; //w +function getYcfgSectionKeys(YcfgFile,Section:string):TStringList; overload; //w +function getYcfgSectionKeys(YcfgFile:TStringlist;Section,DivideParam:string):TStringList; overload; //w +function getYcfgSectionKeys(YcfgFile:TStringlist;Section:string):TStringList; overload; //w + //-- +function getYcfgSectionNoKeys(YcfgFile,Section,DivideParam:string):TStringList; overload; //w +function getYcfgSectionNoKeys(YcfgFile,Section:string):TStringList; overload; //w +function getYcfgSectionNoKeys(YcfgFile:TStringlist;Section,DivideParam:string):TStringList; overload; //w +function getYcfgSectionNoKeys(YcfgFile:TStringlist;Section:string):TStringList; overload; //w + //-- +function getYcfgSectionValues(YcfgFile,Section,DivideParam:string):TStringList; overload; //w +function getYcfgSectionValues(YcfgFile,Section:string):TStringList; overload; //w +function getYcfgSectionValues(YcfgFile:TStringlist;Section,DivideParam:string):TStringList; overload; //w +function getYcfgSectionValues(YcfgFile:TStringlist;Section:string):TStringList; overload; //w + //-- +function getYcfgSectionPos(YcfgFile,Section:string):TPoint; overload; //w +function getYcfgSectionPos(YcfgFile:TStringlist;Section:string):TPoint; overload; //w + //-- +//String //-- + //global //-- +function getYcfgStr(YcfgFile,SearchString,DivideParam:string):string; overload; //w +function getYcfgStr(YcfgFile,SearchString:string):string; overload; //w +function getYcfgStr(YcfgFile:TStringlist;SearchString,DivideParam:string):string; overload; //w +function getYcfgStr(YcfgFile:Tstringlist;SearchString:string):string; overload; //w + //section //-- +function getYcfgSecStr(YcfgFile,Section,SearchString,DivideParam:string):string; overload; //wt +function getYcfgSecStr(YcfgFile,Section,SearchString:string):string; overload; //wt +function getYcfgSecStr(YcfgFile:TStringlist;Section,SearchString,DivideParam:string):string; overload; //wt +function getYcfgSecStr(YcfgFile:Tstringlist;Section,SearchString:string):string; overload; //wt + //-- +//Integer //-- + //global //-- +function getYcfgInt(YcfgFile,SearchString,DivideParam:string;DefaultValue:integer):integer; overload; //w +function getYcfgInt(YcfgFile,SearchString:string;DefaultValue:integer):integer; overload; //w +function getYcfgInt(YcfgFile:TStringlist;SearchString,DivideParam:string;DefaultValue:integer):integer; overload; //w +function getYcfgInt(YcfgFile:TStringlist;SearchString:string;DefaultValue:integer):integer; overload; //w + //section //-- +function getYcfgSecInt(YcfgFile,Section,SearchString,DivideParam:string;DefaultValue:integer):integer; overload; //w +function getYcfgSecInt(YcfgFile,Section,SearchString:string;DefaultValue:integer):integer; overload; //w +function getYcfgSecInt(YcfgFile:TStringlist;Section,SearchString,DivideParam:string;DefaultValue:integer):integer; overload; //w +function getYcfgSecInt(YcfgFile:TStringlist;Section,SearchString:string;DefaultValue:integer):integer; overload; //w + //-- +//Bool //-- + //global //-- +function getYcfgBool(YcfgFile,SearchString,DivideParam:string;DefaultValue:boolean):boolean; overload; //w +function getYcfgBool(YcfgFile,SearchString:string;DefaultValue:boolean):boolean; overload; //w +function getYcfgBool(YcfgFile:TStringlist;SearchString,DivideParam:string;DefaultValue:boolean):boolean; overload; //w +function getYcfgBool(YcfgFile:TStringlist;SearchString:string;DefaultValue:boolean):boolean; overload; //w + //section //-- +function getYcfgSecBool(YcfgFile,Section,SearchString,DivideParam:string;DefaultValue:boolean):boolean; overload; //w +function getYcfgSecBool(YcfgFile,Section,SearchString:string;DefaultValue:boolean):boolean; overload; //w +function getYcfgSecBool(YcfgFile:TStringlist;Section,SearchString,DivideParam:string;DefaultValue:boolean):boolean; overload; //w +function getYcfgSecBool(YcfgFile:TStringlist;Section,SearchString:string;DefaultValue:boolean):boolean; overload; //w + //-- +//DateTime //-- + //global //-- +function getYcfgDateTime(YcfgFile,SearchString,DivideParam:string;DefaultValue:TDateTime):TDateTime; overload; //w +function getYcfgDateTime(YcfgFile,SearchString:string;DefaultValue:TDateTime):TDateTime; overload; //w +function getYcfgDateTime(YcfgFile:TStringlist;SearchString,DivideParam:string;DefaultValue:TDateTime):TDateTime; overload; //w +function getYcfgDateTime(YcfgFile:TStringlist;SearchString:string;DefaultValue:TDateTime):TDateTime; overload; //w + //section //-- +function getYcfgSecDateTime(YcfgFile,Section,SearchString,DivideParam:string;DefaultValue:TDateTime):TDateTime; overload; //w +function getYcfgSecDateTime(YcfgFile,Section,SearchString:string;DefaultValue:TDateTime):TDateTime; overload; //w +function getYcfgSecDateTime(YcfgFile:TStringlist;Section,SearchString,DivideParam:string;DefaultValue:TDateTime):TDateTime; overload; //w +function getYcfgSecDateTime(YcfgFile:TStringlist;Section,SearchString:string;DefaultValue:TDateTime):TDateTime; overload; //w + //-- +//Font //-- + //global //-- +function getYcfgFont(YcfgFile,SearchString,DivideParam:string;DefaultValue:TFont):TFont; overload; //w +function getYcfgFont(YcfgFile,SearchString:string;DefaultValue:TFont):TFont; overload; //w +function getYcfgFont(YcfgFile:TStringlist;SearchString,DivideParam:string;DefaultValue:TFont):TFont; overload; //w +function getYcfgFont(YcfgFile:TStringlist;SearchString:string;DefaultValue:TFont):TFont; overload; //w + //section //-- +function getYcfgSecFont(YcfgFile,Section,SearchString,DivideParam:string;DefaultValue:TFont):TFont; overload; //w +function getYcfgSecFont(YcfgFile,Section,SearchString:string;DefaultValue:TFont):TFont; overload; //w +function getYcfgSecFont(YcfgFile:TStringlist;Section,SearchString,DivideParam:string;DefaultValue:TFont):TFont; overload; //w +function getYcfgSecFont(YcfgFile:TStringlist;Section,SearchString:string;DefaultValue:TFont):TFont; overload; //w + //-- +//DeCrypted String //-- + //global //-- +function getYcfgStrDeCrypted(YcfgFile,SearchString,DivideParam,Key:string):string; overload; //w +function getYcfgStrDeCrypted(YcfgFile,SearchString,Key:string):string; overload; //w +function getYcfgStrDeCrypted(YcfgFile:TStringlist;SearchString,DivideParam,Key:string):string; overload; //w +function getYcfgStrDeCrypted(YcfgFile:Tstringlist;SearchString,Key:string):string; overload; //w + //section //-- +function getYcfgSecStrDeCrypted(YcfgFile,Section,SearchString,DivideParam,Key:string):string; overload; //w +function getYcfgSecStrDeCrypted(YcfgFile,Section,SearchString,Key:string):string; overload; //w +function getYcfgSecStrDeCrypted(YcfgFile:TStringlist;Section,SearchString,DivideParam,Key:string):string; overload; //w +function getYcfgSecStrDeCrypted(YcfgFile:Tstringlist;Section,SearchString,Key:string):string; overload; //w + //-- +// SET******************************************************************************************************************************* //-- + //-- +//sections //-- +function setYcfgSections(YcfgFile,Sections:string;OverrideExisting:boolean):boolean; overload; //w +function setYcfgSections(var YcfgFile:TStringlist;Sections:string;OverrideExisting:boolean):boolean; overload; //w +function setYcfgSections(YcfgFile:string;Sections:TStringList;OverrideExisting:boolean):boolean; overload; //w +function setYcfgSections(var YcfgFile,Sections:TStringlist;OverrideExisting:boolean):boolean; overload; //w + //-- +function setYcfgSection(YcfgFile,Section,Value:string;OverrideExisting:boolean):boolean; overload; //w +function setYcfgSection(var YcfgFile:TStringList;Section,Value:string;OverrideExisting:boolean):boolean; overload; //w +function setYcfgSection(YcfgFile,Section:string;Value:TStringList;OverrideExisting:Boolean):boolean; overload; //w +function setYcfgSection(var YcfgFile:TStringlist;Section:string;Value:TStringList;OverrideExisting:Boolean):boolean; overload; //w + //-- +//String //-- + //global //-- +procedure setYcfgStr(YcfgFile,SearchString,DivideParam,Value:string); overload; //w +procedure setYcfgStr(YcfgFile,SearchString,Value:string); overload; //w +procedure setYcfgStr(var YcfgFile:Tstringlist;SearchString,DivideParam,Value:string); overload; //w +procedure setYcfgStr(var YcfgFile:Tstringlist;SearchString,Value:string); overload; //w + //section //-- +procedure setYcfgSecStr(YcfgFile,Section,SearchString,DivideParam,Value:string); overload; //wt +procedure setYcfgSecStr(YcfgFile,Section,SearchString,Value:string); overload; //wt +procedure setYcfgSecStr(var YcfgFile:Tstringlist;Section,SearchString,DivideParam,Value:string); overload; //wt +procedure setYcfgSecStr(var YcfgFile:Tstringlist;Section,SearchString,Value:string); overload; //wt + //-- +//Integer //-- + //global //-- +procedure setYcfgInt(YcfgFile,SearchString,DivideParam:string;Value:integer); overload; //w +procedure setYcfgInt(YcfgFile,SearchString:string;Value:integer); overload; //w +procedure setYcfgInt(var YcfgFile:Tstringlist;SearchString,DivideParam:string;Value:integer); overload; //w +procedure setYcfgInt(var YcfgFile:Tstringlist;SearchString:string;Value:integer); overload; //w + //section //-- +procedure setYcfgSecInt(YcfgFile,Section,SearchString,DivideParam:string;Value:integer); overload; //w +procedure setYcfgSecInt(YcfgFile,Section,SearchString:string;Value:integer); overload; //w +procedure setYcfgSecInt(var YcfgFile:Tstringlist;Section,SearchString,DivideParam:string;Value:integer); overload; //w +procedure setYcfgSecInt(var YcfgFile:Tstringlist;Section,SearchString:string;Value:integer); overload; //w + //-- +//Bool //-- + //global //-- +procedure setYcfgBool(YcfgFile,SearchString,DivideParam:string;Value:boolean); overload; //w +procedure setYcfgBool(YcfgFile,SearchString:string;Value:boolean); overload; //w +procedure setYcfgBool(var YcfgFile:Tstringlist;SearchString,DivideParam:string;Value:boolean); overload; //w +procedure setYcfgBool(var YcfgFile:Tstringlist;SearchString:string;Value:boolean); overload; //w + //section //-- +procedure setYcfgSecBool(YcfgFile,Section,SearchString,DivideParam:string;Value:boolean); overload; //w +procedure setYcfgSecBool(YcfgFile,Section,SearchString:string;Value:boolean); overload; //w +procedure setYcfgSecBool(var YcfgFile:Tstringlist;Section,SearchString,DivideParam:string;Value:boolean); overload; //w +procedure setYcfgSecBool(var YcfgFile:Tstringlist;Section,SearchString:string;Value:boolean); overload; //w + //-- +//DateTime //-- + //global //-- +procedure setYcfgDateTime(YcfgFile,SearchString,DivideParam:string;Value:TDateTime); overload; //w +procedure setYcfgDateTime(YcfgFile,SearchString:string;Value:TDateTime); overload; //w +procedure setYcfgDateTime(var YcfgFile:Tstringlist;SearchString,DivideParam:string;Value:TDateTime); overload; //w +procedure setYcfgDateTime(var YcfgFile:Tstringlist;SearchString:string;Value:TDateTime); overload; //w + //section //-- +procedure setYcfgSecDateTime(YcfgFile,Section,SearchString,DivideParam:string;Value:TDateTime); overload; //w +procedure setYcfgSecDateTime(YcfgFile,Section,SearchString:string;Value:TDateTime); overload; //w +procedure setYcfgSecDateTime(var YcfgFile:Tstringlist;Section,SearchString,DivideParam:string;Value:TDateTime); overload; //w +procedure setYcfgSecDateTime(var YcfgFile:Tstringlist;Section,SearchString:string;Value:TDateTime); overload; //w + //-- +//Font //-- + //global //-- +procedure setYcfgFont(YcfgFile,SearchString,DivideParam:string;Value:TFont); overload; //w +procedure setYcfgFont(YcfgFile,SearchString:string;Value:TFont); overload; //w +procedure setYcfgFont(var YcfgFile:Tstringlist;SearchString,DivideParam:string;Value:TFont); overload; //w +procedure setYcfgFont(var YcfgFile:Tstringlist;SearchString:string;Value:TFont); overload; //w + //section //-- +procedure setYcfgSecFont(YcfgFile,Section,SearchString,DivideParam:string;Value:TFont); overload; //w +procedure setYcfgSecFont(YcfgFile,Section,SearchString:string;Value:TFont); overload; //w +procedure setYcfgSecFont(var YcfgFile:Tstringlist;Section,SearchString,DivideParam:string;Value:TFont); overload; //w +procedure setYcfgSecFont(var YcfgFile:Tstringlist;Section,SearchString:string;Value:TFont); overload; //w + //-- +//EnCrypted String //-- + //global //-- +procedure setYcfgStrEnCrypted(YcfgFile,SearchString,DivideParam,Key,Value:string); overload; //w +procedure setYcfgStrEnCrypted(YcfgFile,SearchString,Key,Value:string); overload; //w +procedure setYcfgStrEnCrypted(var YcfgFile:Tstringlist;SearchString,DivideParam,Key,Value:string); overload; //w +procedure setYcfgStrEnCrypted(var YcfgFile:Tstringlist;SearchString,Key,Value:string); overload; //w + //section //-- +procedure setYcfgSecStrEnCrypted(YcfgFile,Section,SearchString,DivideParam,Key,Value:string); overload; //w +procedure setYcfgSecStrEnCrypted(YcfgFile,Section,SearchString,Key,Value:string); overload; //w +procedure setYcfgSecStrEnCrypted(var YcfgFile:Tstringlist;Section,SearchString,DivideParam,Key,Value:string); overload; //w +procedure setYcfgSecStrEnCrypted(var YcfgFile:Tstringlist;Section,SearchString,Key,Value:string); overload; //w + //-- +// Add******************************************************************************************************************************* //-- + //-- + //global //-- +//procedure addYcfgStr(YcfgFile,Value:string); overload; // +//procedure addYcfgStr(var YcfgFile:Tstringlist); overload; // +//procedure addYcfgStr(YcfgFile:string;Position:integer); overload; // +//procedure addYcfgStr(var YcfgFile:Tstringlist;Position:integer); overload; // + //Section //-- +//procedure addYcfgStr(YcfgFile,Section:string); overload; // +//procedure addYcfgStr(var YcfgFile:Tstringlist;Section:string;); overload; // +//procedure addYcfgStr(YcfgFile,Section:string;Position:integer); overload; // +//procedure addYcfgStr(var YcfgFile:Tstringlist;Section:string;Position:integer); overload; // + //-- + //global //-- +//procedure addYcfgSpaceLine(YcfgFile:string); overload; // +//procedure addYcfgSpaceLine(var YcfgFile:Tstringlist); overload; // +//procedure addYcfgSpaceLine(YcfgFile:string;Position:integer); overload; // +//procedure addYcfgSpaceLine(var YcfgFile:Tstringlist;Position:integer); overload; // + //Section //-- +//procedure addYcfgSecSpaceLine(YcfgFile,Section:string); overload; // +//procedure addYcfgSecSpaceLine(var YcfgFile:Tstringlist;Section:string;); overload; // +//procedure addYcfgSecSpaceLine(YcfgFile,Section:string;Position:integer); overload; // +//procedure addYcfgSecSpaceLine(var YcfgFile:Tstringlist;Section:string;Position:integer); overload; // + //-- + //gloabl //-- +//procedure addYcfgComment(YcfgFile,Value:string); overload; // +//procedure addYcfgComment(var YcfgFile:Tstringlist;Value:string); overload; // +//procedure addYcfgComment(YcfgFile:string;Position:integer;Value:string); overload; // +//procedure addYcfgComment(var YcfgFile:Tstringlist;Position:integer;Value:string); overload; // + //Section //-- +//procedure addYcfgSecComment(YcfgFile,Section,Value:string); overload; // +//procedure addYcfgSecComment(var YcfgFile:Tstringlist;Section,Value:string); overload; // +//procedure addYcfgSecComment(YcfgFile,Section:string;Position:integer;Value:string); overload; // +//procedure addYcfgSecComment(var YcfgFile:Tstringlist;Section:string;Position:integer;Value:string); overload; // + //-- +// Lists***************************************************************************************************************************** //-- + //-- +//get //-- +function getYcfgList(YcfgFile,ListHeader:string):TStringList; overload; //w +function getYcfgList(YcfgFile:TStringlist;ListHeader:string):TStringList; overload; //w + //-- +//set //-- +function setYcfgList(YcfgFile,ListHeader:string;List:TStringList;OverrideExisting:boolean):Boolean; overload; //w +function setYcfgList(var YcfgFile:TStringlist;ListHeader:string;List:TStringList;OverrideExisting:boolean):Boolean; overload; //w + //-- +//add //-- +{add to an existing List} //-- +procedure addYcfgList(YcfgFile,ListHeader:string;Value:TStringList); overload; //w +procedure addYcfgList(var YcfgFile:TStringlist;ListHeader:string;Value:TStringList); overload; //w + //-- +{Add only one string/int/bool} //-- +procedure addYcfgListStr(YcfgFile,ListHeader,Value:string); overload; //w +procedure addYcfgListStr(var YcfgFile:TStringlist;ListHeader,Value:string); overload; //w + //-- +procedure addYcfgListInt(YcfgFile,ListHeader:string;Value:integer); overload; //w +procedure addYcfgListInt(var YcfgFile:TStringlist;ListHeader:string;Value:integer); overload; //w + //-- +procedure addYcfgListComment(YcfgFile,ListHeader:string;Value:string); overload; //w +procedure addYcfgListComment(var YcfgFile:TStringlist;ListHeader:string;Value:string); overload; //w + //-- +procedure addYcfgListBool(YcfgFile,ListHeader:string;Value:boolean); overload; //w +procedure addYcfgListBool(var YcfgFile:TStringlist;ListHeader:string;Value:boolean); overload; //w + //-- +//misc //-- +function getYcfgListPos(YcfgFile,ListHeader:string):TPoint; overload; //w +function getYcfgListPos(YcfgFile:TStringlist;ListHeader:string):TPoint; overload; //w + //-- +procedure clearYcfgList(YcfgFile,ListHeader:string); overload; //w +procedure clearYcfgList(var YcfgFile:TStringlist;ListHeader:string); overload; //w + //-- +procedure delYcfgList(YcfgFile,ListHeader:string); overload; //w +procedure delYcfgList(var YcfgFile:TStringlist;ListHeader:string); overload; //w + //-- +function YcfgListExists(YcfgFile,ListHeader:string):boolean; overload; //w +function YcfgListExists(YcfgFile:TStringlist;ListHeader:string):boolean; overload; //w + //-- +const //-- + YcfgHeader = '$$YcfgFile 200 $$'; //-- + YcfgComments = '// ** (* ## >