Merge rev. 1524:1721 from trunk in order to get latest initialisation code and feature support for ogl-es driver.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@1722 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
0dd12c09ed
commit
51484af6d3
26
changes.txt
26
changes.txt
|
@ -3,6 +3,16 @@ TA, 01.09.2008
|
|||
|
||||
Changes in version 1.5 (... 2008)
|
||||
|
||||
- Basic support for joystick input events on OSX tested with xbox 360 wireless controller using driver http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/OsxDriver and a logictech wired controller
|
||||
|
||||
- ISceneNode::setParent and addChild now updates node SceneManager pointers if the node was from another SceneManager.
|
||||
|
||||
- Basic support for joystick input events on Windows, Linux and SDL devices.
|
||||
|
||||
- Major API change: RTTs are now created via addRenderTargetTexture instead of createRenderTargetTexture, which allows to retrieve them from the texture cache, but also changes the way of removing the RTTs, and especially one must not drop the pointer anymore.
|
||||
|
||||
- WindowsCE-Bugfix
|
||||
|
||||
- isBetweenPoints return true now even for the begin and end points, i.e. line segments are now including their start and end.
|
||||
|
||||
- Fix XML reader creation for non-existing files and invalid callbacks.
|
||||
|
@ -209,7 +219,19 @@ Changes in version 1.5 (... 2008)
|
|||
- Finally added StarSonata patch with table element and TabControl additions. Table is based on MultiColor listbox by Acki, and has loads of changes by CuteAlien.
|
||||
|
||||
-------------------------------------------
|
||||
Changes in version 1.4.2 (x.x.2008)
|
||||
Changes in version 1.4.2 (22.9.2008)
|
||||
|
||||
- Unified the handling of zwrite enable with transparent materials on all hw accelerated drivers. This means that all transparent materials will now disable ZWrite, ignoring the material flag.
|
||||
There is a scene manager attribute, though, which will revert this behavior to the usual SMaterial driven way. Simply call
|
||||
SceneManager->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true) and set the SMaterial flag as desired.
|
||||
|
||||
- Some changes for texture matrices in q3 shaders.
|
||||
|
||||
- Added BlindSide's irrAllocator patch for proper TextureMatrix release under Win32 with any CRT library.
|
||||
|
||||
- Added VC9 project files.
|
||||
|
||||
- Added getEmitter for particle system scene nodes.
|
||||
|
||||
- Fixed rounding problem in getScreenCoordinatesFrom3DPosition
|
||||
|
||||
|
@ -1287,7 +1309,7 @@ Changes in version 0.14.0 (30 November 2005)
|
|||
|
||||
- Lights now draw their bounding box and radius when debugdata is set to visible for them.
|
||||
|
||||
- Upgraded to irrXML 1.2. Thanks to some hints by Patrik Müller, irrXML, the XML parser used
|
||||
- Upgraded to irrXML 1.2. Thanks to some hints by Patrik Mller, irrXML, the XML parser used
|
||||
by the Irrlicht Engine now has CDATA support and some other useful new features.
|
||||
|
||||
- Support for VisualC++ (Express) 2005. Added a project file and a IrrlichtPropsVC2005.vsprops
|
||||
|
|
|
@ -1277,3 +1277,40 @@ New overload/missing method (completing the findLast... and find...Char methods)
|
|||
Changed signature (Added return value)
|
||||
string<T>& trim()
|
||||
|
||||
Changes for Version 1.4.2
|
||||
-------------------------
|
||||
This is once more a bugfix release of the 1.4 branch, and hence pretty API-consistent and backward compatible. The major reason to publish this release is the OpenGL bug, which made several OpenGL 2.x drivers run in SW emulation.
|
||||
However, we also introduced some driver consistency fixes, which might affect your application's behavior. So read through the next points thoroughly.
|
||||
|
||||
SceneParameters.h (and general video driver behavior)
|
||||
The way Irrlicht handles zbuffer writing with transparent materials has changed. This was an issue ever since, because the default behavior in Irrlicht is to disable writing to the z-buffer for all really transparent, i.e. blending materials. This avoids problems with intersecting faces, but can also break renderings. And this is now consistent for both OpenGL and Direct3D.
|
||||
If transparent materials should use the SMaterial flag for ZWriteEnable just as other material types use the newly introduced attribute scene::ALLOW_ZWRITE_ON_TRANSPARENT like this:
|
||||
SceneManager->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true);
|
||||
All transparent materials will henceforth work as specified by the material flag, until the scenemanager attribute is set to false.
|
||||
|
||||
SMaterialLayer.h
|
||||
The texture matrix now uses irrAllocator for memory handling. This shouldn't be noticeable from the user application (besides fixed heap corruptions on Windows machines), but is still mentioned for completeness.
|
||||
|
||||
ISceneNode.h
|
||||
Documentation error. The docs said that children of a scene node are not visible if the node itself is set to visible. This is of course wrong, children inherit non-visibility of the parent and are hence invisible if the parent is. If the parent is visible, the visibility flag of the child determines its status.
|
||||
|
||||
SColor.h
|
||||
Removed methods (use the unsigned versions and cast in your app if necessary)
|
||||
inline s32 getRedSigned(u16 color)
|
||||
inline s32 getGreenSigned(u16 color)
|
||||
inline s32 getBlueSigned(u16 color)
|
||||
|
||||
IParticleSystemSceneNode.h
|
||||
Changed default values (the old direction default was no real direction)
|
||||
virtual IParticleAnimatedMeshSceneNodeEmitter* createAnimatedMeshSceneNodeEmitter(...)
|
||||
virtual IParticleCylinderEmitter* createCylinderEmitter(...)
|
||||
virtual IParticleMeshEmitter* createMeshEmitter(...)
|
||||
|
||||
IBoneSceneNode.h
|
||||
Changed signature (Made const)
|
||||
virtual E_BONE_SKINNING_SPACE getSkinningSpace() const=0;
|
||||
|
||||
IrrlichtDevice.h
|
||||
Changed signature (Return value bool instead of void). Returns whether the event has been handled somewhere.
|
||||
virtual bool postEventFromUser(const SEvent& event) = 0;
|
||||
|
||||
|
|
|
@ -0,0 +1,230 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="01.HelloWorld_vc9"
|
||||
ProjectGUID="{5AD4C95C-BA38-4692-BA4B-8C25A86208F9}"
|
||||
RootNamespace="HelloWorld_vc9"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/HelloWorld.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/HelloWorld.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\01.HelloWorld.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/HelloWorld.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/HelloWorld.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/HelloWorld.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\01.HelloWorld.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
ProgramDatabaseFile=".\Release/HelloWorld.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,65 +1,67 @@
|
|||
/** Example 001 HelloWorld
|
||||
|
||||
/*
|
||||
This Tutorial shows how to set up the IDE for using the
|
||||
Irrlicht Engine and how to write a simple HelloWorld
|
||||
program with it. The program will show how to use the
|
||||
basics of the VideoDriver, the GUIEnvironment and the
|
||||
SceneManager.
|
||||
Microsoft Visual C++ 6.0 and .NET is used as
|
||||
example IDE, but you will also be able to understand everything
|
||||
if you are using a different one or even another operating
|
||||
system than windows.
|
||||
This Tutorial shows how to set up the IDE for using the Irrlicht Engine and how
|
||||
to write a simple HelloWorld program with it. The program will show how to use
|
||||
the basics of the VideoDriver, the GUIEnvironment, and the SceneManager.
|
||||
Microsoft Visual Studio is used as an IDE, but you will also be able to
|
||||
understand everything if you are using a different one or even another
|
||||
operating system than windows.
|
||||
|
||||
To use the engine, we will have to include the header file
|
||||
irrlicht.h, which can be found in the Irrlicht Engine SDK
|
||||
directory \include.
|
||||
To let the compiler find this header file, the directory where
|
||||
it is located should be specified somewhere. This is different
|
||||
for every IDE and compiler you use. I explain shortly how to
|
||||
do this in Microsift Visual Studio C++ 6.0 and .NET:
|
||||
You have to include the header file <irrlicht.h> in order to use the engine. The
|
||||
header file can be found in the Irrlicht Engine SDK directory \c include. To let
|
||||
the compiler find this header file, the directory where it is located has to be
|
||||
specified. This is different for every IDE and compiler you use. Let's explain
|
||||
shortly how to do this in Microsoft Visual Studio:
|
||||
|
||||
- If you use Version 6.0, select the Menu Extras -> Options.
|
||||
- If you use Version 6.0, select the Menu Extras -> Options.
|
||||
Select the directories tab, and select the 'Include' Item in the combo box.
|
||||
Add the \include directory of the irrlicht engine folder to the list of directories.
|
||||
Now the compiler will find the Irrlicht.h header file. We also
|
||||
need the irrlicht.lib to be found, so stay
|
||||
in that dialog, select 'Libraries' in the combo box and add the
|
||||
\lib\VisualStudio directory.
|
||||
Add the \c include directory of the irrlicht engine folder to the list of
|
||||
directories. Now the compiler will find the Irrlicht.h header file. We also
|
||||
need the irrlicht.lib to be found, so stay in that dialog, select 'Libraries'
|
||||
in the combo box and add the \c lib/VisualStudio directory.
|
||||
\image html "vc6optionsdir.jpg"
|
||||
\image latex "vc6optionsdir.jpg"
|
||||
\image html "vc6include.jpg"
|
||||
\image latex "vc6include.jpg"
|
||||
|
||||
- If your IDE is Visual Studio .NET, select Tools -> Options.
|
||||
Select the projects entry and then select VC++ directories.
|
||||
Select 'show directories for include files' in the combo box, and
|
||||
add the \include directory of the irrlicht engine folder to the list of directories.
|
||||
Now the compiler will find the Irrlicht.h header file. We also
|
||||
need the irrlicht.lib to be found, so stay
|
||||
in that dialog, select 'show directories for Library files' and add the
|
||||
\lib\VisualStudio directory.
|
||||
Select the projects entry and then select VC++ directories. Select 'show
|
||||
directories for include files' in the combo box, and add the \c include
|
||||
directory of the irrlicht engine folder to the list of directories. Now the
|
||||
compiler will find the Irrlicht.h header file. We also need the irrlicht.lib
|
||||
to be found, so stay in that dialog, select 'show directories for Library
|
||||
files' and add the \c lib/VisualStudio directory.
|
||||
\image html "vcnetinclude.jpg"
|
||||
\image latex "vcnetinclude.jpg"
|
||||
|
||||
That's it, with your IDE set up like this, you will now be able to
|
||||
develop applications with the Irrlicht Engine.
|
||||
That's it. With your IDE set up like this, you will now be able to develop
|
||||
applications with the Irrlicht Engine.
|
||||
|
||||
Lets start!
|
||||
|
||||
After we have set up the IDE, the compiler will know where to find the Irrlicht
|
||||
Engine header files so we can include it now in our code.
|
||||
*/
|
||||
#include <irrlicht.h>
|
||||
|
||||
/*
|
||||
In the Irrlicht Engine, everything can be found in the namespace
|
||||
'irr'. So if you want to use a class of the engine, you have to
|
||||
write an irr:: before the name of the class. For example to use
|
||||
the IrrlichtDevice write: irr::IrrlichtDevice. To get rid of the
|
||||
irr:: in front of the name of every class, we tell the compiler
|
||||
that we use that namespace from now on, and we will not have to
|
||||
write that 'irr::'.
|
||||
In the Irrlicht Engine, everything can be found in the namespace 'irr'. So if
|
||||
you want to use a class of the engine, you have to write irr:: before the name
|
||||
of the class. For example to use the IrrlichtDevice write: irr::IrrlichtDevice.
|
||||
To get rid of the irr:: in front of the name of every class, we tell the
|
||||
compiler that we use that namespace from now on, and we will not have to write
|
||||
irr:: anymore.
|
||||
*/
|
||||
using namespace irr;
|
||||
|
||||
/*
|
||||
There are 5 sub namespaces in the Irrlicht Engine. Take a look
|
||||
at them, you can read a detailed description of them in the
|
||||
documentation by clicking on the top menu item 'Namespace List'
|
||||
or using this link: http://irrlicht.sourceforge.net/docu/namespaces.html.
|
||||
Like the irr Namespace, we do not want these 5 sub namespaces now,
|
||||
to keep this example simple. Hence we tell the compiler again
|
||||
that we do not want always to write their names:
|
||||
/*
|
||||
There are 5 sub namespaces in the Irrlicht Engine. Take a look at them, you can
|
||||
read a detailed description of them in the documentation by clicking on the top
|
||||
menu item 'Namespace List' or by using this link:
|
||||
http://irrlicht.sourceforge.net/docu/namespaces.html
|
||||
Like the irr namespace, we do not want these 5 sub namespaces now, to keep this
|
||||
example simple. Hence, we tell the compiler again that we do not want always to
|
||||
write their names.
|
||||
*/
|
||||
using namespace core;
|
||||
using namespace scene;
|
||||
|
@ -68,46 +70,57 @@ using namespace io;
|
|||
using namespace gui;
|
||||
|
||||
/*
|
||||
To be able to use the Irrlicht.DLL file, we need to link with the
|
||||
Irrlicht.lib. We could set this option in the project settings, but
|
||||
to make it easy, we use a pragma comment lib:
|
||||
To be able to use the Irrlicht.DLL file, we need to link with the Irrlicht.lib.
|
||||
We could set this option in the project settings, but to make it easy, we use a
|
||||
pragma comment lib for VisualStudio. On Windows platforms, we have to get rid
|
||||
of the console window, which pops up when starting a program with main(). This
|
||||
is done by the second pragma. We could also use the WinMain method, though
|
||||
losing platform independence then.
|
||||
*/
|
||||
#ifdef _IRR_WINDOWS_
|
||||
#pragma comment(lib, "Irrlicht.lib")
|
||||
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
This is the main method. We can use int main() on every platform.
|
||||
On Windows platforms, we could also use the WinMain method
|
||||
if we would want to get rid of the console window, which pops up when
|
||||
starting a program with main(), but to keep this example simple,
|
||||
we use main().
|
||||
This is the main method. We can now use main() on every platform.
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
/*
|
||||
The most important function of the engine is the 'createDevice'
|
||||
function. The Irrlicht Device can be created with it, which is the
|
||||
root object for doing everything with the engine.
|
||||
createDevice() has 7 paramters:
|
||||
deviceType: Type of the device. This can currently be the Null-device,
|
||||
the Software device, the second software renderer, D3D8, D3D9, or OpenGL.
|
||||
In this example we use EDT_SOFTWARE, but to try out, you might want to change it to
|
||||
EDT_BURNINGSVIDEO, EDT_NULL, EDT_DIRECT3D8 , EDT_DIRECT3D9, or EDT_OPENGL.
|
||||
windowSize: Size of the Window or FullscreenMode to be created. In this
|
||||
example we use 640x480.
|
||||
bits: Amount of bits per pixel when in fullscreen mode. This should
|
||||
be 16 or 32. This parameter is ignored when running in windowed mode.
|
||||
fullscreen: Specifies if we want the device to run in fullscreen mode
|
||||
or not.
|
||||
stencilbuffer: Specifies if we want to use the stencil buffer for drawing shadows.
|
||||
vsync: Specifies if we want to have vsync enabled, this is only useful in fullscreen
|
||||
mode.
|
||||
eventReceiver: An object to receive events. We do not want to use this
|
||||
parameter here, and set it to 0.
|
||||
*/
|
||||
The most important function of the engine is the createDevice()
|
||||
function. The IrrlichtDevice is created by it, which is the root
|
||||
object for doing anything with the engine. createDevice() has 7
|
||||
parameters:
|
||||
|
||||
- deviceType: Type of the device. This can currently be the Null-device,
|
||||
one of the two software renderers, D3D8, D3D9, or OpenGL. In this
|
||||
example we use EDT_SOFTWARE, but to try out, you might want to
|
||||
change it to EDT_BURNINGSVIDEO, EDT_NULL, EDT_DIRECT3D8,
|
||||
EDT_DIRECT3D9, or EDT_OPENGL.
|
||||
|
||||
- windowSize: Size of the Window or screen in FullScreenMode to be
|
||||
created. In this example we use 640x480.
|
||||
|
||||
- bits: Amount of color bits per pixel. This should be 16 or 32. The
|
||||
parameter is often ignored when running in windowed mode.
|
||||
|
||||
- fullscreen: Specifies if we want the device to run in fullscreen mode
|
||||
or not.
|
||||
|
||||
- stencilbuffer: Specifies if we want to use the stencil buffer (for
|
||||
drawing shadows).
|
||||
|
||||
- vsync: Specifies if we want to have vsync enabled, this is only useful
|
||||
in fullscreen mode.
|
||||
|
||||
- eventReceiver: An object to receive events. We do not want to use this
|
||||
parameter here, and set it to 0.
|
||||
|
||||
Always check the return value to cope with unsupported drivers,
|
||||
dimensions, etc.
|
||||
*/
|
||||
IrrlichtDevice *device =
|
||||
#ifdef _IRR_OSX_PLATFORM_
|
||||
createDevice( video::EDT_OPENGL, dimension2d<s32>(640, 480), 16,
|
||||
|
@ -116,19 +129,21 @@ int main()
|
|||
createDevice( video::EDT_SOFTWARE, dimension2d<s32>(640, 480), 16,
|
||||
false, false, false, 0);
|
||||
#endif
|
||||
if (!device)
|
||||
return 1;
|
||||
|
||||
/*
|
||||
Set the caption of the window to some nice text. Note that there is
|
||||
a 'L' in front of the string. The Irrlicht Engine uses wide character
|
||||
Set the caption of the window to some nice text. Note that there is an
|
||||
'L' in front of the string. The Irrlicht Engine uses wide character
|
||||
strings when displaying text.
|
||||
*/
|
||||
device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
|
||||
|
||||
/*
|
||||
Get a pointer to the video driver, the SceneManager and the
|
||||
graphical user interface environment, so that
|
||||
we do not always have to write device->getVideoDriver(),
|
||||
device->getSceneManager() and device->getGUIEnvironment().
|
||||
Get a pointer to the VideoDriver, the SceneManager and the graphical
|
||||
user interface environment, so that we do not always have to write
|
||||
device->getVideoDriver(), device->getSceneManager(), or
|
||||
device->getGUIEnvironment().
|
||||
*/
|
||||
IVideoDriver* driver = device->getVideoDriver();
|
||||
ISceneManager* smgr = device->getSceneManager();
|
||||
|
@ -136,58 +151,65 @@ int main()
|
|||
|
||||
/*
|
||||
We add a hello world label to the window, using the GUI environment.
|
||||
The text is placed at the position (10,10) as top left corner and
|
||||
(260,22) as lower right corner.
|
||||
*/
|
||||
guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
|
||||
rect<s32>(10,10,260,22), true);
|
||||
|
||||
/*
|
||||
To display something interesting, we load a Quake 2 model
|
||||
and display it. We only have to get the Mesh from the Scene
|
||||
Manager (getMesh()) and add a SceneNode to display the mesh.
|
||||
(addAnimatedMeshSceneNode()). Instead of writing the filename
|
||||
sydney.md2, it would also be possible to load a Maya object file
|
||||
(.obj), a complete Quake3 map (.bsp) or a Milshape file (.ms3d).
|
||||
By the way, that cool Quake 2 model called sydney was modelled
|
||||
by Brian Collins.
|
||||
To show something interesting, we load a Quake 2 model and display it.
|
||||
We only have to get the Mesh from the Scene Manager with getMesh() and add
|
||||
a SceneNode to display the mesh with addAnimatedMeshSceneNode(). We
|
||||
check the return value of getMesh() to become aware of loading problems
|
||||
and other errors.
|
||||
|
||||
Instead of writing the filename sydney.md2, it would also be possible
|
||||
to load a Maya object file (.obj), a complete Quake3 map (.bsp) or any
|
||||
other supported file format. By the way, that cool Quake 2 model
|
||||
called sydney was modelled by Brian Collins.
|
||||
*/
|
||||
IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
|
||||
if (!mesh)
|
||||
return 1;
|
||||
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
|
||||
|
||||
/*
|
||||
To let the mesh look a little bit nicer, we change its material a
|
||||
little bit: We disable lighting because we do not have a dynamic light
|
||||
in here, and the mesh would be totally black. Then we set the frame
|
||||
loop, so that the animation is looped between the frames 0 and 310.
|
||||
And at last, we apply a texture to the mesh. Without it the mesh
|
||||
would be drawn using only a color.
|
||||
To let the mesh look a little bit nicer, we change its material. We
|
||||
disable lighting because we do not have a dynamic light in here, and
|
||||
the mesh would be totally black otherwise. Then we set the frame loop,
|
||||
such that the predefined STAND animation is used. And last, we apply a
|
||||
texture to the mesh. Without it the mesh would be drawn using only a
|
||||
color.
|
||||
*/
|
||||
if (node)
|
||||
{
|
||||
node->setMaterialFlag(EMF_LIGHTING, false);
|
||||
node->setMD2Animation ( scene::EMAT_STAND );
|
||||
node->setMD2Animation(scene::EMAT_STAND);
|
||||
node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") );
|
||||
}
|
||||
|
||||
/*
|
||||
To look at the mesh, we place a camera into 3d space at the position
|
||||
(0, 30, -40). The camera looks from there to (0,5,0).
|
||||
(0, 30, -40). The camera looks from there to (0,5,0), which is
|
||||
approximately the place where our md2 model is.
|
||||
*/
|
||||
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
|
||||
|
||||
/*
|
||||
Ok, now we have set up the scene, lets draw everything:
|
||||
We run the device in a while() loop, until the device does not
|
||||
want to run any more. This would be when the user closed the window
|
||||
or pressed ALT+F4 in windows.
|
||||
Ok, now we have set up the scene, lets draw everything: We run the
|
||||
device in a while() loop, until the device does not want to run any
|
||||
more. This would be when the user closes the window or presses ALT+F4
|
||||
(or whatever keycode closes a window).
|
||||
*/
|
||||
while(device->run())
|
||||
{
|
||||
/*
|
||||
Anything can be drawn between a beginScene() and an endScene()
|
||||
call. The beginScene clears the screen with a color and also the
|
||||
depth buffer if wanted. Then we let the Scene Manager and the
|
||||
GUI Environment draw their content. With the endScene() call
|
||||
everything is presented on the screen.
|
||||
call. The beginScene() call clears the screen with a color and
|
||||
the depth buffer, if desired. Then we let the Scene Manager and
|
||||
the GUI Environment draw their content. With the endScene()
|
||||
call everything is presented on the screen.
|
||||
*/
|
||||
driver->beginScene(true, true, SColor(255,100,101,140));
|
||||
|
||||
|
@ -198,17 +220,18 @@ int main()
|
|||
}
|
||||
|
||||
/*
|
||||
After we are finished, we have to delete the Irrlicht Device
|
||||
created before with createDevice(). In the Irrlicht Engine,
|
||||
you will have to delete all objects you created with a method or
|
||||
function which starts with 'create'. The object is simply deleted
|
||||
by calling ->drop().
|
||||
See the documentation at
|
||||
http://irrlicht.sourceforge.net//docu/classirr_1_1IUnknown.html#a3
|
||||
for more information.
|
||||
After we are done with the render loop, we have to delete the Irrlicht
|
||||
Device created before with createDevice(). In the Irrlicht Engine, you
|
||||
have to delete all objects you created with a method or function which
|
||||
starts with 'create'. The object is simply deleted by calling ->drop().
|
||||
See the documentation at irr::IReferenceCounted::drop() for more
|
||||
information.
|
||||
*/
|
||||
device->drop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
That's it. Compile and run.
|
||||
**/
|
||||
|
|
|
@ -0,0 +1,230 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="02.Quake3Map_vc9"
|
||||
ProjectGUID="{D1A464A2-D479-458C-98A2-60965D823CD1}"
|
||||
RootNamespace="Quake3Map_vc9"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/Quake3Map.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/Quake3Map.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\02.Quake3Map.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/Quake3Map.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/Quake3Map.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/Quake3Map.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\02.Quake3Map.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
ProgramDatabaseFile=".\Release/Quake3Map.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,49 +1,52 @@
|
|||
/*
|
||||
This Tutorial shows how to load a Quake 3 map into the
|
||||
engine, create a SceneNode for optimizing the speed of
|
||||
rendering and how to create a user controlled camera.
|
||||
/** Example 002 Quake3Map
|
||||
|
||||
Lets start like the HelloWorld example: We include
|
||||
the irrlicht header files and an additional file to be able
|
||||
to ask the user for a driver type using the console.
|
||||
This Tutorial shows how to load a Quake 3 map into the engine, create a
|
||||
SceneNode for optimizing the speed of rendering, and how to create a user
|
||||
controlled camera.
|
||||
|
||||
Please note that you should know the basics of the engine before starting this
|
||||
tutorial. Just take a short look at the first tutorial, if you haven't done
|
||||
this yet: http://irrlicht.sourceforge.net/tut001.html
|
||||
|
||||
Lets start like the HelloWorld example: We include the irrlicht header files
|
||||
and an additional file to be able to ask the user for a driver type using the
|
||||
console.
|
||||
*/
|
||||
#include <irrlicht.h>
|
||||
#include <iostream>
|
||||
|
||||
/*
|
||||
As already written in the HelloWorld example, in the Irrlicht
|
||||
Engine, everything can be found in the namespace 'irr'.
|
||||
To get rid of the irr:: in front of the name of every class,
|
||||
we tell the compiler that we use that namespace from now on,
|
||||
and we will not have to write that 'irr::'.
|
||||
There are 5 other sub namespaces 'core', 'scene', 'video',
|
||||
'io' and 'gui'. Unlike in the HelloWorld example,
|
||||
we do not a 'using namespace' for these 5 other namespaces
|
||||
because in this way you will see what can be found in which
|
||||
namespace. But if you like, you can also include the namespaces
|
||||
like in the previous example. Code just like you want to.
|
||||
As already written in the HelloWorld example, in the Irrlicht Engine everything
|
||||
can be found in the namespace 'irr'. To get rid of the irr:: in front of the
|
||||
name of every class, we tell the compiler that we use that namespace from now
|
||||
on, and we will not have to write that 'irr::'. There are 5 other sub
|
||||
namespaces 'core', 'scene', 'video', 'io' and 'gui'. Unlike in the HelloWorld
|
||||
example, we do not call 'using namespace' for these 5 other namespaces, because
|
||||
in this way you will see what can be found in which namespace. But if you like,
|
||||
you can also include the namespaces like in the previous example.
|
||||
*/
|
||||
using namespace irr;
|
||||
|
||||
/*
|
||||
Again, to be able to use the Irrlicht.DLL file, we need to link with the
|
||||
Irrlicht.lib. We could set this option in the project settings, but
|
||||
to make it easy, we use a pragma comment lib:
|
||||
Again, to be able to use the Irrlicht.DLL file, we need to link with the
|
||||
Irrlicht.lib. We could set this option in the project settings, but to make it
|
||||
easy, we use a pragma comment lib:
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "Irrlicht.lib")
|
||||
#endif
|
||||
|
||||
/*
|
||||
Ok, lets start. Again, we use the main() method as start, not the
|
||||
WinMain(), because its shorter to write.
|
||||
Ok, lets start. Again, we use the main() method as start, not the WinMain().
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
/*
|
||||
Like in the HelloWorld example, we create an IrrlichtDevice with
|
||||
createDevice(). The difference now is that we ask the user to select
|
||||
which hardware accelerated driver to use. The Software device would be
|
||||
createDevice(). The difference now is that we ask the user to select
|
||||
which video driver to use. The Software device might be
|
||||
too slow to draw a huge Quake 3 map, but just for the fun of it, we make
|
||||
this decision possible too.
|
||||
this decision possible, too.
|
||||
*/
|
||||
|
||||
// ask user for driver
|
||||
|
@ -79,36 +82,40 @@ int main()
|
|||
|
||||
/*
|
||||
Get a pointer to the video driver and the SceneManager so that
|
||||
we do not always have to write device->getVideoDriver() and
|
||||
device->getSceneManager().
|
||||
we do not always have to call irr::IrrlichtDevice::getVideoDriver() and
|
||||
irr::IrrlichtDevice::getSceneManager().
|
||||
*/
|
||||
video::IVideoDriver* driver = device->getVideoDriver();
|
||||
scene::ISceneManager* smgr = device->getSceneManager();
|
||||
|
||||
/*
|
||||
To display the Quake 3 map, we first need to load it. Quake 3 maps
|
||||
are packed into .pk3 files wich are nothing other than .zip files.
|
||||
So we add the .pk3 file to our FileSystem. After it was added,
|
||||
we are able to read from the files in that archive as they would
|
||||
directly be stored on disk.
|
||||
are packed into .pk3 files which are nothing else than .zip files.
|
||||
So we add the .pk3 file to our irr::io::IFileSystem. After it was added,
|
||||
we are able to read from the files in that archive as if they are
|
||||
directly stored on the disk.
|
||||
*/
|
||||
device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3");
|
||||
|
||||
/*
|
||||
Now we can load the mesh by calling getMesh(). We get a pointer returned
|
||||
to a IAnimatedMesh. As you know, Quake 3 maps are not really animated,
|
||||
they are only a huge chunk of static geometry with some materials
|
||||
attached. Hence the IAnimated mesh consists of only one frame,
|
||||
so we get the "first frame" of the "animation", which is our quake level
|
||||
and create an OctTree scene node with it, using addOctTreeSceneNode().
|
||||
The OctTree optimizes the scene a little bit, trying to draw only
|
||||
geometry which is currently visible. An alternative to the OctTree
|
||||
would be a MeshSceneNode, which would draw always the complete geometry
|
||||
of the mesh, without optimization. Try it out: Write addMeshSceneNode
|
||||
instead of addOctTreeSceneNode and compare the primitives drawn by the
|
||||
video driver. (There is a getPrimitiveCountDrawn() method in the
|
||||
IVideoDriver class). Note that this optimization with the Octree is only
|
||||
useful when drawing huge meshes consisting of lots of geometry.
|
||||
/*
|
||||
Now we can load the mesh by calling
|
||||
irr::scene::ISceneManager::getMesh(). We get a pointer returned to an
|
||||
irr::scene::IAnimatedMesh. As you might know, Quake 3 maps are not
|
||||
really animated, they are only a huge chunk of static geometry with
|
||||
some materials attached. Hence the IAnimatedMesh consists of only one
|
||||
frame, so we get the "first frame" of the "animation", which is our
|
||||
quake level and create an OctTree scene node with it, using
|
||||
irr::scene::ISceneManager::addOctTreeSceneNode().
|
||||
The OctTree optimizes the scene a little bit, trying to draw only geometry
|
||||
which is currently visible. An alternative to the OctTree would be a
|
||||
irr::scene::IMeshSceneNode, which would always draw the complete
|
||||
geometry of the mesh, without optimization. Try it: Use
|
||||
irr::scene::ISceneManager::addMeshSceneNode() instead of
|
||||
addOctTreeSceneNode() and compare the primitives drawn by the video
|
||||
driver. (There is a irr::video::IVideoDriver::getPrimitiveCountDrawn()
|
||||
method in the irr::video::IVideoDriver class). Note that this
|
||||
optimization with the OctTree is only useful when drawing huge meshes
|
||||
consisting of lots of geometry.
|
||||
*/
|
||||
scene::IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");
|
||||
scene::ISceneNode* node = 0;
|
||||
|
@ -118,58 +125,70 @@ int main()
|
|||
// node = smgr->addMeshSceneNode(mesh->getMesh(0));
|
||||
|
||||
/*
|
||||
Because the level was modelled not around the origin (0,0,0), we translate
|
||||
the whole level a little bit.
|
||||
Because the level was not modelled around the origin (0,0,0), we
|
||||
translate the whole level a little bit. This is done on
|
||||
irr::scene::ISceneNode level using the methods
|
||||
irr::scene::ISceneNode::setPosition() (in this case),
|
||||
irr::scene::ISceneNode::setRotation(), and
|
||||
irr::scene::ISceneNode::setScale().
|
||||
*/
|
||||
if (node)
|
||||
node->setPosition(core::vector3df(-1300,-144,-1249));
|
||||
|
||||
/*
|
||||
Now we only need a Camera to look at the Quake 3 map.
|
||||
And we want to create a user controlled camera. There are some
|
||||
different cameras available in the Irrlicht engine. For example the
|
||||
Maya Camera which can be controlled compareable to the camera in Maya:
|
||||
Now we only need a camera to look at the Quake 3 map.
|
||||
We want to create a user controlled camera. There are some
|
||||
cameras available in the Irrlicht engine. For example the
|
||||
MayaCamera which can be controlled like the camera in Maya:
|
||||
Rotate with left mouse button pressed, Zoom with both buttons pressed,
|
||||
translate with right mouse button pressed. This could be created with
|
||||
addCameraSceneNodeMaya(). But for this example, we want to create a
|
||||
camera which behaves like the ones in first person shooter games (FPS).
|
||||
irr::scene::ISceneManager::addCameraSceneNodeMaya(). But for this
|
||||
example, we want to create a camera which behaves like the ones in
|
||||
first person shooter games (FPS) and hence use
|
||||
irr::scene::ISceneManager::addCameraSceneNodeFPS().
|
||||
*/
|
||||
smgr->addCameraSceneNodeFPS();
|
||||
|
||||
/*
|
||||
The mouse cursor needs not to be visible, so we make it invisible.
|
||||
The mouse cursor needs not be visible, so we hide it via the
|
||||
irr::IrrlichtDevice::ICursorControl.
|
||||
*/
|
||||
|
||||
device->getCursorControl()->setVisible(false);
|
||||
|
||||
/*
|
||||
We have done everything, so lets draw it. We also write the current
|
||||
frames per second and the drawn primitives to the caption of the
|
||||
window. The 'if (device->isWindowActive())' line is optional, but
|
||||
prevents the engine render to set the position of the mouse cursor
|
||||
after task switching when other program are active.
|
||||
frames per second and the primitives drawn into the caption of the
|
||||
window. The test for irr::IrrlichtDevice::isWindowActive() is optional,
|
||||
but prevents the engine to grab the mouse cursor after task switching
|
||||
when other programs are active. The call to
|
||||
irr::IrrlichtDevice::yield() will avoid the busy loop to eat up all CPU
|
||||
cycles when the window is not active.
|
||||
*/
|
||||
int lastFPS = -1;
|
||||
|
||||
while(device->run())
|
||||
if (device->isWindowActive())
|
||||
{
|
||||
driver->beginScene(true, true, video::SColor(0,200,200,200));
|
||||
smgr->drawAll();
|
||||
driver->endScene();
|
||||
|
||||
int fps = driver->getFPS();
|
||||
|
||||
if (lastFPS != fps)
|
||||
if (device->isWindowActive())
|
||||
{
|
||||
core::stringw str = L"Irrlicht Engine - Quake 3 Map example [";
|
||||
str += driver->getName();
|
||||
str += "] FPS:";
|
||||
str += fps;
|
||||
driver->beginScene(true, true, video::SColor(255,200,200,200));
|
||||
smgr->drawAll();
|
||||
driver->endScene();
|
||||
|
||||
device->setWindowCaption(str.c_str());
|
||||
lastFPS = fps;
|
||||
int fps = driver->getFPS();
|
||||
|
||||
if (lastFPS != fps)
|
||||
{
|
||||
core::stringw str = L"Irrlicht Engine - Quake 3 Map example [";
|
||||
str += driver->getName();
|
||||
str += "] FPS:";
|
||||
str += fps;
|
||||
|
||||
device->setWindowCaption(str.c_str());
|
||||
lastFPS = fps;
|
||||
}
|
||||
}
|
||||
else
|
||||
device->yield();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -179,3 +198,6 @@ int main()
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
That's it. Compile and play around with the program.
|
||||
**/
|
||||
|
|
|
@ -0,0 +1,230 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="03.CustomSceneNode_vc9"
|
||||
ProjectGUID="{171CCDFA-C140-4956-8EB7-F0168F4521D3}"
|
||||
RootNamespace="CustomSceneNode_vc9"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/CustomSceneNode.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/CustomSceneNode.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\03.CustomSceneNode.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/CustomSceneNode.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/CustomSceneNode.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/CustomSceneNode.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\03.CustomSceneNode.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
ProgramDatabaseFile=".\Release/CustomSceneNode.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,14 +1,15 @@
|
|||
/*
|
||||
This Tutorial is a tutorial for more advanced developers.
|
||||
/** Example 003 Custom SceneNode
|
||||
|
||||
This Tutorial is more advanced than the previous ones.
|
||||
If you are currently just playing around with the Irrlicht
|
||||
engine, please look at other examples first.
|
||||
engine, you may want to look at other examples first.
|
||||
This tutorials shows how to create a custom scene node and
|
||||
how to use it in the engine. A custom scene node is needed,
|
||||
if you want to implement a render technique, the Irrlicht
|
||||
Engine is currently not supporting. For example you can write
|
||||
a indoor portal based renderer or a advanced terrain scene
|
||||
node with it. With creating custom scene nodes, you can
|
||||
easily extend the Irrlicht Engine and adapt it to your
|
||||
how to use it in the engine. A custom scene node is needed
|
||||
if you want to implement a render technique the Irrlicht
|
||||
Engine currently does not support. For example, you can write
|
||||
an indoor portal based renderer or an advanced terrain scene
|
||||
node with it. By creating custom scene nodes, you can
|
||||
easily extend the Irrlicht Engine and adapt it to your own
|
||||
needs.
|
||||
|
||||
I will keep the tutorial simple: Keep everything very
|
||||
|
@ -16,45 +17,49 @@ short, everything in one .cpp file, and I'll use the engine
|
|||
here as in all other tutorials.
|
||||
|
||||
To start, I include the header files, use the irr namespace,
|
||||
and tell the linker to link with the .lib file.
|
||||
and tell the linker to link with the .lib file.
|
||||
*/
|
||||
#include <irrlicht.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace irr;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "Irrlicht.lib")
|
||||
#endif
|
||||
|
||||
/*
|
||||
Here comes the most sophisticated part of this tutorial:
|
||||
Here comes the more sophisticated part of this tutorial:
|
||||
The class of our very own custom scene node. To keep it simple,
|
||||
our scene node will not be an indoor portal renderer nor a terrain
|
||||
scene node, but a simple tetraeder, a 3d object consiting of 4
|
||||
scene node, but a simple tetraeder, a 3d object consisting of 4
|
||||
connected vertices, which only draws itself and does nothing more.
|
||||
Note that this scenario does not require a custom scene node in Irrlicht.
|
||||
Instead one would create a mesh from the geometry and pass it to a
|
||||
irr::scene::IMeshSceneNode. This example just illustrates creation of a custom
|
||||
scene node in a very simple setting.
|
||||
|
||||
To let our scene node be able to be inserted into the Irrlicht
|
||||
Engine scene, the class we create needs only be derived from the
|
||||
ISceneNode class and has to override some methods.
|
||||
To let our scene node be able to be inserted into the Irrlicht
|
||||
Engine scene, the class we create needs to be derived from the
|
||||
irr::scene::ISceneNode class and has to override some methods.
|
||||
*/
|
||||
|
||||
class CSampleSceneNode : public scene::ISceneNode
|
||||
{
|
||||
|
||||
/*
|
||||
First, we declare some member variables. Some space to
|
||||
hold data for our tetraeder: The bounding box, 4 vertices, and
|
||||
the material of the tetraeder.
|
||||
First, we declare some member variables:
|
||||
The bounding box, 4 vertices, and the material of the tetraeder.
|
||||
*/
|
||||
core::aabbox3d<f32> Box;
|
||||
video::S3DVertex Vertices[4];
|
||||
video::SMaterial Material;
|
||||
|
||||
|
||||
/*
|
||||
The parameters of the constructor specify the parent of the scene node,
|
||||
a pointer to the scene manager, and an id of the scene node.
|
||||
In the constructor itself, we call the parent classes constructor,
|
||||
set some properties of the material we use to draw the scene nodem and
|
||||
In the constructor we call the parent class' constructor,
|
||||
set some properties of the material, and
|
||||
create the 4 vertices of the tetraeder we will draw later.
|
||||
*/
|
||||
|
||||
|
@ -66,39 +71,45 @@ public:
|
|||
Material.Wireframe = false;
|
||||
Material.Lighting = false;
|
||||
|
||||
Vertices[0] = video::S3DVertex(0,0,10, 1,1,0, video::SColor(255,0,255,255), 0, 1);
|
||||
Vertices[1] = video::S3DVertex(10,0,-10, 1,0,0, video::SColor(255,255,0,255), 1, 1);
|
||||
Vertices[2] = video::S3DVertex(0,20,0, 0,1,1, video::SColor(255,255,255,0), 1, 0);
|
||||
Vertices[3] = video::S3DVertex(-10,0,-10, 0,0,1, video::SColor(255,0,255,0), 0, 0);
|
||||
Vertices[0] = video::S3DVertex(0,0,10, 1,1,0,
|
||||
video::SColor(255,0,255,255), 0, 1);
|
||||
Vertices[1] = video::S3DVertex(10,0,-10, 1,0,0,
|
||||
video::SColor(255,255,0,255), 1, 1);
|
||||
Vertices[2] = video::S3DVertex(0,20,0, 0,1,1,
|
||||
video::SColor(255,255,255,0), 1, 0);
|
||||
Vertices[3] = video::S3DVertex(-10,0,-10, 0,0,1,
|
||||
video::SColor(255,0,255,0), 0, 0);
|
||||
|
||||
/*
|
||||
The Irrlicht Engine needs to know the bounding box of your scene node.
|
||||
It will use it for doing automatic culling and other things. Hence we
|
||||
need to create a bounding box from the 4 vertices we use.
|
||||
If you do not want the engine to use the box for automatic culling,
|
||||
and/or don't want to create the box, you could also write
|
||||
AutomaticCullingEnabled = false;.
|
||||
The Irrlicht Engine needs to know the bounding box of a scene node.
|
||||
It will use it for automatic culling and other things. Hence, we
|
||||
need to create a bounding box from the 4 vertices we use.
|
||||
If you do not want the engine to use the box for automatic culling,
|
||||
and/or don't want to create the box, you could also call
|
||||
irr::scene::ISceneNode::setAutomaticCulling() with irr::scene::EAC_OFF.
|
||||
*/
|
||||
Box.reset(Vertices[0].Pos);
|
||||
for (s32 i=1; i<4; ++i)
|
||||
Box.addInternalPoint(Vertices[i].Pos);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Before it is drawn, the OnRegisterSceneNode() method of every scene node in the scene
|
||||
is called by the scene manager. If the scene node wishes to draw itself,
|
||||
it may register itself in the scene manager to be drawn. This is necessary to
|
||||
tell the scene manager when it should call the ::render method. For example
|
||||
normal scene nodes render their content one after another, while
|
||||
stencil buffer shadows would like to be drawn after all other scene nodes. And
|
||||
camera or light scene nodes need to be rendered before all other scene
|
||||
nodes (if at all).
|
||||
So here we simply register the scene node to get render normally. If we would like
|
||||
to let it be rendered like cameras or light, we would have to call
|
||||
Before it is drawn, the irr::scene::ISceneNode::OnRegisterSceneNode()
|
||||
method of every scene node in the scene is called by the scene manager.
|
||||
If the scene node wishes to draw itself, it may register itself in the
|
||||
scene manager to be drawn. This is necessary to tell the scene manager
|
||||
when it should call irr::scene::ISceneNode::render(). For
|
||||
example, normal scene nodes render their content one after another,
|
||||
while stencil buffer shadows would like to be drawn after all other
|
||||
scene nodes. And camera or light scene nodes need to be rendered before
|
||||
all other scene nodes (if at all). So here we simply register the
|
||||
scene node to render normally. If we would like to let it be rendered
|
||||
like cameras or light, we would have to call
|
||||
SceneManager->registerNodeForRendering(this, SNRT_LIGHT_AND_CAMERA);
|
||||
After this, we call the OnRegisterSceneNode-method of the base class ISceneNode,
|
||||
which simply lets also all the child scene nodes of this node register themselves.
|
||||
After this, we call the actual
|
||||
irr::scene::ISceneNode::OnRegisterSceneNode() method of the base class,
|
||||
which simply lets also all the child scene nodes of this node register
|
||||
themselves.
|
||||
*/
|
||||
virtual void OnRegisterSceneNode()
|
||||
{
|
||||
|
@ -109,7 +120,7 @@ public:
|
|||
}
|
||||
|
||||
/*
|
||||
In the render() method most of the interesting stuff happenes: The
|
||||
In the render() method most of the interesting stuff happens: The
|
||||
Scene node renders itself. We override this method and draw the
|
||||
tetraeder.
|
||||
*/
|
||||
|
@ -124,13 +135,14 @@ public:
|
|||
}
|
||||
|
||||
/*
|
||||
At least, we create three small additional methods.
|
||||
GetBoundingBox() returns the bounding box of this scene node,
|
||||
GetMaterialCount() returns the amount of materials in this scene node
|
||||
(our tetraeder only has one material), and getMaterial() returns the
|
||||
And finally we create three small additional methods.
|
||||
irr::scene::ISceneNode::getBoundingBox() returns the bounding box of
|
||||
this scene node, irr::scene::ISceneNode::getMaterialCount() returns the
|
||||
amount of materials in this scene node (our tetraeder only has one
|
||||
material), and irr::scene::ISceneNode::getMaterial() returns the
|
||||
material at an index. Because we have only one material here, we can
|
||||
return the only one meterial, assuming that no one ever calls getMaterial()
|
||||
with an index greater than 0.
|
||||
return the only one material, assuming that no one ever calls
|
||||
getMaterial() with an index greater than 0.
|
||||
*/
|
||||
virtual const core::aabbox3d<f32>& getBoundingBox() const
|
||||
{
|
||||
|
@ -172,15 +184,15 @@ int main()
|
|||
case 'b': driverType = video::EDT_DIRECT3D8;break;
|
||||
case 'c': driverType = video::EDT_OPENGL; break;
|
||||
case 'd': driverType = video::EDT_SOFTWARE; break;
|
||||
case 'e': driverType = video::EDT_BURNINGSVIDEO; break;
|
||||
case 'e': driverType = video::EDT_BURNINGSVIDEO;break;
|
||||
case 'f': driverType = video::EDT_NULL; break;
|
||||
default: return 0;
|
||||
}
|
||||
|
||||
// create device
|
||||
|
||||
IrrlichtDevice *device =
|
||||
createDevice(driverType, core::dimension2d<s32>(640, 480), 16, false);
|
||||
IrrlichtDevice *device = createDevice(driverType,
|
||||
core::dimension2d<s32>(640, 480), 16, false);
|
||||
|
||||
if (device == 0)
|
||||
return 1; // could not create selected driver.
|
||||
|
@ -194,43 +206,55 @@ int main()
|
|||
|
||||
smgr->addCameraSceneNode(0, core::vector3df(0,-40,0), core::vector3df(0,0,0));
|
||||
|
||||
// Create our scene node. I don't check the result of calling new, as it
|
||||
// should throw an exception rather than returning 0 on failure.
|
||||
// Because the new node will create itself with a reference count of 1, and
|
||||
// then will have another reference added by its parent scene node when it is
|
||||
// added to the scene, I need to drop my reference to it. Best practice is
|
||||
// to drop it only *after* I have finished using it, regardless of what the
|
||||
// reference count of the object is after creation.
|
||||
CSampleSceneNode *myNode =
|
||||
/*
|
||||
Create our scene node. I don't check the result of calling new, as it
|
||||
should throw an exception rather than returning 0 on failure. Because
|
||||
the new node will create itself with a reference count of 1, and then
|
||||
will have another reference added by its parent scene node when it is
|
||||
added to the scene, I need to drop my reference to it. Best practice is
|
||||
to drop it only *after* I have finished using it, regardless of what
|
||||
the reference count of the object is after creation.
|
||||
*/
|
||||
CSampleSceneNode *myNode =
|
||||
new CSampleSceneNode(smgr->getRootSceneNode(), smgr, 666);
|
||||
|
||||
// To animate something in this boring scene consisting only of one tetraeder,
|
||||
// and to show, that you now can use your scene node like any other scene
|
||||
// node in the engine, we add an animator to the scene node, which rotates
|
||||
// the node a little bit.
|
||||
scene::ISceneNodeAnimator* anim =
|
||||
/*
|
||||
To animate something in this boring scene consisting only of one
|
||||
tetraeder, and to show that you now can use your scene node like any
|
||||
other scene node in the engine, we add an animator to the scene node,
|
||||
which rotates the node a little bit.
|
||||
irr::scene::ISceneManager::createRotationAnimator() could return 0, so
|
||||
should be checked.
|
||||
*/
|
||||
scene::ISceneNodeAnimator* anim =
|
||||
smgr->createRotationAnimator(core::vector3df(0.8f, 0, 0.8f));
|
||||
|
||||
// createRotationAnimator() could return 0, so should be checked
|
||||
if(anim)
|
||||
{
|
||||
myNode->addAnimator(anim);
|
||||
|
||||
// I'm done referring to anim, so must drop this reference now because it
|
||||
// was produced by a createFoo() function.
|
||||
/*
|
||||
I'm done referring to anim, so must
|
||||
irr::IReferenceCounted::drop() this reference now because it
|
||||
was produced by a createFoo() function. As I shouldn't refer to
|
||||
it again, ensure that I can't by setting to 0.
|
||||
*/
|
||||
anim->drop();
|
||||
anim = 0; // As I shouldn't refer to it again, ensure that I can't
|
||||
anim = 0;
|
||||
}
|
||||
|
||||
// I'm done with my CSampleSceneNode object, and so must drop my reference
|
||||
/*
|
||||
I'm done with my CSampleSceneNode object, and so must drop my reference.
|
||||
This won't delete the object, yet, because it is still attached to the
|
||||
scene graph, which prevents the deletion until the graph is deleted or the
|
||||
custom scene node is removed from it.
|
||||
*/
|
||||
myNode->drop();
|
||||
myNode = 0; // As I shouldn't refer to it again, ensure that I can't
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
Now draw everything and finish.
|
||||
*/
|
||||
|
||||
u32 frames=0;
|
||||
while(device->run())
|
||||
{
|
||||
|
@ -256,3 +280,6 @@ int main()
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
That's it. Compile and play around with the program.
|
||||
**/
|
||||
|
|
|
@ -0,0 +1,230 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="04.Movement_vc9"
|
||||
ProjectGUID="{7BDBB7E8-E0C9-4A0D-83C1-D389D6140FEF}"
|
||||
RootNamespace="Movement_vc9"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/Movement.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/Movement.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\04.Movement.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/Movement.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/Movement.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/Movement.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\04.Movement.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
ProgramDatabaseFile=".\Release/Movement.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,25 +1,34 @@
|
|||
/*
|
||||
/** Example 004 Movement
|
||||
|
||||
This Tutorial shows how to move and animate SceneNodes. The
|
||||
basic concept of SceneNodeAnimators is shown as well as manual
|
||||
movement of nodes using the keyboard.
|
||||
movement of nodes using the keyboard. We'll demonstrate framerate
|
||||
independent movement, which means moving by an amount dependent
|
||||
on the duration of the last run of the Irrlicht loop.
|
||||
|
||||
Example 19.MouseAndJoystick shows how to handle those kinds of input.
|
||||
|
||||
As always, I include the header files, use the irr namespace,
|
||||
and tell the linker to link with the .lib file.
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
// We'll also define this to stop MSVC complaining about sprintf().
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#pragma comment(lib, "Irrlicht.lib")
|
||||
#endif
|
||||
|
||||
#include <irrlicht.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace irr;
|
||||
|
||||
#pragma comment(lib, "Irrlicht.lib")
|
||||
|
||||
/*
|
||||
To receive events like mouse and keyboard input, or GUI events like
|
||||
"the OK button has been clicked", we need an object which is derived from the
|
||||
IEventReceiver object. There is only one method to override: OnEvent.
|
||||
This method will be called by the engine once when an event happens.
|
||||
What we really want to know is whether a key is being held down,
|
||||
and so we will remember the current state of each key.
|
||||
To receive events like mouse and keyboard input, or GUI events like "the OK
|
||||
button has been clicked", we need an object which is derived from the
|
||||
irr::IEventReceiver object. There is only one method to override:
|
||||
irr::IEventReceiver::OnEvent(). This method will be called by the engine once
|
||||
when an event happens. What we really want to know is whether a key is being
|
||||
held down, and so we will remember the current state of each key.
|
||||
*/
|
||||
class MyEventReceiver : public IEventReceiver
|
||||
{
|
||||
|
@ -39,7 +48,7 @@ public:
|
|||
{
|
||||
return KeyIsDown[keyCode];
|
||||
}
|
||||
|
||||
|
||||
MyEventReceiver()
|
||||
{
|
||||
for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
|
||||
|
@ -53,10 +62,11 @@ private:
|
|||
|
||||
|
||||
/*
|
||||
The event receiver for moving a scene node is ready. So lets just create
|
||||
an Irrlicht Device and the scene node we want to move. We also create some
|
||||
other additional scene nodes, to show that there are also some different
|
||||
possibilities to move and animate scene nodes.
|
||||
The event receiver for keeping the pressed keys is ready, the actual responses
|
||||
will be made inside the render loop, right before drawing the scene. So lets
|
||||
just create an irr::IrrlichtDevice and the scene node we want to move. We also
|
||||
create some other additional scene nodes, to show that there are also some
|
||||
different possibilities to move and animate scene nodes.
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
|
@ -86,20 +96,18 @@ int main()
|
|||
// create device
|
||||
MyEventReceiver receiver;
|
||||
|
||||
IrrlichtDevice* device = createDevice( driverType, core::dimension2d<s32>(640, 480),
|
||||
16, false, false, false, &receiver);
|
||||
IrrlichtDevice* device = createDevice(driverType,
|
||||
core::dimension2d<s32>(640, 480), 16, false, false, false, &receiver);
|
||||
|
||||
if (device == 0)
|
||||
return 1; // could not create selected driver.
|
||||
|
||||
|
||||
video::IVideoDriver* driver = device->getVideoDriver();
|
||||
scene::ISceneManager* smgr = device->getSceneManager();
|
||||
|
||||
|
||||
/*
|
||||
Create the node for moving it with the 'W' and 'S' key. We create a
|
||||
sphere node, which is a built in geometry primitive. We place the node
|
||||
Create the node which will be moved with the WSAD keys. We create a
|
||||
sphere node, which is a built-in geometry primitive. We place the node
|
||||
at (0,0,30) and assign a texture to it to let it look a little bit more
|
||||
interesting. Because we have no dynamic lights in this scene we disable
|
||||
lighting for each model (otherwise the models would be black).
|
||||
|
@ -112,15 +120,14 @@ int main()
|
|||
node->setMaterialFlag(video::EMF_LIGHTING, false);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Now we create another node, moving using a scene node animator. Scene
|
||||
/*
|
||||
Now we create another node, movable using a scene node animator. Scene
|
||||
node animators modify scene nodes and can be attached to any scene node
|
||||
like mesh scene nodes, billboards, lights and even camera scene nodes.
|
||||
Scene node animators are not only able to modify the position of a
|
||||
scene node, they can also animate the textures of an object for
|
||||
example. We create a cube scene node and attach a 'fly circle' scene
|
||||
node to it, letting this node fly around our sphere scene node.
|
||||
example. We create a cube scene node and attach a 'fly circle' scene
|
||||
node animator to it, letting this node fly around our sphere scene node.
|
||||
*/
|
||||
scene::ISceneNode* n = smgr->addCubeSceneNode();
|
||||
|
||||
|
@ -138,15 +145,16 @@ int main()
|
|||
}
|
||||
|
||||
/*
|
||||
The last scene node we add to show possibilities of scene node animators is
|
||||
The last scene node we add to show possibilities of scene node animators is
|
||||
a md2 model, which uses a 'fly straight' animator to run between to points.
|
||||
*/
|
||||
scene::IAnimatedMeshSceneNode* anms = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/sydney.md2"));
|
||||
scene::IAnimatedMeshSceneNode* anms =
|
||||
smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/sydney.md2"));
|
||||
|
||||
if (anms)
|
||||
{
|
||||
scene::ISceneNodeAnimator* anim =
|
||||
smgr->createFlyStraightAnimator(core::vector3df(100,0,60),
|
||||
smgr->createFlyStraightAnimator(core::vector3df(100,0,60),
|
||||
core::vector3df(-100,0,60), 2500, true);
|
||||
if (anim)
|
||||
{
|
||||
|
@ -155,14 +163,16 @@ int main()
|
|||
}
|
||||
|
||||
/*
|
||||
To make to model look right we set the frames between which the animation
|
||||
should loop, rotate the model around 180 degrees, and adjust the animation speed
|
||||
and the texture.
|
||||
To set the right animation (frames and speed), we would also be able to just
|
||||
call "anms->setMD2Animation(scene::EMAT_RUN)" for the 'run' animation
|
||||
instead of "setFrameLoop" and "setAnimationSpeed",
|
||||
but this only works with MD2 animations, and so you know how to start other animations.
|
||||
but it a good advice to use not hardcoded frame-numbers...
|
||||
To make the model look right we disable lighting, set the
|
||||
frames between which the animation should loop, rotate the
|
||||
model around 180 degrees, and adjust the animation speed and
|
||||
the texture. To set the right animation (frames and speed), we
|
||||
would also be able to just call
|
||||
"anms->setMD2Animation(scene::EMAT_RUN)" for the 'run'
|
||||
animation instead of "setFrameLoop" and "setAnimationSpeed",
|
||||
but this only works with MD2 animations, and so you know how to
|
||||
start other animations. But a good advice is to not use
|
||||
hardcoded frame-numbers...
|
||||
*/
|
||||
anms->setMaterialFlag(video::EMF_LIGHTING, false);
|
||||
|
||||
|
@ -180,7 +190,7 @@ int main()
|
|||
To be able to look at and move around in this scene, we create a first
|
||||
person shooter style camera and make the mouse cursor invisible.
|
||||
*/
|
||||
scene::ICameraSceneNode * cam = smgr->addCameraSceneNodeFPS(0, 100.0f, 100.0f);
|
||||
smgr->addCameraSceneNodeFPS(0, 100.0f, 100.0f);
|
||||
device->getCursorControl()->setVisible(false);
|
||||
|
||||
/*
|
||||
|
@ -188,7 +198,11 @@ int main()
|
|||
*/
|
||||
device->getGUIEnvironment()->addImage(
|
||||
driver->getTexture("../../media/irrlichtlogoalpha2.tga"),
|
||||
core::position2d<s32>(10,10));
|
||||
core::position2d<s32>(10,20));
|
||||
|
||||
gui::IGUIStaticText* diagnostics = device->getGUIEnvironment()->addStaticText(
|
||||
L"", core::rect<s32>(10, 10, 400, 20));
|
||||
diagnostics->setOverrideColor(video::SColor(255, 255, 255, 0));
|
||||
|
||||
/*
|
||||
We have done everything, so lets draw it. We also write the current
|
||||
|
@ -197,23 +211,35 @@ int main()
|
|||
*/
|
||||
int lastFPS = -1;
|
||||
|
||||
// In order to do framerate independent movement, we have to know
|
||||
// how long it was since the last frame
|
||||
u32 then = device->getTimer()->getTime();
|
||||
|
||||
// This is the movemen speed in units per second.
|
||||
const f32 MOVEMENT_SPEED = 5.f;
|
||||
|
||||
while(device->run())
|
||||
{
|
||||
/* Check if key W or key S is being held down, and move the
|
||||
sphere node up or down respectively.
|
||||
*/
|
||||
// Work out a frame delta time.
|
||||
const u32 now = device->getTimer()->getTime();
|
||||
const f32 frameDeltaTime = (f32)(now - then) / 1000.f; // Time in seconds
|
||||
then = now;
|
||||
|
||||
/* Check if keys W, S, A or D are being held down, and move the
|
||||
sphere node around respectively. */
|
||||
core::vector3df nodePosition = node->getPosition();
|
||||
|
||||
if(receiver.IsKeyDown(irr::KEY_KEY_W))
|
||||
{
|
||||
core::vector3df v = node->getPosition();
|
||||
v.Y += 0.02f;
|
||||
node->setPosition(v);
|
||||
}
|
||||
nodePosition.Y += MOVEMENT_SPEED * frameDeltaTime;
|
||||
else if(receiver.IsKeyDown(irr::KEY_KEY_S))
|
||||
{
|
||||
core::vector3df v = node->getPosition();
|
||||
v.Y -= 0.02f;
|
||||
node->setPosition(v);
|
||||
}
|
||||
nodePosition.Y -= MOVEMENT_SPEED * frameDeltaTime;
|
||||
|
||||
if(receiver.IsKeyDown(irr::KEY_KEY_A))
|
||||
nodePosition.X -= MOVEMENT_SPEED * frameDeltaTime;
|
||||
else if(receiver.IsKeyDown(irr::KEY_KEY_D))
|
||||
nodePosition.X += MOVEMENT_SPEED * frameDeltaTime;
|
||||
|
||||
node->setPosition(nodePosition);
|
||||
|
||||
driver->beginScene(true, true, video::SColor(255,113,113,133));
|
||||
|
||||
|
@ -228,7 +254,7 @@ int main()
|
|||
{
|
||||
core::stringw tmp(L"Movement Example - Irrlicht Engine [");
|
||||
tmp += driver->getName();
|
||||
tmp += L"] fps: ";
|
||||
tmp += L"] fps: ";
|
||||
tmp += fps;
|
||||
|
||||
device->setWindowCaption(tmp.c_str());
|
||||
|
@ -244,3 +270,6 @@ int main()
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
That's it. Compile and play around with the program.
|
||||
**/
|
||||
|
|
|
@ -0,0 +1,230 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="05.UserInterface_vc8"
|
||||
ProjectGUID="{622C9DD7-0391-49FF-AF53-24F9D5A8EC53}"
|
||||
RootNamespace="UserInterface_vc8"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/UserInterface.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/UserInterface.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\05.UserInterface.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/UserInterface.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/UserInterface.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/UserInterface.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\05.UserInterface.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
ProgramDatabaseFile=".\Release/UserInterface.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,8 +1,9 @@
|
|||
/*
|
||||
/** Example 005 User Interface
|
||||
|
||||
This tutorial shows how to use the built in User Interface of
|
||||
the Irrlicht Engine. It will give a brief overview and show
|
||||
how to create and use windows, buttons, scroll bars, static
|
||||
texts and list boxes.
|
||||
how to create and use windows, buttons, scroll bars, static
|
||||
texts, and list boxes.
|
||||
|
||||
As always, we include the header files, and use the irrlicht
|
||||
namespaces. We also store a pointer to the Irrlicht device,
|
||||
|
@ -32,13 +33,13 @@ IGUIListBox* listbox = 0;
|
|||
|
||||
/*
|
||||
The Event Receiver is not only capable of getting keyboard and
|
||||
mouse input events, but also events of the graphical user interface
|
||||
(gui). There are events for almost everything: Button click,
|
||||
mouse input events, but also events of the graphical user interface
|
||||
(gui). There are events for almost everything: Button click,
|
||||
Listbox selection change, events that say that a element was hovered
|
||||
and so on. To be able to react to some of these events, we create
|
||||
an event receiver.
|
||||
and so on. To be able to react to some of these events, we create
|
||||
an event receiver.
|
||||
We only react to gui events, and if it's such an event, we get the
|
||||
id of the caller (the gui element which caused the event) and get
|
||||
id of the caller (the gui element which caused the event) and get
|
||||
the pointer to the gui environment.
|
||||
*/
|
||||
class MyEventReceiver : public IEventReceiver
|
||||
|
@ -55,12 +56,12 @@ public:
|
|||
{
|
||||
|
||||
/*
|
||||
If a scrollbar changed its scroll position, and it is 'our'
|
||||
scrollbar (the one with id 104), then we change the
|
||||
transparency of all gui elements. This is a very easy task:
|
||||
There is a skin object, in which all color settings are stored.
|
||||
We simply go through all colors stored in the skin and change
|
||||
their alpha value.
|
||||
If a scrollbar changed its scroll position, and it is
|
||||
'our' scrollbar (the one with id 104), then we change
|
||||
the transparency of all gui elements. This is a very
|
||||
easy task: There is a skin object, in which all color
|
||||
settings are stored. We simply go through all colors
|
||||
stored in the skin and change their alpha value.
|
||||
*/
|
||||
case EGET_SCROLL_BAR_CHANGED:
|
||||
if (id == 104)
|
||||
|
@ -80,7 +81,7 @@ public:
|
|||
/*
|
||||
If a button was clicked, it could be one of 'our'
|
||||
three buttons. If it is the first, we shut down the engine.
|
||||
If it is the second, we create a little window with some
|
||||
If it is the second, we create a little window with some
|
||||
text on it. We also add a string to the list box to log
|
||||
what happened. And if it is the third button, we create
|
||||
a file open dialog, and add also this as string to the list box.
|
||||
|
@ -98,15 +99,15 @@ public:
|
|||
{
|
||||
listbox->addItem(L"Window created");
|
||||
cnt += 30;
|
||||
if (cnt > 200)
|
||||
if (cnt > 200)
|
||||
cnt = 0;
|
||||
|
||||
IGUIWindow* window = env->addWindow(
|
||||
rect<s32>(100 + cnt, 100 + cnt, 300 + cnt, 200 + cnt),
|
||||
rect<s32>(100 + cnt, 100 + cnt, 300 + cnt, 200 + cnt),
|
||||
false, // modal?
|
||||
L"Test window");
|
||||
|
||||
env->addStaticText(L"Please close me",
|
||||
env->addStaticText(L"Please close me",
|
||||
rect<s32>(35,35,140,50),
|
||||
true, // border?
|
||||
false, // wordwrap?
|
||||
|
@ -134,9 +135,9 @@ public:
|
|||
|
||||
|
||||
/*
|
||||
Ok, now for the more interesting part. First, create the
|
||||
Irrlicht device. As in some examples before, we ask the user which
|
||||
driver he wants to use for this example:
|
||||
Ok, now for the more interesting part. First, create the Irrlicht device. As in
|
||||
some examples before, we ask the user which driver he wants to use for this
|
||||
example:
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
|
@ -182,7 +183,7 @@ int main()
|
|||
|
||||
/*
|
||||
To make the font a little bit nicer, we load an external font
|
||||
and set it as the new default font in the skin.
|
||||
and set it as the new default font in the skin.
|
||||
To keep the standard font for tool tip text, we set it to
|
||||
the built-in font.
|
||||
*/
|
||||
|
@ -201,20 +202,24 @@ int main()
|
|||
the button in the event receiver.
|
||||
*/
|
||||
|
||||
env->addButton(rect<s32>(10,240,110,240 + 32), 0, 101, L"Quit", L"Exits Program");
|
||||
env->addButton(rect<s32>(10,280,110,280 + 32), 0, 102, L"New Window", L"Launches a new Window");
|
||||
env->addButton(rect<s32>(10,320,110,320 + 32), 0, 103, L"File Open", L"Opens a file");
|
||||
env->addButton(rect<s32>(10,240,110,240 + 32), 0, 101,
|
||||
L"Quit", L"Exits Program");
|
||||
env->addButton(rect<s32>(10,280,110,280 + 32), 0, 102,
|
||||
L"New Window", L"Launches a new Window");
|
||||
env->addButton(rect<s32>(10,320,110,320 + 32), 0, 103,
|
||||
L"File Open", L"Opens a file");
|
||||
|
||||
/*
|
||||
Now, we add a static text and a scrollbar, which modifies the
|
||||
transparency of all gui elements. We set the maximum value of
|
||||
the scrollbar to 255, because that's the maximal value for
|
||||
the scrollbar to 255, because that's the maximal value for
|
||||
a color value.
|
||||
Then we create an other static text and a list box.
|
||||
*/
|
||||
|
||||
env->addStaticText(L"Transparent Control:", rect<s32>(150,20,350,40), true);
|
||||
IGUIScrollBar* scrollbar = env->addScrollBar(true, rect<s32>(150, 45, 350, 60), 0, 104);
|
||||
IGUIScrollBar* scrollbar = env->addScrollBar(true,
|
||||
rect<s32>(150, 45, 350, 60), 0, 104);
|
||||
scrollbar->setMax(255);
|
||||
|
||||
// set scrollbar position to alpha value of an arbitrary element
|
||||
|
@ -224,7 +229,9 @@ int main()
|
|||
listbox = env->addListBox(rect<s32>(50, 140, 250, 210));
|
||||
env->addEditBox(L"Editable Text", rect<s32>(350, 80, 550, 100));
|
||||
|
||||
// add the engine logo
|
||||
/*
|
||||
And at last, we create a nice Irrlicht Engine logo in the top left corner.
|
||||
*/
|
||||
env->addImage(driver->getTexture("../../media/irrlichtlogo2.png"),
|
||||
position2d<int>(10,10));
|
||||
|
||||
|
@ -247,3 +254,6 @@ int main()
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
**/
|
||||
|
|
|
@ -0,0 +1,230 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="06.2DGraphics_vc9"
|
||||
ProjectGUID="{E71B6F18-10DC-4101-A541-F6D33F71B2BD}"
|
||||
RootNamespace="2DGraphics_vc9"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/2DGraphics.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/2DGraphics.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\06.2DGraphics.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
ProgramDatabaseFile=".\Release/2DGraphics.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/2DGraphics.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/2DGraphics.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\06.2DGraphics.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/2DGraphics.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,171 +1,176 @@
|
|||
/*
|
||||
This Tutorial shows how to do 2d graphics with the Irrlicht Engine.
|
||||
It shows how to draw images, keycolor based sprites,
|
||||
transparent rectangles and different fonts. You will may consider
|
||||
this useful if you want to make a 2d game with the engine, or if
|
||||
you want to draw a cool interface or head up display for your 3d game.
|
||||
|
||||
As always, I include the header files, use the irr namespace,
|
||||
and tell the linker to link with the .lib file.
|
||||
*/
|
||||
#include <irrlicht.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace irr;
|
||||
|
||||
#pragma comment(lib, "Irrlicht.lib")
|
||||
|
||||
/*
|
||||
At first, we let the user select the driver type, then
|
||||
start up the engine, set a caption, and get a pointer
|
||||
to the video driver.
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
// let user select driver type
|
||||
|
||||
video::E_DRIVER_TYPE driverType;
|
||||
|
||||
printf("Please select the driver you want for this example:\n"\
|
||||
" (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\
|
||||
" (d) Software Renderer\n (e) Burning's Software Renderer\n"\
|
||||
" (f) NullDevice\n (otherKey) exit\n\n");
|
||||
|
||||
char i;
|
||||
std::cin >> i;
|
||||
|
||||
switch(i)
|
||||
{
|
||||
case 'a': driverType = video::EDT_DIRECT3D9;break;
|
||||
case 'b': driverType = video::EDT_DIRECT3D8;break;
|
||||
case 'c': driverType = video::EDT_OPENGL; break;
|
||||
case 'd': driverType = video::EDT_SOFTWARE; break;
|
||||
case 'e': driverType = video::EDT_BURNINGSVIDEO;break;
|
||||
case 'f': driverType = video::EDT_NULL; break;
|
||||
default: return 0;
|
||||
}
|
||||
|
||||
// create device
|
||||
|
||||
IrrlichtDevice *device = createDevice(driverType,
|
||||
core::dimension2d<s32>(512, 384));
|
||||
|
||||
if (device == 0)
|
||||
return 1; // could not create selected driver.
|
||||
|
||||
device->setWindowCaption(L"Irrlicht Engine - 2D Graphics Demo");
|
||||
|
||||
video::IVideoDriver* driver = device->getVideoDriver();
|
||||
|
||||
/*
|
||||
All 2d graphics in this example are put together into one texture,
|
||||
2ddemo.bmp. Because we want to draw colorkey based sprites, we need
|
||||
to load this texture and tell the engine, which
|
||||
part of it should be transparent based on a colorkey. In this example,
|
||||
we don't tell it the color directly, we just say "Hey Irrlicht Engine,
|
||||
you'll find the color I want at position (0,0) on the texture.".
|
||||
Instead, it would be also possible to call
|
||||
driver->makeColorKeyTexture(images, video::SColor(0,0,0,0)), to make
|
||||
e.g. all black pixels transparent. Please note, that makeColorKeyTexture
|
||||
just creates an alpha channel based on the color.
|
||||
*/
|
||||
video::ITexture* images = driver->getTexture("../../media/2ddemo.bmp");
|
||||
driver->makeColorKeyTexture(images, core::position2d<s32>(0,0));
|
||||
|
||||
|
||||
/*
|
||||
To be able to draw some text with two different fonts, we load them.
|
||||
Ok, we load just one, as first font we just use the default font which is
|
||||
built into the engine.
|
||||
Also, we define two rectangles, which specify the position of the
|
||||
images of the red imps (little flying creatures) in the texture.
|
||||
*/
|
||||
gui::IGUIFont* font = device->getGUIEnvironment()->getBuiltInFont();
|
||||
gui::IGUIFont* font2 = device->getGUIEnvironment()->getFont("../../media/fonthaettenschweiler.bmp");
|
||||
|
||||
core::rect<s32> imp1(349,15,385,78);
|
||||
core::rect<s32> imp2(387,15,423,78);
|
||||
|
||||
|
||||
/*
|
||||
Everything is prepared, now we can draw everything in the draw loop,
|
||||
between the begin scene and end scene calls. In this example, we
|
||||
are just doing 2d graphics, but it would be no problem to mix them
|
||||
with 3d graphics. Just try it out, and draw some 3d vertices or set
|
||||
up a scene with the scene manager and draw it.
|
||||
*/
|
||||
while(device->run() && driver)
|
||||
{
|
||||
if (device->isWindowActive())
|
||||
{
|
||||
u32 time = device->getTimer()->getTime();
|
||||
|
||||
driver->beginScene(true, true, video::SColor(0,120,102,136));
|
||||
|
||||
/*
|
||||
First, we draw 3 sprites, using the alpha channel we created with
|
||||
makeColorKeyTexture. The last parameter specifiys that the drawing
|
||||
method should use thiw alpha channel. The parameter before the last
|
||||
one specifies a color, with wich the sprite should be colored.
|
||||
(255,255,255,255) is full white, so the sprite will look like the
|
||||
original. The third sprite is drawed colored based on the time.
|
||||
*/
|
||||
|
||||
// draw fire & dragons background world
|
||||
driver->draw2DImage(images, core::position2d<s32>(50,50),
|
||||
core::rect<s32>(0,0,342,224), 0,
|
||||
video::SColor(255,255,255,255), true);
|
||||
|
||||
// draw flying imp
|
||||
driver->draw2DImage(images, core::position2d<s32>(164,125),
|
||||
(time/500 % 2) ? imp1 : imp2, 0,
|
||||
video::SColor(255,255,255,255), true);
|
||||
|
||||
// draw second flying imp with colorcylce
|
||||
driver->draw2DImage(images, core::position2d<s32>(270,105),
|
||||
(time/500 % 2) ? imp1 : imp2, 0,
|
||||
video::SColor(255,(time) % 255,255,255), true);
|
||||
|
||||
/*
|
||||
Drawing text is really simple. The code should be self explanatory.
|
||||
*/
|
||||
|
||||
// draw some text
|
||||
if (font)
|
||||
font->draw(L"This demo shows that Irrlicht is also capable of drawing 2D graphics.",
|
||||
core::rect<s32>(130,10,300,50),
|
||||
video::SColor(255,255,255,255));
|
||||
|
||||
// draw some other text
|
||||
if (font2)
|
||||
font2->draw(L"Also mixing with 3d graphics is possible.",
|
||||
core::rect<s32>(130,20,300,60),
|
||||
video::SColor(255,time % 255,time % 255,255));
|
||||
|
||||
/*
|
||||
At last, we draw the Irrlicht Engine logo (without using a color or
|
||||
an alpha channel) and a transparent 2d Rectangle at the position of
|
||||
the mouse cursor.
|
||||
*/
|
||||
|
||||
// draw logo
|
||||
driver->draw2DImage(images, core::position2d<s32>(10,10),
|
||||
core::rect<s32>(354,87,442,118));
|
||||
|
||||
// draw transparent rect under cursor
|
||||
core::position2d<s32> m = device->getCursorControl()->getPosition();
|
||||
driver->draw2DRectangle(video::SColor(100,255,255,255),
|
||||
core::rect<s32>(m.X-20, m.Y-20, m.X+20, m.Y+20));
|
||||
|
||||
driver->endScene();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
That's all, it was not really difficult, I hope.
|
||||
*/
|
||||
|
||||
device->drop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
/** Example 006 2D Graphics
|
||||
|
||||
This Tutorial shows how to do 2d graphics with the Irrlicht Engine.
|
||||
It shows how to draw images, keycolor based sprites,
|
||||
transparent rectangles, and different fonts. You may consider
|
||||
this useful if you want to make a 2d game with the engine, or if
|
||||
you want to draw a cool interface or head up display for your 3d game.
|
||||
|
||||
As always, I include the header files, use the irr namespace,
|
||||
and tell the linker to link with the .lib file.
|
||||
*/
|
||||
#include <irrlicht.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace irr;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "Irrlicht.lib")
|
||||
#endif
|
||||
|
||||
/*
|
||||
At first, we let the user select the driver type, then start up the engine, set
|
||||
a caption, and get a pointer to the video driver.
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
// let user select driver type
|
||||
|
||||
video::E_DRIVER_TYPE driverType;
|
||||
|
||||
printf("Please select the driver you want for this example:\n"\
|
||||
" (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\
|
||||
" (d) Software Renderer\n (e) Burning's Software Renderer\n"\
|
||||
" (f) NullDevice\n (otherKey) exit\n\n");
|
||||
|
||||
char i;
|
||||
std::cin >> i;
|
||||
|
||||
switch(i)
|
||||
{
|
||||
case 'a': driverType = video::EDT_DIRECT3D9;break;
|
||||
case 'b': driverType = video::EDT_DIRECT3D8;break;
|
||||
case 'c': driverType = video::EDT_OPENGL; break;
|
||||
case 'd': driverType = video::EDT_SOFTWARE; break;
|
||||
case 'e': driverType = video::EDT_BURNINGSVIDEO;break;
|
||||
case 'f': driverType = video::EDT_NULL; break;
|
||||
default: return 0;
|
||||
}
|
||||
|
||||
// create device
|
||||
|
||||
IrrlichtDevice *device = createDevice(driverType,
|
||||
core::dimension2d<s32>(512, 384));
|
||||
|
||||
if (device == 0)
|
||||
return 1; // could not create selected driver.
|
||||
|
||||
device->setWindowCaption(L"Irrlicht Engine - 2D Graphics Demo");
|
||||
|
||||
video::IVideoDriver* driver = device->getVideoDriver();
|
||||
|
||||
/*
|
||||
All 2d graphics in this example are put together into one texture,
|
||||
2ddemo.bmp. Because we want to draw colorkey based sprites, we need to
|
||||
load this texture and tell the engine, which part of it should be
|
||||
transparent based on a colorkey.
|
||||
|
||||
In this example, we don't tell it the color directly, we just say "Hey
|
||||
Irrlicht Engine, you'll find the color I want at position (0,0) on the
|
||||
texture.". Instead, it would be also possible to call
|
||||
driver->makeColorKeyTexture(images, video::SColor(0,0,0,0)), to make
|
||||
e.g. all black pixels transparent. Please note that
|
||||
makeColorKeyTexture just creates an alpha channel based on the color.
|
||||
*/
|
||||
video::ITexture* images = driver->getTexture("../../media/2ddemo.bmp");
|
||||
driver->makeColorKeyTexture(images, core::position2d<s32>(0,0));
|
||||
|
||||
/*
|
||||
To be able to draw some text with two different fonts, we first load
|
||||
them. Ok, we load just one. As the first font we just use the default
|
||||
font which is built into the engine. Also, we define two rectangles
|
||||
which specify the position of the images of the red imps (little flying
|
||||
creatures) in the texture.
|
||||
*/
|
||||
gui::IGUIFont* font = device->getGUIEnvironment()->getBuiltInFont();
|
||||
gui::IGUIFont* font2 =
|
||||
device->getGUIEnvironment()->getFont("../../media/fonthaettenschweiler.bmp");
|
||||
|
||||
core::rect<s32> imp1(349,15,385,78);
|
||||
core::rect<s32> imp2(387,15,423,78);
|
||||
|
||||
/*
|
||||
Everything is prepared, now we can draw everything in the draw loop,
|
||||
between the begin scene and end scene calls. In this example, we are
|
||||
just doing 2d graphics, but it would be no problem to mix them with 3d
|
||||
graphics. Just try it out, and draw some 3d vertices or set up a scene
|
||||
with the scene manager and draw it.
|
||||
*/
|
||||
while(device->run() && driver)
|
||||
{
|
||||
if (device->isWindowActive())
|
||||
{
|
||||
u32 time = device->getTimer()->getTime();
|
||||
|
||||
driver->beginScene(true, true, video::SColor(255,120,102,136));
|
||||
|
||||
/*
|
||||
First, we draw 3 sprites, using the alpha channel we
|
||||
created with makeColorKeyTexture. The last parameter
|
||||
specifies that the drawing method should use this alpha
|
||||
channel. The last-but-one parameter specifies a
|
||||
color, with which the sprite should be colored.
|
||||
(255,255,255,255) is full white, so the sprite will
|
||||
look like the original. The third sprite is drawn
|
||||
with the red channel modulated based on the time.
|
||||
*/
|
||||
|
||||
// draw fire & dragons background world
|
||||
driver->draw2DImage(images, core::position2d<s32>(50,50),
|
||||
core::rect<s32>(0,0,342,224), 0,
|
||||
video::SColor(255,255,255,255), true);
|
||||
|
||||
// draw flying imp
|
||||
driver->draw2DImage(images, core::position2d<s32>(164,125),
|
||||
(time/500 % 2) ? imp1 : imp2, 0,
|
||||
video::SColor(255,255,255,255), true);
|
||||
|
||||
// draw second flying imp with colorcylce
|
||||
driver->draw2DImage(images, core::position2d<s32>(270,105),
|
||||
(time/500 % 2) ? imp1 : imp2, 0,
|
||||
video::SColor(255,(time) % 255,255,255), true);
|
||||
|
||||
/*
|
||||
Drawing text is really simple. The code should be self
|
||||
explanatory.
|
||||
*/
|
||||
|
||||
// draw some text
|
||||
if (font)
|
||||
font->draw(L"This demo shows that Irrlicht is also capable of drawing 2D graphics.",
|
||||
core::rect<s32>(130,10,300,50),
|
||||
video::SColor(255,255,255,255));
|
||||
|
||||
// draw some other text
|
||||
if (font2)
|
||||
font2->draw(L"Also mixing with 3d graphics is possible.",
|
||||
core::rect<s32>(130,20,300,60),
|
||||
video::SColor(255,time % 255,time % 255,255));
|
||||
|
||||
/*
|
||||
At last, we draw the Irrlicht Engine logo (without
|
||||
using a color or an alpha channel) and a transparent 2d
|
||||
Rectangle at the position of the mouse cursor.
|
||||
*/
|
||||
|
||||
// draw logo
|
||||
driver->draw2DImage(images, core::position2d<s32>(10,10),
|
||||
core::rect<s32>(354,87,442,118));
|
||||
|
||||
// draw transparent rect under cursor
|
||||
core::position2d<s32> m = device->getCursorControl()->getPosition();
|
||||
driver->draw2DRectangle(video::SColor(100,255,255,255),
|
||||
core::rect<s32>(m.X-20, m.Y-20, m.X+20, m.Y+20));
|
||||
|
||||
driver->endScene();
|
||||
}
|
||||
}
|
||||
|
||||
device->drop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
That's all. I hope it was not too difficult.
|
||||
**/
|
||||
|
|
|
@ -0,0 +1,230 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="07.Collision_vc9"
|
||||
ProjectGUID="{3E30297B-5BE3-4A5C-B31E-08A28ADDB29E}"
|
||||
RootNamespace="Collision_vc9"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/Collision.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/Collision.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\07.Collision.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/Collision.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/Collision.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/Collision.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\07.Collision.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
ProgramDatabaseFile=".\Release/Collision.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,15 +1,15 @@
|
|||
/*
|
||||
In this tutorial, I will show how to collision detection with the Irrlicht Engine.
|
||||
I will describe 3 methods: Automatic collision detection for moving through 3d worlds
|
||||
with stair climbing and sliding, manual triangle picking and manual
|
||||
/** Example 007 Collision
|
||||
|
||||
In this tutorial, I will show how to detect collisions with the Irrlicht Engine.
|
||||
I will describe 3 methods: Automatic collision detection for moving through 3d
|
||||
worlds with stair climbing and sliding, manual triangle picking, and manual
|
||||
scene node picking.
|
||||
|
||||
To start, we take the program from tutorial 2, which loaded and displayed a quake 3
|
||||
level. We will use the level to walk in it and to pick triangles from it. In addition
|
||||
we'll place 3 animated models into it for scene node picking. The following code
|
||||
starts up the engine and loads
|
||||
a quake 3 level. I will not explain it, because it should already be known from tutorial
|
||||
2.
|
||||
To start, we take the program from tutorial 2, which loads and displays a quake
|
||||
3 level. We will use the level to walk in it and to pick triangles from it. In
|
||||
addition we'll place 3 animated models into it for scene node picking. The
|
||||
following code starts up the engine and loads a quake 3 level. I will not
|
||||
explain it, because it should already be known from tutorial 2.
|
||||
*/
|
||||
#include <irrlicht.h>
|
||||
#include <iostream>
|
||||
|
@ -20,7 +20,6 @@ using namespace irr;
|
|||
#pragma comment(lib, "Irrlicht.lib")
|
||||
#endif
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
// let user select driver type
|
||||
|
@ -50,77 +49,84 @@ int main()
|
|||
|
||||
IrrlichtDevice *device =
|
||||
createDevice(driverType, core::dimension2d<s32>(640, 480), 16, false);
|
||||
|
||||
|
||||
if (device == 0)
|
||||
return 1; // could not create selected driver.
|
||||
|
||||
video::IVideoDriver* driver = device->getVideoDriver();
|
||||
scene::ISceneManager* smgr = device->getSceneManager();
|
||||
|
||||
|
||||
device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3");
|
||||
|
||||
|
||||
scene::IAnimatedMesh* q3levelmesh = smgr->getMesh("20kdm2.bsp");
|
||||
scene::ISceneNode* q3node = 0;
|
||||
|
||||
|
||||
if (q3levelmesh)
|
||||
q3node = smgr->addOctTreeSceneNode(q3levelmesh->getMesh(0));
|
||||
|
||||
/*
|
||||
So far so good, we've loaded the quake 3 level like in tutorial 2. Now, here
|
||||
comes something different: We create a triangle selector. A triangle selector
|
||||
is a class which can fetch the triangles from scene nodes for doing different
|
||||
things with them, for example collision detection. There are different triangle
|
||||
selectors, and all can be created with the ISceneManager. In this example,
|
||||
we create an OctTreeTriangleSelector, which optimizes the triangle output a
|
||||
little bit by reducing it like an octree. This is very useful for huge meshes
|
||||
like quake 3 levels.
|
||||
After we created the triangle selector, we attach it to the q3node. This is not
|
||||
necessary, but in this way, we do not need to care for the selector, for example
|
||||
dropping it after we do not need it anymore.
|
||||
So far so good, we've loaded the quake 3 level like in tutorial 2. Now,
|
||||
here comes something different: We create a triangle selector. A
|
||||
triangle selector is a class which can fetch the triangles from scene
|
||||
nodes for doing different things with them, for example collision
|
||||
detection. There are different triangle selectors, and all can be
|
||||
created with the ISceneManager. In this example, we create an
|
||||
OctTreeTriangleSelector, which optimizes the triangle output a little
|
||||
bit by reducing it like an octree. This is very useful for huge meshes
|
||||
like quake 3 levels. After we created the triangle selector, we attach
|
||||
it to the q3node. This is not necessary, but in this way, we do not
|
||||
need to care for the selector, for example dropping it after we do not
|
||||
need it anymore.
|
||||
*/
|
||||
|
||||
scene::ITriangleSelector* selector = 0;
|
||||
|
||||
|
||||
if (q3node)
|
||||
{
|
||||
{
|
||||
q3node->setPosition(core::vector3df(-1350,-130,-1400));
|
||||
|
||||
selector = smgr->createOctTreeTriangleSelector(q3levelmesh->getMesh(0), q3node, 128);
|
||||
selector = smgr->createOctTreeTriangleSelector(
|
||||
q3levelmesh->getMesh(0), q3node, 128);
|
||||
q3node->setTriangleSelector(selector);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
We add a first person shooter camera to the scene for being able to move in the quake 3
|
||||
level like in tutorial 2. But this, time, we add a special animator to the
|
||||
camera: A Collision Response animator. This thing modifies the scene node to which
|
||||
it is attached to in that way, that it may no more move through walls and is affected
|
||||
by gravity. The only thing we have to tell the animator is how the world looks like,
|
||||
how big the scene node is, how gravity and so on. After the collision response animator
|
||||
is attached to the camera, we do not have to do anything more for collision detection,
|
||||
anything is done automaticly, all other collision detection code below is for picking.
|
||||
And please note another cool feature: The collsion response animator can be attached
|
||||
also to all other scene nodes, not only to cameras. And it can be mixed with other
|
||||
scene node animators. In this way, collision detection and response in the Irrlicht
|
||||
engine is really, really easy.
|
||||
Now we'll take a closer look on the parameters of createCollisionResponseAnimator().
|
||||
The first parameter is the TriangleSelector, which specifies how the world, against
|
||||
collision detection is done looks like. The second parameter is the scene node, which
|
||||
is the object, which is affected by collision detection, in our case it is the camera.
|
||||
The third defines how big the object is, it is the radius of an ellipsoid. Try it out
|
||||
and change the radius to smaller values, the camera will be able to move closer to walls
|
||||
after this. The next parameter is the direction and speed of gravity. You could
|
||||
set it to (0,0,0) to disable gravity. And the last value is just a translation: Without
|
||||
this, the ellipsoid with which collision detection is done would be around the camera,
|
||||
and the camera would be in the middle of the ellipsoid. But as human beings, we are
|
||||
used to have our eyes on top of the body, with which we collide with our world, not
|
||||
in the middle of it. So we place the scene node 50 units over the center of the
|
||||
ellipsoid with this parameter. And that's it, collision detection works now.
|
||||
We add a first person shooter camera to the scene for being able to
|
||||
move in the quake 3 level like in tutorial 2. But this, time, we add a
|
||||
special animator to the camera: A Collision Response animator. This
|
||||
thing modifies the scene node to which it is attached to in that way,
|
||||
that it may no more move through walls and is affected by gravity. The
|
||||
only thing we have to tell the animator is how the world looks like,
|
||||
how big the scene node is, how gravity and so on. After the collision
|
||||
response animator is attached to the camera, we do not have to do
|
||||
anything more for collision detection, anything is done automaticly,
|
||||
all other collision detection code below is for picking. And please
|
||||
note another cool feature: The collsion response animator can be
|
||||
attached also to all other scene nodes, not only to cameras. And it can
|
||||
be mixed with other scene node animators. In this way, collision
|
||||
detection and response in the Irrlicht engine is really, really easy.
|
||||
|
||||
Now we'll take a closer look on the parameters of
|
||||
createCollisionResponseAnimator(). The first parameter is the
|
||||
TriangleSelector, which specifies how the world, against collision
|
||||
detection is done looks like. The second parameter is the scene node,
|
||||
which is the object, which is affected by collision detection, in our
|
||||
case it is the camera. The third defines how big the object is, it is
|
||||
the radius of an ellipsoid. Try it out and change the radius to smaller
|
||||
values, the camera will be able to move closer to walls after this. The
|
||||
next parameter is the direction and speed of gravity. You could set it
|
||||
to (0,0,0) to disable gravity. And the last value is just a
|
||||
translation: Without this, the ellipsoid with which collision detection
|
||||
is done would be around the camera, and the camera would be in the
|
||||
middle of the ellipsoid. But as human beings, we are used to have our
|
||||
eyes on top of the body, with which we collide with our world, not in
|
||||
the middle of it. So we place the scene node 50 units over the center
|
||||
of the ellipsoid with this parameter. And that's it, collision
|
||||
detection works now.
|
||||
*/
|
||||
|
||||
scene::ICameraSceneNode* camera =
|
||||
scene::ICameraSceneNode* camera =
|
||||
smgr->addCameraSceneNodeFPS(0, 100.0f, 300.0f, -1, 0, 0, true);
|
||||
camera->setPosition(core::vector3df(-100,50,-150));
|
||||
|
||||
|
@ -128,7 +134,7 @@ int main()
|
|||
{
|
||||
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
|
||||
selector, camera, core::vector3df(30,50,30),
|
||||
core::vector3df(0,-3,0),
|
||||
core::vector3df(0,-3,0),
|
||||
core::vector3df(0,50,0));
|
||||
camera->addAnimator(anim);
|
||||
anim->drop();
|
||||
|
@ -137,7 +143,7 @@ int main()
|
|||
/*
|
||||
Because collision detection is no big deal in irrlicht, I'll describe how to
|
||||
do two different types of picking in the next section. But before this,
|
||||
I'll prepare the scene a little. I need three animated characters which we
|
||||
I'll prepare the scene a little. I need three animated characters which we
|
||||
could pick later, a dynamic light for lighting them,
|
||||
a billboard for drawing where we found an intersection, and, yes, I need to
|
||||
get rid of this mouse cursor. :)
|
||||
|
@ -194,16 +200,16 @@ int main()
|
|||
|
||||
|
||||
/*
|
||||
For not making it to complicated, I'm doing picking inside the drawing loop.
|
||||
We take two pointers for storing the current and the last selected scene node and
|
||||
start the loop.
|
||||
For not making it to complicated, I'm doing picking inside the drawing
|
||||
loop. We take two pointers for storing the current and the last
|
||||
selected scene node and start the loop.
|
||||
*/
|
||||
|
||||
|
||||
scene::ISceneNode* selectedSceneNode = 0;
|
||||
scene::ISceneNode* lastSelectedSceneNode = 0;
|
||||
|
||||
|
||||
|
||||
int lastFPS = -1;
|
||||
|
||||
while(device->run())
|
||||
|
@ -214,14 +220,16 @@ int main()
|
|||
smgr->drawAll();
|
||||
|
||||
/*
|
||||
After we've drawn the whole scene whit smgr->drawAll(), we'll do the first
|
||||
picking: We want to know which triangle of the world we are looking at. In addition,
|
||||
we want the exact point of the quake 3 level we are looking at.
|
||||
For this, we create a 3d line starting at the position of the camera and going
|
||||
through the lookAt-target of it. Then we ask the collision manager if this line
|
||||
collides with a triangle of the world stored in the triangle selector. If yes,
|
||||
we draw the 3d triangle and set the position of the billboard to the intersection
|
||||
point.
|
||||
After we've drawn the whole scene with smgr->drawAll(), we'll
|
||||
do the first picking: We want to know which triangle of the
|
||||
world we are looking at. In addition, we want the exact point
|
||||
of the quake 3 level we are looking at. For this, we create a
|
||||
3d line starting at the position of the camera and going
|
||||
through the lookAt-target of it. Then we ask the collision
|
||||
manager if this line collides with a triangle of the world
|
||||
stored in the triangle selector. If yes, we draw the 3d
|
||||
triangle and set the position of the billboard to the
|
||||
intersection point.
|
||||
*/
|
||||
|
||||
core::line3d<f32> line;
|
||||
|
@ -235,7 +243,7 @@ int main()
|
|||
line, selector, intersection, tri))
|
||||
{
|
||||
bill->setPosition(intersection);
|
||||
|
||||
|
||||
driver->setTransform(video::ETS_WORLD, core::matrix4());
|
||||
driver->setMaterial(material);
|
||||
driver->draw3DTriangle(tri, video::SColor(0,255,0,0));
|
||||
|
@ -243,15 +251,17 @@ int main()
|
|||
|
||||
|
||||
/*
|
||||
Another type of picking supported by the Irrlicht Engine is scene node picking
|
||||
based on bouding boxes. Every scene node has got a bounding box, and because of
|
||||
that, it's very fast for example to get the scene node which the camera looks
|
||||
at. Again, we ask the collision manager for this, and if we've got a scene node,
|
||||
we highlight it by disabling Lighting in its material, if it is not the
|
||||
billboard or the quake 3 level.
|
||||
Another type of picking supported by the Irrlicht Engine is
|
||||
scene node picking based on bounding boxes. Every scene node has
|
||||
got a bounding box, and because of that, it's very fast for
|
||||
example to get the scene node which the camera looks at. Again,
|
||||
we ask the collision manager for this, and if we've got a scene
|
||||
node, we highlight it by disabling Lighting in its material, if
|
||||
it is not the billboard or the quake 3 level.
|
||||
*/
|
||||
|
||||
selectedSceneNode = smgr->getSceneCollisionManager()->getSceneNodeFromCameraBB(camera);
|
||||
selectedSceneNode =
|
||||
smgr->getSceneCollisionManager()->getSceneNodeFromCameraBB(camera);
|
||||
|
||||
if (lastSelectedSceneNode)
|
||||
lastSelectedSceneNode->setMaterialFlag(video::EMF_LIGHTING, true);
|
||||
|
@ -275,19 +285,21 @@ int main()
|
|||
|
||||
if (lastFPS != fps)
|
||||
{
|
||||
core::stringw str = L"Collision detection example - Irrlicht Engine [";
|
||||
str += driver->getName();
|
||||
str += "] FPS:";
|
||||
str += fps;
|
||||
core::stringw str = L"Collision detection example - Irrlicht Engine [";
|
||||
str += driver->getName();
|
||||
str += "] FPS:";
|
||||
str += fps;
|
||||
|
||||
device->setWindowCaption(str.c_str());
|
||||
lastFPS = fps;
|
||||
device->setWindowCaption(str.c_str());
|
||||
lastFPS = fps;
|
||||
}
|
||||
}
|
||||
|
||||
selector->drop();
|
||||
device->drop();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
**/
|
||||
|
|
|
@ -0,0 +1,230 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="08.SpecialFX_vc9"
|
||||
ProjectGUID="{C869BF55-B9D6-4980-BC92-60FA0CF8411A}"
|
||||
RootNamespace="SpecialFX_vc9"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/SpecialFX.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/SpecialFX.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\08.SpecialFx.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
ProgramDatabaseFile=".\Release/SpecialFx.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/SpecialFX.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/SpecialFX.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\08.SpecialFx.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/SpecialFx.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,20 +1,25 @@
|
|||
/* This tutorials describes how to do special effects. It shows how to use stencil
|
||||
buffer shadows, the particle system, billboards, dynamic light and the water
|
||||
/** Example 008 SpecialFX
|
||||
|
||||
This tutorials describes how to do special effects. It shows how to use stencil
|
||||
buffer shadows, the particle system, billboards, dynamic light, and the water
|
||||
surface scene node.
|
||||
|
||||
We start like in some tutorials before. Please note that this time, the 'shadows' flag in
|
||||
createDevice() is set to true, for we want to have a dynamic shadow casted from
|
||||
an animated character. If your this example runs to slow, set it to false.
|
||||
The Irrlicht Engine checks if your hardware doesn't support the stencil
|
||||
buffer, and disables shadows by itself, but just in case the demo runs slow
|
||||
on your hardware.*/
|
||||
We start like in some tutorials before. Please note that this time, the
|
||||
'shadows' flag in createDevice() is set to true, for we want to have a dynamic
|
||||
shadow casted from an animated character. If this example runs too slow,
|
||||
set it to false. The Irrlicht Engine checks if your hardware doesn't support
|
||||
the stencil buffer, and disables shadows by itself, but just in case the demo
|
||||
runs slow on your hardware.
|
||||
*/
|
||||
|
||||
#include <irrlicht.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace irr;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "Irrlicht.lib")
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -25,7 +30,7 @@ int main()
|
|||
|
||||
std::cin >> i;
|
||||
|
||||
bool shadows = (i == 'y');
|
||||
const bool shadows = (i == 'y');
|
||||
|
||||
// ask user for driver
|
||||
|
||||
|
@ -49,7 +54,10 @@ int main()
|
|||
default: return 1;
|
||||
}
|
||||
|
||||
// create device and exit if creation failed
|
||||
/*
|
||||
Create device and exit if creation failed. We make the stencil flag
|
||||
optional to avoid slow screen modes for runs without shadows.
|
||||
*/
|
||||
|
||||
IrrlichtDevice *device =
|
||||
createDevice(driverType, core::dimension2d<s32>(640, 480),
|
||||
|
@ -63,41 +71,39 @@ int main()
|
|||
|
||||
/*
|
||||
For our environment, we load a .3ds file. It is a small room I modelled
|
||||
with Anim8or and exported it into the 3ds format because the Irrlicht Engine
|
||||
did not support the .an8 format when I wrote this tutorial. I am a very bad
|
||||
3d graphic artist, and so the texture mapping is not very nice in this model.
|
||||
Luckily I am a better programmer than artist, and so the Irrlicht Engine
|
||||
is able to create a cool texture mapping for me: Just use the mesh manipulator
|
||||
and create a planar texture mapping for the mesh. If you want to see the mapping
|
||||
I made with Anim8or, uncomment this line. I also did not figure out how to
|
||||
set the material right in Anim8or, it has a specular light color which I don't really
|
||||
like. I'll switch it off too with this code.
|
||||
with Anim8or and exported into the 3ds format because the Irrlicht
|
||||
Engine does not support the .an8 format. I am a very bad 3d graphic
|
||||
artist, and so the texture mapping is not very nice in this model.
|
||||
Luckily I am a better programmer than artist, and so the Irrlicht
|
||||
Engine is able to create a cool texture mapping for me: Just use the
|
||||
mesh manipulator and create a planar texture mapping for the mesh. If
|
||||
you want to see the mapping I made with Anim8or, uncomment this line. I
|
||||
also did not figure out how to set the material right in Anim8or, it
|
||||
has a specular light color which I don't really like. I'll switch it
|
||||
off too with this code.
|
||||
*/
|
||||
|
||||
scene::IAnimatedMesh* mesh = smgr->getMesh(
|
||||
"../../media/room.3ds");
|
||||
scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/room.3ds");
|
||||
|
||||
smgr->getMeshManipulator()->makePlanarTextureMapping(
|
||||
mesh->getMesh(0), 0.004f);
|
||||
smgr->getMeshManipulator()->makePlanarTextureMapping(mesh->getMesh(0), 0.004f);
|
||||
|
||||
scene::ISceneNode* node = 0;
|
||||
|
||||
node = smgr->addAnimatedMeshSceneNode(mesh);
|
||||
node->setMaterialTexture(0, driver->getTexture("../../media/wall.jpg"));
|
||||
node->setMaterialTexture(0, driver->getTexture("../../media/wall.jpg"));
|
||||
node->getMaterial(0).SpecularColor.set(0,0,0,0);
|
||||
|
||||
/*
|
||||
Now, for the first special effect: Animated water. It works like this: The
|
||||
WaterSurfaceSceneNode takes a mesh as input and makes
|
||||
it wave like a water surface. And if we let this scene node use a nice
|
||||
material like the EMT_REFLECTION_2_LAYER, it looks really cool. We are
|
||||
doing this with the next few lines of code. As input mesh, we create a hill
|
||||
plane mesh, without hills. But any other mesh could be used for this, you could
|
||||
even use the room.3ds (which would look really strange) if you wanted to.
|
||||
Now, for the first special effect: Animated water. It works like this:
|
||||
The WaterSurfaceSceneNode takes a mesh as input and makes it wave like
|
||||
a water surface. And if we let this scene node use a nice material like
|
||||
the EMT_REFLECTION_2_LAYER, it looks really cool. We are doing this
|
||||
with the next few lines of code. As input mesh, we create a hill plane
|
||||
mesh, without hills. But any other mesh could be used for this, you
|
||||
could even use the room.3ds (which would look really strange) if you
|
||||
want to.
|
||||
*/
|
||||
|
||||
// add animated water
|
||||
|
||||
mesh = smgr->addHillPlaneMesh("myHill",
|
||||
core::dimension2d<f32>(20,20),
|
||||
core::dimension2d<u32>(40,40), 0, 0,
|
||||
|
@ -113,10 +119,10 @@ int main()
|
|||
node->setMaterialType(video::EMT_REFLECTION_2_LAYER);
|
||||
|
||||
/*
|
||||
The second special effect is very basic, I bet you saw it already in some
|
||||
Irrlicht Engine demos: A transparent billboard combined with a dynamic light.
|
||||
We simply create a light scene node, let it fly around, an to make it look
|
||||
more cool, we attach a billboard scene node to it.
|
||||
The second special effect is very basic, I bet you saw it already in
|
||||
some Irrlicht Engine demos: A transparent billboard combined with a
|
||||
dynamic light. We simply create a light scene node, let it fly around,
|
||||
and to make it look more cool, we attach a billboard scene node to it.
|
||||
*/
|
||||
|
||||
// create light
|
||||
|
@ -136,55 +142,62 @@ int main()
|
|||
node->setMaterialTexture(0, driver->getTexture("../../media/particlewhite.bmp"));
|
||||
|
||||
/*
|
||||
The next special effect is a lot more interesting: A particle system. The particle
|
||||
system in the Irrlicht Engine is quit modular and extensible and yet easy to use.
|
||||
There is a particle system scene node into which you can put particle emitters, which
|
||||
make particles come out of nothing. These emitters are quite flexible and usually have
|
||||
lots of parameters like direction, amount and color of the particles they should create.
|
||||
There are different emitters, for example a point emitter which lets particles pop out
|
||||
at a fixed point. If the particle emitters available in the engine are not enough for
|
||||
you, you can easily create your own ones, you'll simply have to create a class derived
|
||||
from the IParticleEmitter interface and attach it to the particle system using setEmitter().
|
||||
In this example we create a box particle emitter, which creates particles randomly
|
||||
inside a box. The parameters define the box, direction of the particles, minimal and
|
||||
maximal new particles per second, color and minimal and maximal livetime of the particles.
|
||||
The next special effect is a lot more interesting: A particle system.
|
||||
The particle system in the Irrlicht Engine is quite modular and
|
||||
extensible, but yet easy to use. There is a particle system scene node
|
||||
into which you can put a particle emitter, which makes particles come out
|
||||
of nothing. These emitters are quite flexible and usually have lots of
|
||||
parameters like direction, amount, and color of the particles they
|
||||
create.
|
||||
|
||||
Because only with emitters particle system would be a little bit boring,
|
||||
there are particle affectors, which modify particles during they fly around. They can
|
||||
be added to the particle system, simulating additional effects like gravity or wind.
|
||||
The particle affector we use in this example is an affector, which modifies the color
|
||||
of the particles: It lets them fade out. Like the particle emitters, additional
|
||||
particle affectors can also be implemented by you, simply derive a class from
|
||||
IParticleAffector and add it with addAffector().
|
||||
There are different emitters, for example a point emitter which lets
|
||||
particles pop out at a fixed point. If the particle emitters available
|
||||
in the engine are not enough for you, you can easily create your own
|
||||
ones, you'll simply have to create a class derived from the
|
||||
IParticleEmitter interface and attach it to the particle system using
|
||||
setEmitter(). In this example we create a box particle emitter, which
|
||||
creates particles randomly inside a box. The parameters define the box,
|
||||
direction of the particles, minimal and maximal new particles per
|
||||
second, color, and minimal and maximal lifetime of the particles.
|
||||
|
||||
After we set a nice material to the particle system, we have a cool looking camp fire.
|
||||
By adjusting material, texture, particle emitter and affector parameters, it is also
|
||||
easily possible to create smoke, rain, explosions, snow, and so on.
|
||||
Because only with emitters particle system would be a little bit
|
||||
boring, there are particle affectors which modify particles while
|
||||
they fly around. Affectors can be added to a particle system for
|
||||
simulating additional effects like gravity or wind.
|
||||
The particle affector we use in this example is an affector which
|
||||
modifies the color of the particles: It lets them fade out. Like the
|
||||
particle emitters, additional particle affectors can also be
|
||||
implemented by you, simply derive a class from IParticleAffector and
|
||||
add it with addAffector().
|
||||
|
||||
After we set a nice material to the particle system, we have a cool
|
||||
looking camp fire. By adjusting material, texture, particle emitter,
|
||||
and affector parameters, it is also easily possible to create smoke,
|
||||
rain, explosions, snow, and so on.
|
||||
*/
|
||||
|
||||
// create a particle system
|
||||
|
||||
scene::IParticleSystemSceneNode* ps = 0;
|
||||
ps = smgr->addParticleSystemSceneNode(false);
|
||||
scene::IParticleSystemSceneNode* ps =
|
||||
smgr->addParticleSystemSceneNode(false);
|
||||
ps->setPosition(core::vector3df(-70,60,40));
|
||||
ps->setScale(core::vector3df(2,2,2));
|
||||
|
||||
ps->setParticleSize(core::dimension2d<f32>(20.0f, 20.0f));
|
||||
|
||||
scene::IParticleEmitter* em = ps->createBoxEmitter(
|
||||
core::aabbox3d<f32>(-7,0,-7,7,1,7),
|
||||
core::vector3df(0.0f,0.06f,0.0f),
|
||||
80,100,
|
||||
video::SColor(0,255,255,255), video::SColor(0,255,255,255),
|
||||
800,2000);
|
||||
core::aabbox3d<f32>(-7,0,-7,7,1,7), // emitter size
|
||||
core::vector3df(0.0f,0.06f,0.0f), // initial direction
|
||||
80,100, // emit rate
|
||||
video::SColor(0,255,255,255), // darkest color
|
||||
video::SColor(0,255,255,255), // brightest color
|
||||
800,2000); // min and max age
|
||||
|
||||
ps->setEmitter(em);
|
||||
em->drop();
|
||||
ps->setEmitter(em); // this grabs the emitter
|
||||
em->drop(); // so we can drop it here without deleting it
|
||||
|
||||
scene::IParticleAffector* paf =
|
||||
ps->createFadeOutParticleAffector();
|
||||
scene::IParticleAffector* paf = ps->createFadeOutParticleAffector();
|
||||
|
||||
ps->addAffector(paf);
|
||||
ps->addAffector(paf); // same goes for the affector
|
||||
paf->drop();
|
||||
|
||||
ps->setMaterialFlag(video::EMF_LIGHTING, false);
|
||||
|
@ -192,24 +205,23 @@ int main()
|
|||
ps->setMaterialTexture(0, driver->getTexture("../../media/fire.bmp"));
|
||||
ps->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);
|
||||
|
||||
/*
|
||||
Next we add a volumetric light node, which adds a glowing fake area light to
|
||||
the scene. Like with the billboards and particle systems we also assign a
|
||||
texture for the desired effect, though this time we'll use a texture animator
|
||||
/*
|
||||
Next we add a volumetric light node, which adds a glowing fake area light to
|
||||
the scene. Like with the billboards and particle systems we also assign a
|
||||
texture for the desired effect, though this time we'll use a texture animator
|
||||
to create the illusion of a magical glowing area effect.
|
||||
*/
|
||||
scene::IVolumeLightSceneNode * n = smgr->addVolumeLightSceneNode(0, -1,
|
||||
32, // Subdivisions on U axis
|
||||
32, // Subdivisions on V axis
|
||||
video::SColor(0, 255, 255, 255), // foot color
|
||||
video::SColor(0, 0, 0, 0) // tail color
|
||||
);
|
||||
|
||||
if (n)
|
||||
32, // Subdivisions on U axis
|
||||
32, // Subdivisions on V axis
|
||||
video::SColor(0, 255, 255, 255), // foot color
|
||||
video::SColor(0, 0, 0, 0)); // tail color
|
||||
|
||||
if (n)
|
||||
{
|
||||
n->setScale(core::vector3df(56.0f, 56.0f, 56.0f));
|
||||
n->setPosition(core::vector3df(-120,50,40));
|
||||
|
||||
|
||||
// load textures for animation
|
||||
core::array<video::ITexture*> textures;
|
||||
for (s32 g=7; g > 0; --g)
|
||||
|
@ -218,12 +230,12 @@ int main()
|
|||
tmp = "../../media/portal";
|
||||
tmp += g;
|
||||
tmp += ".bmp";
|
||||
video::ITexture* t = driver->getTexture( tmp.c_str () );
|
||||
video::ITexture* t = driver->getTexture( tmp.c_str() );
|
||||
textures.push_back(t);
|
||||
}
|
||||
|
||||
// create texture animator
|
||||
scene::ISceneNodeAnimator *glow = smgr->createTextureAnimator(textures, 150);
|
||||
scene::ISceneNodeAnimator* glow = smgr->createTextureAnimator(textures, 150);
|
||||
|
||||
// add the animator
|
||||
n->addAnimator(glow);
|
||||
|
@ -233,17 +245,19 @@ int main()
|
|||
}
|
||||
|
||||
/*
|
||||
As our last special effect, we want a dynamic shadow be casted from an animated
|
||||
character. For this we load a DirectX .x model and place it into our world.
|
||||
For creating the shadow, we simply need to call addShadowVolumeSceneNode().
|
||||
The color of shadows is only adjustable globally for all shadows, by calling
|
||||
ISceneManager::setShadowColor(). Voila, here is our dynamic shadow.
|
||||
As our last special effect, we want a dynamic shadow be casted from an
|
||||
animated character. For this we load a DirectX .x model and place it
|
||||
into our world. For creating the shadow, we simply need to call
|
||||
addShadowVolumeSceneNode(). The color of shadows is only adjustable
|
||||
globally for all shadows, by calling ISceneManager::setShadowColor().
|
||||
Voila, here is our dynamic shadow.
|
||||
|
||||
Because the character is a little bit too small for this scene, we make it bigger
|
||||
using setScale(). And because the character is lighted by a dynamic light, we need
|
||||
to normalize the normals to make the lighting on it correct. This is always necessary if
|
||||
the scale of a dynamic lighted model is not (1,1,1). Otherwise it would get too dark or
|
||||
too bright because the normals will be scaled too.
|
||||
Because the character is a little bit too small for this scene, we make
|
||||
it bigger using setScale(). And because the character is lighted by a
|
||||
dynamic light, we need to normalize the normals to make the lighting on
|
||||
it correct. This is always necessary if the scale of a dynamic lighted
|
||||
model is not (1,1,1). Otherwise it would get too dark or too bright
|
||||
because the normals will be scaled too.
|
||||
*/
|
||||
|
||||
// add animated character
|
||||
|
@ -260,7 +274,7 @@ int main()
|
|||
smgr->setShadowColor(video::SColor(150,0,0,0));
|
||||
|
||||
// make the model a little bit bigger and normalize its normals
|
||||
// because of this for correct lighting
|
||||
// because of the scaling, for correct lighting
|
||||
anode->setScale(core::vector3df(2,2,2));
|
||||
anode->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
|
||||
|
||||
|
@ -274,8 +288,7 @@ int main()
|
|||
// disable mouse cursor
|
||||
device->getCursorControl()->setVisible(false);
|
||||
|
||||
|
||||
int lastFPS = -1;
|
||||
s32 lastFPS = -1;
|
||||
|
||||
while(device->run())
|
||||
if (device->isWindowActive())
|
||||
|
@ -286,7 +299,7 @@ int main()
|
|||
|
||||
driver->endScene();
|
||||
|
||||
int fps = driver->getFPS();
|
||||
const s32 fps = driver->getFPS();
|
||||
|
||||
if (lastFPS != fps)
|
||||
{
|
||||
|
@ -305,3 +318,5 @@ int main()
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
**/
|
||||
|
|
|
@ -0,0 +1,230 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="09.Meshviewer_vc9"
|
||||
ProjectGUID="{2AE24484-22FC-481B-9A40-7CD0DA5C8E06}"
|
||||
RootNamespace="Meshviewer_vc9"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/Meshviewer.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/Meshviewer.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\09.MeshViewer.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
ProgramDatabaseFile=".\Release/MeshViewer.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/Meshviewer.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/Meshviewer.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\09.MeshViewer.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/MeshViewer.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,230 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="10.Shaders_vc9"
|
||||
ProjectGUID="{27158C82-CD15-4A9B-9848-35E7065B209F}"
|
||||
RootNamespace="Shaders_vc9"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/Shaders.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/Shaders.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\10.Shaders.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/Shaders.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/Shaders.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/Shaders.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\10.Shaders.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
ProgramDatabaseFile=".\Release/Shaders.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,41 +1,42 @@
|
|||
/*
|
||||
This tutorial shows how to use shaders for D3D8, D3D9 and OpenGL
|
||||
with the engine and how to create new material types with them. It also
|
||||
shows how to disable the generation of mipmaps at texture loading, and
|
||||
how to use text scene nodes.
|
||||
/** Example 010 Shaders
|
||||
|
||||
This tutorial does not explain how shaders work. I would recommend to read the D3D
|
||||
or OpenGL documentation, to search a tutorial, or to read a book about this.
|
||||
This tutorial shows how to use shaders for D3D8, D3D9, and OpenGL with the
|
||||
engine and how to create new material types with them. It also shows how to
|
||||
disable the generation of mipmaps at texture loading, and how to use text scene
|
||||
nodes.
|
||||
|
||||
At first, we need to include all headers and do the stuff we always do, like
|
||||
in nearly all other tutorials:
|
||||
This tutorial does not explain how shaders work. I would recommend to read the
|
||||
D3D or OpenGL documentation, to search a tutorial, or to read a book about
|
||||
this.
|
||||
|
||||
At first, we need to include all headers and do the stuff we always do, like in
|
||||
nearly all other tutorials:
|
||||
*/
|
||||
#include <irrlicht.h>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
using namespace irr;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "Irrlicht.lib")
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
Because we want to use some interesting shaders in this tutorials, we
|
||||
need to set some data for them to make them able to compute nice
|
||||
colors. In this example, we'll use a simple vertex shader which will
|
||||
calculate the color of the vertex based on the position of the camera.
|
||||
For this, the shader needs the following data: The inverted world matrix
|
||||
for transforming the normal, the clip matrix for transforming the position,
|
||||
the camera position and the world position of the object for the calculation
|
||||
of the angle of light, and the color of the light. To be able to tell the
|
||||
shader all this data every frame, we have to derive a class from the
|
||||
IShaderConstantSetCallBack interface and override its only method,
|
||||
namely OnSetConstants(). This method will be called every time the material
|
||||
is set.
|
||||
Because we want to use some interesting shaders in this tutorials, we need to
|
||||
set some data for them to make them able to compute nice colors. In this
|
||||
example, we'll use a simple vertex shader which will calculate the color of the
|
||||
vertex based on the position of the camera.
|
||||
For this, the shader needs the following data: The inverted world matrix for
|
||||
transforming the normal, the clip matrix for transforming the position, the
|
||||
camera position and the world position of the object for the calculation of the
|
||||
angle of light, and the color of the light. To be able to tell the shader all
|
||||
this data every frame, we have to derive a class from the
|
||||
IShaderConstantSetCallBack interface and override its only method, namely
|
||||
OnSetConstants(). This method will be called every time the material is set.
|
||||
The method setVertexShaderConstant() of the IMaterialRendererServices interface
|
||||
is used to set the data the shader needs. If the user chose to use a High Level shader
|
||||
language like HLSL instead of Assembler in this example, you have to set the
|
||||
variable name as parameter instead of the register index.
|
||||
is used to set the data the shader needs. If the user chose to use a High Level
|
||||
shader language like HLSL instead of Assembler in this example, you have to set
|
||||
the variable name as parameter instead of the register index.
|
||||
*/
|
||||
|
||||
IrrlichtDevice* device = 0;
|
||||
|
@ -45,7 +46,8 @@ class MyShaderCallBack : public video::IShaderConstantSetCallBack
|
|||
{
|
||||
public:
|
||||
|
||||
virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData)
|
||||
virtual void OnSetConstants(video::IMaterialRendererServices* services,
|
||||
s32 userData)
|
||||
{
|
||||
video::IVideoDriver* driver = services->getVideoDriver();
|
||||
|
||||
|
@ -83,12 +85,13 @@ public:
|
|||
else
|
||||
services->setVertexShaderConstant(reinterpret_cast<f32*>(&pos), 8, 1);
|
||||
|
||||
// set light color
|
||||
// set light color
|
||||
|
||||
video::SColorf col(0.0f,1.0f,1.0f,0.0f);
|
||||
|
||||
if (UseHighLevelShaders)
|
||||
services->setVertexShaderConstant("mLightColor", reinterpret_cast<f32*>(&col), 4);
|
||||
services->setVertexShaderConstant("mLightColor",
|
||||
reinterpret_cast<f32*>(&col), 4);
|
||||
else
|
||||
services->setVertexShaderConstant(reinterpret_cast<f32*>(&col), 9, 1);
|
||||
|
||||
|
@ -105,9 +108,9 @@ public:
|
|||
};
|
||||
|
||||
/*
|
||||
The next few lines start up the engine. Just like in most other tutorials
|
||||
before. But in addition, we ask the user if he wants this example to use
|
||||
high level shaders if he selected a driver which is capable of doing so.
|
||||
The next few lines start up the engine just like in most other tutorials
|
||||
before. But in addition, we ask the user if he wants to use high level shaders
|
||||
in this example, if he selected a driver which is capable of doing so.
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
|
@ -135,7 +138,7 @@ int main()
|
|||
}
|
||||
|
||||
// ask the user if we should use high level shaders for this example
|
||||
if (driverType == video::EDT_DIRECT3D9 ||
|
||||
if (driverType == video::EDT_DIRECT3D9 ||
|
||||
driverType == video::EDT_OPENGL)
|
||||
{
|
||||
printf("Please press 'y' if you want to use high level shaders.\n");
|
||||
|
@ -157,15 +160,15 @@ int main()
|
|||
gui::IGUIEnvironment* gui = device->getGUIEnvironment();
|
||||
|
||||
/*
|
||||
Now for the more interesting parts.
|
||||
If we are using Direct3D, we want to load vertex and pixel shader programs, if we have
|
||||
OpenGL, we want to use ARB fragment and vertex programs. I wrote the
|
||||
corresponding programs down into the files d3d8.ps, d3d8.vs, d3d9.ps, d3d9.vs,
|
||||
opengl.ps and opengl.vs. We only need the right filenames now. This is done in the
|
||||
following switch. Note, that it is not necessary to write the shaders into text
|
||||
files, like in this example. You can even write the shaders directly as strings
|
||||
into the cpp source file, and use later addShaderMaterial() instead of
|
||||
addShaderMaterialFromFiles().
|
||||
Now for the more interesting parts. If we are using Direct3D, we want
|
||||
to load vertex and pixel shader programs, if we have OpenGL, we want to
|
||||
use ARB fragment and vertex programs. I wrote the corresponding
|
||||
programs down into the files d3d8.ps, d3d8.vs, d3d9.ps, d3d9.vs,
|
||||
opengl.ps and opengl.vs. We only need the right filenames now. This is
|
||||
done in the following switch. Note, that it is not necessary to write
|
||||
the shaders into text files, like in this example. You can even write
|
||||
the shaders directly as strings into the cpp source file, and use later
|
||||
addShaderMaterial() instead of addShaderMaterialFromFiles().
|
||||
*/
|
||||
|
||||
c8* vsFileName = 0; // filename for the vertex shader
|
||||
|
@ -205,15 +208,16 @@ int main()
|
|||
}
|
||||
|
||||
/*
|
||||
In addition, we check if the hardware and the selected renderer is capable
|
||||
of executing the shaders we want. If not, we simply set the filename string
|
||||
to 0. This is not necessary, but useful in this example: For example, if
|
||||
the hardware is able to execute vertex shaders but not pixel shaders, we create
|
||||
a new material which only uses the vertex shader, and no pixel shader.
|
||||
Otherwise, if we would tell the engine to create this material and the engine
|
||||
sees that the hardware wouldn't be able to fullfill the request completely,
|
||||
it would not create any new material at all. So in this example you would see
|
||||
at least the vertex shader in action, without the pixel shader.
|
||||
In addition, we check if the hardware and the selected renderer is
|
||||
capable of executing the shaders we want. If not, we simply set the
|
||||
filename string to 0. This is not necessary, but useful in this
|
||||
example: For example, if the hardware is able to execute vertex shaders
|
||||
but not pixel shaders, we create a new material which only uses the
|
||||
vertex shader, and no pixel shader. Otherwise, if we would tell the
|
||||
engine to create this material and the engine sees that the hardware
|
||||
wouldn't be able to fullfill the request completely, it would not
|
||||
create any new material at all. So in this example you would see at
|
||||
least the vertex shader in action, without the pixel shader.
|
||||
*/
|
||||
|
||||
if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1) &&
|
||||
|
@ -233,22 +237,26 @@ int main()
|
|||
}
|
||||
|
||||
/*
|
||||
Now lets create the new materials.
|
||||
As you maybe know from previous examples, a material type in the Irrlicht engine
|
||||
is set by simply changing the MaterialType value in the SMaterial struct. And this
|
||||
value is just a simple 32 bit value, like video::EMT_SOLID. So we only need the
|
||||
engine to create a new value for us which we can set there.
|
||||
To do this, we get a pointer to the IGPUProgrammingServices and call
|
||||
addShaderMaterialFromFiles(), which returns such a new 32 bit value. That's all.
|
||||
The parameters to this method are the following:
|
||||
First, the names of the files containing the code of the vertex and the pixel shader.
|
||||
If you would use addShaderMaterial() instead, you would not need file names, then you
|
||||
could write the code of the shader directly as string.
|
||||
The following parameter is a pointer to the IShaderConstantSetCallBack class we wrote
|
||||
at the beginning of this tutorial. If you don't want to set constants, set this to 0.
|
||||
The last paramter tells the engine which material it should use as base material.
|
||||
To demonstrate this, we create two materials with a different base material, one
|
||||
with EMT_SOLID and one with EMT_TRANSPARENT_ADD_COLOR.
|
||||
Now lets create the new materials. As you maybe know from previous
|
||||
examples, a material type in the Irrlicht engine is set by simply
|
||||
changing the MaterialType value in the SMaterial struct. And this value
|
||||
is just a simple 32 bit value, like video::EMT_SOLID. So we only need
|
||||
the engine to create a new value for us which we can set there. To do
|
||||
this, we get a pointer to the IGPUProgrammingServices and call
|
||||
addShaderMaterialFromFiles(), which returns such a new 32 bit value.
|
||||
That's all.
|
||||
|
||||
The parameters to this method are the following: First, the names of
|
||||
the files containing the code of the vertex and the pixel shader. If
|
||||
you would use addShaderMaterial() instead, you would not need file
|
||||
names, then you could write the code of the shader directly as string.
|
||||
The following parameter is a pointer to the IShaderConstantSetCallBack
|
||||
class we wrote at the beginning of this tutorial. If you don't want to
|
||||
set constants, set this to 0. The last paramter tells the engine which
|
||||
material it should use as base material.
|
||||
|
||||
To demonstrate this, we create two materials with a different base
|
||||
material, one with EMT_SOLID and one with EMT_TRANSPARENT_ADD_COLOR.
|
||||
*/
|
||||
|
||||
// create materials
|
||||
|
@ -293,10 +301,10 @@ int main()
|
|||
}
|
||||
|
||||
/*
|
||||
Now time for testing out the materials. We create a test cube
|
||||
and set the material we created. In addition, we add a text scene node to
|
||||
the cube and a rotation animator to make it look more interesting and
|
||||
important.
|
||||
Now it's time for testing the materials. We create a test cube and set
|
||||
the material we created. In addition, we add a text scene node to the
|
||||
cube and a rotation animator to make it look more interesting and
|
||||
important.
|
||||
*/
|
||||
|
||||
// create test scene node 1, with the new created material type 1
|
||||
|
@ -307,8 +315,8 @@ int main()
|
|||
node->setMaterialFlag(video::EMF_LIGHTING, false);
|
||||
node->setMaterialType((video::E_MATERIAL_TYPE)newMaterialType1);
|
||||
|
||||
smgr->addTextSceneNode(gui->getBuiltInFont(),
|
||||
L"PS & VS & EMT_SOLID",
|
||||
smgr->addTextSceneNode(gui->getBuiltInFont(),
|
||||
L"PS & VS & EMT_SOLID",
|
||||
video::SColor(255,255,255,255), node);
|
||||
|
||||
scene::ISceneNodeAnimator* anim = smgr->createRotationAnimator(
|
||||
|
@ -328,8 +336,8 @@ int main()
|
|||
node->setMaterialFlag(video::EMF_LIGHTING, false);
|
||||
node->setMaterialType((video::E_MATERIAL_TYPE)newMaterialType2);
|
||||
|
||||
smgr->addTextSceneNode(gui->getBuiltInFont(),
|
||||
L"PS & VS & EMT_TRANSPARENT",
|
||||
smgr->addTextSceneNode(gui->getBuiltInFont(),
|
||||
L"PS & VS & EMT_TRANSPARENT",
|
||||
video::SColor(255,255,255,255), node);
|
||||
|
||||
anim = smgr->createRotationAnimator(core::vector3df(0,0.3f,0));
|
||||
|
@ -337,11 +345,11 @@ int main()
|
|||
anim->drop();
|
||||
|
||||
/*
|
||||
Then we add a third cube without a shader on it, to be able to compare the
|
||||
cubes.
|
||||
Then we add a third cube without a shader on it, to be able to compare
|
||||
the cubes.
|
||||
*/
|
||||
|
||||
// add a scene node with no shader
|
||||
// add a scene node with no shader
|
||||
|
||||
node = smgr->addCubeSceneNode(50);
|
||||
node->setPosition(core::vector3df(0,50,25));
|
||||
|
@ -394,13 +402,13 @@ int main()
|
|||
|
||||
if (lastFPS != fps)
|
||||
{
|
||||
core::stringw str = L"Irrlicht Engine - Vertex and pixel shader example [";
|
||||
str += driver->getName();
|
||||
str += "] FPS:";
|
||||
str += fps;
|
||||
core::stringw str = L"Irrlicht Engine - Vertex and pixel shader example [";
|
||||
str += driver->getName();
|
||||
str += "] FPS:";
|
||||
str += fps;
|
||||
|
||||
device->setWindowCaption(str.c_str());
|
||||
lastFPS = fps;
|
||||
device->setWindowCaption(str.c_str());
|
||||
lastFPS = fps;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -409,3 +417,7 @@ int main()
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Compile and run this, and I hope you have fun with your new little shader
|
||||
writing tool :).
|
||||
**/
|
||||
|
|
|
@ -0,0 +1,230 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="11.PerPixelLighting_vc9"
|
||||
ProjectGUID="{C4B42409-542D-4EFC-9E6B-44713FD47A33}"
|
||||
RootNamespace="PerPixelLighting_vc9"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/PerPixelLighting.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/PerPixelLighting.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\11.PerPixelLighting.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/PerPixelLighting.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/PerPixelLighting.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/PerPixelLighting.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\11.PerPixelLighting.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
ProgramDatabaseFile=".\Release/PerPixelLighting.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,27 +1,26 @@
|
|||
/*
|
||||
This tutorial shows how to use one of the built in more complex materials in irrlicht:
|
||||
Per pixel lighted surfaces using normal maps and parallax mapping. It will also show
|
||||
how to use fog and moving particle systems. And don't panic: You dont need any
|
||||
experience with shaders to use these materials in Irrlicht.
|
||||
/** Example 011 Per-Pixel Lighting
|
||||
|
||||
At first, we need to include all headers and do the stuff we always do, like
|
||||
in nearly all other tutorials.
|
||||
This tutorial shows how to use one of the built in more complex materials in
|
||||
irrlicht: Per pixel lighted surfaces using normal maps and parallax mapping. It
|
||||
will also show how to use fog and moving particle systems. And don't panic: You
|
||||
dont need any experience with shaders to use these materials in Irrlicht.
|
||||
|
||||
At first, we need to include all headers and do the stuff we always do, like in
|
||||
nearly all other tutorials.
|
||||
*/
|
||||
#include <irrlicht.h>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
using namespace irr;
|
||||
|
||||
#pragma comment(lib, "Irrlicht.lib")
|
||||
|
||||
|
||||
/*
|
||||
For this example, we need an event receiver, to make it possible for the user
|
||||
to switch between the three available material types. In addition, the event
|
||||
receiver will create some small GUI window which displays what material is
|
||||
currently being used. There is nothing special done in this class, so maybe
|
||||
you want to skip reading it.
|
||||
currently being used. There is nothing special done in this class, so maybe you
|
||||
want to skip reading it.
|
||||
*/
|
||||
class MyEventReceiver : public IEventReceiver
|
||||
{
|
||||
|
@ -120,13 +119,14 @@ private:
|
|||
Room->setMaterialType(type);
|
||||
|
||||
/*
|
||||
We need to add a warning if the materials will not be able to be
|
||||
displayed 100% correctly. This is no problem, they will be renderered
|
||||
using fall back materials, but at least the user should know that
|
||||
it would look better on better hardware.
|
||||
We simply check if the material renderer is able to draw at full
|
||||
quality on the current hardware. The IMaterialRenderer::getRenderCapability()
|
||||
returns 0 if this is the case.
|
||||
We need to add a warning if the materials will not be able to
|
||||
be displayed 100% correctly. This is no problem, they will be
|
||||
renderered using fall back materials, but at least the user
|
||||
should know that it would look better on better hardware. We
|
||||
simply check if the material renderer is able to draw at full
|
||||
quality on the current hardware. The
|
||||
IMaterialRenderer::getRenderCapability() returns 0 if this is
|
||||
the case.
|
||||
*/
|
||||
video::IMaterialRenderer* renderer = Driver->getMaterialRenderer(type);
|
||||
|
||||
|
@ -177,7 +177,8 @@ int main()
|
|||
|
||||
// create device
|
||||
|
||||
IrrlichtDevice* device = createDevice(driverType, core::dimension2d<s32>(640, 480));
|
||||
IrrlichtDevice* device = createDevice(driverType,
|
||||
core::dimension2d<s32>(640, 480));
|
||||
|
||||
if (device == 0)
|
||||
return 1; // could not create selected driver.
|
||||
|
@ -186,11 +187,11 @@ int main()
|
|||
/*
|
||||
Before we start with the interesting stuff, we do some simple things:
|
||||
Store pointers to the most important parts of the engine (video driver,
|
||||
scene manager, gui environment) to safe us from typing too much,
|
||||
add an irrlicht engine logo to the window and a user controlled
|
||||
first person shooter style camera. Also, we let the engine now
|
||||
that it should store all textures in 32 bit. This necessary because
|
||||
for parallax mapping, we need 32 bit textures.
|
||||
scene manager, gui environment) to safe us from typing too much, add an
|
||||
irrlicht engine logo to the window and a user controlled first person
|
||||
shooter style camera. Also, we let the engine know that it should store
|
||||
all textures in 32 bit. This necessary because for parallax mapping, we
|
||||
need 32 bit textures.
|
||||
*/
|
||||
|
||||
video::IVideoDriver* driver = device->getVideoDriver();
|
||||
|
@ -213,21 +214,21 @@ int main()
|
|||
|
||||
|
||||
/*
|
||||
Because we want the whole scene to look a little bit scarier, we add some fog
|
||||
to it. This is done by a call to IVideoDriver::setFog(). There you can set
|
||||
various fog settings. In this example, we use pixel fog, because it will
|
||||
work well with the materials we'll use in this example.
|
||||
Because we want the whole scene to look a little bit scarier, we add
|
||||
some fog to it. This is done by a call to IVideoDriver::setFog(). There
|
||||
you can set various fog settings. In this example, we use pixel fog,
|
||||
because it will work well with the materials we'll use in this example.
|
||||
Please note that you will have to set the material flag EMF_FOG_ENABLE
|
||||
to 'true' in every scene node which should be affected by this fog.
|
||||
*/
|
||||
driver->setFog(video::SColor(0,138,125,81), true, 250, 1000, 0, true);
|
||||
|
||||
/*
|
||||
To be able to display something interesting, we load a mesh from a .3ds file
|
||||
which is a room I modeled with anim8or. It is the same room as
|
||||
from the specialFX example. Maybe you remember from that tutorial,
|
||||
I am no good modeler at all and so I totally messed up the texture
|
||||
mapping in this model, but we can simply repair it with the
|
||||
To be able to display something interesting, we load a mesh from a .3ds
|
||||
file which is a room I modeled with anim8or. It is the same room as
|
||||
from the specialFX example. Maybe you remember from that tutorial, I am
|
||||
no good modeler at all and so I totally messed up the texture mapping
|
||||
in this model, but we can simply repair it with the
|
||||
IMeshManipulator::makePlanarTextureMapping() method.
|
||||
*/
|
||||
|
||||
|
@ -241,33 +242,39 @@ int main()
|
|||
roomMesh->getMesh(0), 0.003f);
|
||||
|
||||
/*
|
||||
Now for the first exciting thing: If we successfully loaded the mesh
|
||||
we need to apply textures to it. Because we want this room to be
|
||||
displayed with a very cool material, we have to do a little bit more
|
||||
than just set the textures. Instead of only loading a color map as usual,
|
||||
we also load a height map which is simply a grayscale texture. From this
|
||||
height map, we create a normal map which we will set as second texture of the
|
||||
room. If you already have a normal map, you could directly set it, but I simply
|
||||
didn´t find a nice normal map for this texture.
|
||||
The normal map texture is being generated by the makeNormalMapTexture method
|
||||
of the VideoDriver. The second parameter specifies the height of the heightmap.
|
||||
If you set it to a bigger value, the map will look more rocky.
|
||||
Now for the first exciting thing: If we successfully loaded the
|
||||
mesh we need to apply textures to it. Because we want this room
|
||||
to be displayed with a very cool material, we have to do a
|
||||
little bit more than just set the textures. Instead of only
|
||||
loading a color map as usual, we also load a height map which
|
||||
is simply a grayscale texture. From this height map, we create
|
||||
a normal map which we will set as second texture of the room.
|
||||
If you already have a normal map, you could directly set it,
|
||||
but I simply didn't find a nice normal map for this texture.
|
||||
The normal map texture is being generated by the
|
||||
makeNormalMapTexture method of the VideoDriver. The second
|
||||
parameter specifies the height of the heightmap. If you set it
|
||||
to a bigger value, the map will look more rocky.
|
||||
*/
|
||||
|
||||
video::ITexture* colorMap = driver->getTexture("../../media/rockwall.bmp");
|
||||
video::ITexture* normalMap = driver->getTexture("../../media/rockwall_height.bmp");
|
||||
video::ITexture* colorMap =
|
||||
driver->getTexture("../../media/rockwall.bmp");
|
||||
video::ITexture* normalMap =
|
||||
driver->getTexture("../../media/rockwall_height.bmp");
|
||||
|
||||
driver->makeNormalMapTexture(normalMap, 9.0f);
|
||||
|
||||
/*
|
||||
But just setting color and normal map is not everything. The material we want to
|
||||
use needs some additional informations per vertex like tangents and binormals.
|
||||
Because we are too lazy to calculate that information now, we let Irrlicht do
|
||||
this for us. That's why we call IMeshManipulator::createMeshWithTangents(). It
|
||||
creates a mesh copy with tangents and binormals from any other mesh.
|
||||
After we've done that, we simply create a standard mesh scene node with this
|
||||
mesh copy, set color and normal map and adjust some other material settings.
|
||||
Note that we set EMF_FOG_ENABLE to true to enable fog in the room.
|
||||
But just setting color and normal map is not everything. The
|
||||
material we want to use needs some additional informations per
|
||||
vertex like tangents and binormals. Because we are too lazy to
|
||||
calculate that information now, we let Irrlicht do this for us.
|
||||
That's why we call IMeshManipulator::createMeshWithTangents().
|
||||
It creates a mesh copy with tangents and binormals from another
|
||||
mesh. After we've done that, we simply create a standard
|
||||
mesh scene node with this mesh copy, set color and normal map
|
||||
and adjust some other material settings. Note that we set
|
||||
EMF_FOG_ENABLE to true to enable fog in the room.
|
||||
*/
|
||||
|
||||
scene::IMesh* tangentMesh = smgr->getMeshManipulator()->createMeshWithTangents(
|
||||
|
@ -281,20 +288,21 @@ int main()
|
|||
|
||||
room->setMaterialFlag(video::EMF_FOG_ENABLE, true);
|
||||
room->setMaterialType(video::EMT_PARALLAX_MAP_SOLID);
|
||||
room->getMaterial(0).MaterialTypeParam = 0.035f; // adjust height for parallax effect
|
||||
// adjust height for parallax effect
|
||||
room->getMaterial(0).MaterialTypeParam = 0.035f;
|
||||
|
||||
// drop mesh because we created it with a create.. call.
|
||||
tangentMesh->drop();
|
||||
}
|
||||
|
||||
/*
|
||||
After we've created a room shaded by per pixel lighting, we add a sphere
|
||||
into it with the same material, but we'll make it transparent. In addition,
|
||||
because the sphere looks somehow like a familiar planet, we make it rotate.
|
||||
The procedure is similar as before. The difference is that we are loading
|
||||
the mesh from an .x file which already contains a color map so we do not
|
||||
need to load it manually. But the sphere is a little bit too small for our
|
||||
needs, so we scale it by the factor 50.
|
||||
After we've created a room shaded by per pixel lighting, we add a
|
||||
sphere into it with the same material, but we'll make it transparent.
|
||||
In addition, because the sphere looks somehow like a familiar planet,
|
||||
we make it rotate. The procedure is similar as before. The difference
|
||||
is that we are loading the mesh from an .x file which already contains
|
||||
a color map so we do not need to load it manually. But the sphere is a
|
||||
little bit too small for our needs, so we scale it by the factor 50.
|
||||
*/
|
||||
|
||||
// add earth sphere
|
||||
|
@ -341,10 +349,11 @@ int main()
|
|||
}
|
||||
|
||||
/*
|
||||
Per pixel lighted materials only look cool when there are moving lights. So we
|
||||
add some. And because moving lights alone are so boring, we add billboards
|
||||
to them, and a whole particle system to one of them.
|
||||
We start with the first light which is red and has only the billboard attached.
|
||||
Per pixel lighted materials only look cool when there are moving
|
||||
lights. So we add some. And because moving lights alone are so boring,
|
||||
we add billboards to them, and a whole particle system to one of them.
|
||||
We start with the first light which is red and has only the billboard
|
||||
attached.
|
||||
*/
|
||||
|
||||
// add light 1 (nearly red)
|
||||
|
@ -369,15 +378,16 @@ int main()
|
|||
bill->setMaterialTexture(0, driver->getTexture("../../media/particlered.bmp"));
|
||||
|
||||
/*
|
||||
Now the same again, with the second light. The difference is that we add a particle
|
||||
system to it too. And because the light moves, the particles of the particlesystem
|
||||
will follow. If you want to know more about how particle systems are created in
|
||||
Irrlicht, take a look at the specialFx example.
|
||||
Maybe you will have noticed that we only add 2 lights, this has a simple reason: The
|
||||
low end version of this material was written in ps1.1 and vs1.1, which doesn't allow
|
||||
more lights. You could add a third light to the scene, but it won't be used to
|
||||
shade the walls. But of course, this will change in future versions of Irrlicht were
|
||||
higher versions of pixel/vertex shaders will be implemented too.
|
||||
Now the same again, with the second light. The difference is that we
|
||||
add a particle system to it too. And because the light moves, the
|
||||
particles of the particlesystem will follow. If you want to know more
|
||||
about how particle systems are created in Irrlicht, take a look at the
|
||||
specialFx example. Maybe you will have noticed that we only add 2
|
||||
lights, this has a simple reason: The low end version of this material
|
||||
was written in ps1.1 and vs1.1, which doesn't allow more lights. You
|
||||
could add a third light to the scene, but it won't be used to shade the
|
||||
walls. But of course, this will change in future versions of Irrlicht
|
||||
where higher versions of pixel/vertex shaders will be implemented too.
|
||||
*/
|
||||
|
||||
// add light 2 (gray)
|
||||
|
@ -386,7 +396,8 @@ int main()
|
|||
video::SColorf(1.0f, 0.2f, 0.2f, 0.0f), 800.0f);
|
||||
|
||||
// add fly circle animator to light 2
|
||||
anim = smgr->createFlyCircleAnimator (core::vector3df(0,150,0),200.0f, 0.001f, core::vector3df ( 0.2f, 0.9f, 0.f ));
|
||||
anim = smgr->createFlyCircleAnimator(core::vector3df(0,150,0), 200.0f,
|
||||
0.001f, core::vector3df(0.2f, 0.9f, 0.f));
|
||||
light2->addAnimator(anim);
|
||||
anim->drop();
|
||||
|
||||
|
@ -463,3 +474,5 @@ int main()
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
**/
|
||||
|
|
|
@ -0,0 +1,230 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="12.TerrainRendering_vc9"
|
||||
ProjectGUID="{3A5B74E5-6390-43B0-A459-2793B81FFD31}"
|
||||
RootNamespace="TerrainRendering_vc9"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/TerrainRendering.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/TerrainRendering.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\12.TerrainRendering.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/TerrainRendering.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/TerrainRendering.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/TerrainRendering.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\12.TerrainRendering.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
ProgramDatabaseFile=".\Release/TerrainRendering.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,15 +1,18 @@
|
|||
/*
|
||||
This tutorial will briefly show how to use the terrain renderer of Irrlicht. It will also
|
||||
show the terrain renderer triangle selector to be able to do collision detection with
|
||||
terrain.
|
||||
/** Example 012 Terrain Rendering
|
||||
|
||||
Note that the Terrain Renderer in Irrlicht is based on Spintz' GeoMipMapSceneNode, lots
|
||||
of thanks go to him.
|
||||
DeusXL provided a new elegant simple solution for building larger area on small heightmaps
|
||||
-> terrain smoothing.
|
||||
In the beginning there is nothing special. We include the needed header files and create
|
||||
an event listener to listen if the user presses the 'W' key so we can switch to wireframe
|
||||
mode and if he presses 'D' we toggle to material between solid and detail mapped.
|
||||
This tutorial will briefly show how to use the terrain renderer of Irrlicht. It
|
||||
will also show the terrain renderer triangle selector to be able to do
|
||||
collision detection with terrain.
|
||||
|
||||
Note that the Terrain Renderer in Irrlicht is based on Spintz'
|
||||
GeoMipMapSceneNode, lots of thanks go to him. DeusXL provided a new elegant
|
||||
simple solution for building larger area on small heightmaps -> terrain
|
||||
smoothing.
|
||||
|
||||
In the beginning there is nothing special. We include the needed header files
|
||||
and create an event listener to listen if the user presses a key: The 'W' key
|
||||
switches to wireframe mode, the 'P' key to pointcloud mode, and the 'D' key
|
||||
toggles between solid and detail mapped material.
|
||||
*/
|
||||
#include <irrlicht.h>
|
||||
#include <iostream>
|
||||
|
@ -37,16 +40,18 @@ public:
|
|||
switch (event.KeyInput.Key)
|
||||
{
|
||||
case irr::KEY_KEY_W: // switch wire frame mode
|
||||
Terrain->setMaterialFlag(video::EMF_WIREFRAME, !Terrain->getMaterial(0).Wireframe);
|
||||
Terrain->setMaterialFlag(video::EMF_WIREFRAME,
|
||||
!Terrain->getMaterial(0).Wireframe);
|
||||
Terrain->setMaterialFlag(video::EMF_POINTCLOUD, false);
|
||||
return true;
|
||||
case irr::KEY_KEY_P: // switch wire frame mode
|
||||
Terrain->setMaterialFlag(video::EMF_POINTCLOUD, !Terrain->getMaterial(0).PointCloud);
|
||||
Terrain->setMaterialFlag(video::EMF_POINTCLOUD,
|
||||
!Terrain->getMaterial(0).PointCloud);
|
||||
Terrain->setMaterialFlag(video::EMF_WIREFRAME, false);
|
||||
return true;
|
||||
case irr::KEY_KEY_D: // toggle detail map
|
||||
Terrain->setMaterialType(
|
||||
Terrain->getMaterial(0).MaterialType == video::EMT_SOLID ?
|
||||
Terrain->getMaterial(0).MaterialType == video::EMT_SOLID ?
|
||||
video::EMT_DETAIL_MAP : video::EMT_SOLID);
|
||||
return true;
|
||||
}
|
||||
|
@ -91,7 +96,8 @@ int main()
|
|||
|
||||
// create device
|
||||
|
||||
IrrlichtDevice* device = createDevice(driverType, core::dimension2d<s32>(640, 480));
|
||||
IrrlichtDevice* device = createDevice(driverType,
|
||||
core::dimension2d<s32>(640, 480));
|
||||
|
||||
if (device == 0)
|
||||
return 1; // could not create selected driver.
|
||||
|
@ -101,7 +107,7 @@ int main()
|
|||
First, we add standard stuff to the scene: A nice irrlicht engine
|
||||
logo, a small help text, a user controlled camera, and we disable
|
||||
the mouse cursor.
|
||||
*/
|
||||
*/
|
||||
|
||||
video::IVideoDriver* driver = device->getVideoDriver();
|
||||
scene::ISceneManager* smgr = device->getSceneManager();
|
||||
|
@ -122,7 +128,7 @@ int main()
|
|||
core::rect<s32>(10,440,250,475), true, true, 0, -1, true);
|
||||
|
||||
// add camera
|
||||
scene::ICameraSceneNode* camera =
|
||||
scene::ICameraSceneNode* camera =
|
||||
smgr->addCameraSceneNodeFPS(0,100.0f,1200.f);
|
||||
|
||||
camera->setPosition(core::vector3df(1900*2,255*2,3700*2));
|
||||
|
@ -133,37 +139,42 @@ int main()
|
|||
device->getCursorControl()->setVisible(false);
|
||||
|
||||
/*
|
||||
Here comes the terrain renderer scene node: We add it just like any
|
||||
other scene node to the scene using ISceneManager::addTerrainSceneNode().
|
||||
The only parameter we use is a file name to the heightmap we use. A heightmap
|
||||
is simply a gray scale texture. The terrain renderer loads it and creates
|
||||
the 3D terrain from it.
|
||||
To make the terrain look more big, we change the scale factor of it to (40, 4.4, 40).
|
||||
Because we don't have any dynamic lights in the scene, we switch off the lighting,
|
||||
and we set the file terrain-texture.jpg as texture for the terrain and
|
||||
detailmap3.jpg as second texture, called detail map. At last, we set
|
||||
the scale values for the texture: The first texture will be repeated only one time over
|
||||
the whole terrain, and the second one (detail map) 20 times.
|
||||
Here comes the terrain renderer scene node: We add it just like any
|
||||
other scene node to the scene using
|
||||
ISceneManager::addTerrainSceneNode(). The only parameter we use is a
|
||||
file name to the heightmap we use. A heightmap is simply a gray scale
|
||||
texture. The terrain renderer loads it and creates the 3D terrain from
|
||||
it.
|
||||
|
||||
To make the terrain look more big, we change the scale factor of
|
||||
it to (40, 4.4, 40). Because we don't have any dynamic lights in the
|
||||
scene, we switch off the lighting, and we set the file
|
||||
terrain-texture.jpg as texture for the terrain and detailmap3.jpg as
|
||||
second texture, called detail map. At last, we set the scale values for
|
||||
the texture: The first texture will be repeated only one time over the
|
||||
whole terrain, and the second one (detail map) 20 times.
|
||||
*/
|
||||
|
||||
// add terrain scene node
|
||||
scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
|
||||
scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
|
||||
"../../media/terrain-heightmap.bmp",
|
||||
0, // parent node
|
||||
-1, // node id
|
||||
core::vector3df(0.f, 0.f, 0.f), // position
|
||||
core::vector3df(0.f, 0.f, 0.f), // rotation
|
||||
core::vector3df(40.f, 4.4f, 40.f), // scale
|
||||
video::SColor ( 255, 255, 255, 255 ), // vertexColor,
|
||||
5, // maxLOD
|
||||
scene::ETPS_17, // patchSize
|
||||
4 // smoothFactor
|
||||
0, // parent node
|
||||
-1, // node id
|
||||
core::vector3df(0.f, 0.f, 0.f), // position
|
||||
core::vector3df(0.f, 0.f, 0.f), // rotation
|
||||
core::vector3df(40.f, 4.4f, 40.f), // scale
|
||||
video::SColor ( 255, 255, 255, 255 ), // vertexColor
|
||||
5, // maxLOD
|
||||
scene::ETPS_17, // patchSize
|
||||
4 // smoothFactor
|
||||
);
|
||||
|
||||
terrain->setMaterialFlag(video::EMF_LIGHTING, false);
|
||||
|
||||
terrain->setMaterialTexture(0, driver->getTexture("../../media/terrain-texture.jpg"));
|
||||
terrain->setMaterialTexture(1, driver->getTexture("../../media/detailmap3.jpg"));
|
||||
terrain->setMaterialTexture(0,
|
||||
driver->getTexture("../../media/terrain-texture.jpg"));
|
||||
terrain->setMaterialTexture(1,
|
||||
driver->getTexture("../../media/detailmap3.jpg"));
|
||||
|
||||
terrain->setMaterialType(video::EMT_DETAIL_MAP);
|
||||
|
||||
|
@ -172,10 +183,10 @@ int main()
|
|||
|
||||
/*
|
||||
To be able to do collision with the terrain, we create a triangle selector.
|
||||
If you want to know what triangle selectors do, just take a look into the
|
||||
If you want to know what triangle selectors do, just take a look into the
|
||||
collision tutorial. The terrain triangle selector works together with the
|
||||
terrain. To demonstrate this, we create a collision response animator
|
||||
and attach it to the camera, so that the camera will not be able to fly
|
||||
terrain. To demonstrate this, we create a collision response animator
|
||||
and attach it to the camera, so that the camera will not be able to fly
|
||||
through the terrain.
|
||||
*/
|
||||
|
||||
|
@ -187,23 +198,24 @@ int main()
|
|||
// create collision response animator and attach it to the camera
|
||||
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
|
||||
selector, camera, core::vector3df(60,100,60),
|
||||
core::vector3df(0,0,0),
|
||||
core::vector3df(0,0,0),
|
||||
core::vector3df(0,50,0));
|
||||
selector->drop();
|
||||
camera->addAnimator(anim);
|
||||
anim->drop();
|
||||
|
||||
/*
|
||||
To make the user be able to switch between normal and wireframe mode, we create
|
||||
an instance of the event reciever from above and let Irrlicht know about it. In
|
||||
addition, we add the skybox which we already used in lots of Irrlicht examples.
|
||||
To make the user be able to switch between normal and wireframe mode,
|
||||
we create an instance of the event reciever from above and let Irrlicht
|
||||
know about it. In addition, we add the skybox which we already used in
|
||||
lots of Irrlicht examples.
|
||||
*/
|
||||
|
||||
// create event receiver
|
||||
MyEventReceiver receiver(terrain);
|
||||
device->setEventReceiver(&receiver);
|
||||
|
||||
// create skybox
|
||||
// create skybox
|
||||
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
|
||||
|
||||
smgr->addSkyBoxSceneNode(
|
||||
|
@ -218,7 +230,7 @@ int main()
|
|||
|
||||
|
||||
/*
|
||||
That's it, draw everything. Now you know how to use terrain in Irrlicht.
|
||||
That's it, draw everything.
|
||||
*/
|
||||
|
||||
int lastFPS = -1;
|
||||
|
@ -244,7 +256,8 @@ int main()
|
|||
// Also print terrain height of current camera position
|
||||
// We can use camera position because terrain is located at coordinate origin
|
||||
str += " Height: ";
|
||||
str += terrain->getHeight(camera->getAbsolutePosition().X, camera->getAbsolutePosition().Z);
|
||||
str += terrain->getHeight(camera->getAbsolutePosition().X,
|
||||
camera->getAbsolutePosition().Z);
|
||||
|
||||
device->setWindowCaption(str.c_str());
|
||||
lastFPS = fps;
|
||||
|
@ -256,3 +269,6 @@ int main()
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Now you know how to use terrain in Irrlicht.
|
||||
**/
|
||||
|
|
|
@ -0,0 +1,230 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="13.RenderToTexture_vc9"
|
||||
ProjectGUID="{0914E5C8-5352-467B-8421-C9EB35BD5596}"
|
||||
RootNamespace="RenderToTexture_vc9"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/RenderToTexture.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/RenderToTexture.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\13.RenderToTexture.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
ProgramDatabaseFile=".\Release/RenderToTexture.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/RenderToTexture.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/RenderToTexture.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\13.RenderToTexture.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/RenderToTexture.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,10 +1,11 @@
|
|||
/*
|
||||
This tutorial shows how to render to a texture using Irrlicht. Render to texture is a feature with which
|
||||
it is possible to create nice special effects. In addition, this tutorial shows how to enable specular
|
||||
highlights.
|
||||
/** Example 013 Render To Texture
|
||||
|
||||
In the beginning, everything as usual. Include the needed headers, ask the user for the rendering
|
||||
driver, create the Irrlicht Device:
|
||||
This tutorial shows how to render to a texture using Irrlicht. Render to
|
||||
texture is a feature with which it is possible to create nice special effects.
|
||||
In addition, this tutorial shows how to enable specular highlights.
|
||||
|
||||
In the beginning, everything as usual. Include the needed headers, ask the user
|
||||
for the rendering driver, create the Irrlicht Device:
|
||||
*/
|
||||
|
||||
#include <irrlicht.h>
|
||||
|
@ -54,10 +55,10 @@ int main()
|
|||
|
||||
/*
|
||||
Now, we load an animated mesh to be displayed. As in most examples,
|
||||
we'll take the fairy md2 model. The difference here: We set the shininess
|
||||
of the model to a value other than 0 which is the default value. This
|
||||
enables specular highlights on the model if dynamic lighting is on.
|
||||
The value influences the size of the highlights.
|
||||
we'll take the fairy md2 model. The difference here: We set the
|
||||
shininess of the model to a value other than 0 which is the default
|
||||
value. This enables specular highlights on the model if dynamic
|
||||
lighting is on. The value influences the size of the highlights.
|
||||
*/
|
||||
|
||||
// load and display animated fairy mesh
|
||||
|
@ -67,7 +68,8 @@ int main()
|
|||
|
||||
if (fairy)
|
||||
{
|
||||
fairy->setMaterialTexture(0, driver->getTexture("../../media/faerie2.bmp")); // set diffuse texture
|
||||
fairy->setMaterialTexture(0,
|
||||
driver->getTexture("../../media/faerie2.bmp")); // set diffuse texture
|
||||
fairy->setMaterialFlag(video::EMF_LIGHTING, true); // enable dynamic lighting
|
||||
fairy->getMaterial(0).Shininess = 20.0f; // set size of specular highlights
|
||||
fairy->setPosition(core::vector3df(-10,0,-100));
|
||||
|
@ -75,9 +77,10 @@ int main()
|
|||
}
|
||||
|
||||
/*
|
||||
To make specular highlights appear on the model, we need a dynamic light in the scene.
|
||||
We add one directly in vicinity of the model. In addition, to make the model not that
|
||||
dark, we set the ambient light to gray.
|
||||
To make specular highlights appear on the model, we need a dynamic
|
||||
light in the scene. We add one directly in vicinity of the model. In
|
||||
addition, to make the model not that dark, we set the ambient light to
|
||||
gray.
|
||||
*/
|
||||
|
||||
// add white light
|
||||
|
@ -88,8 +91,9 @@ int main()
|
|||
smgr->setAmbientLight(video::SColor(0,60,60,60));
|
||||
|
||||
/*
|
||||
The next is just some standard stuff: Add a user controlled camera to the scene, disable
|
||||
mouse cursor, and add a test cube and let it rotate to make the scene more interesting.
|
||||
The next is just some standard stuff: Add a user controlled camera to
|
||||
the scene, disable mouse cursor, and add a test cube and let it rotate
|
||||
to make the scene more interesting.
|
||||
*/
|
||||
|
||||
// add fps camera
|
||||
|
@ -115,14 +119,16 @@ int main()
|
|||
device->setWindowCaption(L"Irrlicht Engine - Render to Texture and Specular Highlights example");
|
||||
|
||||
/*
|
||||
To test out the render to texture feature, we need a render target texture. These are not
|
||||
like standard textures, but need to be created first. To create one, we call
|
||||
IVideoDriver::createRenderTargetTexture() and specify the size of the texture. Please
|
||||
don't use sizes bigger than the frame buffer for this, because the render target shares
|
||||
the zbuffer with the frame buffer. And because we want to render the scene not from the
|
||||
user camera into the texture, we add another, fixed camera to the scene. But before we
|
||||
do all this, we check if the current running driver is able to render to textures. If
|
||||
it is not, we simply display a warning text.
|
||||
To test out the render to texture feature, we need a render target
|
||||
texture. These are not like standard textures, but need to be created
|
||||
first. To create one, we call IVideoDriver::addRenderTargetTexture()
|
||||
and specify the size of the texture. Please don't use sizes bigger than
|
||||
the frame buffer for this, because the render target shares the zbuffer
|
||||
with the frame buffer.
|
||||
Because we want to render the scene not from the user camera into the
|
||||
texture, we add another fixed camera to the scene. But before we do all
|
||||
this, we check if the current running driver is able to render to
|
||||
textures. If it is not, we simply display a warning text.
|
||||
*/
|
||||
|
||||
// create render target
|
||||
|
@ -132,7 +138,7 @@ int main()
|
|||
|
||||
if (driver->queryFeature(video::EVDF_RENDER_TO_TARGET))
|
||||
{
|
||||
rt = driver->createRenderTargetTexture(core::dimension2d<s32>(256,256));
|
||||
rt = driver->addRenderTargetTexture(core::dimension2d<s32>(256,256), "RTT1");
|
||||
test->setMaterialTexture(0, rt); // set material of cube to render target
|
||||
|
||||
// add fixed camera
|
||||
|
@ -156,11 +162,12 @@ int main()
|
|||
}
|
||||
|
||||
/*
|
||||
Nearly finished. Now we need to draw everything. Every frame, we draw the scene twice.
|
||||
Once from the fixed camera into the render target texture and once as usual. When rendering
|
||||
into the render target, we need to disable the visibilty of the test cube, because it has
|
||||
the render target texture applied to it.
|
||||
That's, wasn't quite complicated I hope. :)
|
||||
Nearly finished. Now we need to draw everything. Every frame, we draw
|
||||
the scene twice. Once from the fixed camera into the render target
|
||||
texture and once as usual. When rendering into the render target, we
|
||||
need to disable the visibilty of the test cube, because it has the
|
||||
render target texture applied to it. That's it, wasn't too complicated
|
||||
I hope. :)
|
||||
*/
|
||||
|
||||
int lastFPS = -1;
|
||||
|
@ -175,18 +182,18 @@ int main()
|
|||
// draw scene into render target
|
||||
|
||||
// set render target texture
|
||||
driver->setRenderTarget(rt, true, true, video::SColor(0,0,0,255));
|
||||
driver->setRenderTarget(rt, true, true, video::SColor(0,0,0,255));
|
||||
|
||||
// make cube invisible and set fixed camera as active camera
|
||||
test->setVisible(false);
|
||||
smgr->setActiveCamera(fixedCam);
|
||||
|
||||
// draw whole scene into render buffer
|
||||
smgr->drawAll();
|
||||
smgr->drawAll();
|
||||
|
||||
// set back old render target
|
||||
// The buffer might have been distorted, so clear it
|
||||
driver->setRenderTarget(0, true, true, 0);
|
||||
driver->setRenderTarget(0, true, true, 0);
|
||||
|
||||
// make the cube visible and set the user controlled camera as active one
|
||||
test->setVisible(true);
|
||||
|
@ -194,7 +201,7 @@ int main()
|
|||
}
|
||||
|
||||
// draw scene normally
|
||||
smgr->drawAll();
|
||||
smgr->drawAll();
|
||||
env->drawAll();
|
||||
|
||||
driver->endScene();
|
||||
|
@ -212,9 +219,9 @@ int main()
|
|||
}
|
||||
}
|
||||
|
||||
if (rt)
|
||||
rt->drop(); // drop render target because we created if with a create() method
|
||||
|
||||
device->drop(); // drop device
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
**/
|
||||
|
|
|
@ -0,0 +1,231 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="14.Win32Window_vc9"
|
||||
ProjectGUID="{772FBE05-D05A-467B-9842-BEC409EEA8D0}"
|
||||
RootNamespace="Win32Window_vc9"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/Win32Window.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/Win32Window.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="kernel32.lib user32.lib gdi32.lib"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\14.Win32Window.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/Win32Window.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/Win32Window.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/Win32Window.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\14.Win32Window.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
ProgramDatabaseFile=".\Release/Win32Window.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,5 +1,13 @@
|
|||
// this example only runs in windows and demonstrates that Irrlicht
|
||||
// can run inside a win32 window.
|
||||
/** Example 014 Win32 Window
|
||||
|
||||
This example only runs under MS Windows and demonstrates that Irrlicht can
|
||||
render inside a win32 window. MFC and .NET Windows.Forms windows are possible,
|
||||
too.
|
||||
|
||||
In the begining, we create a windows window using the windows API. I'm not
|
||||
going to explain this code, because it is windows specific. See the MSDN or a
|
||||
windows book for details.
|
||||
*/
|
||||
|
||||
#include <irrlicht.h>
|
||||
#ifndef _IRR_WINDOWS_
|
||||
|
@ -14,7 +22,8 @@ using namespace irr;
|
|||
HWND hOKButton;
|
||||
HWND hWnd;
|
||||
|
||||
static LRESULT CALLBACK CustomWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
static LRESULT CALLBACK CustomWndProc(HWND hWnd, UINT message,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
|
@ -41,9 +50,6 @@ static LRESULT CALLBACK CustomWndProc(HWND hWnd, UINT message, WPARAM wParam, LP
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
//int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hpre, LPSTR cmd, int cc)
|
||||
{
|
||||
|
@ -96,9 +102,16 @@ int main()
|
|||
|
||||
// create window to put irrlicht in
|
||||
|
||||
HWND hIrrlichtWindow = CreateWindow("BUTTON", "", WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
|
||||
HWND hIrrlichtWindow = CreateWindow("BUTTON", "",
|
||||
WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
|
||||
50, 80, 320, 220, hWnd, NULL, hInstance, NULL);
|
||||
|
||||
/*
|
||||
So now that we have some window, we can create an Irrlicht device
|
||||
inside of it. We use Irrlicht createEx() function for this. We only
|
||||
need the handle (HWND) to that window, set it as windowsID parameter
|
||||
and start up the engine as usual. That's it.
|
||||
*/
|
||||
// create irrlicht device in the button window
|
||||
|
||||
irr::SIrrlichtCreationParameters param;
|
||||
|
@ -115,7 +128,8 @@ int main()
|
|||
scene::ICameraSceneNode* cam = smgr->addCameraSceneNode();
|
||||
cam->setTarget(core::vector3df(0,0,0));
|
||||
|
||||
scene::ISceneNodeAnimator* anim = smgr->createFlyCircleAnimator(core::vector3df(0,15,0), 30.0f);
|
||||
scene::ISceneNodeAnimator* anim =
|
||||
smgr->createFlyCircleAnimator(core::vector3df(0,15,0), 30.0f);
|
||||
cam->addAnimator(anim);
|
||||
anim->drop();
|
||||
|
||||
|
@ -141,13 +155,17 @@ int main()
|
|||
|
||||
// do message queue
|
||||
|
||||
// Instead of this, you can also simply use your own message loop
|
||||
// using GetMessage, DispatchMessage and whatever. Calling
|
||||
// Device->run() will cause Irrlicht to dispatch messages internally too.
|
||||
// You need not call Device->run() if you want to do your own message
|
||||
// dispatching loop, but Irrlicht will not be able to fetch
|
||||
// user input then and you have to do it on your own using the window
|
||||
// messages, DirectInput, or whatever.
|
||||
/*
|
||||
Now the only thing missing is the drawing loop using
|
||||
IrrlichtDevice::run(). We do this as usual. But instead of this, there
|
||||
is another possibility: You can also simply use your own message loop
|
||||
using GetMessage, DispatchMessage and whatever. Calling
|
||||
Device->run() will cause Irrlicht to dispatch messages internally too.
|
||||
You need not call Device->run() if you want to do your own message
|
||||
dispatching loop, but Irrlicht will not be able to fetch user input
|
||||
then and you have to do it on your own using the window messages,
|
||||
DirectInput, or whatever.
|
||||
*/
|
||||
|
||||
while (device->run())
|
||||
{
|
||||
|
@ -156,8 +174,10 @@ int main()
|
|||
driver->endScene();
|
||||
}
|
||||
|
||||
// the alternative, own message dispatching loop without Device->run() would
|
||||
// look like this:
|
||||
/*
|
||||
The alternative, own message dispatching loop without Device->run()
|
||||
would look like this:
|
||||
*/
|
||||
|
||||
/*MSG msg;
|
||||
while (true)
|
||||
|
@ -187,3 +207,6 @@ int main()
|
|||
}
|
||||
#endif // if windows
|
||||
|
||||
/*
|
||||
That's it, Irrlicht now runs in your own windows window.
|
||||
**/
|
||||
|
|
|
@ -0,0 +1,230 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="15.LoadIrrFile_vc9"
|
||||
ProjectGUID="{78C9F424-523C-49AC-94B7-823AA4A26BF9}"
|
||||
RootNamespace="LoadIrrFile_vc9"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/LoadIrrFile.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/LoadIrrFile.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\15.LoadIrrFile.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/LoadIrrFile.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/LoadIrrFile.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/LoadIrrFile.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\15.LoadIrrFile.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
ProgramDatabaseFile=".\Release/LoadIrrFile.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,8 +1,9 @@
|
|||
/*
|
||||
/** Example 015 Loading Scenes from .irr Files
|
||||
|
||||
Since version 1.1, Irrlicht is able to save and load
|
||||
the full scene graph into an .irr file, an xml based
|
||||
format. There is an editor available to edit
|
||||
those files, named irrEdit on http://www.ambiera.com/irredit,
|
||||
those files, named irrEdit (http://www.ambiera.com/irredit)
|
||||
which can also be used as world and particle editor.
|
||||
This tutorial shows how to use .irr files.
|
||||
|
||||
|
@ -13,7 +14,9 @@ Lets start: Create an Irrlicht device and setup the window.
|
|||
#include <iostream>
|
||||
using namespace irr;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "Irrlicht.lib")
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -38,7 +41,7 @@ int main()
|
|||
case 'e': driverType = video::EDT_BURNINGSVIDEO;break;
|
||||
case 'f': driverType = video::EDT_NULL; break;
|
||||
default: return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// create device and exit if creation failed
|
||||
|
||||
|
@ -53,30 +56,35 @@ int main()
|
|||
video::IVideoDriver* driver = device->getVideoDriver();
|
||||
scene::ISceneManager* smgr = device->getSceneManager();
|
||||
|
||||
/* Now load our .irr file.
|
||||
.irr files can store the whole scene graph including animators, materials
|
||||
and particle systems. And there is also the possibility to store arbitrary
|
||||
user data for every scene node in that file. To keep this
|
||||
example simple, we are simply loading the scene here. See the documentation
|
||||
at ISceneManager::loadScene and ISceneManager::saveScene for more information.
|
||||
So to load and display a complicated huge scene, we only need a single call
|
||||
to loadScene().
|
||||
/*
|
||||
Now load our .irr file.
|
||||
.irr files can store the whole scene graph including animators,
|
||||
materials and particle systems. And there is also the possibility to
|
||||
store arbitrary user data for every scene node in that file. To keep
|
||||
this example simple, we are simply loading the scene here. See the
|
||||
documentation at ISceneManager::loadScene and ISceneManager::saveScene
|
||||
for more information. So to load and display a complicated huge scene,
|
||||
we only need a single call to loadScene().
|
||||
*/
|
||||
|
||||
// load the scene
|
||||
smgr->loadScene("../../media/example.irr");
|
||||
|
||||
// Now we'll create a camera, and give it a collision response animator
|
||||
// that's built from the mesh nodes in the scene we just loaded.
|
||||
/*
|
||||
Now we'll create a camera, and give it a collision response animator
|
||||
that's built from the mesh nodes in the scene we just loaded.
|
||||
*/
|
||||
scene::ICameraSceneNode * camera = smgr->addCameraSceneNodeFPS(0, 50, 100);
|
||||
|
||||
// Create a meta triangle selector to hold several triangle selectors.
|
||||
scene::IMetaTriangleSelector * meta = smgr->createMetaTriangleSelector();
|
||||
|
||||
// Now we will find all the nodes in the scene and create triangle
|
||||
// selectors for all suitable nodes. Typically, you would want to make a
|
||||
// more informed decision about which nodes to performs collision checks
|
||||
// on; you could capture that information in the node name or Id.
|
||||
/*
|
||||
Now we will find all the nodes in the scene and create triangle
|
||||
selectors for all suitable nodes. Typically, you would want to make a
|
||||
more informed decision about which nodes to performs collision checks
|
||||
on; you could capture that information in the node name or Id.
|
||||
*/
|
||||
core::array<scene::ISceneNode *> nodes;
|
||||
smgr->getSceneNodesFromType(scene::ESNT_ANY, nodes); // Find all nodes
|
||||
|
||||
|
@ -88,41 +96,44 @@ int main()
|
|||
switch(node->getType())
|
||||
{
|
||||
case scene::ESNT_CUBE:
|
||||
case scene::ESNT_ANIMATED_MESH: // Because the selector won't animate with the mesh,
|
||||
// and is only being used for camera collision, we'll just use an approximate
|
||||
// bounding box instead of ((scene::IAnimatedMeshSceneNode*)node)->getMesh(0)
|
||||
selector = smgr->createTriangleSelectorFromBoundingBox(node);
|
||||
break;
|
||||
case scene::ESNT_ANIMATED_MESH:
|
||||
// Because the selector won't animate with the mesh,
|
||||
// and is only being used for camera collision, we'll just use an approximate
|
||||
// bounding box instead of ((scene::IAnimatedMeshSceneNode*)node)->getMesh(0)
|
||||
selector = smgr->createTriangleSelectorFromBoundingBox(node);
|
||||
break;
|
||||
|
||||
case scene::ESNT_MESH:
|
||||
case scene::ESNT_SPHERE: // Derived from IMeshSceneNode
|
||||
selector = smgr->createTriangleSelector(((scene::IMeshSceneNode*)node)->getMesh(), node);
|
||||
break;
|
||||
selector = smgr->createTriangleSelector(((scene::IMeshSceneNode*)node)->getMesh(), node);
|
||||
break;
|
||||
|
||||
case scene::ESNT_TERRAIN:
|
||||
selector = smgr->createTerrainTriangleSelector((scene::ITerrainSceneNode*)node);
|
||||
break;
|
||||
selector = smgr->createTerrainTriangleSelector((scene::ITerrainSceneNode*)node);
|
||||
break;
|
||||
|
||||
case scene::ESNT_OCT_TREE:
|
||||
selector = smgr->createOctTreeTriangleSelector(((scene::IMeshSceneNode*)node)->getMesh(), node);
|
||||
break;
|
||||
selector = smgr->createOctTreeTriangleSelector(((scene::IMeshSceneNode*)node)->getMesh(), node);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Don't create a selector for this node type
|
||||
break;
|
||||
// Don't create a selector for this node type
|
||||
break;
|
||||
}
|
||||
|
||||
if(selector)
|
||||
{
|
||||
// Add it to the meta selector, which will take a reference to it
|
||||
meta->addTriangleSelector(selector);
|
||||
// And drop my reference to it, so that the meta selector owns it.
|
||||
selector->drop();
|
||||
// Add it to the meta selector, which will take a reference to it
|
||||
meta->addTriangleSelector(selector);
|
||||
// And drop my reference to it, so that the meta selector owns it.
|
||||
selector->drop();
|
||||
}
|
||||
}
|
||||
|
||||
// Now that the mesh scene nodes have had triangle selectors created and added
|
||||
// to the meta selector, create a collision response animator from that meta selector.
|
||||
/*
|
||||
Now that the mesh scene nodes have had triangle selectors created and added
|
||||
to the meta selector, create a collision response animator from that meta selector.
|
||||
*/
|
||||
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
|
||||
meta, camera, core::vector3df(5,5,5),
|
||||
core::vector3df(0,0,0));
|
||||
|
@ -138,8 +149,10 @@ int main()
|
|||
scene::ISceneNode * cube = smgr->getSceneNodeFromType(scene::ESNT_CUBE);
|
||||
if(cube)
|
||||
camera->setTarget(cube->getAbsolutePosition());
|
||||
|
||||
// and draw everything.
|
||||
|
||||
/*
|
||||
That's it. Draw everything and finish as usual.
|
||||
*/
|
||||
|
||||
int lastFPS = -1;
|
||||
|
||||
|
@ -154,19 +167,21 @@ int main()
|
|||
|
||||
if (lastFPS != fps)
|
||||
{
|
||||
core::stringw str = L"Load Irrlicht File example - Irrlicht Engine [";
|
||||
str += driver->getName();
|
||||
str += "] FPS:";
|
||||
str += fps;
|
||||
core::stringw str = L"Load Irrlicht File example - Irrlicht Engine [";
|
||||
str += driver->getName();
|
||||
str += "] FPS:";
|
||||
str += fps;
|
||||
|
||||
device->setWindowCaption(str.c_str());
|
||||
lastFPS = fps;
|
||||
device->setWindowCaption(str.c_str());
|
||||
lastFPS = fps;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
device->drop();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
**/
|
||||
|
|
|
@ -0,0 +1,188 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="16.Quake3MapShader_vc9"
|
||||
ProjectGUID="{EB3B38EA-5CE7-4983-845B-880661E69D09}"
|
||||
RootNamespace="16.Quake3MapShader_vc9"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\16.Quake3MapShader.exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile="$(OutDir)/Quake3MapShader.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
||||
RuntimeLibrary="0"
|
||||
BufferSecurityCheck="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="0"
|
||||
CallingConvention="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\16.Quake3MapShader.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="false"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\main.cpp"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,4 +1,5 @@
|
|||
/*
|
||||
/** Example 016 Quake3 Map Shader Support
|
||||
|
||||
This Tutorial shows how to load a Quake 3 map into the
|
||||
engine, create a SceneNode for optimizing the speed of
|
||||
rendering and how to create a user controlled camera.
|
||||
|
@ -38,9 +39,9 @@ to ask the user for a driver type using the console.
|
|||
|
||||
/*
|
||||
As already written in the HelloWorld example, in the Irrlicht
|
||||
Engine, everything can be found in the namespace 'irr'.
|
||||
Engine, everything can be found in the namespace 'irr'.
|
||||
To get rid of the irr:: in front of the name of every class,
|
||||
we tell the compiler that we use that namespace from now on,
|
||||
we tell the compiler that we use that namespace from now on,
|
||||
and we will not have to write that 'irr::'.
|
||||
There are 5 other sub namespaces 'core', 'scene', 'video',
|
||||
'io' and 'gui'. Unlike in the HelloWorld example,
|
||||
|
@ -53,7 +54,7 @@ using namespace irr;
|
|||
using namespace scene;
|
||||
|
||||
/*
|
||||
Again, to be able to use the Irrlicht.DLL file, we need to link with the
|
||||
Again, to be able to use the Irrlicht.DLL file, we need to link with the
|
||||
Irrlicht.lib. We could set this option in the project settings, but
|
||||
to make it easy, we use a pragma comment lib:
|
||||
*/
|
||||
|
@ -109,14 +110,14 @@ private:
|
|||
|
||||
|
||||
/*
|
||||
Ok, lets start.
|
||||
Ok, lets start.
|
||||
*/
|
||||
|
||||
int IRRCALLCONV main(int argc, char* argv[])
|
||||
{
|
||||
/*
|
||||
Like in the HelloWorld example, we create an IrrlichtDevice with
|
||||
createDevice(). The difference now is that we ask the user to select
|
||||
createDevice(). The difference now is that we ask the user to select
|
||||
which hardware accelerated driver to use. The Software device would be
|
||||
too slow to draw a huge Quake 3 map, but just for the fun of it, we make
|
||||
this decision possible too.
|
||||
|
@ -188,7 +189,7 @@ int IRRCALLCONV main(int argc, char* argv[])
|
|||
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
Now we can load the mesh by calling getMesh(). We get a pointer returned
|
||||
to a IAnimatedMesh. As you know, Quake 3 maps are not really animated,
|
||||
they are only a huge chunk of static geometry with some materials
|
||||
|
@ -196,15 +197,16 @@ int IRRCALLCONV main(int argc, char* argv[])
|
|||
so we get the "first frame" of the "animation", which is our quake level
|
||||
and create an OctTree scene node with it, using addOctTreeSceneNode().
|
||||
The OctTree optimizes the scene a little bit, trying to draw only geometry
|
||||
which is currently visible. An alternative to the OctTree would be a
|
||||
AnimatedMeshSceneNode, which would draw always the complete geometry of
|
||||
which is currently visible. An alternative to the OctTree would be a
|
||||
AnimatedMeshSceneNode, which would draw always the complete geometry of
|
||||
the mesh, without optimization. Try it out: Write addAnimatedMeshSceneNode
|
||||
instead of addOctTreeSceneNode and compare the primitives drawed by the
|
||||
video driver. (There is a getPrimitiveCountDrawed() method in the
|
||||
video driver. (There is a getPrimitiveCountDrawed() method in the
|
||||
IVideoDriver class). Note that this optimization with the Octree is only
|
||||
useful when drawing huge meshes consisting of lots of geometry.
|
||||
*/
|
||||
scene::IQ3LevelMesh* mesh = (scene::IQ3LevelMesh*) smgr->getMesh(mapname);
|
||||
scene::IQ3LevelMesh* mesh =
|
||||
(scene::IQ3LevelMesh*) smgr->getMesh(mapname);
|
||||
|
||||
/*
|
||||
add the geometry mesh to the Scene ( polygon & patches )
|
||||
|
@ -251,8 +253,10 @@ int IRRCALLCONV main(int argc, char* argv[])
|
|||
continue;
|
||||
}
|
||||
|
||||
// we can dump the shader to the console in it's original but already parsed layout
|
||||
// in a pretty printers way.. commented out, because the console would be full...
|
||||
// we can dump the shader to the console in it's
|
||||
// original but already parsed layout in a pretty
|
||||
// printers way.. commented out, because the console
|
||||
// would be full...
|
||||
// quake3::dumpShader ( Shader );
|
||||
|
||||
#ifndef SHOW_SHADER_NAME
|
||||
|
@ -291,21 +295,22 @@ int IRRCALLCONV main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
/*
|
||||
Now we only need a Camera to look at the Quake 3 map.
|
||||
And we want to create a user controlled camera. There are some
|
||||
different cameras available in the Irrlicht engine. For example the
|
||||
Maya Camera which can be controlled compareable to the camera in Maya:
|
||||
Rotate with left mouse button pressed, Zoom with both buttons pressed,
|
||||
translate with right mouse button pressed. This could be created with
|
||||
addCameraSceneNodeMaya(). But for this example, we want to create a
|
||||
camera which behaves like the ones in first person shooter games (FPS).
|
||||
Now we only need a Camera to look at the Quake 3 map. And we want to
|
||||
create a user controlled camera. There are some different cameras
|
||||
available in the Irrlicht engine. For example the Maya Camera which can
|
||||
be controlled compareable to the camera in Maya: Rotate with left mouse
|
||||
button pressed, Zoom with both buttons pressed, translate with right
|
||||
mouse button pressed. This could be created with
|
||||
addCameraSceneNodeMaya(). But for this example, we want to create a
|
||||
camera which behaves like the ones in first person shooter games (FPS).
|
||||
*/
|
||||
|
||||
scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
|
||||
|
||||
/*
|
||||
so we need a good starting Position in the level.
|
||||
we can ask the Quake3 Loader for all entities with class_name "info_player_deathmatch"
|
||||
we can ask the Quake3 Loader for all entities with class_name
|
||||
"info_player_deathmatch"
|
||||
we choose a random launch
|
||||
|
||||
*/
|
||||
|
@ -326,7 +331,8 @@ int IRRCALLCONV main(int argc, char* argv[])
|
|||
group = entityList[ index ].getGroup(1);
|
||||
|
||||
u32 parsepos = 0;
|
||||
core::vector3df pos = quake3::getAsVector3df ( group->get ( "origin" ), parsepos );
|
||||
core::vector3df pos =
|
||||
quake3::getAsVector3df ( group->get ( "origin" ), parsepos );
|
||||
|
||||
parsepos = 0;
|
||||
f32 angle = quake3::getAsFloat ( group->get ( "angle"), parsepos );
|
||||
|
@ -357,7 +363,8 @@ int IRRCALLCONV main(int argc, char* argv[])
|
|||
device->getCursorControl()->setVisible(false);
|
||||
|
||||
// load the engine logo
|
||||
gui->addImage(driver->getTexture("irrlichtlogo2.png"),core::position2d<s32>(10, 10));
|
||||
gui->addImage(driver->getTexture("irrlichtlogo2.png"),
|
||||
core::position2d<s32>(10, 10));
|
||||
|
||||
// show the driver logo
|
||||
core::position2di pos ( videoDim.Width - 128, videoDim.Height - 64 );
|
||||
|
@ -365,22 +372,22 @@ int IRRCALLCONV main(int argc, char* argv[])
|
|||
switch ( driverType )
|
||||
{
|
||||
case video::EDT_BURNINGSVIDEO:
|
||||
gui->addImage(driver->getTexture("burninglogo.png"),pos );
|
||||
gui->addImage(driver->getTexture("burninglogo.png"),pos);
|
||||
break;
|
||||
case video::EDT_OPENGL:
|
||||
gui->addImage(driver->getTexture("opengllogo.png"),pos );
|
||||
gui->addImage(driver->getTexture("opengllogo.png"),pos);
|
||||
break;
|
||||
case video::EDT_DIRECT3D8:
|
||||
case video::EDT_DIRECT3D9:
|
||||
gui->addImage(driver->getTexture("directxlogo.png"),pos );
|
||||
gui->addImage(driver->getTexture("directxlogo.png"),pos);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
We have done everything, so lets draw it. We also write the current
|
||||
frames per second and the drawn primitives to the caption of the
|
||||
window. The 'if (device->isWindowActive())' line is optional, but
|
||||
prevents the engine render to set the position of the mouse cursor
|
||||
window. The 'if (device->isWindowActive())' line is optional, but
|
||||
prevents the engine render to set the position of the mouse cursor
|
||||
after task switching when other program are active.
|
||||
*/
|
||||
int lastFPS = -1;
|
||||
|
@ -425,4 +432,5 @@ int IRRCALLCONV main(int argc, char* argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
**/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloWorld_mobile", "HelloWorld_mobile.vcproj", "{AD95D5D7-91D2-4030-B28D-23A6FE5C0359}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "17.HelloWorld_mobile", "HelloWorld_mobile.vcproj", "{AD95D5D7-91D2-4030-B28D-23A6FE5C0359}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "..\..\source\Irrlicht\Irrlicht_mobile6.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}"
|
||||
EndProject
|
||||
|
|
|
@ -92,9 +92,9 @@
|
|||
/>
|
||||
<DeploymentTool
|
||||
ForceDirty="-1"
|
||||
RemoteDirectory="%CSIDL_PROGRAM_FILES%\irrlicht\bin\wince"
|
||||
RemoteDirectory="%CSIDL_PROGRAM_FILES%\irrlicht\bin\wince-visualstudio"
|
||||
RegisterOutput="0"
|
||||
AdditionalFiles="sydney.md2|$(InputDir)..\..\media|%CSIDL_PROGRAM_FILES%\irrlicht\media|0;sydney.bmp|$(InputDir)..\..\media|%CSIDL_PROGRAM_FILES%\irrlicht\media|0;irrlicht.dll|$(InputDir)$(OutDir)|%CSIDL_PROGRAM_FILES%\irrlicht\bin\wince|0"
|
||||
AdditionalFiles="sydney.md2|$(InputDir)..\..\media|%CSIDL_PROGRAM_FILES%\irrlicht\media|0;sydney.bmp|$(InputDir)..\..\media|%CSIDL_PROGRAM_FILES%\irrlicht\media|0;irrlicht.dll|$(InputDir)$(OutDir)|%CSIDL_PROGRAM_FILES%\irrlicht\bin\wince-visualstudio|0"
|
||||
/>
|
||||
<DebuggerTool
|
||||
/>
|
||||
|
@ -177,9 +177,9 @@
|
|||
/>
|
||||
<DeploymentTool
|
||||
ForceDirty="-1"
|
||||
RemoteDirectory="%CSIDL_PROGRAM_FILES%\irrlicht\bin\wince"
|
||||
RemoteDirectory="%CSIDL_PROGRAM_FILES%\irrlicht\bin\wince-visualstudio"
|
||||
RegisterOutput="0"
|
||||
AdditionalFiles="sydney.md2|$(InputDir)..\..\media|%CSIDL_PROGRAM_FILES%\irrlicht\media|0;sydney.bmp|$(InputDir)..\..\media|%CSIDL_PROGRAM_FILES%\irrlicht\media|0;irrlicht.dll|$(InputDir)$(OutDir)|%CSIDL_PROGRAM_FILES%\irrlicht\bin\wince|0"
|
||||
AdditionalFiles="sydney.md2|$(InputDir)..\..\media|%CSIDL_PROGRAM_FILES%\irrlicht\media|0;sydney.bmp|$(InputDir)..\..\media|%CSIDL_PROGRAM_FILES%\irrlicht\media|0;irrlicht.dll|$(InputDir)$(OutDir)|%CSIDL_PROGRAM_FILES%\irrlicht\bin\wince-visualstudio|0"
|
||||
/>
|
||||
<DebuggerTool
|
||||
/>
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/** Example 017 Helloworld mobile
|
||||
|
||||
This example show Hello World for Windows mobile
|
||||
*/
|
||||
|
||||
#include <irrlicht.h>
|
||||
|
||||
#ifdef _IRR_USE_WINDOWS_CE_DEVICE_
|
||||
|
@ -110,7 +115,6 @@ int main()
|
|||
// create device
|
||||
|
||||
IrrlichtDevice *device =
|
||||
//createDevice(driverType, dimension2d<s32>(220, 240), 16, false );
|
||||
createDevice(driverType, dimension2d<s32>(240, 320), 16, true );
|
||||
|
||||
if (device == 0)
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
# Makefile for Irrlicht Examples
|
||||
# It's usually sufficient to change just the target name and source file list
|
||||
# and be sure that CXX is set to a valid compiler
|
||||
Target = 18.SplitScreen
|
||||
Sources = main.cpp
|
||||
|
||||
# general compiler settings
|
||||
CPPFLAGS = -I../../include -I/usr/X11R6/include
|
||||
CXXFLAGS = -O3 -ffast-math
|
||||
#CXXFLAGS = -g -Wall
|
||||
|
||||
#default target is Linux
|
||||
all: all_linux
|
||||
|
||||
ifeq ($(HOSTTYPE), x86_64)
|
||||
LIBSELECT=64
|
||||
endif
|
||||
|
||||
# target specific settings
|
||||
all_linux: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L../../lib/Linux -lIrrlicht -lGL -lXxf86vm -lXext -lX11
|
||||
all_linux clean_linux: SYSTEM=Linux
|
||||
all_win32: LDFLAGS = -L../../lib/Win32-gcc -lIrrlicht -lopengl32 -lm
|
||||
all_win32 clean_win32: SYSTEM=Win32-gcc
|
||||
all_win32 clean_win32: SUF=.exe
|
||||
# name of the binary - only valid for targets which set SYSTEM
|
||||
DESTPATH = ../../bin/$(SYSTEM)/$(Target)$(SUF)
|
||||
|
||||
all_linux all_win32:
|
||||
$(warning Building...)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(Sources) -o $(DESTPATH) $(LDFLAGS)
|
||||
|
||||
clean: clean_linux clean_win32
|
||||
$(warning Cleaning...)
|
||||
|
||||
clean_linux clean_win32:
|
||||
@$(RM) $(DESTPATH)
|
||||
|
||||
.PHONY: all all_win32 clean clean_linux clean_win32
|
|
@ -0,0 +1,21 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "18.SplitScreen", "SplitScreen.vcproj", "{EB3B38EA-5CE7-4983-845B-880661E69D09}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
Release = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{EB3B38EA-5CE7-4983-845B-880661E69D09}.Debug.ActiveCfg = Debug|Win32
|
||||
{EB3B38EA-5CE7-4983-845B-880661E69D09}.Debug.Build.0 = Debug|Win32
|
||||
{EB3B38EA-5CE7-4983-845B-880661E69D09}.Release.ActiveCfg = Release|Win32
|
||||
{EB3B38EA-5CE7-4983-845B-880661E69D09}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,132 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="18.SplitScreen"
|
||||
ProjectGUID="{EB3B38EA-5CE7-4983-845B-880661E69D09}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\18.SplitScreen.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/SplitScreen.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/QIfist /Oa"
|
||||
Optimization="3"
|
||||
GlobalOptimizations="TRUE"
|
||||
InlineFunctionExpansion="2"
|
||||
EnableIntrinsicFunctions="TRUE"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="TRUE"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
||||
RuntimeLibrary="4"
|
||||
BufferSecurityCheck="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"
|
||||
CallingConvention="1"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\18.SplitScreen.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="FALSE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\main.cpp">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1,190 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="18.SplitScreen_vc8"
|
||||
ProjectGUID="{EB3B38EA-5CE7-4983-845B-880661E69D09}"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\18.SplitScreen.exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile="$(OutDir)/SplitScreen.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
||||
RuntimeLibrary="0"
|
||||
BufferSecurityCheck="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="0"
|
||||
CallingConvention="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\18.SplitScreen.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="false"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\main.cpp"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1,188 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="18.SplitScreen_vc9"
|
||||
ProjectGUID="{1AB9413E-4F53-42A3-8CB2-CB4BE22336D0}"
|
||||
RootNamespace="18.SplitScreen_vc9"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\18.SplitScreen.exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile="$(OutDir)/SplitScreen.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
||||
RuntimeLibrary="0"
|
||||
BufferSecurityCheck="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="0"
|
||||
CallingConvention="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\18.SplitScreen.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="false"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\main.cpp"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1,59 @@
|
|||
[Project]
|
||||
FileName=example.dev
|
||||
Name=Irrlicht Example 18 SplitScreen
|
||||
UnitCount=1
|
||||
Type=1
|
||||
Ver=1
|
||||
ObjFiles=
|
||||
Includes=..\..\include
|
||||
Libs=
|
||||
PrivateResource=
|
||||
ResourceIncludes=
|
||||
MakeIncludes=
|
||||
Compiler=
|
||||
CppCompiler=
|
||||
Linker=../../lib/Win32-gcc/libIrrlicht.a_@@_
|
||||
IsCpp=1
|
||||
Icon=
|
||||
ExeOutput=../../bin/Win32-gcc
|
||||
ObjectOutput=obj
|
||||
OverrideOutput=1
|
||||
OverrideOutputName=18.SplitScreen.exe
|
||||
HostApplication=
|
||||
Folders=
|
||||
CommandLine=
|
||||
IncludeVersionInfo=0
|
||||
SupportXPThemes=0
|
||||
CompilerSet=0
|
||||
CompilerSettings=0000000000000000000000
|
||||
UseCustomMakefile=0
|
||||
CustomMakefile=
|
||||
|
||||
[Unit1]
|
||||
FileName=main.cpp
|
||||
CompileCpp=1
|
||||
Folder=Projekt1
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[VersionInfo]
|
||||
Major=0
|
||||
Minor=1
|
||||
Release=1
|
||||
Build=1
|
||||
LanguageID=1033
|
||||
CharsetID=1252
|
||||
CompanyName=
|
||||
FileVersion=
|
||||
FileDescription=Irrlicht Engine example compiled using DevCpp and gcc
|
||||
InternalName=
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=
|
||||
ProductName=
|
||||
ProductVersion=
|
||||
AutoIncBuildNr=0
|
||||
|
|
@ -0,0 +1,230 @@
|
|||
/** Example 018 Splitscreen
|
||||
|
||||
A tutorial by Max Winkel.
|
||||
|
||||
In this tutorial we'll learn how to use splitscreen (e.g. for racing-games)
|
||||
with Irrlicht. We'll create a viewport divided
|
||||
into 4 parts, wtih 3 fixed cameras and one user-controlled.
|
||||
|
||||
Ok, let's start with the headers (I think there's
|
||||
nothing to say about it)
|
||||
*/
|
||||
|
||||
#include <irrlicht.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "Irrlicht.lib")
|
||||
#endif
|
||||
|
||||
//Namespaces for the engine
|
||||
using namespace irr;
|
||||
using namespace video;
|
||||
using namespace core;
|
||||
using namespace scene;
|
||||
using namespace io;
|
||||
using namespace gui;
|
||||
|
||||
/*
|
||||
Now we'll define the resolution in a constant for use in
|
||||
initializing the device and setting up the viewport. In addition
|
||||
we set up a global variable saying splitscreen is active or not.
|
||||
*/
|
||||
//Resolution
|
||||
const int ResX=800;
|
||||
const int ResY=600;
|
||||
const bool fullScreen=false;
|
||||
|
||||
//Use SplitScreen?
|
||||
bool SplitScreen=true;
|
||||
|
||||
/*
|
||||
Now we need four pointers to our cameras which are created later:
|
||||
*/
|
||||
//cameras
|
||||
ICameraSceneNode *camera[4]={0,0,0,0};
|
||||
/*
|
||||
In our event-receiver we switch the SplitScreen-variable,
|
||||
whenever the user press the S-key. All other events are sent
|
||||
to the FPS camera.
|
||||
*/
|
||||
|
||||
class MyEventReceiver : public IEventReceiver {
|
||||
public:
|
||||
virtual bool OnEvent(const SEvent& event)
|
||||
{
|
||||
//Key S enables/disables SplitScreen
|
||||
if (event.EventType == irr::EET_KEY_INPUT_EVENT &&
|
||||
event.KeyInput.Key == KEY_KEY_S && event.KeyInput.PressedDown)
|
||||
{
|
||||
SplitScreen = !SplitScreen;
|
||||
return true;
|
||||
}
|
||||
//Send all other events to camera4
|
||||
if (camera[3])
|
||||
return camera[3]->OnEvent(event);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Ok, now the main-function:
|
||||
First, we initialize the device, get the SourceManager and
|
||||
VideoDriver, load an animated mesh from .md2 and a map from
|
||||
.pk3. Because that's old stuff, I won't explain every step.
|
||||
Just take care of the maps position.
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
//Instance of the EventReceiver
|
||||
MyEventReceiver receiver;
|
||||
|
||||
//Initialise the engine
|
||||
IrrlichtDevice *device = createDevice(EDT_OPENGL,
|
||||
dimension2d<s32>(ResX,ResY), 32, fullScreen,
|
||||
false, false, &receiver);
|
||||
|
||||
ISceneManager *smgr = device->getSceneManager();
|
||||
IVideoDriver *driver = device->getVideoDriver();
|
||||
|
||||
//Load model
|
||||
IAnimatedMesh *model = smgr->getMesh("../../media/sydney.md2");
|
||||
if (!model)
|
||||
return 1;
|
||||
IAnimatedMeshSceneNode *model_node = smgr->addAnimatedMeshSceneNode(model);
|
||||
//Load texture
|
||||
ITexture *texture = driver->getTexture("../../media/sydney.bmp");
|
||||
model_node->setMaterialTexture(0,texture);
|
||||
//Disable lighting (we've got no light)
|
||||
model_node->setMaterialFlag(EMF_LIGHTING,false);
|
||||
|
||||
//Load map
|
||||
device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3");
|
||||
IAnimatedMesh *map = smgr->getMesh("20kdm2.bsp");
|
||||
if (map)
|
||||
{
|
||||
ISceneNode *map_node = smgr->addOctTreeSceneNode(map->getMesh(0));
|
||||
//Set position
|
||||
map_node->setPosition(vector3df(-850,-220,-850));
|
||||
}
|
||||
|
||||
/*
|
||||
Now we create our four cameras. One is looking at the model
|
||||
from the front, one from the top and one from the side. In
|
||||
addition there's a FPS-camera which can be controlled by the
|
||||
user.
|
||||
*/
|
||||
// Create 3 fixed and one user-controlled cameras
|
||||
//Front
|
||||
camera[0] = smgr->addCameraSceneNode(0, vector3df(50,0,0), vector3df(0,0,0));
|
||||
//Top
|
||||
camera[1] = smgr->addCameraSceneNode(0, vector3df(0,50,0), vector3df(0,0,0));
|
||||
//Left
|
||||
camera[2] = smgr->addCameraSceneNode(0, vector3df(0,0,50), vector3df(0,0,0));
|
||||
//User-controlled
|
||||
camera[3] = smgr->addCameraSceneNodeFPS();
|
||||
|
||||
/*
|
||||
Create a variable for counting the fps and hide the mouse:
|
||||
*/
|
||||
//Hide mouse
|
||||
device->getCursorControl()->setVisible(false);
|
||||
//We want to count the fps
|
||||
int lastFPS = -1;
|
||||
|
||||
/*
|
||||
There wasn't much new stuff - till now!
|
||||
Only by defining four cameras, the game won't be splitscreen.
|
||||
To do this you need several steps:
|
||||
- Set the viewport to the whole screen
|
||||
- Begin a new scene (Clear screen)
|
||||
|
||||
- The following 3 steps are repeated for every viewport in the splitscreen
|
||||
- Set the viewport to the area you wish
|
||||
- Activate the camera which should be "linked" with the viewport
|
||||
- Render all objects
|
||||
|
||||
- If you have a GUI:
|
||||
- Set the viewport the whole screen
|
||||
- Display the GUI
|
||||
- End scene
|
||||
|
||||
Sounds a little complicated, but you'll see it isn't:
|
||||
*/
|
||||
|
||||
while(device->run())
|
||||
{
|
||||
//Set the viewpoint to the whole screen and begin scene
|
||||
driver->setViewPort(rect<s32>(0,0,ResX,ResY));
|
||||
driver->beginScene(true,true,SColor(255,100,100,100));
|
||||
//If SplitScreen is used
|
||||
if (SplitScreen)
|
||||
{
|
||||
//Activate camera1
|
||||
smgr->setActiveCamera(camera[0]);
|
||||
//Set viewpoint to the first quarter (left top)
|
||||
driver->setViewPort(rect<s32>(0,0,ResX/2,ResY/2));
|
||||
//Draw scene
|
||||
smgr->drawAll();
|
||||
//Activate camera2
|
||||
smgr->setActiveCamera(camera[1]);
|
||||
//Set viewpoint to the second quarter (right top)
|
||||
driver->setViewPort(rect<s32>(ResX/2,0,ResX,ResY/2));
|
||||
//Draw scene
|
||||
smgr->drawAll();
|
||||
//Activate camera3
|
||||
smgr->setActiveCamera(camera[2]);
|
||||
//Set viewpoint to the third quarter (left bottom)
|
||||
driver->setViewPort(rect<s32>(0,ResY/2,ResX/2,ResY));
|
||||
//Draw scene
|
||||
smgr->drawAll();
|
||||
//Set viewport the last quarter (right bottom)
|
||||
driver->setViewPort(rect<s32>(ResX/2,ResY/2,ResX,ResY));
|
||||
}
|
||||
//Activate camera4
|
||||
smgr->setActiveCamera(camera[3]);
|
||||
//Draw scene
|
||||
smgr->drawAll();
|
||||
driver->endScene();
|
||||
|
||||
/*
|
||||
As you can probably see, the image is rendered for every
|
||||
viewport seperately. That means, that you'll loose much performance.
|
||||
Ok, if you're aksing "How do I have to set the viewport
|
||||
to get this or that screen?", don't panic. It's really
|
||||
easy: In the rect-function you define 4 coordinates:
|
||||
- X-coordinate of the corner left top
|
||||
- Y-coordinate of the corner left top
|
||||
- X-coordinate of the corner right bottom
|
||||
- Y-coordinate of the corner right bottom
|
||||
|
||||
That means, if you want to split the screen into 2 viewports
|
||||
you would give the following coordinates:
|
||||
- 1st viewport: 0,0,ResX/2,ResY
|
||||
- 2nd viewport: ResX/2,0,ResX,ResY
|
||||
|
||||
If you didn't fully understand, just play arround with the example
|
||||
to check out what happens.
|
||||
|
||||
Now we just view the current fps and shut down the engine,
|
||||
when the user wants to:
|
||||
*/
|
||||
//Get and show fps
|
||||
if (driver->getFPS() != lastFPS)
|
||||
{
|
||||
lastFPS = driver->getFPS();
|
||||
wchar_t tmp[1024];
|
||||
swprintf( tmp, 1024, L"Irrlicht SplitScreen-Example (FPS: %d)", lastFPS);
|
||||
device->setWindowCaption(tmp);
|
||||
}
|
||||
}
|
||||
//Delete device
|
||||
device->drop();
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
That's it! Just compile and play around with the program.
|
||||
Note: With the S-Key you can switch between using splitscreen
|
||||
and not.
|
||||
**/
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
# Makefile for Irrlicht Examples
|
||||
# It's usually sufficient to change just the target name and source file list
|
||||
# and be sure that CXX is set to a valid compiler
|
||||
Target = 19.MouseAndJoystick
|
||||
Sources = main.cpp
|
||||
|
||||
# general compiler settings
|
||||
CPPFLAGS = -I../../include -I/usr/X11R6/include
|
||||
#CXXFLAGS = -O3 -ffast-math
|
||||
CXXFLAGS = -g -Wall
|
||||
|
||||
#default target is Linux
|
||||
all: all_linux
|
||||
|
||||
ifeq ($(HOSTTYPE), x86_64)
|
||||
LIBSELECT=64
|
||||
endif
|
||||
|
||||
# target specific settings
|
||||
all_linux: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L../../lib/Linux -lIrrlicht -lGL -lXxf86vm -lXext -lX11
|
||||
all_linux clean_linux: SYSTEM=Linux
|
||||
all_win32: LDFLAGS = -L../../lib/Win32-gcc -lIrrlicht -lopengl32 -lm
|
||||
all_win32: CPPFLAGS += -D__GNUWIN32__ -D_WIN32 -DWIN32 -D_WINDOWS -D_MBCS -D_USRDLL
|
||||
all_win32 clean_win32: SYSTEM=Win32-gcc
|
||||
all_win32 clean_win32: SUF=.exe
|
||||
# name of the binary - only valid for targets which set SYSTEM
|
||||
DESTPATH = ../../bin/$(SYSTEM)/$(Target)$(SUF)
|
||||
|
||||
all_linux all_win32:
|
||||
$(warning Building...)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(Sources) -o $(DESTPATH) $(LDFLAGS)
|
||||
|
||||
clean: clean_linux clean_win32
|
||||
$(warning Cleaning...)
|
||||
|
||||
clean_linux clean_win32:
|
||||
@$(RM) $(DESTPATH)
|
||||
|
||||
.PHONY: all all_win32 clean clean_linux clean_win32
|
|
@ -0,0 +1,90 @@
|
|||
# Microsoft Developer Studio Project File - Name="MouseAndJoystick" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** NICHT BEARBEITEN **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=MouseAndJoystick - Win32 Debug
|
||||
!MESSAGE Dies ist kein g<>s Makefile. Zum Erstellen dieses Projekts mit NMAKE
|
||||
!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und f<>Sie den Befehl
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "MouseAndJoystick.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE Sie k<>n beim Ausf<73>von NMAKE eine Konfiguration angeben
|
||||
!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "MouseAndJoystick.mak" CFG="MouseAndJoystick - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE F<> Konfiguration stehen zur Auswahl:
|
||||
!MESSAGE
|
||||
!MESSAGE "MouseAndJoystick - Win32 Release" (basierend auf "Win32 (x86) Console Application")
|
||||
!MESSAGE "MouseAndJoystick - Win32 Debug" (basierend auf "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "MouseAndJoystick - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0xc07 /d "NDEBUG"
|
||||
# ADD RSC /l 0xc07 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"..\..\bin\Win32-VisualStudio\MouseAndJoystick.exe" /libpath:"..\..\lib\Win32-visualstudio"
|
||||
|
||||
!ELSEIF "$(CFG)" == "MouseAndJoystick - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0xc07 /d "_DEBUG"
|
||||
# ADD RSC /l 0xc07 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"..\..\bin\Win32-VisualStudio\MouseAndJoystick.exe" /pdbtype:sept /libpath:"..\..\lib\Win32-visualstudio"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "MouseAndJoystick - Win32 Release"
|
||||
# Name "MouseAndJoystick - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\main.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
|
@ -0,0 +1,29 @@
|
|||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "MouseAndJoystick"=".\MouseAndJoystick.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MouseAndJoystick", "MouseAndJoystick.vcproj", "{1A16BBE1-A49B-4406-8883-681E6EA8702C}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
Release = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{1A16BBE1-A49B-4406-8883-681E6EA8702C}.Debug.ActiveCfg = Debug|Win32
|
||||
{1A16BBE1-A49B-4406-8883-681E6EA8702C}.Debug.Build.0 = Debug|Win32
|
||||
{1A16BBE1-A49B-4406-8883-681E6EA8702C}.Release.ActiveCfg = Release|Win32
|
||||
{1A16BBE1-A49B-4406-8883-681E6EA8702C}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,163 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="19.MouseAndJoystick"
|
||||
ProjectGUID="{735B050B-1AC5-4602-B0BE-D2D2B5893E94}"
|
||||
SccProjectName=""
|
||||
SccLocalPath="">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\Debug/MouseAndJoystick.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\19.MouseAndJoystick.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\Debug/MouseAndJoystick.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/MouseAndJoystick.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3079"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="4"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\Release/MouseAndJoystick.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\19.MouseAndJoystick.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
ProgramDatabaseFile=".\Release/MouseAndJoystick.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/MouseAndJoystick.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3079"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="main.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1,231 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="19.MouseAndJoystick_vc8"
|
||||
ProjectGUID="{7BDBB7E8-E0C9-4A0D-83C1-D389D6140FEF}"
|
||||
RootNamespace="MouseAndJoystick_vc8"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/MouseAndJoystick.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/MouseAndJoystick.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\19.MouseAndJoystick.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/MouseAndJoystick.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/MouseAndJoystick.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/MouseAndJoystick.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\19.MouseAndJoystick.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
ProgramDatabaseFile=".\Release/MouseAndJoystick.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1,230 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="19.MouseAndJoystick_vc9"
|
||||
ProjectGUID="{FE853A36-E0D1-4AC5-A792-B643E70D2953}"
|
||||
RootNamespace="MouseAndJoystick_vc9"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/MouseAndJoystick.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/MouseAndJoystick.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\19.MouseAndJoystick.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/MouseAndJoystick.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/MouseAndJoystick.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/MouseAndJoystick.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\19.MouseAndJoystick.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
ProgramDatabaseFile=".\Release/MouseAndJoystick.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE CodeBlocks_project_file>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="1"/>
|
||||
<Project>
|
||||
<Option title="Irrlicht Example 04 MouseAndJoystick"/>
|
||||
<Option makefile="Makefile"/>
|
||||
<Option makefile_is_custom="0"/>
|
||||
<Option compiler="0"/>
|
||||
<Build>
|
||||
<Target title="default">
|
||||
<Option output="..\..\bin\Win32-gcc\19.MouseAndJoystick.exe"/>
|
||||
<Option working_dir="."/>
|
||||
<Option object_output=".objs"/>
|
||||
<Option deps_output=".deps"/>
|
||||
<Option type="1"/>
|
||||
<Option compiler="0"/>
|
||||
<Option projectResourceIncludeDirsRelation="1"/>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add directory="..\..\include"/>
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="../../lib/Win32-gcc/libIrrlicht.a"/>
|
||||
</Linker>
|
||||
<Unit filename="main.cpp">
|
||||
<Option compilerVar="CPP"/>
|
||||
<Option target="default"/>
|
||||
</Unit>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
|
@ -0,0 +1,59 @@
|
|||
[Project]
|
||||
FileName=example.dev
|
||||
Name=Irrlicht Example 04 MouseAndJoystick
|
||||
UnitCount=1
|
||||
Type=1
|
||||
Ver=1
|
||||
ObjFiles=
|
||||
Includes=..\..\include
|
||||
Libs=
|
||||
PrivateResource=
|
||||
ResourceIncludes=
|
||||
MakeIncludes=
|
||||
Compiler=
|
||||
CppCompiler=
|
||||
Linker=../../lib/Win32-gcc/libIrrlicht.a_@@_
|
||||
IsCpp=1
|
||||
Icon=
|
||||
ExeOutput=../../bin/Win32-gcc
|
||||
ObjectOutput=obj
|
||||
OverrideOutput=1
|
||||
OverrideOutputName=19.MouseAndJoystick.exe
|
||||
HostApplication=
|
||||
Folders=
|
||||
CommandLine=
|
||||
IncludeVersionInfo=0
|
||||
SupportXPThemes=0
|
||||
CompilerSet=0
|
||||
CompilerSettings=0000000000000000000000
|
||||
UseCustomMakefile=0
|
||||
CustomMakefile=
|
||||
|
||||
[Unit1]
|
||||
FileName=main.cpp
|
||||
CompileCpp=1
|
||||
Folder=Projekt1
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[VersionInfo]
|
||||
Major=0
|
||||
Minor=1
|
||||
Release=1
|
||||
Build=1
|
||||
LanguageID=1033
|
||||
CharsetID=1252
|
||||
CompanyName=
|
||||
FileVersion=
|
||||
FileDescription=Irrlicht Engine example compiled using DevCpp and gcc
|
||||
InternalName=
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=
|
||||
ProductName=
|
||||
ProductVersion=
|
||||
AutoIncBuildNr=0
|
||||
|
|
@ -0,0 +1,284 @@
|
|||
/** Example 019 Mouse and Joystick
|
||||
|
||||
This tutorial builds on example 04.Movement which showed how to
|
||||
handle keyboard events in Irrlicht. Here we'll handle mouse events
|
||||
and joystick events, if you have a joystick connected and a device
|
||||
that supports joysticks. These are currently Windows, Linux and SDL
|
||||
devices.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// We'll define this to stop MSVC complaining about sprintf().
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#pragma comment(lib, "Irrlicht.lib")
|
||||
#endif
|
||||
|
||||
#include <irrlicht.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace irr;
|
||||
|
||||
/*
|
||||
Just as we did in example 04.Movement, we'll store the latest state of the
|
||||
mouse and the first joystick, updating them as we receive events.
|
||||
*/
|
||||
class MyEventReceiver : public IEventReceiver
|
||||
{
|
||||
public:
|
||||
// We'll create a struct to record info on the mouse state
|
||||
struct SMouseState
|
||||
{
|
||||
core::position2di Position;
|
||||
bool LeftButtonDown;
|
||||
SMouseState() : LeftButtonDown(false) { }
|
||||
} MouseState;
|
||||
|
||||
// This is the one method that we have to implement
|
||||
virtual bool OnEvent(const SEvent& event)
|
||||
{
|
||||
// Remember the mouse state
|
||||
if (event.EventType == irr::EET_MOUSE_INPUT_EVENT)
|
||||
{
|
||||
switch(event.MouseInput.Event)
|
||||
{
|
||||
case EMIE_LMOUSE_PRESSED_DOWN:
|
||||
MouseState.LeftButtonDown = true;
|
||||
break;
|
||||
|
||||
case EMIE_LMOUSE_LEFT_UP:
|
||||
MouseState.LeftButtonDown = false;
|
||||
break;
|
||||
|
||||
case EMIE_MOUSE_MOVED:
|
||||
MouseState.Position.X = event.MouseInput.X;
|
||||
MouseState.Position.Y = event.MouseInput.Y;
|
||||
break;
|
||||
|
||||
default:
|
||||
// We won't use the wheel
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// The state of each connected joystick is sent to us
|
||||
// once every run() of the Irrlicht device. Store the
|
||||
// state of the first joystick, ignoring other joysticks.
|
||||
// This is currently only supported on Windows and Linux.
|
||||
if (event.EventType == irr::EET_JOYSTICK_INPUT_EVENT
|
||||
&& event.JoystickEvent.Joystick == 0)
|
||||
{
|
||||
JoystickState = event.JoystickEvent;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const SEvent::SJoystickEvent & GetJoystickState(void) const
|
||||
{
|
||||
return JoystickState;
|
||||
}
|
||||
|
||||
const SMouseState & GetMouseState(void) const
|
||||
{
|
||||
return MouseState;
|
||||
}
|
||||
|
||||
|
||||
MyEventReceiver()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
SEvent::SJoystickEvent JoystickState;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
The event receiver for keeping the pressed keys is ready, the actual responses
|
||||
will be made inside the render loop, right before drawing the scene. So lets
|
||||
just create an irr::IrrlichtDevice and the scene node we want to move. We also
|
||||
create some other additional scene nodes, to show that there are also some
|
||||
different possibilities to move and animate scene nodes.
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
// let user select driver type
|
||||
|
||||
video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D9;
|
||||
|
||||
printf("Please select the driver you want for this example:\n"\
|
||||
" (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\
|
||||
" (d) Software Renderer\n (e) Burning's Software Renderer\n"\
|
||||
" (f) NullDevice\n (otherKey) exit\n\n");
|
||||
|
||||
char i;
|
||||
std::cin >> i;
|
||||
|
||||
switch(i)
|
||||
{
|
||||
case 'a': driverType = video::EDT_DIRECT3D9;break;
|
||||
case 'b': driverType = video::EDT_DIRECT3D8;break;
|
||||
case 'c': driverType = video::EDT_OPENGL; break;
|
||||
case 'd': driverType = video::EDT_SOFTWARE; break;
|
||||
case 'e': driverType = video::EDT_BURNINGSVIDEO;break;
|
||||
case 'f': driverType = video::EDT_NULL; break;
|
||||
default: return 0;
|
||||
}
|
||||
|
||||
// create device
|
||||
MyEventReceiver receiver;
|
||||
|
||||
IrrlichtDevice* device = createDevice(driverType,
|
||||
core::dimension2d<s32>(640, 480), 16, false, false, false, &receiver);
|
||||
|
||||
if (device == 0)
|
||||
return 1; // could not create selected driver.
|
||||
|
||||
|
||||
core::array<SJoystickInfo> joystickInfo;
|
||||
if(device->activateJoysticks(joystickInfo))
|
||||
{
|
||||
std::cout << "Joystick support is enabled and " << joystickInfo.size() << " joystick(s) are present." << std::endl;
|
||||
|
||||
for(u32 joystick = 0; joystick < joystickInfo.size(); ++joystick)
|
||||
{
|
||||
std::cout << "Joystick " << joystick << ":" << std::endl;
|
||||
std::cout << "\tName: '" << joystickInfo[joystick].Name.c_str() << "'" << std::endl;
|
||||
std::cout << "\tAxes: " << joystickInfo[joystick].Axes << std::endl;
|
||||
std::cout << "\tButtons: " << joystickInfo[joystick].Buttons << std::endl;
|
||||
|
||||
std::cout << "\tHat is: ";
|
||||
|
||||
switch(joystickInfo[joystick].PovHat)
|
||||
{
|
||||
case SJoystickInfo::POV_HAT_PRESENT:
|
||||
std::cout << "present" << std::endl;
|
||||
break;
|
||||
|
||||
case SJoystickInfo::POV_HAT_ABSENT:
|
||||
std::cout << "absent" << std::endl;
|
||||
break;
|
||||
|
||||
case SJoystickInfo::POV_HAT_UNKNOWN:
|
||||
default:
|
||||
std::cout << "unknown" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Joystick support is not enabled." << std::endl;
|
||||
}
|
||||
|
||||
video::IVideoDriver* driver = device->getVideoDriver();
|
||||
scene::ISceneManager* smgr = device->getSceneManager();
|
||||
|
||||
/*
|
||||
We'll create an arrow mesh and move it around either with the joystick axis/hat,
|
||||
or make it follow the mouse pointer. */
|
||||
scene::ISceneNode * node = smgr->addMeshSceneNode(smgr->addArrowMesh("Arrow", video::SColor(255, 255, 0, 0), video::SColor(255, 0, 255, 0)));
|
||||
node->setMaterialFlag(video::EMF_LIGHTING, false);
|
||||
|
||||
scene::ICameraSceneNode * camera = smgr->addCameraSceneNode();
|
||||
camera->setPosition(core::vector3df(0, 0, -10));
|
||||
|
||||
// As in example 04, we'll use framerate independent movement.
|
||||
u32 then = device->getTimer()->getTime();
|
||||
const f32 MOVEMENT_SPEED = 5.f;
|
||||
|
||||
while(device->run())
|
||||
{
|
||||
// Work out a frame delta time.
|
||||
const u32 now = device->getTimer()->getTime();
|
||||
const f32 frameDeltaTime = (f32)(now - then) / 1000.f; // Time in seconds
|
||||
then = now;
|
||||
|
||||
bool movedWithJoystick = false;
|
||||
core::vector3df nodePosition = node->getPosition();
|
||||
|
||||
if(joystickInfo.size() > 0)
|
||||
{
|
||||
f32 moveHorizontal = 0.f; // Range is -1.f for full left to +1.f for full right
|
||||
f32 moveVertical = 0.f; // -1.f for full down to +1.f for full up.
|
||||
|
||||
const SEvent::SJoystickEvent & joystickData = receiver.GetJoystickState();
|
||||
|
||||
// Use the analog range of the axes, and a 5% dead zone
|
||||
moveHorizontal =
|
||||
(f32)joystickData.Axis[SEvent::SJoystickEvent::AXIS_X] / 32767.f;
|
||||
if(fabs(moveHorizontal) < 0.05f)
|
||||
moveHorizontal = 0.f;
|
||||
|
||||
moveVertical =
|
||||
(f32)joystickData.Axis[SEvent::SJoystickEvent::AXIS_Y] / -32767.f;
|
||||
if(fabs(moveVertical) < 0.05f)
|
||||
moveVertical = 0.f;
|
||||
|
||||
// POV hat info is only currently supported on Windows, but the value is
|
||||
// guaranteed to be 65535 if it's not supported, so we can check its range.
|
||||
const u16 povDegrees = joystickData.POV / 100;
|
||||
if(povDegrees < 360)
|
||||
{
|
||||
if(povDegrees > 0 && povDegrees < 180)
|
||||
moveHorizontal = 1.f;
|
||||
else if(povDegrees > 180)
|
||||
moveHorizontal = -1.f;
|
||||
|
||||
if(povDegrees > 90 && povDegrees < 270)
|
||||
moveVertical = -1.f;
|
||||
else if(povDegrees > 270 || povDegrees < 90)
|
||||
moveVertical = +1.f;
|
||||
}
|
||||
|
||||
if(!core::equals(moveHorizontal, 0.f) || !core::equals(moveVertical, 0.f))
|
||||
{
|
||||
nodePosition.X += MOVEMENT_SPEED * frameDeltaTime * moveHorizontal;
|
||||
nodePosition.Y += MOVEMENT_SPEED * frameDeltaTime * moveVertical;
|
||||
movedWithJoystick = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If the arrow node isn't being moved with the joystick, then have it follow the mouse cursor.
|
||||
if(!movedWithJoystick)
|
||||
{
|
||||
// Create a ray through the mouse cursor.
|
||||
core::line3df ray = smgr->getSceneCollisionManager()->getRayFromScreenCoordinates(
|
||||
receiver.GetMouseState().Position, camera);
|
||||
|
||||
// And intersect the ray with a plane around the node facing towards the camera.
|
||||
core::plane3df plane(nodePosition, core::vector3df(0, 0, -1));
|
||||
core::vector3df mousePosition;
|
||||
if(plane.getIntersectionWithLine(ray.start, ray.getVector(), mousePosition))
|
||||
{
|
||||
// We now have a mouse position in 3d space; move towards it.
|
||||
core::vector3df toMousePosition(mousePosition - nodePosition);
|
||||
const f32 availableMovement = MOVEMENT_SPEED * frameDeltaTime;
|
||||
|
||||
if(toMousePosition.getLength() <= availableMovement)
|
||||
nodePosition = mousePosition; // Jump to the final position
|
||||
else
|
||||
nodePosition += toMousePosition.normalize() * availableMovement; // Move towards it
|
||||
}
|
||||
}
|
||||
|
||||
node->setPosition(nodePosition);
|
||||
|
||||
// Turn lighting on and off depending on whether the left mouse button is down.
|
||||
if(receiver.GetMouseState().LeftButtonDown)
|
||||
node->setMaterialFlag(video::EMF_LIGHTING, true);
|
||||
else
|
||||
node->setMaterialFlag(video::EMF_LIGHTING, false);
|
||||
|
||||
driver->beginScene(true, true, video::SColor(255,113,113,133));
|
||||
smgr->drawAll(); // draw the 3d scene
|
||||
driver->endScene();
|
||||
}
|
||||
|
||||
/*
|
||||
In the end, delete the Irrlicht device.
|
||||
*/
|
||||
device->drop();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -74,6 +74,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "16.Quake3MapShader", "16.Qu
|
|||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "19.MouseAndJoystick", "19.MouseAndJoystick\MouseAndJoystick.vcproj", "{1AB9413E-4F53-42A3-8CB2-CB4BE22336D0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
|
|
|
@ -38,10 +38,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Demo_vc8", "Demo\Demo_vc8.v
|
|||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "16.Quake3MapShader_vc8", "16.Quake3MapShader\Quake3MapShader_vc8.vcproj", "{EB3B38EA-5CE7-4983-845B-880661E69D09}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
EndProjectSection
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Quake3MapShader_vc8", "16.Quake3MapShader\Quake3MapShader_vc8.vcproj", "{EB3B38EA-5CE7-4983-845B-880661E69D09}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "19.MouseAndJoystick_vc8", "19.MouseAndJoystick\MouseAndJoystick_vc8.vcproj", "{1AB9413E-4F53-42A3-8CB2-CB4BE22336D0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
@ -0,0 +1,184 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual C++ Express 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "01.HelloWorld_vc9", "01.HelloWorld\HelloWorld_vc9.vcproj", "{5AD4C95C-BA38-4692-BA4B-8C25A86208F9}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "02.Quake3Map_vc9", "02.Quake3Map\Quake3Map_vc9.vcproj", "{D1A464A2-D479-458C-98A2-60965D823CD1}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "03.CustomSceneNode_vc9", "03.CustomSceneNode\CustomSceneNode_vc9.vcproj", "{171CCDFA-C140-4956-8EB7-F0168F4521D3}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "04.Movement_vc9", "04.Movement\Movement_vc9.vcproj", "{7BDBB7E8-E0C9-4A0D-83C1-D389D6140FEF}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "05.UserInterface_vc8", "05.UserInterface\UserInterface_vc9.vcproj", "{622C9DD7-0391-49FF-AF53-24F9D5A8EC53}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "06.2DGraphics_vc9", "06.2DGraphics\2DGraphics_vc9.vcproj", "{E71B6F18-10DC-4101-A541-F6D33F71B2BD}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "07.Collision_vc9", "07.Collision\Collision_vc9.vcproj", "{3E30297B-5BE3-4A5C-B31E-08A28ADDB29E}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "08.SpecialFX_vc9", "08.SpecialFX\SpecialFX_vc9.vcproj", "{C869BF55-B9D6-4980-BC92-60FA0CF8411A}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "09.Meshviewer_vc9", "09.Meshviewer\Meshviewer_vc9.vcproj", "{2AE24484-22FC-481B-9A40-7CD0DA5C8E06}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "10.Shaders_vc9", "10.Shaders\Shaders_vc9.vcproj", "{27158C82-CD15-4A9B-9848-35E7065B209F}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "11.PerPixelLighting_vc9", "11.PerPixelLighting\PerPixelLighting_vc9.vcproj", "{C4B42409-542D-4EFC-9E6B-44713FD47A33}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "12.TerrainRendering_vc9", "12.TerrainRendering\TerrainRendering_vc9.vcproj", "{3A5B74E5-6390-43B0-A459-2793B81FFD31}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "13.RenderToTexture_vc9", "13.RenderToTexture\RenderToTexture_vc9.vcproj", "{0914E5C8-5352-467B-8421-C9EB35BD5596}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "14.Win32Window_vc9", "14.Win32Window\Win32Window_vc9.vcproj", "{772FBE05-D05A-467B-9842-BEC409EEA8D0}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "15.LoadIrrFile_vc9", "15.LoadIrrFile\LoadIrrFile_vc9.vcproj", "{78C9F424-523C-49AC-94B7-823AA4A26BF9}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "..\source\Irrlicht\Irrlicht9.0.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Demo_vc9", "Demo\Demo_vc9.vcproj", "{6F076455-D955-45D4-9C68-4AD4E45F2D47}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "16.Quake3MapShader_vc9", "16.Quake3MapShader\Quake3MapShader_vc9.vcproj", "{EB3B38EA-5CE7-4983-845B-880661E69D09}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "18.SplitScreen_vc9", "18.SplitScreen\SplitScreen_vc9.vcproj", "{1AB9413E-4F53-42A3-8CB2-CB4BE22336D0}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "19.MouseAndJoystick_vc9", "19.MouseAndJoystick\MouseAndJoystick_vc9.vcproj", "{FE853A36-E0D1-4AC5-A792-B643E70D2953}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5AD4C95C-BA38-4692-BA4B-8C25A86208F9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{5AD4C95C-BA38-4692-BA4B-8C25A86208F9}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{5AD4C95C-BA38-4692-BA4B-8C25A86208F9}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{5AD4C95C-BA38-4692-BA4B-8C25A86208F9}.Release|Win32.Build.0 = Release|Win32
|
||||
{D1A464A2-D479-458C-98A2-60965D823CD1}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D1A464A2-D479-458C-98A2-60965D823CD1}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D1A464A2-D479-458C-98A2-60965D823CD1}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D1A464A2-D479-458C-98A2-60965D823CD1}.Release|Win32.Build.0 = Release|Win32
|
||||
{171CCDFA-C140-4956-8EB7-F0168F4521D3}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{171CCDFA-C140-4956-8EB7-F0168F4521D3}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{171CCDFA-C140-4956-8EB7-F0168F4521D3}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{171CCDFA-C140-4956-8EB7-F0168F4521D3}.Release|Win32.Build.0 = Release|Win32
|
||||
{7BDBB7E8-E0C9-4A0D-83C1-D389D6140FEF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{7BDBB7E8-E0C9-4A0D-83C1-D389D6140FEF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{7BDBB7E8-E0C9-4A0D-83C1-D389D6140FEF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{7BDBB7E8-E0C9-4A0D-83C1-D389D6140FEF}.Release|Win32.Build.0 = Release|Win32
|
||||
{622C9DD7-0391-49FF-AF53-24F9D5A8EC53}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{622C9DD7-0391-49FF-AF53-24F9D5A8EC53}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{622C9DD7-0391-49FF-AF53-24F9D5A8EC53}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{622C9DD7-0391-49FF-AF53-24F9D5A8EC53}.Release|Win32.Build.0 = Release|Win32
|
||||
{E71B6F18-10DC-4101-A541-F6D33F71B2BD}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E71B6F18-10DC-4101-A541-F6D33F71B2BD}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E71B6F18-10DC-4101-A541-F6D33F71B2BD}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{E71B6F18-10DC-4101-A541-F6D33F71B2BD}.Release|Win32.Build.0 = Release|Win32
|
||||
{3E30297B-5BE3-4A5C-B31E-08A28ADDB29E}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{3E30297B-5BE3-4A5C-B31E-08A28ADDB29E}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{3E30297B-5BE3-4A5C-B31E-08A28ADDB29E}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{3E30297B-5BE3-4A5C-B31E-08A28ADDB29E}.Release|Win32.Build.0 = Release|Win32
|
||||
{C869BF55-B9D6-4980-BC92-60FA0CF8411A}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{C869BF55-B9D6-4980-BC92-60FA0CF8411A}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{C869BF55-B9D6-4980-BC92-60FA0CF8411A}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{C869BF55-B9D6-4980-BC92-60FA0CF8411A}.Release|Win32.Build.0 = Release|Win32
|
||||
{2AE24484-22FC-481B-9A40-7CD0DA5C8E06}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{2AE24484-22FC-481B-9A40-7CD0DA5C8E06}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{2AE24484-22FC-481B-9A40-7CD0DA5C8E06}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{2AE24484-22FC-481B-9A40-7CD0DA5C8E06}.Release|Win32.Build.0 = Release|Win32
|
||||
{27158C82-CD15-4A9B-9848-35E7065B209F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{27158C82-CD15-4A9B-9848-35E7065B209F}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{27158C82-CD15-4A9B-9848-35E7065B209F}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{27158C82-CD15-4A9B-9848-35E7065B209F}.Release|Win32.Build.0 = Release|Win32
|
||||
{C4B42409-542D-4EFC-9E6B-44713FD47A33}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{C4B42409-542D-4EFC-9E6B-44713FD47A33}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{C4B42409-542D-4EFC-9E6B-44713FD47A33}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{C4B42409-542D-4EFC-9E6B-44713FD47A33}.Release|Win32.Build.0 = Release|Win32
|
||||
{3A5B74E5-6390-43B0-A459-2793B81FFD31}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{3A5B74E5-6390-43B0-A459-2793B81FFD31}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{3A5B74E5-6390-43B0-A459-2793B81FFD31}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{3A5B74E5-6390-43B0-A459-2793B81FFD31}.Release|Win32.Build.0 = Release|Win32
|
||||
{0914E5C8-5352-467B-8421-C9EB35BD5596}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{0914E5C8-5352-467B-8421-C9EB35BD5596}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{0914E5C8-5352-467B-8421-C9EB35BD5596}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{0914E5C8-5352-467B-8421-C9EB35BD5596}.Release|Win32.Build.0 = Release|Win32
|
||||
{772FBE05-D05A-467B-9842-BEC409EEA8D0}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{772FBE05-D05A-467B-9842-BEC409EEA8D0}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{772FBE05-D05A-467B-9842-BEC409EEA8D0}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{772FBE05-D05A-467B-9842-BEC409EEA8D0}.Release|Win32.Build.0 = Release|Win32
|
||||
{78C9F424-523C-49AC-94B7-823AA4A26BF9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{78C9F424-523C-49AC-94B7-823AA4A26BF9}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{78C9F424-523C-49AC-94B7-823AA4A26BF9}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{78C9F424-523C-49AC-94B7-823AA4A26BF9}.Release|Win32.Build.0 = Release|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.ActiveCfg = Release - Fast FPU|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.Build.0 = Release - Fast FPU|Win32
|
||||
{6F076455-D955-45D4-9C68-4AD4E45F2D47}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{6F076455-D955-45D4-9C68-4AD4E45F2D47}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{6F076455-D955-45D4-9C68-4AD4E45F2D47}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{6F076455-D955-45D4-9C68-4AD4E45F2D47}.Release|Win32.Build.0 = Release|Win32
|
||||
{EB3B38EA-5CE7-4983-845B-880661E69D09}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{EB3B38EA-5CE7-4983-845B-880661E69D09}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{EB3B38EA-5CE7-4983-845B-880661E69D09}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{EB3B38EA-5CE7-4983-845B-880661E69D09}.Release|Win32.Build.0 = Release|Win32
|
||||
{1AB9413E-4F53-42A3-8CB2-CB4BE22336D0}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{1AB9413E-4F53-42A3-8CB2-CB4BE22336D0}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{1AB9413E-4F53-42A3-8CB2-CB4BE22336D0}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{1AB9413E-4F53-42A3-8CB2-CB4BE22336D0}.Release|Win32.Build.0 = Release|Win32
|
||||
{FE853A36-E0D1-4AC5-A792-B643E70D2953}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{FE853A36-E0D1-4AC5-A792-B643E70D2953}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{FE853A36-E0D1-4AC5-A792-B643E70D2953}.Release|Win32.ActiveCfg = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -1,10 +1,10 @@
|
|||
// This is a Demo of the Irrlicht Engine (c) 2005 by N.Gebhardt.
|
||||
// This file is not documentated.
|
||||
// This is a Demo of the Irrlicht Engine (c) 2005-2008 by N.Gebhardt.
|
||||
// This file is not documented.
|
||||
|
||||
#include "CDemo.h"
|
||||
|
||||
CDemo::CDemo(bool f, bool m, bool s, bool a, bool v, video::E_DRIVER_TYPE d)
|
||||
: fullscreen(f), music(m), shadows(s), additive(a), vsync(v),
|
||||
CDemo::CDemo(bool f, bool m, bool s, bool a, bool v, bool fsaa, video::E_DRIVER_TYPE d)
|
||||
: fullscreen(f), music(m), shadows(s), additive(a), vsync(v), aa(fsaa),
|
||||
driverType(d), device(0),
|
||||
#ifdef USE_IRRKLANG
|
||||
irrKlang(0), ballSound(0), impactSound(0),
|
||||
|
@ -45,8 +45,18 @@ void CDemo::run()
|
|||
resolution.Height = 480;
|
||||
}
|
||||
|
||||
device = createDevice(driverType,resolution, 32, fullscreen, shadows, vsync, this);
|
||||
if ( 0 == device )
|
||||
irr::SIrrlichtCreationParameters params;
|
||||
params.DriverType=driverType;
|
||||
params.WindowSize=resolution;
|
||||
params.Bits=32;
|
||||
params.Fullscreen=fullscreen;
|
||||
params.Stencilbuffer=shadows;
|
||||
params.Vsync=vsync;
|
||||
params.AntiAlias=aa;
|
||||
params.EventReceiver=this;
|
||||
|
||||
device = createDeviceEx(params);
|
||||
if (!device)
|
||||
return;
|
||||
|
||||
if (device->getFileSystem()->existFile("irrlicht.dat"))
|
||||
|
@ -161,6 +171,7 @@ bool CDemo::OnEvent(const SEvent& event)
|
|||
device->getVideoDriver()->writeImageToFile(image, "screenshot.tga");
|
||||
device->getVideoDriver()->writeImageToFile(image, "screenshot.ppm");
|
||||
device->getVideoDriver()->writeImageToFile(image, "screenshot.jpg");
|
||||
device->getVideoDriver()->writeImageToFile(image, "screenshot.pcx");
|
||||
image->drop();
|
||||
}
|
||||
}
|
||||
|
@ -468,8 +479,7 @@ void CDemo::loadSceneData()
|
|||
core::array<video::ITexture*> textures;
|
||||
for (s32 g=1; g<8; ++g)
|
||||
{
|
||||
core::stringc tmp;
|
||||
tmp = "../../media/portal";
|
||||
core::stringc tmp("../../media/portal");
|
||||
tmp += g;
|
||||
tmp += ".bmp";
|
||||
video::ITexture* t = driver->getTexture( tmp.c_str () );
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#ifndef __C_DEMO_H_INCLUDED__
|
||||
#define __C_DEMO_H_INCLUDED__
|
||||
|
||||
//#define USE_IRRKLANG
|
||||
#define USE_IRRKLANG
|
||||
//#define USE_SDL_MIXER
|
||||
|
||||
#include <irrlicht.h>
|
||||
|
@ -36,7 +36,7 @@ class CDemo : public IEventReceiver
|
|||
{
|
||||
public:
|
||||
|
||||
CDemo(bool fullscreen, bool music, bool shadows, bool additive, bool vsync, video::E_DRIVER_TYPE driver);
|
||||
CDemo(bool fullscreen, bool music, bool shadows, bool additive, bool vsync, bool aa, video::E_DRIVER_TYPE driver);
|
||||
|
||||
~CDemo();
|
||||
|
||||
|
@ -57,6 +57,7 @@ private:
|
|||
bool shadows;
|
||||
bool additive;
|
||||
bool vsync;
|
||||
bool aa;
|
||||
video::E_DRIVER_TYPE driverType;
|
||||
IrrlichtDevice *device;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// This is a Demo of the Irrlicht Engine (c) 2005 by N.Gebhardt.
|
||||
// This file is not documentated.
|
||||
// This is a Demo of the Irrlicht Engine (c) 2005-2008 by N.Gebhardt.
|
||||
// This file is not documented.
|
||||
|
||||
#include "CMainMenu.h"
|
||||
|
||||
|
@ -10,32 +10,30 @@ class CSceneNodeAnimatorFollowBoundingBox : public irr::scene::ISceneNodeAnimato
|
|||
public:
|
||||
|
||||
//! constructor
|
||||
CSceneNodeAnimatorFollowBoundingBox( irr::scene::ISceneNode* tofollow, const core::vector3df &offset, u32 frequency, s32 phase )
|
||||
CSceneNodeAnimatorFollowBoundingBox(irr::scene::ISceneNode* tofollow,
|
||||
const core::vector3df &offset, u32 frequency, s32 phase)
|
||||
: Offset(offset), ToFollow(tofollow), Frequency(frequency), Phase(phase)
|
||||
{
|
||||
Frequency = frequency;
|
||||
Phase = phase;
|
||||
Offset = offset;
|
||||
ToFollow = tofollow;
|
||||
if ( ToFollow )
|
||||
ToFollow->grab ();
|
||||
if (ToFollow)
|
||||
ToFollow->grab();
|
||||
}
|
||||
|
||||
//! destructor
|
||||
virtual ~CSceneNodeAnimatorFollowBoundingBox()
|
||||
{
|
||||
if ( ToFollow )
|
||||
ToFollow->drop ();
|
||||
if (ToFollow)
|
||||
ToFollow->drop();
|
||||
}
|
||||
|
||||
//! animates a scene node
|
||||
virtual void animateNode(irr::scene::ISceneNode* node, u32 timeMs)
|
||||
{
|
||||
if ( 0 == node || node->getType () != irr::scene::ESNT_LIGHT)
|
||||
if (0 == node || node->getType() != irr::scene::ESNT_LIGHT)
|
||||
return;
|
||||
|
||||
irr::scene::ILightSceneNode* l = (irr::scene::ILightSceneNode*) node;
|
||||
|
||||
if ( ToFollow )
|
||||
if (ToFollow)
|
||||
{
|
||||
core::vector3df now = l->getPosition();
|
||||
now += ToFollow->getBoundingBox().getCenter();
|
||||
|
@ -45,17 +43,17 @@ public:
|
|||
|
||||
irr::video::SColorHSL color;
|
||||
irr::video::SColor rgb(0);
|
||||
color.Hue = ( ( timeMs + Phase ) % Frequency ) * ( 2.f * irr::core::PI / Frequency );
|
||||
color.Hue = ( (timeMs + Phase) % Frequency ) * ( 2.f * irr::core::PI / Frequency );
|
||||
color.Saturation = 1.f;
|
||||
color.Luminance = 0.5f;
|
||||
color.settoRGB ( rgb );
|
||||
color.toRGB(rgb);
|
||||
|
||||
video::SLight light = l->getLightData();
|
||||
light.DiffuseColor = rgb;
|
||||
l->setLightData(light);
|
||||
}
|
||||
|
||||
|
||||
virtual scene::ISceneNodeAnimator* createClone(scene::ISceneNode* node, scene::ISceneManager* newManager=0) {return 0;}
|
||||
private:
|
||||
|
||||
core::vector3df Offset;
|
||||
|
@ -65,37 +63,35 @@ private:
|
|||
};
|
||||
|
||||
|
||||
|
||||
|
||||
CMainMenu::CMainMenu()
|
||||
: startButton(0), device(0), selected(2), start(false), fullscreen(true),
|
||||
music(true), shadows(false), additive(false), transparent(true), vsync(false)
|
||||
: startButton(0), MenuDevice(0), selected(2), start(false), fullscreen(true),
|
||||
music(true), shadows(false), additive(false), transparent(true), vsync(false), aa(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows,
|
||||
bool& outAdditive, bool &outVSync, video::E_DRIVER_TYPE& outDriver)
|
||||
bool& outAdditive, bool& outVSync, bool& outAA,
|
||||
video::E_DRIVER_TYPE& outDriver)
|
||||
{
|
||||
device = createDevice( outDriver, //Varmint: 2007/12/18 video::EDT_BURNINGSVIDEO,
|
||||
MenuDevice = createDevice(video::EDT_BURNINGSVIDEO,
|
||||
core::dimension2d<s32>(512, 384), 16, false, false, false, this);
|
||||
|
||||
if (device->getFileSystem()->existFile("irrlicht.dat"))
|
||||
device->getFileSystem()->addZipFileArchive("irrlicht.dat");
|
||||
if (MenuDevice->getFileSystem()->existFile("irrlicht.dat"))
|
||||
MenuDevice->getFileSystem()->addZipFileArchive("irrlicht.dat");
|
||||
else
|
||||
device->getFileSystem()->addZipFileArchive("../../media/irrlicht.dat");
|
||||
MenuDevice->getFileSystem()->addZipFileArchive("../../media/irrlicht.dat");
|
||||
|
||||
video::IVideoDriver* driver = device->getVideoDriver();
|
||||
scene::ISceneManager* smgr = device->getSceneManager();
|
||||
gui::IGUIEnvironment* guienv = device->getGUIEnvironment();
|
||||
video::IVideoDriver* driver = MenuDevice->getVideoDriver();
|
||||
scene::ISceneManager* smgr = MenuDevice->getSceneManager();
|
||||
gui::IGUIEnvironment* guienv = MenuDevice->getGUIEnvironment();
|
||||
|
||||
core::stringw str = "Irrlicht Engine Demo v";
|
||||
str += device->getVersion();
|
||||
device->setWindowCaption(str.c_str());
|
||||
str += MenuDevice->getVersion();
|
||||
MenuDevice->setWindowCaption(str.c_str());
|
||||
|
||||
// set new Skin
|
||||
gui::IGUISkin* newskin = guienv->createSkin( gui::EGST_BURNING_SKIN);
|
||||
gui::IGUISkin* newskin = guienv->createSkin(gui::EGST_BURNING_SKIN);
|
||||
guienv->setSkin(newskin);
|
||||
newskin->drop();
|
||||
|
||||
|
@ -106,7 +102,6 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows,
|
|||
|
||||
// add images
|
||||
|
||||
|
||||
const s32 leftX = 260;
|
||||
|
||||
// add tab control
|
||||
|
@ -135,58 +130,46 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows,
|
|||
|
||||
guienv->addCheckBox(fullscreen, core::rect<int>(20,85+d,130,110+d),
|
||||
optTab, 3, L"Fullscreen");
|
||||
guienv->addCheckBox(music, core::rect<int>(20,110+d,130,135+d),
|
||||
guienv->addCheckBox(music, core::rect<int>(135,85+d,245,110+d),
|
||||
optTab, 4, L"Music & Sfx");
|
||||
guienv->addCheckBox(shadows, core::rect<int>(20,135+d,230,160+d),
|
||||
guienv->addCheckBox(shadows, core::rect<int>(20,110+d,135,135+d),
|
||||
optTab, 5, L"Realtime shadows");
|
||||
guienv->addCheckBox(additive, core::rect<int>(20,160+d,230,185+d),
|
||||
guienv->addCheckBox(additive, core::rect<int>(20,135+d,230,160+d),
|
||||
optTab, 6, L"Old HW compatible blending");
|
||||
guienv->addCheckBox(vsync, core::rect<int>(20,185+d,230,210+d),
|
||||
guienv->addCheckBox(vsync, core::rect<int>(20,160+d,230,185+d),
|
||||
optTab, 7, L"Vertical synchronisation");
|
||||
|
||||
// add text
|
||||
|
||||
/*wchar_t* text = L"Welcome to the Irrlicht Engine. Please select "\
|
||||
L"the settings you prefer and press 'Start Demo'. "\
|
||||
L"Right click for changing menu style.";
|
||||
|
||||
guienv->addStaticText(text, core::rect<int>(10, 220, 220, 280),
|
||||
true, true, optTab);*/
|
||||
guienv->addCheckBox(aa, core::rect<int>(20,185+d,230,210+d),
|
||||
optTab, 8, L"Antialiasing");
|
||||
|
||||
// add about text
|
||||
|
||||
wchar_t* text2 = L"This is the tech demo of the Irrlicht engine. To start, "\
|
||||
L"select a device which works best with your hardware and press 'start demo'. "\
|
||||
L"What you currently see is displayed using the Burning Software Renderer (Thomas Alten). "\
|
||||
L"select a video driver which works best with your hardware and press 'Start Demo'.\n"\
|
||||
L"What you currently see is displayed using the Burning Software Renderer (Thomas Alten).\n"\
|
||||
L"The Irrlicht Engine was written by me, Nikolaus Gebhardt. The models, "\
|
||||
L"maps and textures were placed at my disposal by B.Collins, M.Cook and J.Marton. The music was created by "\
|
||||
L"M.Rohde and is played back by Audiere."\
|
||||
L"For more informations, please visit the homepage of the Irrlicht engine:\nhttp://www.irrlicht.sourceforge.net";
|
||||
L"M.Rohde and is played back by irrKlang.\n"\
|
||||
L"For more informations, please visit the homepage of the Irrlicht engine:\nhttp://irrlicht.sourceforge.net";
|
||||
|
||||
guienv->addStaticText(text2, core::rect<int>(10, 10, 230, 320),
|
||||
true, true, aboutTab);
|
||||
|
||||
|
||||
// add md2 model
|
||||
|
||||
scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/faerie.md2");
|
||||
scene::IAnimatedMeshSceneNode* modelNode = smgr->addAnimatedMeshSceneNode(mesh);
|
||||
if (modelNode)
|
||||
{
|
||||
modelNode->setPosition ( core::vector3df ( 0.f, 0.f, -5.f ) );
|
||||
modelNode->setPosition( core::vector3df(0.f, 0.f, -5.f) );
|
||||
modelNode->setMaterialTexture(0, driver->getTexture("../../media/faerie2.bmp"));
|
||||
modelNode->setMaterialFlag(video::EMF_LIGHTING, true);
|
||||
modelNode->getMaterial(0).Shininess = 28.f;
|
||||
modelNode->getMaterial(0).NormalizeNormals = true;
|
||||
modelNode->setMD2Animation ( scene::EMAT_STAND );
|
||||
|
||||
//modelNode->setMD2Animation ( scene::EMAT_JUMP );
|
||||
//modelNode->setDebugDataVisible ( scene::EDS_BBOX_ALL );
|
||||
//modelNode->setFrameLoop ( 0, 0 );
|
||||
modelNode->setMD2Animation(scene::EMAT_STAND);
|
||||
}
|
||||
|
||||
// set ambient light ( no sun light in the catacombs )
|
||||
smgr->setAmbientLight ( video::SColorf ( 0.f, 0.f, 0.f ) );
|
||||
// set ambient light (no sun light in the catacombs)
|
||||
smgr->setAmbientLight( video::SColorf(0.f, 0.f, 0.f) );
|
||||
|
||||
scene::ISceneNodeAnimator* anim;
|
||||
scene::ISceneNode* bill;
|
||||
|
@ -197,16 +180,15 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows,
|
|||
video::SColorf(0.86f, 0.38f, 0.05f), 200.0f);
|
||||
|
||||
// add fly circle animator to light 1
|
||||
anim = smgr->createFlyCircleAnimator (core::vector3df(0,0,0),30.0f, -0.004f, core::vector3df ( 0.41f, 0.4f, 0.0f ) );
|
||||
anim = smgr->createFlyCircleAnimator(core::vector3df(0,0,0),30.0f, -0.004f, core::vector3df(0.41f, 0.4f, 0.0f));
|
||||
light1->addAnimator(anim);
|
||||
anim->drop();
|
||||
|
||||
// let the lights follow the model...
|
||||
anim = new CSceneNodeAnimatorFollowBoundingBox ( modelNode, core::vector3df(0,16,0), 4000, 0 );
|
||||
anim = new CSceneNodeAnimatorFollowBoundingBox(modelNode, core::vector3df(0,16,0), 4000, 0);
|
||||
//light1->addAnimator(anim);
|
||||
anim->drop();
|
||||
|
||||
|
||||
// attach billboard to the light
|
||||
bill = smgr->addBillboardSceneNode(light1, core::dimension2d<f32>(10, 10));
|
||||
bill->setMaterialFlag(video::EMF_LIGHTING, false);
|
||||
|
@ -220,12 +202,12 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows,
|
|||
video::SColorf(0.9f, 1.0f, 0.f, 0.0f), 200.0f);
|
||||
|
||||
// add fly circle animator to light 1
|
||||
anim = smgr->createFlyCircleAnimator (core::vector3df(0,0,0),30.0f, 0.004f, core::vector3df ( 0.41f, 0.4f, 0.0f ) );
|
||||
anim = smgr->createFlyCircleAnimator(core::vector3df(0,0,0),30.0f, 0.004f, core::vector3df(0.41f, 0.4f, 0.0f));
|
||||
light2->addAnimator(anim);
|
||||
anim->drop();
|
||||
|
||||
// let the lights follow the model...
|
||||
anim = new CSceneNodeAnimatorFollowBoundingBox ( modelNode, core::vector3df(0,-8,0), 2000, 0 );
|
||||
anim = new CSceneNodeAnimatorFollowBoundingBox( modelNode, core::vector3df(0,-8,0), 2000, 0 );
|
||||
//light2->addAnimator(anim);
|
||||
anim->drop();
|
||||
|
||||
|
@ -242,21 +224,23 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows,
|
|||
video::SColorf(0.f, 0.0f, 0.9f, 0.0f), 40.0f);
|
||||
|
||||
// add fly circle animator to light 2
|
||||
anim = smgr->createFlyCircleAnimator (core::vector3df(0,0,0),40.0f, 0.004f, core::vector3df ( -0.41f, -0.4f, 0.0f ) );
|
||||
anim = smgr->createFlyCircleAnimator(core::vector3df(0,0,0),40.0f, 0.004f, core::vector3df(-0.41f, -0.4f, 0.0f));
|
||||
light3->addAnimator(anim);
|
||||
anim->drop();
|
||||
|
||||
// let the lights follow the model...
|
||||
anim = new CSceneNodeAnimatorFollowBoundingBox ( modelNode, core::vector3df(0,8,0), 8000, 0 );
|
||||
anim = new CSceneNodeAnimatorFollowBoundingBox(modelNode, core::vector3df(0,8,0), 8000, 0);
|
||||
//light3->addAnimator(anim);
|
||||
anim->drop();
|
||||
|
||||
// attach billboard to the light
|
||||
bill = smgr->addBillboardSceneNode(light3, core::dimension2d<f32>(10, 10));
|
||||
|
||||
bill->setMaterialFlag(video::EMF_LIGHTING, false);
|
||||
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
|
||||
bill->setMaterialTexture(0, driver->getTexture("../../media/portal1.bmp"));
|
||||
if (bill)
|
||||
{
|
||||
bill->setMaterialFlag(video::EMF_LIGHTING, false);
|
||||
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
|
||||
bill->setMaterialTexture(0, driver->getTexture("../../media/portal1.bmp"));
|
||||
}
|
||||
#endif
|
||||
|
||||
// create a fixed camera
|
||||
|
@ -274,25 +258,23 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows,
|
|||
|
||||
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState);
|
||||
|
||||
|
||||
// query original skin color
|
||||
getOriginalSkinColor ();
|
||||
getOriginalSkinColor();
|
||||
|
||||
// set transparency
|
||||
setTransparency();
|
||||
|
||||
// draw all
|
||||
|
||||
while(device->run())
|
||||
while(MenuDevice->run())
|
||||
{
|
||||
if (device->isWindowActive())
|
||||
if (MenuDevice->isWindowActive())
|
||||
{
|
||||
driver->beginScene(false, true, video::SColor(0,0,0,0));
|
||||
|
||||
if ( irrlichtBack )
|
||||
if (irrlichtBack)
|
||||
driver->draw2DImage(irrlichtBack,
|
||||
core::position2d<int>(0,0)
|
||||
);
|
||||
core::position2d<int>(0,0));
|
||||
|
||||
smgr->drawAll();
|
||||
guienv->drawAll();
|
||||
|
@ -300,13 +282,14 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows,
|
|||
}
|
||||
}
|
||||
|
||||
device->drop();
|
||||
MenuDevice->drop();
|
||||
|
||||
outFullscreen = fullscreen;
|
||||
outMusic = music;
|
||||
outShadows = shadows;
|
||||
outAdditive = additive;
|
||||
outVSync = vsync;
|
||||
outAA = aa;
|
||||
|
||||
switch(selected)
|
||||
{
|
||||
|
@ -321,17 +304,16 @@ bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows,
|
|||
}
|
||||
|
||||
|
||||
|
||||
bool CMainMenu::OnEvent(const SEvent& event)
|
||||
{
|
||||
if (event.EventType == EET_KEY_INPUT_EVENT &&
|
||||
event.KeyInput.Key == KEY_F9 &&
|
||||
event.KeyInput.PressedDown == false)
|
||||
{
|
||||
video::IImage* image = device->getVideoDriver()->createScreenShot();
|
||||
video::IImage* image = MenuDevice->getVideoDriver()->createScreenShot();
|
||||
if (image)
|
||||
{
|
||||
device->getVideoDriver()->writeImageToFile(image, "screenshot_main.jpg");
|
||||
MenuDevice->getVideoDriver()->writeImageToFile(image, "screenshot_main.jpg");
|
||||
image->drop();
|
||||
}
|
||||
}
|
||||
|
@ -340,7 +322,7 @@ bool CMainMenu::OnEvent(const SEvent& event)
|
|||
event.MouseInput.Event == EMIE_RMOUSE_LEFT_UP )
|
||||
{
|
||||
core::rect<s32> r(event.MouseInput.X, event.MouseInput.Y, 0, 0);
|
||||
gui::IGUIContextMenu* menu = device->getGUIEnvironment()->addContextMenu(r, 0, 45);
|
||||
gui::IGUIContextMenu* menu = MenuDevice->getGUIEnvironment()->addContextMenu(r, 0, 45);
|
||||
menu->addItem(L"transparent menus", 666, transparent == false);
|
||||
menu->addItem(L"solid menus", 666, transparent == true);
|
||||
menu->addSeparator();
|
||||
|
@ -369,13 +351,13 @@ bool CMainMenu::OnEvent(const SEvent& event)
|
|||
{
|
||||
selected = ((gui::IGUIListBox*)event.GUIEvent.Caller)->getSelected();
|
||||
//startButton->setEnabled(selected != 4);
|
||||
startButton->setEnabled( true );
|
||||
startButton->setEnabled(true);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED )
|
||||
{
|
||||
device->closeDevice();
|
||||
MenuDevice->closeDevice();
|
||||
start = true;
|
||||
}
|
||||
case 3:
|
||||
|
@ -398,6 +380,10 @@ bool CMainMenu::OnEvent(const SEvent& event)
|
|||
if (event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED )
|
||||
vsync = ((gui::IGUICheckBox*)event.GUIEvent.Caller)->isChecked();
|
||||
break;
|
||||
case 8:
|
||||
if (event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED )
|
||||
aa = ((gui::IGUICheckBox*)event.GUIEvent.Caller)->isChecked();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -407,26 +393,27 @@ bool CMainMenu::OnEvent(const SEvent& event)
|
|||
|
||||
void CMainMenu::getOriginalSkinColor()
|
||||
{
|
||||
irr::gui::IGUISkin * skin = device->getGUIEnvironment()->getSkin();
|
||||
irr::gui::IGUISkin * skin = MenuDevice->getGUIEnvironment()->getSkin();
|
||||
for (s32 i=0; i<gui::EGDC_COUNT ; ++i)
|
||||
{
|
||||
SkinColor [ i ] = skin->getColor ( (gui::EGUI_DEFAULT_COLOR)i );
|
||||
SkinColor[i] = skin->getColor( (gui::EGUI_DEFAULT_COLOR)i );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CMainMenu::setTransparency()
|
||||
{
|
||||
irr::gui::IGUISkin * skin = device->getGUIEnvironment()->getSkin();
|
||||
irr::gui::IGUISkin * skin = MenuDevice->getGUIEnvironment()->getSkin();
|
||||
|
||||
u32 i;
|
||||
for ( i=0; i<gui::EGDC_COUNT ; ++i)
|
||||
for (u32 i=0; i<gui::EGDC_COUNT ; ++i)
|
||||
{
|
||||
video::SColor col = SkinColor [ i ];
|
||||
video::SColor col = SkinColor[i];
|
||||
|
||||
if ( false == transparent )
|
||||
col.setAlpha( 255);
|
||||
if (false == transparent)
|
||||
col.setAlpha(255);
|
||||
|
||||
skin->setColor((gui::EGUI_DEFAULT_COLOR)i, col);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@ public:
|
|||
CMainMenu();
|
||||
|
||||
bool run(bool& outFullscreen, bool& outMusic, bool& outShadows,
|
||||
bool& outAdditive, bool &outVSync, video::E_DRIVER_TYPE& outDriver);
|
||||
bool& outAdditive, bool &outVSync, bool& outAA,
|
||||
video::E_DRIVER_TYPE& outDriver);
|
||||
|
||||
virtual bool OnEvent(const SEvent& event);
|
||||
|
||||
|
@ -24,7 +25,7 @@ private:
|
|||
void setTransparency();
|
||||
|
||||
gui::IGUIButton* startButton;
|
||||
IrrlichtDevice *device;
|
||||
IrrlichtDevice *MenuDevice;
|
||||
s32 selected;
|
||||
bool start;
|
||||
bool fullscreen;
|
||||
|
@ -33,6 +34,7 @@ private:
|
|||
bool additive;
|
||||
bool transparent;
|
||||
bool vsync;
|
||||
bool aa;
|
||||
|
||||
scene::IAnimatedMesh* quakeLevel;
|
||||
scene::ISceneNode* lightMapNode;
|
||||
|
|
|
@ -0,0 +1,299 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="Demo_vc9"
|
||||
ProjectGUID="{6F076455-D955-45D4-9C68-4AD4E45F2D47}"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="true"
|
||||
SuppressStartupBanner="true"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Release/Demo.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/Demo.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\Demo.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
ProgramDatabaseFile=".\Release/Demo.pdb"
|
||||
SubSystem="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="true"
|
||||
SuppressStartupBanner="true"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Debug/Demo.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/Demo.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3079"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="..\..\bin\Win32-VisualStudio\Demo.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/Demo.pdb"
|
||||
SubSystem="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="CDemo.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="CDemo.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="CMainMenu.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="CMainMenu.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="icon.ico"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,5 +1,5 @@
|
|||
// This is a Demo of the Irrlicht Engine (c) 2005 by N.Gebhardt.
|
||||
// This file is not documentated.
|
||||
// This is a Demo of the Irrlicht Engine (c) 2005-2008 by N.Gebhardt.
|
||||
// This file is not documented.
|
||||
|
||||
#include <irrlicht.h>
|
||||
#ifdef _IRR_WINDOWS_
|
||||
|
@ -26,6 +26,7 @@ int main(int argc, char* argv[])
|
|||
bool shadows = false;
|
||||
bool additive = false;
|
||||
bool vsync = false;
|
||||
bool aa = false;
|
||||
|
||||
#ifndef _IRR_WINDOWS_
|
||||
video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;
|
||||
|
@ -36,10 +37,10 @@ int main(int argc, char* argv[])
|
|||
CMainMenu menu;
|
||||
|
||||
//#ifndef _DEBUG
|
||||
if (menu.run(fullscreen, music, shadows, additive, vsync, driverType))
|
||||
if (menu.run(fullscreen, music, shadows, additive, vsync, aa, driverType))
|
||||
//#endif
|
||||
{
|
||||
CDemo demo(fullscreen, music, shadows, additive, vsync, driverType);
|
||||
CDemo demo(fullscreen, music, shadows, additive, vsync, aa, driverType);
|
||||
demo.run();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
/*
|
||||
In this tutorial, I will show how to collision detection with the Irrlicht Engine.
|
||||
I will describe 3 methods: Automatic collision detection for moving through 3d worlds
|
||||
with stair climbing and sliding, manual triangle picking and manual
|
||||
scene node picking.
|
||||
In this tutorial, I will show how to collision detection with the Irrlicht
|
||||
Engine. I will describe 3 methods: Automatic collision detection for moving
|
||||
through 3d worlds with stair climbing and sliding, manual triangle picking and
|
||||
manual scene node picking.
|
||||
|
||||
To start, we take the program from tutorial 2, which loaded and displayed a quake 3
|
||||
level. We will use the level to walk in it and to pick triangles from it. In addition
|
||||
we'll place 3 animated models into it for scene node picking. The following code
|
||||
starts up the engine and loads
|
||||
a quake 3 level. I will not explain it, because it should already be known from tutorial
|
||||
2.
|
||||
To start, we take the program from tutorial 2, which loaded and displayed a
|
||||
quake 3 level. We will use the level to walk in it and to pick triangles from
|
||||
it. In addition we'll place 3 animated models into it for scene node picking.
|
||||
The following code starts up the engine and loads a quake 3 level. I will not
|
||||
explain it, because it should already be known from tutorial 2.
|
||||
*/
|
||||
#include <irrlicht.h>
|
||||
#include <iostream>
|
||||
|
@ -85,38 +84,45 @@ int main()
|
|||
{
|
||||
q3node->setPosition(core::vector3df(-1350,-130,-1400));
|
||||
|
||||
selector = smgr->createOctTreeTriangleSelector(q3levelmesh->getMesh(0), q3node, 128);
|
||||
selector = smgr->createOctTreeTriangleSelector(
|
||||
q3levelmesh->getMesh(0), q3node, 128);
|
||||
q3node->setTriangleSelector(selector);
|
||||
selector->drop();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
We add a first person shooter camera to the scene for being able to move in the quake 3
|
||||
level like in tutorial 2. But this, time, we add a special animator to the
|
||||
camera: A Collision Response animator. This thing modifies the scene node to which
|
||||
it is attached to in that way, that it may no more move through walls and is affected
|
||||
by gravity. The only thing we have to tell the animator is how the world looks like,
|
||||
how big the scene node is, how gravity and so on. After the collision response animator
|
||||
is attached to the camera, we do not have to do anything more for collision detection,
|
||||
anything is done automaticly, all other collision detection code below is for picking.
|
||||
And please note another cool feature: The collsion response animator can be attached
|
||||
also to all other scene nodes, not only to cameras. And it can be mixed with other
|
||||
scene node animators. In this way, collision detection and response in the Irrlicht
|
||||
engine is really, really easy.
|
||||
Now we'll take a closer look on the parameters of createCollisionResponseAnimator().
|
||||
The first parameter is the TriangleSelector, which specifies how the world, against
|
||||
collision detection is done looks like. The second parameter is the scene node, which
|
||||
is the object, which is affected by collision detection, in our case it is the camera.
|
||||
The third defines how big the object is, it is the radius of an ellipsoid. Try it out
|
||||
and change the radius to smaller values, the camera will be able to move closer to walls
|
||||
after this. The next parameter is the direction and speed of gravity. You could
|
||||
set it to (0,0,0) to disable gravity. And the last value is just a translation: Without
|
||||
this, the ellipsoid with which collision detection is done would be around the camera,
|
||||
and the camera would be in the middle of the ellipsoid. But as human beings, we are
|
||||
used to have our eyes on top of the body, with which we collide with our world, not
|
||||
in the middle of it. So we place the scene node 50 units over the center of the
|
||||
ellipsoid with this parameter. And that's it, collision detection works now.
|
||||
We add a first person shooter camera to the scene for being able to
|
||||
move in the quake 3 level like in tutorial 2. But this, time, we add a
|
||||
special animator to the camera: A Collision Response animator. This
|
||||
thing modifies the scene node to which it is attached to in that way,
|
||||
that it may no more move through walls and is affected by gravity. The
|
||||
only thing we have to tell the animator is how the world looks like,
|
||||
how big the scene node is, how gravity and so on. After the collision
|
||||
response animator is attached to the camera, we do not have to do
|
||||
anything more for collision detection, anything is done automaticly,
|
||||
all other collision detection code below is for picking. And please
|
||||
note another cool feature: The collsion response animator can be
|
||||
attached also to all other scene nodes, not only to cameras. And it can
|
||||
be mixed with other scene node animators. In this way, collision
|
||||
detection and response in the Irrlicht engine is really, really easy.
|
||||
Now we'll take a closer look on the parameters of
|
||||
createCollisionResponseAnimator().
|
||||
The first parameter is the TriangleSelector, which specifies how the
|
||||
world, against collision detection is done looks like. The second
|
||||
parameter is the scene node, which is the object, which is affected by
|
||||
collision detection, in our case it is the camera. The third defines
|
||||
how big the object is, it is the radius of an ellipsoid. Try it out and
|
||||
change the radius to smaller values, the camera will be able to move
|
||||
closer to walls after this. The next parameter is the direction and
|
||||
speed of gravity. You could set it to (0,0,0) to disable gravity. And
|
||||
the last value is just a translation: Without this, the ellipsoid with
|
||||
which collision detection is done would be around the camera, and the
|
||||
camera would be in the middle of the ellipsoid. But as human beings, we
|
||||
are used to have our eyes on top of the body, with which we collide
|
||||
with our world, not in the middle of it. So we place the scene node 50
|
||||
units over the center of the ellipsoid with this parameter. And that's
|
||||
it, collision detection works now.
|
||||
*/
|
||||
|
||||
scene::ICameraSceneNode* camera =
|
||||
|
@ -210,14 +216,16 @@ int main()
|
|||
smgr->drawAll();
|
||||
|
||||
/*
|
||||
After we've drawn the whole scene whit smgr->drawAll(), we'll do the first
|
||||
picking: We want to know which triangle of the world we are looking at. In addition,
|
||||
we want the exact point of the quake 3 level we are looking at.
|
||||
For this, we create a 3d line starting at the position of the camera and going
|
||||
through the lookAt-target of it. Then we ask the collision manager if this line
|
||||
collides with a triangle of the world stored in the triangle selector. If yes,
|
||||
we draw the 3d triangle and set the position of the billboard to the intersection
|
||||
point.
|
||||
After we've drawn the whole scene whit smgr->drawAll(), we'll
|
||||
do the first picking: We want to know which triangle of the
|
||||
world we are looking at. In addition, we want the exact point
|
||||
of the quake 3 level we are looking at. For this, we create a
|
||||
3d line starting at the position of the camera and going
|
||||
through the lookAt-target of it. Then we ask the collision
|
||||
manager if this line collides with a triangle of the world
|
||||
stored in the triangle selector. If yes, we draw the 3d
|
||||
triangle and set the position of the billboard to the
|
||||
intersection point.
|
||||
*/
|
||||
|
||||
core::line3d<f32> line;
|
||||
|
@ -247,7 +255,8 @@ int main()
|
|||
billboard or the quake 3 level.
|
||||
*/
|
||||
|
||||
selectedSceneNode = smgr->getSceneCollisionManager()->getSceneNodeFromCameraBB(camera);
|
||||
selectedSceneNode =
|
||||
smgr->getSceneCollisionManager()->getSceneNodeFromCameraBB(camera);
|
||||
|
||||
if (lastSelectedSceneNode)
|
||||
lastSelectedSceneNode->setMaterialFlag(video::EMF_LIGHTING, true);
|
||||
|
@ -271,13 +280,14 @@ int main()
|
|||
|
||||
if (lastFPS != fps)
|
||||
{
|
||||
core::stringw str = L"Collision detection example - Irrlicht Engine [";
|
||||
str += driver->getName();
|
||||
str += "] FPS:";
|
||||
str += fps;
|
||||
core::stringw str =
|
||||
L"Collision detection example - Irrlicht Engine [";
|
||||
str += driver->getName();
|
||||
str += "] FPS:";
|
||||
str += fps;
|
||||
|
||||
device->setWindowCaption(str.c_str());
|
||||
lastFPS = fps;
|
||||
device->setWindowCaption(str.c_str());
|
||||
lastFPS = fps;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,12 +34,12 @@ namespace scene
|
|||
IndexBuffer->drop();
|
||||
}
|
||||
|
||||
virtual IVertexBuffer &getVertexBuffer() const
|
||||
virtual IVertexBuffer& getVertexBuffer() const
|
||||
{
|
||||
return *VertexBuffer;
|
||||
}
|
||||
|
||||
virtual IIndexBuffer &getIndexBuffer() const
|
||||
virtual IIndexBuffer& getIndexBuffer() const
|
||||
{
|
||||
return *IndexBuffer;
|
||||
}
|
||||
|
|
|
@ -73,6 +73,9 @@ namespace video
|
|||
//! Is HLSL supported?
|
||||
EVDF_HLSL,
|
||||
|
||||
//! Are non-square textures supported?
|
||||
EVDF_TEXTURE_NSQUARE,
|
||||
|
||||
//! Are non-power-of-two textures supported?
|
||||
EVDF_TEXTURE_NPOT,
|
||||
|
||||
|
@ -80,7 +83,10 @@ namespace video
|
|||
EVDF_FRAMEBUFFER_OBJECT,
|
||||
|
||||
//! Are vertex buffer objects supported?
|
||||
EVDF_VERTEX_BUFFER_OBJECT
|
||||
EVDF_VERTEX_BUFFER_OBJECT,
|
||||
|
||||
//! Only used for counting the elements of this enum
|
||||
EVDF_COUNT
|
||||
};
|
||||
|
||||
} // end namespace video
|
||||
|
@ -89,4 +95,3 @@ namespace video
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -29,37 +29,40 @@ namespace video
|
|||
EMF_ZBUFFER,
|
||||
|
||||
//! May be written to the zbuffer or is it readonly. Default: true
|
||||
//! This flag is ignored, if the material type is a transparent type.
|
||||
/** This flag is ignored, if the material type is a transparent type. */
|
||||
EMF_ZWRITE_ENABLE,
|
||||
|
||||
//! Is backface culling enabled? Default: true
|
||||
EMF_BACK_FACE_CULLING,
|
||||
|
||||
//! Is frontface culling enabled? Default: false
|
||||
/** Overrides EMF_BACK_FACE_CULLING if both are enabled. */
|
||||
EMF_FRONT_FACE_CULLING,
|
||||
|
||||
//! Is bilinear filtering enabled? Default: true
|
||||
EMF_BILINEAR_FILTER,
|
||||
|
||||
//! Is trilinear filtering enabled? Default: false
|
||||
//! If the trilinear filter flag is enabled,
|
||||
//! the bilinear filtering flag is ignored.
|
||||
/** If the trilinear filter flag is enabled,
|
||||
the bilinear filtering flag is ignored. */
|
||||
EMF_TRILINEAR_FILTER,
|
||||
|
||||
//! Is anisotropic filtering? Default: false
|
||||
//! In Irrlicht you can use anisotropic texture filtering in
|
||||
//! conjunction with bilinear or trilinear texture filtering
|
||||
//! to improve rendering results. Primitives will look less
|
||||
//! blurry with this flag switched on.
|
||||
/** In Irrlicht you can use anisotropic texture filtering in
|
||||
conjunction with bilinear or trilinear texture filtering
|
||||
to improve rendering results. Primitives will look less
|
||||
blurry with this flag switched on. */
|
||||
EMF_ANISOTROPIC_FILTER,
|
||||
|
||||
//! Is fog enabled? Default: false
|
||||
EMF_FOG_ENABLE,
|
||||
|
||||
//! Normalizes normals.You can enable this if you need
|
||||
//! to scale a dynamic lighted model. Usually, its normals will get scaled
|
||||
//! too then and it will get darker. If you enable the EMF_NORMALIZE_NORMALS flag,
|
||||
//! the normals will be normalized again, and the model will look as bright as it should.
|
||||
//! Normalizes normals. Default: false
|
||||
/** You can enable this if you need to scale a dynamic lighted
|
||||
model. Usually, its normals will get scaled too then and it
|
||||
will get darker. If you enable the EMF_NORMALIZE_NORMALS flag,
|
||||
the normals will be normalized again, and the model will look
|
||||
as bright as it should. */
|
||||
EMF_NORMALIZE_NORMALS,
|
||||
|
||||
//! Access to all layers texture wrap settings. Overwrites separate layer settings.
|
||||
|
|
|
@ -25,7 +25,10 @@ namespace scene
|
|||
EMWT_COLLADA = MAKE_IRR_ID('c','o','l','l'),
|
||||
|
||||
//! STL mesh writer for .stl files
|
||||
EMWT_STL = MAKE_IRR_ID('s','t','l',0)
|
||||
EMWT_STL = MAKE_IRR_ID('s','t','l',0),
|
||||
|
||||
//! OBJ mesh writer for .obj files
|
||||
EMWT_OBJ = MAKE_IRR_ID('o','b','j',0)
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -220,6 +220,12 @@ namespace scene
|
|||
return Container[index];
|
||||
}
|
||||
|
||||
SMD3QuaterionTagList & operator = (const SMD3QuaterionTagList & copyMe)
|
||||
{
|
||||
Container = copyMe.Container;
|
||||
return *this;
|
||||
}
|
||||
|
||||
core::array < SMD3QuaterionTag > Container;
|
||||
};
|
||||
|
||||
|
|
|
@ -211,6 +211,13 @@ namespace scene
|
|||
//! render mesh ignoring it's transformation.
|
||||
/** Used with ragdolls. Culling is unaffected. */
|
||||
virtual void setRenderFromIdentity( bool On )=0;
|
||||
|
||||
//! Creates a clone of this scene node and its children.
|
||||
/** \param newParent An optional new parent.
|
||||
\param newManager An optional new scene manager.
|
||||
\return The newly created clone of this node. */
|
||||
virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0) = 0;
|
||||
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
|
|
|
@ -60,7 +60,8 @@ namespace scene
|
|||
ISceneNode(parent, mgr, id),positionHint(-1),scaleHint(-1),rotationHint(-1) { }
|
||||
|
||||
//! Get the name of the bone
|
||||
virtual const c8* getBoneName() const = 0;
|
||||
/** \deprecated Use getName instead. */
|
||||
virtual const c8* getBoneName() const { return getName(); }
|
||||
|
||||
//! Get the index of the bone
|
||||
virtual u32 getBoneIndex() const = 0;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "ILogger.h"
|
||||
#include "position2d.h"
|
||||
#include "Keycodes.h"
|
||||
#include "irrString.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
@ -34,6 +35,16 @@ namespace irr
|
|||
IrrlichtDevice::postEventFromUser. They take the same path as mouse events. */
|
||||
EET_KEY_INPUT_EVENT,
|
||||
|
||||
//! A joystick (joypad, gamepad) input event.
|
||||
/** Joystick events are created by polling all connected joysticks once per
|
||||
device run() and then passing the events to IrrlichtDevice::postEventFromUser.
|
||||
They take the same path as mouse events.
|
||||
Windows, SDL: Implemented.
|
||||
Linux: Implemented, with POV hat issues.
|
||||
MacOS / Other: Not yet implemented.
|
||||
*/
|
||||
EET_JOYSTICK_INPUT_EVENT,
|
||||
|
||||
//! A log event
|
||||
/** Log events are only passed to the user receiver if there is one. If they are absorbed by the
|
||||
user receiver then no text will be sent to the console. */
|
||||
|
@ -52,7 +63,12 @@ namespace irr
|
|||
casted to s32 and used as UserData1 and UserData2.
|
||||
MacOS: Not yet implemented
|
||||
*/
|
||||
EET_USER_EVENT
|
||||
EET_USER_EVENT,
|
||||
|
||||
//! This enum is never used, it only forces the compiler to
|
||||
//! compile these enumeration values to 32 bit.
|
||||
EGUIET_FORCE_32_BIT = 0x7fffffff
|
||||
|
||||
};
|
||||
|
||||
//! Enumeration for all mouse input events
|
||||
|
@ -224,6 +240,66 @@ struct SEvent
|
|||
bool Control;
|
||||
};
|
||||
|
||||
//! A joystick event.
|
||||
/** Unlike other events, joystick events represent the result of polling
|
||||
* each connected joystick once per run() of the device. Joystick events will
|
||||
* not be generated by default. If joystick support is available for the
|
||||
* active device, _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ is defined, and
|
||||
* @ref IrrlichtDevice::activateJoysticks() has been called, an event of
|
||||
* this type will be generated once per joystick per @ref IrrlichtDevice::run()
|
||||
* regardless of whether the state of the joystick has actually changed. */
|
||||
struct SJoystickEvent
|
||||
{
|
||||
enum
|
||||
{
|
||||
NUMBER_OF_BUTTONS = 32,
|
||||
|
||||
AXIS_X = 0, // e.g. analog stick 1 left to right
|
||||
AXIS_Y, // e.g. analog stick 1 top to bottom
|
||||
AXIS_Z, // e.g. throttle, or analog 2 stick 2 left to right
|
||||
AXIS_R, // e.g. rudder, or analog 2 stick 2 top to bottom
|
||||
AXIS_U,
|
||||
AXIS_V,
|
||||
NUMBER_OF_AXES
|
||||
};
|
||||
|
||||
/** A bitmap of button states. You can use IsButtonPressed() to
|
||||
( check the state of each button from 0 to (NUMBER_OF_BUTTONS - 1) */
|
||||
u32 ButtonStates;
|
||||
|
||||
/** For AXIS_X, AXIS_Y, AXIS_Z, AXIS_R, AXIS_U and AXIS_V
|
||||
* Values are in the range -32768 to 32767, with 0 representing
|
||||
* the center position. You will usually want to add a dead
|
||||
* zone around this center range. Axes not supported by this
|
||||
* joystick will always have a value of 0.
|
||||
* On Linux, POV hats are represented as axes, usually the
|
||||
* last two active axis.
|
||||
*/
|
||||
s16 Axis[NUMBER_OF_AXES];
|
||||
|
||||
/** The POV represents the angle of the POV hat in degrees * 100,
|
||||
* from 0 to 35,900. A value of 65535 indicates that the POV hat
|
||||
* is centered (or not present).
|
||||
* This value is only supported on Windows. On Linux, the POV hat
|
||||
* will be sent as 2 axes instead. */
|
||||
u16 POV;
|
||||
|
||||
//! The ID of the joystick which generated this event.
|
||||
/** This is an internal Irrlicht index; it does not map directly
|
||||
* to any particular hardware joystick. */
|
||||
u8 Joystick;
|
||||
|
||||
//! A helper function to check if a button is pressed.
|
||||
bool IsButtonPressed(u32 button) const
|
||||
{
|
||||
if(button >= (u32)NUMBER_OF_BUTTONS)
|
||||
return false;
|
||||
|
||||
return (ButtonStates & (1 << button)) ? true : false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! Any kind of log event.
|
||||
struct SLogEvent
|
||||
{
|
||||
|
@ -250,6 +326,7 @@ struct SEvent
|
|||
struct SGUIEvent GUIEvent;
|
||||
struct SMouseInput MouseInput;
|
||||
struct SKeyInput KeyInput;
|
||||
struct SJoystickEvent JoystickEvent;
|
||||
struct SLogEvent LogEvent;
|
||||
struct SUserEvent UserEvent;
|
||||
};
|
||||
|
@ -275,6 +352,43 @@ public:
|
|||
};
|
||||
|
||||
|
||||
//! Information on a joystick, returned from @ref IrrlichtDevice::activateJoysticks()
|
||||
struct SJoystickInfo
|
||||
{
|
||||
//! The ID of the joystick
|
||||
/** This is an internal Irrlicht index; it does not map directly
|
||||
* to any particular hardware joystick. It corresponds to the
|
||||
* @ref SJoystickEvent Joystick ID. */
|
||||
u8 Joystick;
|
||||
|
||||
//! The name that the joystick uses to identify itself.
|
||||
core::stringc Name;
|
||||
|
||||
//! The number of buttons that the joystick has.
|
||||
u32 Buttons;
|
||||
|
||||
//! The number of axes that the joystick has, i.e. X, Y, Z, R, U, V.
|
||||
/** Note: with a Linux device, the POV hat (if any) will use two axes. These
|
||||
* will be included in this count. */
|
||||
u32 Axes;
|
||||
|
||||
//! An indication of whether the joystick has a POV hat.
|
||||
/** A Windows device will identify the presence or absence or the POV hat. A
|
||||
* Linux device cannot, and will always return POV_HAT_UNKNOWN. */
|
||||
enum
|
||||
{
|
||||
//! A hat is definitely present.
|
||||
POV_HAT_PRESENT,
|
||||
|
||||
//! A hat is definitely not present.
|
||||
POV_HAT_ABSENT,
|
||||
|
||||
//! The presence or absence of a hat cannot be determined.
|
||||
POV_HAT_UNKNOWN
|
||||
} PovHat;
|
||||
}; // struct SJoystickInfo
|
||||
|
||||
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
|
|
@ -120,7 +120,7 @@ public:
|
|||
//! Returns the base part of a filename, i.e. the name without the directory
|
||||
//! part. If no directory is prefixed, the full name is returned.
|
||||
/** \param filename: The file to get the basename from */
|
||||
virtual core::stringc getFileBasename(const core::stringc& filename) const = 0;
|
||||
virtual core::stringc getFileBasename(const core::stringc& filename, bool keepExtension=true) const = 0;
|
||||
|
||||
//! Creates a list of files and directories in the current working directory and returns it.
|
||||
/** \return a Pointer to the created IFileList is returned. After the list has been used
|
||||
|
@ -133,6 +133,11 @@ public:
|
|||
\return Returns true if file exists, and false if it does not exist or an error occured. */
|
||||
virtual bool existFile(const c8* filename) const = 0;
|
||||
|
||||
//! Determines if a file exists and could be opened.
|
||||
/** \param filename is the string identifying the file which should be tested for existence.
|
||||
\return Returns true if file exists, and false if it does not exist or an error occured. */
|
||||
virtual bool existFile(const core::stringc& filename) const = 0;
|
||||
|
||||
//! Creates a XML Reader from a file which returns all parsed strings as wide characters (wchar_t*).
|
||||
/** Use createXMLReaderUTF8() if you prefer char* instead of wchar_t*. See IIrrXMLReader for
|
||||
more information on how to use the parser.
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
\param position: Rectangle specifying position where to draw the text.
|
||||
\param color: Color of the text
|
||||
\param hcenter: Specifiies if the text should be centered horizontally into the rectangle.
|
||||
\param vcenter: Specifiies if the text should be centered vertically into the rectangle.
|
||||
\param vcenter: Specifies if the text should be centered vertically into the rectangle.
|
||||
\param clip: Optional pointer to a rectangle against which the text will be clipped.
|
||||
If the pointer is null, no clipping will be done. */
|
||||
virtual void draw(const wchar_t* text, const core::rect<s32>& position,
|
||||
|
|
|
@ -142,6 +142,14 @@ namespace scene
|
|||
}
|
||||
|
||||
|
||||
//! Sets the name of the node.
|
||||
/** \param name New name of the scene node. */
|
||||
virtual void setName(const core::stringc& name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
|
||||
//! Get the axis aligned, not transformed bounding box of this node.
|
||||
/** This means that if this node is an animated 3d character,
|
||||
moving in a room, the bounding box will always be around the
|
||||
|
@ -240,6 +248,10 @@ namespace scene
|
|||
{
|
||||
if (child && (child != this))
|
||||
{
|
||||
// Change scene manager?
|
||||
if (SceneManager != child->SceneManager)
|
||||
child->setSceneManager(SceneManager);
|
||||
|
||||
child->grab();
|
||||
child->remove(); // remove from old parent
|
||||
Children.push_back(child);
|
||||
|
@ -709,6 +721,17 @@ namespace scene
|
|||
}
|
||||
}
|
||||
|
||||
//! Sets the new scene manager for this node and all children.
|
||||
//! Called by addChild when moving nodes between scene managers
|
||||
void setSceneManager(ISceneManager* newManager)
|
||||
{
|
||||
SceneManager = newManager;
|
||||
|
||||
core::list<ISceneNode*>::Iterator it = Children.begin();
|
||||
for (; it != Children.end(); ++it)
|
||||
(*it)->setSceneManager(newManager);
|
||||
}
|
||||
|
||||
//! Name of the scene node.
|
||||
core::stringc Name;
|
||||
|
||||
|
|
|
@ -43,14 +43,11 @@ namespace scene
|
|||
/** Please note that you will have to drop
|
||||
(IReferenceCounted::drop()) the returned pointer after calling
|
||||
this. */
|
||||
virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0)
|
||||
{
|
||||
return 0; // to be implemented by derived classes.
|
||||
}
|
||||
virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0) = 0;
|
||||
|
||||
//! Returns true if this animator receives events.
|
||||
//! When attached to the an active camera, this animator will be able to respond to events
|
||||
//! such as mouse and keyboard events.
|
||||
/** When attached to the an active camera, this animator will be able to respond to events
|
||||
such as mouse and keyboard events. */
|
||||
virtual bool isEventReceiverEnabled() const
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -65,6 +65,17 @@ namespace video
|
|||
ETS_COUNT
|
||||
};
|
||||
|
||||
enum E_LOST_RESSOURCE
|
||||
{
|
||||
//! The whole device/driver is lost
|
||||
ELR_DEVICE = 1,
|
||||
//! All texture are lost, rare problem
|
||||
ELR_TEXTURES = 2,
|
||||
//! The Render Target Textures are lost, typical problem for D3D
|
||||
ELR_RTTS = 4,
|
||||
//! The HW buffers are lost, will be recreated automatically, but might require some more time this frame
|
||||
ELR_HW_BUFFERS = 8
|
||||
};
|
||||
|
||||
//! Interface to driver which is able to perform 2d and 3d graphics functions.
|
||||
/** This interface is one of the most important interfaces of
|
||||
|
@ -88,23 +99,24 @@ namespace video
|
|||
be cleared. It is not nesesarry to do so if only 2d drawing is
|
||||
used.
|
||||
\param color The color used for back buffer clearing
|
||||
\param windowId Handle of another window, if you want the
|
||||
bitmap to be displayed on another window. If this is null,
|
||||
everything will be displayed in the default window.
|
||||
Note: This feature is not fully implemented for all devices.
|
||||
\param sourceRect Pointer to a rectangle defining the source
|
||||
rectangle of the area to be presented. Set to null to present
|
||||
everything. Note: not implemented in all devices.
|
||||
\return False if failed. */
|
||||
virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color) = 0;
|
||||
virtual bool beginScene(bool backBuffer=true, bool zBuffer=true,
|
||||
SColor color=SColor(255,0,0,0),
|
||||
void* windowId=0,
|
||||
core::rect<s32>* sourceRect=0) = 0;
|
||||
|
||||
//! Presents the rendered image to the screen.
|
||||
/** Applications must call this method after performing any
|
||||
rendering.
|
||||
\param windowId Handle of another window, if you want the
|
||||
bitmap to be displayed on another window. If this is null,
|
||||
everything will be displayed in the default window.
|
||||
Note: This does not work in fullscreen mode and is not
|
||||
implemented for all devices (only for D3D8, D3D9, Software1 and
|
||||
Software2, and only for Windows).
|
||||
\param sourceRect Pointer to a rectangle defining the source
|
||||
rectangle of the area to be presented. Set to null to present
|
||||
everything. Note: not implemented in all devices.
|
||||
\return False if failed and true if succeeded. */
|
||||
virtual bool endScene( void* windowId=0, core::rect<s32>* sourceRect=0 ) = 0;
|
||||
virtual bool endScene() = 0;
|
||||
|
||||
//! Queries the features of the driver.
|
||||
/** Returns true if a feature is available
|
||||
|
@ -112,6 +124,19 @@ namespace video
|
|||
\return True if the feature is available, false if not. */
|
||||
virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const = 0;
|
||||
|
||||
//! Disable a feature of the driver.
|
||||
/** Can also be used to enable the features again. It is not
|
||||
possible to enable unsupported features this way, though.
|
||||
\param feature Feature to disable.
|
||||
\param flag When true the feature is disabled, otherwise it is enabled. */
|
||||
virtual void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag=true) =0;
|
||||
|
||||
//! Check if the driver was recently reset.
|
||||
/** For d3d devices you will need to recreate the RTTs if the
|
||||
driver was reset. Should be queried right after beginScene().
|
||||
*/
|
||||
virtual bool checkDriverReset() =0;
|
||||
|
||||
//! Sets transformation matrices.
|
||||
/** \param state Transformation type to be set, e.g. view,
|
||||
world, or projection.
|
||||
|
@ -140,6 +165,18 @@ namespace video
|
|||
IReferenceCounted::drop() for more information. */
|
||||
virtual ITexture* getTexture(const c8* filename) = 0;
|
||||
|
||||
//! Get access to a named texture.
|
||||
/** Loads the texture from disk if it is not
|
||||
already loaded and generates mipmap levels if desired.
|
||||
Texture loading can be influenced using the
|
||||
setTextureCreationFlag() method. The texture can be in several
|
||||
imageformats, such as BMP, JPG, TGA, PCX, PNG, and PSD.
|
||||
\param filename Filename of the texture to be loaded.
|
||||
\return Pointer to the texture, or 0 if the texture
|
||||
could not be loaded. This pointer should not be dropped. See
|
||||
IReferenceCounted::drop() for more information. */
|
||||
virtual ITexture* getTexture(const core::stringc& filename) = 0;
|
||||
|
||||
//! Get access to a named texture.
|
||||
/** Loads the texture from disk if it is not
|
||||
already loaded and generates mipmap levels if desired.
|
||||
|
@ -167,7 +204,7 @@ namespace video
|
|||
|
||||
//! Renames a texture
|
||||
/** \param texture Pointer to the texture to rename.
|
||||
\param newName New name for the texture. */
|
||||
\param newName New name for the texture. This should be a unique name. */
|
||||
virtual void renameTexture(ITexture* texture, const c8* newName) = 0;
|
||||
|
||||
//! Creates an empty texture of specified size.
|
||||
|
@ -192,17 +229,22 @@ namespace video
|
|||
information. */
|
||||
virtual ITexture* addTexture(const c8* name, IImage* image) = 0;
|
||||
|
||||
//! Creates a render target texture.
|
||||
//! Adds a new render target texture to the texture cache.
|
||||
/** \param size Size of the texture, in pixels. Width and
|
||||
height should be a power of two (e.g. 64, 128, 256, 512, ...)
|
||||
and it should not be bigger than the backbuffer, because it
|
||||
shares the zbuffer with the screen buffer.
|
||||
\param name An optional name for the RTT.
|
||||
\return Pointer to the created texture or 0 if the texture
|
||||
could not be created. If you no longer need the image, you
|
||||
should call ITexture::drop(). See IReferenceCounted::drop()
|
||||
for more information. */
|
||||
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name = 0) = 0;
|
||||
could not be created. This pointer should not be dropped. See
|
||||
IReferenceCounted::drop() for more information. */
|
||||
virtual ITexture* addRenderTargetTexture(const core::dimension2d<s32>& size,
|
||||
const c8* name=0) =0;
|
||||
|
||||
//! Adds a new render target texture
|
||||
/** \deprecated use addRenderTargetTexture instead. */
|
||||
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size,
|
||||
const c8* name=0) =0;
|
||||
|
||||
//! Removes a texture from the texture cache and deletes it.
|
||||
/** This method can free a lot of memory!
|
||||
|
@ -271,7 +313,7 @@ namespace video
|
|||
way:
|
||||
\code
|
||||
// create render target
|
||||
ITexture* target = driver->createRenderTargetTexture(core::dimension2d<s32>(128,128));
|
||||
ITexture* target = driver->addRenderTargetTexture(core::dimension2d<s32>(128,128), "rtt1");
|
||||
|
||||
// ...
|
||||
|
||||
|
@ -283,21 +325,17 @@ namespace video
|
|||
render target as texture on it when you are rendering the scene
|
||||
into this render target at the same time. It is usually only
|
||||
possible to render into a texture between the
|
||||
IVideoDriver::beginScene() and endScene() method calls. And
|
||||
please also note that the scene will be rendered upside down
|
||||
into the texture in some drivers (e.g. OpenGL vs. D3D). A
|
||||
simple workaround for this is to flip the texture coordinates
|
||||
of the geometry where the render target texture is displayed on.
|
||||
IVideoDriver::beginScene() and endScene() method calls.
|
||||
\param texture New render target. Must be a texture created with
|
||||
IVideoDriver::createRenderTargetTexture(). If set to 0, it sets
|
||||
IVideoDriver::addRenderTargetTexture(). If set to 0, it sets
|
||||
the previous render target which was set before the last
|
||||
setRenderTarget() call.
|
||||
\param clearBackBuffer Clears the backbuffer of the render
|
||||
target with the color parameter
|
||||
\param clearZBuffer Clears the zBuffer of the rendertarget.
|
||||
Note that, because the frame buffer shares the zbuffer with the
|
||||
rendertarget, its zbuffer will be partially cleared too with
|
||||
this.
|
||||
Note that because the frame buffer may share the zbuffer with
|
||||
the rendertarget, its zbuffer might be partially cleared too
|
||||
by this.
|
||||
\param color The background color for the render target.
|
||||
\return True if sucessful and false if not. */
|
||||
virtual bool setRenderTarget(video::ITexture* texture,
|
||||
|
@ -552,6 +590,11 @@ namespace video
|
|||
const core::position2d<s32>& end,
|
||||
SColor color=SColor(255,255,255,255)) = 0;
|
||||
|
||||
//! Draws a pixel.
|
||||
/** \param position: the position of the pixel.
|
||||
\param color: Color of the pixel to draw. */
|
||||
virtual void drawPixel(u32 x, u32 y, const SColor & color) = 0;
|
||||
|
||||
//! Draws a non filled concyclic regular 2d polyon.
|
||||
/** This method can be used to draw circles, but also
|
||||
triangles, tetragons, pentagons, hexagons, heptagons, octagons,
|
||||
|
@ -653,7 +696,11 @@ namespace video
|
|||
virtual const core::dimension2d<s32>& getCurrentRenderTargetSize() const = 0;
|
||||
|
||||
//! Returns current frames per second value.
|
||||
/** \return Amount of frames per second drawn. */
|
||||
/** This value is updated approximately every 1.5 seconds and
|
||||
is only intended to provide a rough guide to the average frame
|
||||
rate. It is not suitable for use in performing timing
|
||||
calculations or framerate independent movement.
|
||||
\return Approximate amount of frames per second drawn. */
|
||||
virtual s32 getFPS() const = 0;
|
||||
|
||||
//! Returns amount of primitives (mostly triangles) which were drawn in the last frame.
|
||||
|
@ -808,8 +855,9 @@ namespace video
|
|||
\return The created image.
|
||||
If you no longer need the image, you should call IImage::drop().
|
||||
See IReferenceCounted::drop() for more information. */
|
||||
virtual IImage* createImage(IImage* imageToCopy,
|
||||
const core::position2d<s32>& pos, const core::dimension2d<s32>& size) =0;
|
||||
virtual IImage* createImage(IImage* imageToCopy,
|
||||
const core::position2d<s32>& pos,
|
||||
const core::dimension2d<s32>& size) =0;
|
||||
|
||||
//! Event handler for resize events. Only used by the engine internally.
|
||||
/** Used to notify the driver that the window was resized.
|
||||
|
@ -948,15 +996,20 @@ namespace video
|
|||
it. */
|
||||
virtual void enableClipPlane(u32 index, bool enable) = 0;
|
||||
|
||||
//! Sets the driver's ambient light color. Only used by the engine internally.
|
||||
/** This color is set in the scene manager, see
|
||||
//! Returns the graphics card vendor name.
|
||||
virtual core::stringc getVendorInfo() = 0;
|
||||
|
||||
//! Only used by the engine internally.
|
||||
/** The ambient color is set in the scene manager, see
|
||||
scene::ISceneManager::setAmbientLight().
|
||||
\param color New color of the ambient light. */
|
||||
virtual void setAmbientLight(const SColorf& color) = 0;
|
||||
|
||||
//! Returns the graphics card vendor name.
|
||||
virtual core::stringc getVendorInfo() = 0;
|
||||
|
||||
//! Only used by the engine internally.
|
||||
/** Passes the global material flag AllowZWriteOnTransparent.
|
||||
Use the SceneManager attribute to set this value from your app.
|
||||
\param flag Default behavior is to disable ZWrite, i.e. false. */
|
||||
virtual void setAllowZWriteOnTransparent(bool flag) = 0;
|
||||
};
|
||||
|
||||
} // end namespace video
|
||||
|
|
|
@ -6,7 +6,9 @@
|
|||
#define __IRR_COMPILE_CONFIG_H_INCLUDED__
|
||||
|
||||
//! Irrlicht SDK Version
|
||||
#define IRRLICHT_SDK_VERSION "1.4.1"
|
||||
#define IRRLICHT_SDK_VERSION "1.4.2"
|
||||
|
||||
#include <stdio.h> // TODO: Although included elsewhere this is required at least for mingw
|
||||
|
||||
//! The defines for different operating system are:
|
||||
//! _IRR_XBOX_PLATFORM_ for XBox
|
||||
|
@ -69,7 +71,8 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h> // TODO: Although included elsewhere this is required at least for mingw
|
||||
//! Define _IRR_COMPILE_WITH_JOYSTICK_SUPPORT_ if you want joystick events.
|
||||
#define _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
||||
|
||||
//! Define _IRR_COMPILE_WITH_DIRECT3D_8_ and _IRR_COMPILE_WITH_DIRECT3D_9_ to
|
||||
//! compile the Irrlicht engine with Direct3D8 and/or DIRECT3D9.
|
||||
|
@ -116,7 +119,7 @@ define out. */
|
|||
|
||||
//! On some Linux systems the XF86 vidmode extension or X11 RandR are missing. Use these flags
|
||||
//! to remove the dependencies such that Irrlicht will compile on those systems, too.
|
||||
#if defined(_IRR_LINUX_PLATFORM_)
|
||||
#if defined(_IRR_LINUX_PLATFORM_) && defined(_IRR_COMPILE_WITH_X11_)
|
||||
#define _IRR_LINUX_X11_VIDMODE_
|
||||
//#define _IRR_LINUX_X11_RANDR_
|
||||
#endif
|
||||
|
@ -177,42 +180,6 @@ Note that the engine will run in D3D REF for this, which is a lot slower than HA
|
|||
tool <http://developer.nvidia.com/object/nvperfhud_home.html>. */
|
||||
#undef _IRR_USE_NVIDIA_PERFHUD_
|
||||
|
||||
|
||||
#ifdef _IRR_WINDOWS_API_
|
||||
|
||||
#ifndef _IRR_STATIC_LIB_
|
||||
#ifdef IRRLICHT_EXPORTS
|
||||
#define IRRLICHT_API __declspec(dllexport)
|
||||
#else
|
||||
#define IRRLICHT_API __declspec(dllimport)
|
||||
#endif // IRRLICHT_EXPORT
|
||||
#else
|
||||
#define IRRLICHT_API
|
||||
#endif // _IRR_STATIC_LIB_
|
||||
|
||||
// Declare the calling convention.
|
||||
#if defined(_STDCALL_SUPPORTED)
|
||||
#define IRRCALLCONV __stdcall
|
||||
#else
|
||||
#define IRRCALLCONV __cdecl
|
||||
#endif // STDCALL_SUPPORTED
|
||||
|
||||
#else
|
||||
#define IRRLICHT_API
|
||||
#define IRRCALLCONV
|
||||
#endif // _IRR_WINDOWS_API_
|
||||
|
||||
// We need to disable DIRECT3D9 support for Visual Studio 6.0 because
|
||||
// those $%&$!! disabled support for it since Dec. 2004 and users are complaining
|
||||
// about linker errors. Comment this out only if you are knowing what you are
|
||||
// doing. (Which means you have an old DX9 SDK and VisualStudio6).
|
||||
#ifdef _MSC_VER
|
||||
#if (_MSC_VER < 1300 && !defined(__GNUC__))
|
||||
#undef _IRR_COMPILE_WITH_DIRECT3D_9_
|
||||
#pragma message("Compiling Irrlicht with Visual Studio 6.0, support for DX9 is disabled.")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//! Define one of the three setting for Burning's Video Software Rasterizer
|
||||
/** So if we were marketing guys we could say Irrlicht has 4 Software-Rasterizers.
|
||||
In a Nutshell:
|
||||
|
@ -289,6 +256,8 @@ B3D, MS3D or X meshes */
|
|||
#define _IRR_COMPILE_WITH_COLLADA_WRITER_
|
||||
//! Define _IRR_COMPILE_WITH_STL_WRITER_ if you want to write .stl files
|
||||
#define _IRR_COMPILE_WITH_STL_WRITER_
|
||||
//! Define _IRR_COMPILE_WITH_OBJ_WRITER_ if you want to write .obj files
|
||||
#define _IRR_COMPILE_WITH_OBJ_WRITER_
|
||||
|
||||
//! Define _IRR_COMPILE_WITH_BMP_LOADER_ if you want to load .bmp files
|
||||
//! Disabling this loader will also disable the built-in font
|
||||
|
@ -331,7 +300,43 @@ precision will be lower but speed higher. currently X86 only
|
|||
//#define IRRLICHT_FAST_MATH
|
||||
#endif
|
||||
|
||||
// Some cleanup
|
||||
// Some cleanup and standard stuff
|
||||
|
||||
#ifdef _IRR_WINDOWS_API_
|
||||
|
||||
#ifndef _IRR_STATIC_LIB_
|
||||
#ifdef IRRLICHT_EXPORTS
|
||||
#define IRRLICHT_API __declspec(dllexport)
|
||||
#else
|
||||
#define IRRLICHT_API __declspec(dllimport)
|
||||
#endif // IRRLICHT_EXPORT
|
||||
#else
|
||||
#define IRRLICHT_API
|
||||
#endif // _IRR_STATIC_LIB_
|
||||
|
||||
// Declare the calling convention.
|
||||
#if defined(_STDCALL_SUPPORTED)
|
||||
#define IRRCALLCONV __stdcall
|
||||
#else
|
||||
#define IRRCALLCONV __cdecl
|
||||
#endif // STDCALL_SUPPORTED
|
||||
|
||||
#else
|
||||
#define IRRLICHT_API
|
||||
#define IRRCALLCONV
|
||||
#endif // _IRR_WINDOWS_API_
|
||||
|
||||
// We need to disable DIRECT3D9 support for Visual Studio 6.0 because
|
||||
// those $%&$!! disabled support for it since Dec. 2004 and users are complaining
|
||||
// about linker errors. Comment this out only if you are knowing what you are
|
||||
// doing. (Which means you have an old DX9 SDK and VisualStudio6).
|
||||
#ifdef _MSC_VER
|
||||
#if (_MSC_VER < 1300 && !defined(__GNUC__))
|
||||
#undef _IRR_COMPILE_WITH_DIRECT3D_9_
|
||||
#pragma message("Compiling Irrlicht with Visual Studio 6.0, support for DX9 is disabled.")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// XBox does not have OpenGL or DirectX9
|
||||
#if defined(_IRR_XBOX_PLATFORM_)
|
||||
#undef _IRR_COMPILE_WITH_OPENGL_
|
||||
|
@ -350,6 +355,9 @@ precision will be lower but speed higher. currently X86 only
|
|||
#define BURNINGVIDEO_RENDERER_CE
|
||||
#endif
|
||||
|
||||
#if defined(_IRR_SOLARIS_PLATFORM_)
|
||||
#undef _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
||||
#endif
|
||||
|
||||
#endif // __IRR_COMPILE_CONFIG_H_INCLUDED__
|
||||
|
||||
|
||||
|
|
|
@ -207,6 +207,16 @@ namespace irr
|
|||
mode.
|
||||
\param resize Flag whether the window should be resizeable. */
|
||||
virtual void setResizeAble(bool resize=false) = 0;
|
||||
|
||||
//! Activate any joysticks, and generate events for them.
|
||||
/** Irrlicht contains support for joysticks, but does not generate joystick events by default,
|
||||
as this would consume joystick info that 3rd party libraries might rely on. Call this method to
|
||||
activate joystick support in Irrlicht and to receive @ref SJoystickEvent events.
|
||||
\param joystickInfo On return, this will contain an array of each joystick that was found and activated.
|
||||
\return true if joysticks are supported on this device and _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
||||
is defined, false if joysticks are not supported or support is compiled out.
|
||||
*/
|
||||
virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo) = 0;
|
||||
};
|
||||
|
||||
} // end namespace irr
|
||||
|
|
|
@ -467,8 +467,8 @@ namespace video
|
|||
SColorHSL ( f32 h = 0.f, f32 s = 0.f, f32 l = 0.f )
|
||||
: Hue ( h ), Saturation ( s ), Luminance ( l ) {}
|
||||
|
||||
// void setfromRGB ( const SColor &color );
|
||||
void settoRGB ( SColor &color ) const;
|
||||
void fromRGB(const SColor &color);
|
||||
void toRGB(SColor &color) const;
|
||||
|
||||
f32 Hue;
|
||||
f32 Saturation;
|
||||
|
@ -479,7 +479,42 @@ namespace video
|
|||
|
||||
};
|
||||
|
||||
inline void SColorHSL::settoRGB ( SColor &color ) const
|
||||
inline void SColorHSL::fromRGB(const SColor &color)
|
||||
{
|
||||
const f32 maxVal = (f32)core::max_(color.getRed(), color.getGreen(), color.getBlue());
|
||||
const f32 minVal = (f32)core::min_(color.getRed(), color.getGreen(), color.getBlue());
|
||||
Luminance = (maxVal/minVal)*0.5f;
|
||||
if (maxVal==minVal)
|
||||
{
|
||||
Hue=0.f;
|
||||
Saturation=0.f;
|
||||
return;
|
||||
}
|
||||
|
||||
const f32 delta = maxVal-minVal;
|
||||
if ( Luminance <= 0.5f )
|
||||
{
|
||||
Saturation = (delta)/(maxVal+minVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
Saturation = (delta)/(2-maxVal-minVal);
|
||||
}
|
||||
|
||||
if (maxVal==color.getRed())
|
||||
Hue = (color.getRed()-color.getBlue())/delta;
|
||||
else if (maxVal==color.getGreen())
|
||||
Hue = 2+(color.getBlue()-color.getRed())/delta;
|
||||
else if (maxVal==color.getBlue())
|
||||
Hue = 4+(color.getRed()-color.getGreen())/delta;
|
||||
|
||||
Hue *= (60.0f * core::DEGTORAD);
|
||||
while ( Hue < 0.f )
|
||||
Hue += 2.f * core::PI;
|
||||
}
|
||||
|
||||
|
||||
inline void SColorHSL::toRGB(SColor &color) const
|
||||
{
|
||||
if ( Saturation == 0.0f) // grey
|
||||
{
|
||||
|
|
|
@ -89,6 +89,10 @@ namespace video
|
|||
/** \param other Material to copy from. */
|
||||
SMaterial& operator=(const SMaterial& other)
|
||||
{
|
||||
// Check for self-assignment!
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
MaterialType = other.MaterialType;
|
||||
|
||||
AmbientColor = other.AmbientColor;
|
||||
|
@ -410,6 +414,14 @@ namespace video
|
|||
\return True if the materials are equal, else false. */
|
||||
inline bool operator==(const SMaterial& b) const
|
||||
{ return !(b!=*this); }
|
||||
|
||||
bool isTransparent() const
|
||||
{
|
||||
return MaterialType==EMT_TRANSPARENT_ADD_COLOR ||
|
||||
MaterialType==EMT_TRANSPARENT_ALPHA_CHANNEL ||
|
||||
MaterialType==EMT_TRANSPARENT_VERTEX_ALPHA ||
|
||||
MaterialType==EMT_TRANSPARENT_REFLECTION_2_LAYER;
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace video
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#define __S_MATERIAL_LAYER_H_INCLUDED__
|
||||
|
||||
#include "matrix4.h"
|
||||
#include "irrAllocator.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
@ -40,11 +41,11 @@ namespace video
|
|||
public:
|
||||
//! Default constructor
|
||||
SMaterialLayer()
|
||||
: Texture(0), TextureMatrix(0),
|
||||
: Texture(0),
|
||||
TextureWrap(ETC_REPEAT),
|
||||
BilinearFilter(true),
|
||||
TrilinearFilter(false),
|
||||
AnisotropicFilter(false)
|
||||
AnisotropicFilter(false), TextureMatrix(0)
|
||||
{}
|
||||
|
||||
//! Copy constructor
|
||||
|
@ -59,7 +60,8 @@ namespace video
|
|||
//! Destructor
|
||||
~SMaterialLayer()
|
||||
{
|
||||
delete TextureMatrix;
|
||||
MatrixAllocator.destruct(TextureMatrix);
|
||||
MatrixAllocator.deallocate(TextureMatrix);
|
||||
}
|
||||
|
||||
//! Assignment operator
|
||||
|
@ -67,6 +69,10 @@ namespace video
|
|||
\return This material layer, updated. */
|
||||
SMaterialLayer& operator=(const SMaterialLayer& other)
|
||||
{
|
||||
// Check for self-assignment!
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
Texture = other.Texture;
|
||||
if (TextureMatrix)
|
||||
{
|
||||
|
@ -74,14 +80,18 @@ namespace video
|
|||
*TextureMatrix = *other.TextureMatrix;
|
||||
else
|
||||
{
|
||||
delete TextureMatrix;
|
||||
MatrixAllocator.destruct(TextureMatrix);
|
||||
MatrixAllocator.deallocate(TextureMatrix);
|
||||
TextureMatrix = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (other.TextureMatrix)
|
||||
TextureMatrix = new core::matrix4(*other.TextureMatrix);
|
||||
{
|
||||
TextureMatrix = MatrixAllocator.allocate(1);
|
||||
MatrixAllocator.construct(TextureMatrix,*other.TextureMatrix);
|
||||
}
|
||||
else
|
||||
TextureMatrix = 0;
|
||||
}
|
||||
|
@ -96,11 +106,6 @@ namespace video
|
|||
//! Texture
|
||||
ITexture* Texture;
|
||||
|
||||
//! Texture Matrix
|
||||
/** Do not access this element directly as the internal
|
||||
resource management has to cope with Null pointers etc. */
|
||||
core::matrix4* TextureMatrix;
|
||||
|
||||
//! Texture Clamp Mode
|
||||
E_TEXTURE_CLAMP TextureWrap;
|
||||
|
||||
|
@ -124,7 +129,10 @@ namespace video
|
|||
core::matrix4& getTextureMatrix()
|
||||
{
|
||||
if (!TextureMatrix)
|
||||
TextureMatrix = new core::matrix4(core::matrix4::EM4CONST_IDENTITY);
|
||||
{
|
||||
TextureMatrix = MatrixAllocator.allocate(1);
|
||||
MatrixAllocator.construct(TextureMatrix,core::IdentityMatrix);
|
||||
}
|
||||
return *TextureMatrix;
|
||||
}
|
||||
|
||||
|
@ -143,7 +151,10 @@ namespace video
|
|||
void setTextureMatrix(const core::matrix4& mat)
|
||||
{
|
||||
if (!TextureMatrix)
|
||||
TextureMatrix = new core::matrix4(mat);
|
||||
{
|
||||
TextureMatrix = MatrixAllocator.allocate(1);
|
||||
MatrixAllocator.construct(TextureMatrix,mat);
|
||||
}
|
||||
else
|
||||
*TextureMatrix = mat;
|
||||
}
|
||||
|
@ -173,10 +184,18 @@ namespace video
|
|||
\return True if layers are equal, else false. */
|
||||
inline bool operator==(const SMaterialLayer& b) const
|
||||
{ return !(b!=*this); }
|
||||
|
||||
private:
|
||||
friend class SMaterial;
|
||||
irr::core::irrAllocator<irr::core::matrix4> MatrixAllocator;
|
||||
|
||||
//! Texture Matrix
|
||||
/** Do not access this element directly as the internal
|
||||
ressource management has to cope with Null pointers etc. */
|
||||
core::matrix4* TextureMatrix;
|
||||
};
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
#endif // __S_MATERIAL_LAYER_H_INCLUDED__
|
||||
|
||||
|
|
|
@ -16,6 +16,19 @@ namespace irr
|
|||
{
|
||||
namespace scene
|
||||
{
|
||||
//! Name of the parameter for changing how Irrlicht handles the ZWrite flag for transparent (blending) materials
|
||||
/** The default behavior in Irrlicht is to disable writing to the
|
||||
z-buffer for all really transparent, i.e. blending materials. This
|
||||
avoids problems with intersecting faces, but can also break renderings.
|
||||
If transparent materials should use the SMaterial flag for ZWriteEnable
|
||||
just as other material types use this attribute.
|
||||
Use it like this:
|
||||
\code
|
||||
SceneManager->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true);
|
||||
\endcode
|
||||
**/
|
||||
const c8* const ALLOW_ZWRITE_ON_TRANSPARENT = "Allow_ZWrite_On_Transparent";
|
||||
|
||||
//! Name of the parameter for changing the texture path of the built-in csm loader.
|
||||
/** Use it like this:
|
||||
\code
|
||||
|
|
|
@ -78,6 +78,53 @@ namespace core
|
|||
return Width*Height;
|
||||
}
|
||||
|
||||
//! Get the optimal size according to some properties
|
||||
/** This is a function often used for texture dimension
|
||||
calculations. The function returns the next larger or
|
||||
smaller dimension which is a power-of-two dimension
|
||||
(2^n,2^m) and/or square (Width=Height).
|
||||
\param requirePowerOfTwo Forces the result to use only
|
||||
powers of two as values.
|
||||
\param requireSquare Makes width==height in the result
|
||||
\param larger Choose whether the result is larger or
|
||||
smaller than the current dimension. If one dimension
|
||||
need not be changed it is kept with any value of larger.
|
||||
\return The optimal dimension under the given
|
||||
constraints. */
|
||||
dimension2d<T> getOptimalSize(
|
||||
bool requirePowerOfTwo=true,
|
||||
bool requireSquare=false,
|
||||
bool larger=true) const
|
||||
{
|
||||
u32 i=1;
|
||||
u32 j=1;
|
||||
if (requirePowerOfTwo)
|
||||
{
|
||||
while (i<(u32)Width)
|
||||
i<<=1;
|
||||
if (!larger && i!=1 && i!=(u32)Width)
|
||||
i>>=1;
|
||||
while (j<(u32)Height)
|
||||
j<<=1;
|
||||
if (!larger && j!=1 && j!=(u32)Height)
|
||||
j>>=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
i=(u32)Width;
|
||||
j=(u32)Height;
|
||||
}
|
||||
|
||||
if (requireSquare)
|
||||
{
|
||||
if ((larger && (i>j)) || (!larger && (i<j)))
|
||||
j=i;
|
||||
else
|
||||
i=j;
|
||||
}
|
||||
return dimension2d<T>((T)i,(T)j);
|
||||
}
|
||||
|
||||
//! Width of the dimension.
|
||||
T Width;
|
||||
//! Height of the dimension.
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include "irrMath.h"
|
||||
#include <float.h> // For FLT_MAX
|
||||
#include <limits.h> // For INT_MAX / UINT_MAX
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
@ -33,77 +35,157 @@ const float fast_atof_table[16] = {
|
|||
0.000000000000001f
|
||||
};
|
||||
|
||||
inline u32 strtol10(const char* in, const char** out=0)
|
||||
//! Convert a simple string of base 10 digits into a signed 32 bit integer.
|
||||
//! \param[in] in: The string of digits to convert. Only a leading - or + followed
|
||||
//! by digits 0 to 9 will be considered. Parsing stops at the
|
||||
//! first non-digit.
|
||||
//! \param[out] out: (optional) If provided, it will be set to point at the first
|
||||
//! character not used in the calculation.
|
||||
//! \return The signed integer value of the digits. If the string specifies too many
|
||||
//! digits to encode in an s32 then +INT_MAX or -INT_MAX will be returned.
|
||||
inline s32 strtol10(const char* in, const char** out=0)
|
||||
{
|
||||
u32 value = 0;
|
||||
if(!in)
|
||||
return 0;
|
||||
|
||||
bool negative = false;
|
||||
if('-' == *in)
|
||||
{
|
||||
negative = true;
|
||||
++in;
|
||||
}
|
||||
else if('+' == *in)
|
||||
++in;
|
||||
|
||||
u32 unsignedValue = 0;
|
||||
|
||||
while ( ( *in >= '0') && ( *in <= '9' ))
|
||||
{
|
||||
value = ( value * 10 ) + ( *in - '0' );
|
||||
unsignedValue = ( unsignedValue * 10 ) + ( *in - '0' );
|
||||
++in;
|
||||
|
||||
if(unsignedValue > (u32)INT_MAX)
|
||||
{
|
||||
unsignedValue = (u32)INT_MAX;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (out)
|
||||
*out = in;
|
||||
return value;
|
||||
|
||||
if(negative)
|
||||
return -((s32)unsignedValue);
|
||||
else
|
||||
return (s32)unsignedValue;
|
||||
}
|
||||
|
||||
//! Provides a fast function for converting a string into a float,
|
||||
//! about 6 times faster than atof in win32.
|
||||
// If you find any bugs, please send them to me, niko (at) irrlicht3d.org.
|
||||
inline const char* fast_atof_move( const char* c, float& out)
|
||||
//! Converts a sequence of digits into a whole positive floating point value.
|
||||
//! Only digits 0 to 9 are parsed. Parsing stops at any other character,
|
||||
//! including sign characters or a decimal point.
|
||||
//! \param in: the sequence of digits to convert.
|
||||
//! \param out: (optional) will be set to point at the first non-converted character.
|
||||
//! \return The whole positive floating point representation of the digit sequence.
|
||||
inline f32 strtof10(const char* in, const char * * out = 0)
|
||||
{
|
||||
bool inv = false;
|
||||
const char *t;
|
||||
float f;
|
||||
if(!in)
|
||||
return 0.f;
|
||||
|
||||
if (*c=='-')
|
||||
static const u32 MAX_SAFE_U32_VALUE = UINT_MAX / 10 - 10;
|
||||
f32 floatValue = 0.f;
|
||||
u32 intValue = 0;
|
||||
|
||||
// Use integer arithmetic for as long as possible, for speed
|
||||
// and precision.
|
||||
while ( ( *in >= '0') && ( *in <= '9' ) )
|
||||
{
|
||||
++c;
|
||||
inv = true;
|
||||
// If it looks like we're going to overflow, bail out
|
||||
// now and start using floating point.
|
||||
if(intValue >= MAX_SAFE_U32_VALUE)
|
||||
break;
|
||||
|
||||
intValue = ( intValue * 10) + ( *in - '0' );
|
||||
++in;
|
||||
}
|
||||
|
||||
//f = (float)strtol(c, &t, 10);
|
||||
f = (float) strtol10 ( c, &c );
|
||||
floatValue = (f32)intValue;
|
||||
|
||||
if (*c == '.')
|
||||
// If there are any digits left to parse, then we need to use
|
||||
// floating point arithmetic from here.
|
||||
while ( ( *in >= '0') && ( *in <= '9' ) )
|
||||
{
|
||||
++c;
|
||||
|
||||
//float pl = (float)strtol(c, &t, 10);
|
||||
float pl = (float) strtol10 ( c, &t );
|
||||
pl *= fast_atof_table[t-c];
|
||||
|
||||
f += pl;
|
||||
|
||||
c = t;
|
||||
|
||||
if (*c == 'e')
|
||||
{
|
||||
++c;
|
||||
//float exp = (float)strtol(c, &t, 10);
|
||||
bool einv = (*c=='-');
|
||||
if (einv)
|
||||
++c;
|
||||
|
||||
float exp = (float)strtol10(c, &c);
|
||||
if (einv)
|
||||
exp *= -1.0f;
|
||||
|
||||
f *= (float)pow(10.0f, exp);
|
||||
}
|
||||
floatValue = ( floatValue * 10.f ) + (f32)( *in - '0' );
|
||||
++in;
|
||||
if(floatValue > FLT_MAX) // Just give up.
|
||||
break;
|
||||
}
|
||||
|
||||
if (inv)
|
||||
f *= -1.0f;
|
||||
if(out)
|
||||
*out = in;
|
||||
|
||||
out = f;
|
||||
return c;
|
||||
return floatValue;
|
||||
}
|
||||
|
||||
inline float fast_atof(const char* c)
|
||||
//! Provides a fast function for converting a string into a float.
|
||||
//! This is not guaranteed to be as accurate as atof(), but is
|
||||
//! approximately 6 to 8 times as fast.
|
||||
//! \param[in] in: The string to convert.
|
||||
//! \param[out] out: The resultant float will be written here.
|
||||
//! \return A pointer to the first character in the string that wasn't
|
||||
//! use to create the float value.
|
||||
inline const char* fast_atof_move( const char * in, f32 & out)
|
||||
{
|
||||
// Please run this regression test when making any modifications to this function:
|
||||
// https://sourceforge.net/tracker/download.php?group_id=74339&atid=540676&file_id=298968&aid=1865300
|
||||
|
||||
out = 0.f;
|
||||
if(!in)
|
||||
return 0;
|
||||
|
||||
bool negative = false;
|
||||
if(*in == '-')
|
||||
{
|
||||
negative = true;
|
||||
++in;
|
||||
}
|
||||
|
||||
f32 value = strtof10 ( in, &in );
|
||||
|
||||
if (*in == '.')
|
||||
{
|
||||
++in;
|
||||
|
||||
const char * afterDecimal;
|
||||
f32 decimal = strtof10 ( in, &afterDecimal );
|
||||
decimal *= fast_atof_table[afterDecimal - in];
|
||||
|
||||
value += decimal;
|
||||
|
||||
in = afterDecimal;
|
||||
}
|
||||
|
||||
if ('e' == *in || 'E' == *in)
|
||||
{
|
||||
++in;
|
||||
// Assume that the exponent is a whole number.
|
||||
// strtol10() will deal with both + and - signs,
|
||||
// but cast to (f32) to prevent overflow at FLT_MAX
|
||||
value *= (f32)pow(10.0f, (f32)strtol10(in, &in));
|
||||
}
|
||||
|
||||
if(negative)
|
||||
out = -value;
|
||||
else
|
||||
out = value;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
//! Convert a string to a floating point number
|
||||
//! \param floatAsString: The string to convert.
|
||||
inline float fast_atof(const char* floatAsString)
|
||||
{
|
||||
float ret;
|
||||
fast_atof_move(c, ret);
|
||||
fast_atof_move(floatAsString, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,10 +32,10 @@ namespace core
|
|||
|
||||
#ifdef IRRLICHT_FAST_MATH
|
||||
const f32 ROUNDING_ERROR_32 = 0.00005f;
|
||||
const f64 ROUNDING_ERROR_64 = 0.000005f;
|
||||
const f64 ROUNDING_ERROR_64 = 0.000005;
|
||||
#else
|
||||
const f32 ROUNDING_ERROR_32 = 0.000001f;
|
||||
const f64 ROUNDING_ERROR_64 = 0.00000001f;
|
||||
const f64 ROUNDING_ERROR_64 = 0.00000001;
|
||||
#endif
|
||||
|
||||
#ifdef PI // make sure we don't collide with a define
|
||||
|
@ -71,6 +71,42 @@ namespace core
|
|||
//! 64bit constant for converting from radians to degrees
|
||||
const f64 RADTODEG64 = 180.0 / PI64;
|
||||
|
||||
//! Utility function to convert a radian value to degrees
|
||||
/** Provided as it can be clearer to write radToDeg(X) than RADTODEG * X
|
||||
\param radians The radians value to convert to degrees.
|
||||
*/
|
||||
inline f32 radToDeg(f32 radians)
|
||||
{
|
||||
return RADTODEG * radians;
|
||||
}
|
||||
|
||||
//! Utility function to convert a radian value to degrees
|
||||
/** Provided as it can be clearer to write radToDeg(X) than RADTODEG * X
|
||||
\param radians The radians value to convert to degrees.
|
||||
*/
|
||||
inline f64 radToDeg(f64 radians)
|
||||
{
|
||||
return RADTODEG64 * radians;
|
||||
}
|
||||
|
||||
//! Utility function to convert a degrees value to radians
|
||||
/** Provided as it can be clearer to write degToRad(X) than DEGTORAD * X
|
||||
\param degrees The degrees value to convert to radians.
|
||||
*/
|
||||
inline f32 degToRad(f32 degrees)
|
||||
{
|
||||
return DEGTORAD * degrees;
|
||||
}
|
||||
|
||||
//! Utility function to convert a degrees value to radians
|
||||
/** Provided as it can be clearer to write degToRad(X) than DEGTORAD * X
|
||||
\param degrees The degrees value to convert to radians.
|
||||
*/
|
||||
inline f64 degToRad(f64 degrees)
|
||||
{
|
||||
return DEGTORAD64 * degrees;
|
||||
}
|
||||
|
||||
//! returns minimum of two values. Own implementation to get rid of the STL (VS6 problems)
|
||||
template<class T>
|
||||
inline const T& min_(const T& a, const T& b)
|
||||
|
|
|
@ -41,7 +41,6 @@ public:
|
|||
}
|
||||
|
||||
|
||||
|
||||
//! Constructor
|
||||
string(const string<T>& other)
|
||||
: array(0), allocated(0), used(0)
|
||||
|
@ -49,10 +48,17 @@ public:
|
|||
*this = other;
|
||||
}
|
||||
|
||||
//! Constructor from other string types
|
||||
template <class B>
|
||||
string(const string<B>& other)
|
||||
: array(0), allocated(0), used(0)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
|
||||
//! Constructs a string from a float
|
||||
string(const double number)
|
||||
explicit string(const double number)
|
||||
: array(0), allocated(0), used(0)
|
||||
{
|
||||
c8 tmpbuf[255];
|
||||
|
@ -61,9 +67,8 @@ public:
|
|||
}
|
||||
|
||||
|
||||
|
||||
//! Constructs a string from an int
|
||||
string(int number)
|
||||
explicit string(int number)
|
||||
: array(0), allocated(0), used(0)
|
||||
{
|
||||
// store if negative and make positive
|
||||
|
@ -111,9 +116,8 @@ public:
|
|||
}
|
||||
|
||||
|
||||
|
||||
//! Constructs a string from an unsigned int
|
||||
string(unsigned int number)
|
||||
explicit string(unsigned int number)
|
||||
: array(0), allocated(0), used(0)
|
||||
{
|
||||
// temporary buffer for 16 numbers
|
||||
|
@ -144,7 +148,6 @@ public:
|
|||
}
|
||||
|
||||
|
||||
|
||||
//! Constructor for copying a string from a pointer with a given length
|
||||
template <class B>
|
||||
string(const B* const c, u32 length)
|
||||
|
@ -167,7 +170,6 @@ public:
|
|||
}
|
||||
|
||||
|
||||
|
||||
//! Constructor for unicode and ascii strings
|
||||
template <class B>
|
||||
string(const B* const c)
|
||||
|
@ -177,7 +179,6 @@ public:
|
|||
}
|
||||
|
||||
|
||||
|
||||
//! destructor
|
||||
~string()
|
||||
{
|
||||
|
@ -185,7 +186,6 @@ public:
|
|||
}
|
||||
|
||||
|
||||
|
||||
//! Assignment operator
|
||||
string<T>& operator=(const string<T>& other)
|
||||
{
|
||||
|
@ -203,6 +203,13 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
//! Assignment operator for other string types
|
||||
template <class B>
|
||||
string<T>& operator=(const string<B>& other)
|
||||
{
|
||||
*this = other.c_str();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//! Assignment operator for strings, ascii and unicode
|
||||
|
@ -247,7 +254,8 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
//! Add operator for other strings
|
||||
|
||||
//! Append operator for other strings
|
||||
string<T> operator+(const string<T>& other) const
|
||||
{
|
||||
string<T> str(*this);
|
||||
|
@ -256,7 +264,8 @@ public:
|
|||
return str;
|
||||
}
|
||||
|
||||
//! Add operator for strings, ascii and unicode
|
||||
|
||||
//! Append operator for strings, ascii and unicode
|
||||
template <class B>
|
||||
string<T> operator+(const B* const c) const
|
||||
{
|
||||
|
@ -283,7 +292,7 @@ public:
|
|||
}
|
||||
|
||||
|
||||
//! Comparison operator
|
||||
//! Equality operator
|
||||
bool operator ==(const T* const str) const
|
||||
{
|
||||
if (!str)
|
||||
|
@ -298,8 +307,7 @@ public:
|
|||
}
|
||||
|
||||
|
||||
|
||||
//! Comparison operator
|
||||
//! Equality operator
|
||||
bool operator ==(const string<T>& other) const
|
||||
{
|
||||
for(u32 i=0; array[i] && other.array[i]; ++i)
|
||||
|
@ -310,7 +318,7 @@ public:
|
|||
}
|
||||
|
||||
|
||||
//! Is smaller operator
|
||||
//! Is smaller comparator
|
||||
bool operator <(const string<T>& other) const
|
||||
{
|
||||
for(u32 i=0; array[i] && other.array[i]; ++i)
|
||||
|
@ -328,41 +336,36 @@ public:
|
|||
}
|
||||
|
||||
|
||||
|
||||
//! Equals not operator
|
||||
//! Inequality operator
|
||||
bool operator !=(const T* const str) const
|
||||
{
|
||||
return !(*this == str);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Equals not operator
|
||||
//! Inequality operator
|
||||
bool operator !=(const string<T>& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Returns length of string
|
||||
/** \return Returns length of the string in characters. */
|
||||
/** \return Length of the string in characters. */
|
||||
u32 size() const
|
||||
{
|
||||
return used-1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Returns character string
|
||||
/** \return Returns pointer to C-style zero terminated string. */
|
||||
/** \return pointer to C-style zero terminated string. */
|
||||
const T* c_str() const
|
||||
{
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Makes the string lower case.
|
||||
void make_lower()
|
||||
{
|
||||
|
@ -371,7 +374,6 @@ public:
|
|||
}
|
||||
|
||||
|
||||
|
||||
//! Makes the string upper case.
|
||||
void make_upper()
|
||||
{
|
||||
|
@ -387,10 +389,9 @@ public:
|
|||
}
|
||||
|
||||
|
||||
|
||||
//! Compares the string ignoring case.
|
||||
//! Compares the strings ignoring case.
|
||||
/** \param other: Other string to compare.
|
||||
\return Returns true if the string are equal ignoring case. */
|
||||
\return True if the strings are equal ignoring case. */
|
||||
bool equals_ignore_case(const string<T>& other) const
|
||||
{
|
||||
for(u32 i=0; array[i] && other[i]; ++i)
|
||||
|
@ -400,9 +401,10 @@ public:
|
|||
return used == other.used;
|
||||
}
|
||||
|
||||
//! Compares the string ignoring case.
|
||||
|
||||
//! Compares the strings ignoring case.
|
||||
/** \param other: Other string to compare.
|
||||
\return Returns true if the string is smaller ignoring case. */
|
||||
\return True if this string is smaller ignoring case. */
|
||||
bool lower_ignore_case(const string<T>& other) const
|
||||
{
|
||||
for(u32 i=0; array[i] && other.array[i]; ++i)
|
||||
|
@ -416,8 +418,10 @@ public:
|
|||
}
|
||||
|
||||
|
||||
|
||||
//! compares the first n characters of the strings
|
||||
/** \param other Other string to compare.
|
||||
\param n Number of characters to compare
|
||||
\return True if the n first characters of this string are smaller. */
|
||||
bool equalsn(const string<T>& other, u32 n) const
|
||||
{
|
||||
u32 i;
|
||||
|
@ -432,11 +436,14 @@ public:
|
|||
|
||||
|
||||
//! compares the first n characters of the strings
|
||||
/** \param str Other string to compare.
|
||||
\param n Number of characters to compare
|
||||
\return True if the n first characters of this string are smaller. */
|
||||
bool equalsn(const T* const str, u32 n) const
|
||||
{
|
||||
if (!str)
|
||||
return false;
|
||||
s32 i;
|
||||
u32 i;
|
||||
for(i=0; array[i] && str[i] && i < n; ++i)
|
||||
if (array[i] != str[i])
|
||||
return false;
|
||||
|
@ -460,6 +467,7 @@ public:
|
|||
array[used-1] = 0;
|
||||
}
|
||||
|
||||
|
||||
//! Appends a char string to this string
|
||||
/** \param other: Char string to append. */
|
||||
void append(const T* const other)
|
||||
|
@ -692,7 +700,7 @@ public:
|
|||
if (len > used-1)
|
||||
return -1;
|
||||
|
||||
for (s32 i=0; i<used-len; ++i)
|
||||
for (u32 i=0; i<used-len; ++i)
|
||||
{
|
||||
u32 j=0;
|
||||
|
||||
|
@ -734,6 +742,8 @@ public:
|
|||
}
|
||||
|
||||
|
||||
//! Appends a character to this string
|
||||
/** \param character: Character to append. */
|
||||
string<T>& operator += (T c)
|
||||
{
|
||||
append(c);
|
||||
|
@ -741,6 +751,8 @@ public:
|
|||
}
|
||||
|
||||
|
||||
//! Appends a char string to this string
|
||||
/** \param other: Char string to append. */
|
||||
string<T>& operator += (const T* const c)
|
||||
{
|
||||
append(c);
|
||||
|
@ -748,6 +760,8 @@ public:
|
|||
}
|
||||
|
||||
|
||||
//! Appends a string to this string
|
||||
/** \param other: String to append. */
|
||||
string<T>& operator += (const string<T>& other)
|
||||
{
|
||||
append(other);
|
||||
|
@ -805,6 +819,7 @@ public:
|
|||
array[i] = replaceWith;
|
||||
}
|
||||
|
||||
|
||||
//! trims the string.
|
||||
/** Removes whitespace from begin and end of the string. */
|
||||
string<T>& trim()
|
||||
|
@ -823,9 +838,10 @@ public:
|
|||
}
|
||||
|
||||
|
||||
//! Erases a character from the string. May be slow, because all elements
|
||||
//! following after the erased element have to be copied.
|
||||
//! \param index: Index of element to be erased.
|
||||
//! Erases a character from the string.
|
||||
/** May be slow, because all elements
|
||||
following after the erased element have to be copied.
|
||||
\param index: Index of element to be erased. */
|
||||
void erase(u32 index)
|
||||
{
|
||||
_IRR_DEBUG_BREAK_IF(index>=used) // access violation
|
||||
|
|
|
@ -141,7 +141,7 @@
|
|||
#include "SMeshBufferTangents.h"
|
||||
#include "SViewFrustum.h"
|
||||
|
||||
/*! \mainpage Irrlicht Engine 1.4.1 API documentation
|
||||
/*! \mainpage Irrlicht Engine 1.4.2 API documentation
|
||||
*
|
||||
* <div align="center"><img src="logobig.png" ></div>
|
||||
*
|
||||
|
|
|
@ -74,35 +74,52 @@ class line2d
|
|||
\return True if there is an intersection, false if not. */
|
||||
bool intersectWith(const line2d<T>& l, vector2d<T>& out) const
|
||||
{
|
||||
bool found=false;
|
||||
// Uses the method given at:
|
||||
// http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/
|
||||
const f32 commonDenominator = (l.end.Y - l.start.Y)*(end.X - start.X) -
|
||||
(l.end.X - l.start.X)*(end.Y - start.Y);
|
||||
|
||||
f32 a1,a2,b1,b2;
|
||||
const f32 numeratorA = (l.end.X - l.start.X)*(start.Y - l.start.Y) -
|
||||
(l.end.Y - l.start.Y)*(start.X -l.start.X);
|
||||
|
||||
// calculate slopes, deal with infinity
|
||||
if (end.X-start.X == 0)
|
||||
b1 = (f32)1e+10;
|
||||
else
|
||||
b1 = (end.Y-start.Y)/(end.X-start.X);
|
||||
if (l.end.X-l.start.X == 0)
|
||||
b2 = (f32)1e+10;
|
||||
else
|
||||
b2 = (l.end.Y-l.start.Y)/(l.end.X-l.start.X);
|
||||
const f32 numeratorB = (end.X - start.X)*(start.Y - l.start.Y) -
|
||||
(end.Y - start.Y)*(start.X -l.start.X);
|
||||
|
||||
// calculate position
|
||||
a1 = start.Y - b1 * start.X;
|
||||
a2 = l.start.Y - b2 * l.start.X;
|
||||
out.X = - (a1-a2)/(b1-b2);
|
||||
out.Y = a1 + b1*out.X;
|
||||
if(equals(commonDenominator, 0.f))
|
||||
{
|
||||
// The lines are either coincident or parallel
|
||||
if(equals(numeratorA, 0.f) && equals(numeratorB, 0.f))
|
||||
{
|
||||
// Try and find a common endpoint
|
||||
if(l.start == start || l.end == start)
|
||||
out = start;
|
||||
else if(l.end == end || l.start == end)
|
||||
out = end;
|
||||
else
|
||||
// one line is contained in the other, so for lack of a better
|
||||
// answer, pick the average of both lines
|
||||
out = ((start + end + l.start + l.end) * 0.25f);
|
||||
|
||||
// did the lines cross?
|
||||
if ((start.X-out.X) *(out.X-end.X) >= -ROUNDING_ERROR_32 &&
|
||||
(l.start.X-out.X)*(out.X-l.end.X)>= -ROUNDING_ERROR_32 &&
|
||||
(start.Y-out.Y) *(out.Y-end.Y) >= -ROUNDING_ERROR_32 &&
|
||||
(l.start.Y-out.Y)*(out.Y-l.end.Y)>= -ROUNDING_ERROR_32 )
|
||||
{
|
||||
found = true;
|
||||
return true; // coincident
|
||||
}
|
||||
|
||||
return false; // parallel
|
||||
}
|
||||
return found;
|
||||
|
||||
// Get the point of intersection on this line, checking that
|
||||
// it is within the line segment.
|
||||
const f32 uA = numeratorA / commonDenominator;
|
||||
if(uA < 0.f || uA > 1.f)
|
||||
return false; // Outside the line segment
|
||||
|
||||
const f32 uB = numeratorB / commonDenominator;
|
||||
if(uB < 0.f || uB > 1.f)
|
||||
return false; // Outside the line segment
|
||||
|
||||
// Calculate the intersection point.
|
||||
out.X = start.X + uA * (end.X - start.X);
|
||||
out.Y = start.Y + uA * (end.Y - start.Y);
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Get unit vector of the line.
|
||||
|
|
|
@ -1733,7 +1733,7 @@ namespace core
|
|||
//! Typedef for f32 matrix
|
||||
typedef CMatrix4<f32> matrix4;
|
||||
//! global const identity matrix
|
||||
const matrix4 IdentityMatrix(matrix4::EM4CONST_IDENTITY);
|
||||
extern const matrix4 IdentityMatrix;
|
||||
|
||||
} // end namespace core
|
||||
} // end namespace irr
|
||||
|
|
|
@ -18,6 +18,9 @@ namespace core
|
|||
/** Mostly used by 2D GUI elements and for 2D drawing methods.
|
||||
It has 2 positions instead of position and dimension and a fast
|
||||
method for collision detection with other rectangles and points.
|
||||
|
||||
Coordinates are (0,0) for top-left corner, and increasing to the right
|
||||
and to the bottom.
|
||||
*/
|
||||
template <class T>
|
||||
class rect
|
||||
|
@ -88,8 +91,8 @@ namespace core
|
|||
}
|
||||
|
||||
//! Returns if a 2d point is within this rectangle.
|
||||
//! \param pos: Position to test if it lies within this rectangle.
|
||||
//! \return Returns true if the position is within the rectangle, false if not.
|
||||
/** \param pos Position to test if it lies within this rectangle.
|
||||
\return True if the position is within the rectangle, false if not. */
|
||||
bool isPointInside(const position2d<T>& pos) const
|
||||
{
|
||||
return (UpperLeftCorner.X <= pos.X &&
|
||||
|
@ -128,7 +131,7 @@ namespace core
|
|||
}
|
||||
|
||||
//! Moves this rectangle to fit inside another one.
|
||||
//! \return: returns true on success, false if not possible
|
||||
/** \return True on success, false if not possible */
|
||||
bool constrainTo(const rect<T>& other)
|
||||
{
|
||||
if (other.getWidth() < getWidth() || other.getHeight() < getHeight())
|
||||
|
@ -177,8 +180,7 @@ namespace core
|
|||
return LowerRightCorner.Y - UpperLeftCorner.Y;
|
||||
}
|
||||
|
||||
//! If the lower right corner of the rect is smaller then the
|
||||
//! upper left, the points are swapped.
|
||||
//! If the lower right corner of the rect is smaller then the upper left, the points are swapped.
|
||||
void repair()
|
||||
{
|
||||
if (LowerRightCorner.X < UpperLeftCorner.X)
|
||||
|
@ -196,9 +198,9 @@ namespace core
|
|||
}
|
||||
}
|
||||
|
||||
//! Returns if the rect is valid to draw. It could be invalid
|
||||
//! if the UpperLeftCorner is lower or more right than the
|
||||
//! LowerRightCorner, or if any dimension is 0.
|
||||
//! Returns if the rect is valid to draw.
|
||||
/** It would be invalid if the UpperLeftCorner is lower or more
|
||||
right than the LowerRightCorner. */
|
||||
bool isValid() const
|
||||
{
|
||||
return ((LowerRightCorner.X >= UpperLeftCorner.X) &&
|
||||
|
@ -208,8 +210,9 @@ namespace core
|
|||
//! Returns the center of the rectangle
|
||||
position2d<T> getCenter() const
|
||||
{
|
||||
return position2d<T>((UpperLeftCorner.X + LowerRightCorner.X) / 2,
|
||||
(UpperLeftCorner.Y + LowerRightCorner.Y) / 2);
|
||||
return position2d<T>(
|
||||
(UpperLeftCorner.X + LowerRightCorner.X) / 2,
|
||||
(UpperLeftCorner.Y + LowerRightCorner.Y) / 2);
|
||||
}
|
||||
|
||||
//! Returns the dimensions of the rectangle
|
||||
|
@ -219,18 +222,19 @@ namespace core
|
|||
}
|
||||
|
||||
|
||||
//! Adds a point to the rectangle, causing it to grow bigger,
|
||||
//! if point is outside of the box
|
||||
//! \param p: Point to add into the box.
|
||||
//! Adds a point to the rectangle
|
||||
/** Cause the rectangle to grow bigger, if point is outside of
|
||||
the box
|
||||
\param p Point to add into the box. */
|
||||
void addInternalPoint(const position2d<T>& p)
|
||||
{
|
||||
addInternalPoint(p.X, p.Y);
|
||||
}
|
||||
|
||||
//! Adds a point to the bounding rectangle, causing it to grow bigger,
|
||||
//! if point is outside of the box.
|
||||
//! \param x: X Coordinate of the point to add to this box.
|
||||
//! \param y: Y Coordinate of the point to add to this box.
|
||||
//! Adds a point to the bounding rectangle
|
||||
/** Cause the rectangle to grow bigger, if point is outside of
|
||||
\param x X Coordinate of the point to add to this box.
|
||||
\param y Y Coordinate of the point to add to this box. */
|
||||
void addInternalPoint(T x, T y)
|
||||
{
|
||||
if (x>LowerRightCorner.X)
|
||||
|
@ -244,7 +248,6 @@ namespace core
|
|||
UpperLeftCorner.Y = y;
|
||||
}
|
||||
|
||||
|
||||
position2d<T> UpperLeftCorner;
|
||||
position2d<T> LowerRightCorner;
|
||||
};
|
||||
|
|
24
readme.txt
24
readme.txt
|
@ -1,5 +1,5 @@
|
|||
==========================================================================
|
||||
The Irrlicht Engine SDK version 1.4.1
|
||||
The Irrlicht Engine SDK version 1.4.2
|
||||
==========================================================================
|
||||
|
||||
Welcome the Irrlicht Engine SDK.
|
||||
|
@ -69,6 +69,8 @@ The Irrlicht Engine SDK version 1.4.1
|
|||
(libIrrlicht.so.versionNumber). Use the proper makefile target for this by
|
||||
running 'make sharedlib' in the source folder. See the Makefile for details.
|
||||
|
||||
For OSX you can find an XCode project file in source/Irrlicht/MacOSX. This will
|
||||
build the libIrrlicht.a library necessary to create the apps.
|
||||
|
||||
==========================================================================
|
||||
3. Requirements
|
||||
|
@ -80,10 +82,10 @@ The Irrlicht Engine SDK version 1.4.1
|
|||
|
||||
* gcc 3.3
|
||||
* gcc 3.4
|
||||
* gcc 4.0.3
|
||||
* Visual Studio 6.0
|
||||
* gcc 4.x
|
||||
* Visual Studio.NET 2003 (7.1)
|
||||
* Visual Studio 2005 (8.0)
|
||||
* Visual Studio 2008 (9.0)
|
||||
* Code::Blocks 1.0 (& gcc or visual studio toolkit)
|
||||
* DevC++ 5.0 & gcc (project files included)
|
||||
|
||||
|
@ -91,16 +93,20 @@ The Irrlicht Engine SDK version 1.4.1
|
|||
want to use the precompiled version) you need the following:
|
||||
|
||||
* Windows:
|
||||
* Needed: PlatformSDK (which usually comes with all IDEs)
|
||||
* Optional: DirectX 9 SDK, for D3D9 support
|
||||
* Optional: DirectX 8 SDK, for D3D8 support
|
||||
* Needed: PlatformSDK (which usually comes with all IDEs, download
|
||||
it separately for MSVC Express 2005)
|
||||
* Optional: DirectX SDK, for D3D9 support
|
||||
* Optional: DirectX SDK prior to May 2006, for D3D8 support
|
||||
|
||||
* Linux:
|
||||
* Needed: XServer with include files
|
||||
* Optional: OpenGL headers and libraries (libGL and libGLU), for
|
||||
OpenGL support
|
||||
* GLX + XF86VidMode extension (X11 support libraries)
|
||||
* Optional: OpenGL headers and libraries (libGL.so), for OpenGL support
|
||||
* GLX + XF86VidMode or XRandr extension (X11 support libraries,
|
||||
the latter two for fullscreen mode)
|
||||
|
||||
* OSX:
|
||||
* Needed: XCode and Cocoa framework
|
||||
* Needed: OpenGL headers and libraries
|
||||
|
||||
==========================================================================
|
||||
4. Release Notes
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -444,7 +444,7 @@ WARN_LOGFILE =
|
|||
# directories like "/usr/src/myproject". Separate the files or directories
|
||||
# with spaces.
|
||||
|
||||
INPUT = ../../../include/
|
||||
INPUT = ../../../include/ tut.txt
|
||||
|
||||
# If the value of the INPUT tag contains directories, you can use the
|
||||
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
|
||||
|
@ -504,7 +504,7 @@ EXAMPLE_RECURSIVE = NO
|
|||
# directories that contain image that are included in the documentation (see
|
||||
# the \image command).
|
||||
|
||||
IMAGE_PATH =
|
||||
IMAGE_PATH = ../../../media
|
||||
|
||||
# The INPUT_FILTER tag can be used to specify a program that doxygen should
|
||||
# invoke to filter for each input file. Doxygen will invoke the filter program
|
||||
|
|
|
@ -444,7 +444,7 @@ WARN_LOGFILE =
|
|||
# directories like "/usr/src/myproject". Separate the files or directories
|
||||
# with spaces.
|
||||
|
||||
INPUT = ../../../include/
|
||||
INPUT = ../../../include/ tut.txt
|
||||
|
||||
# If the value of the INPUT tag contains directories, you can use the
|
||||
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
|
||||
|
@ -504,7 +504,7 @@ EXAMPLE_RECURSIVE = NO
|
|||
# directories that contain image that are included in the documentation (see
|
||||
# the \image command).
|
||||
|
||||
IMAGE_PATH =
|
||||
IMAGE_PATH = ../../../media
|
||||
|
||||
# The INPUT_FILTER tag can be used to specify a program that doxygen should
|
||||
# invoke to filter for each input file. Doxygen will invoke the filter program
|
||||
|
@ -761,13 +761,13 @@ LATEX_HEADER =
|
|||
# contain links (just like the HTML output) instead of page references
|
||||
# This makes the output suitable for online browsing using a pdf viewer.
|
||||
|
||||
PDF_HYPERLINKS = NO
|
||||
PDF_HYPERLINKS = YES
|
||||
|
||||
# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
|
||||
# plain latex in the generated Makefile. Set this option to YES to get a
|
||||
# higher quality PDF documentation.
|
||||
|
||||
USE_PDFLATEX = NO
|
||||
USE_PDFLATEX = YES
|
||||
|
||||
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
|
||||
# command to the generated LaTeX files. This will instruct LaTeX to keep
|
||||
|
|
|
@ -14,6 +14,6 @@
|
|||
| <a class="qindex" href="namespacemembers.html"><font color="#FFFFFF">
|
||||
Namespace Members</font></a> | <a class="qindex" href="functions.html"><font color="#FFFFFF">Class
|
||||
members</font></a> | <a class="qindex" href="globals.html"><font color="#FFFFFF">File
|
||||
members</font></a></font> </td>
|
||||
members</font></a> | <a class="qindex" href="pages.html"><font color="#FFFFFF">Tutorials</font></a></font> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
@ -4,6 +4,25 @@ copy doxygen.css ..\..\..\doctemp\html
|
|||
copy irrlicht.png ..\..\..\doctemp\html
|
||||
copy logobig.png ..\..\..\doctemp\html
|
||||
|
||||
rem for /F %%i in ('dir ..\..\..\examples\[01]*\main.cpp') DO ..\sed.exe -f tutorials.sed %i >>tut.txt
|
||||
..\sed.exe -f tutorials.sed ..\..\..\examples\01.HelloWorld\main.cpp >tut.txt
|
||||
..\sed.exe -f tutorials.sed ..\..\..\examples\02.Quake3Map\main.cpp >>tut.txt
|
||||
..\sed.exe -f tutorials.sed ..\..\..\examples\03.CustomSceneNode\main.cpp >>tut.txt
|
||||
..\sed.exe -f tutorials.sed ..\..\..\examples\04.Movement\main.cpp >>tut.txt
|
||||
..\sed.exe -f tutorials.sed ..\..\..\examples\05.UserInterface\main.cpp >>tut.txt
|
||||
..\sed.exe -f tutorials.sed ..\..\..\examples\06.2DGraphics\main.cpp >>tut.txt
|
||||
..\sed.exe -f tutorials.sed ..\..\..\examples\07.Collision\main.cpp >>tut.txt
|
||||
..\sed.exe -f tutorials.sed ..\..\..\examples\08.SpecialFX\main.cpp >>tut.txt
|
||||
..\sed.exe -f tutorials.sed ..\..\..\examples\09.MeshViewer\main.cpp >>tut.txt
|
||||
..\sed.exe -f tutorials.sed ..\..\..\examples\10.Shaders\main.cpp >>tut.txt
|
||||
..\sed.exe -f tutorials.sed ..\..\..\examples\11.PerPixelLighting\main.cpp >>tut.txt
|
||||
..\sed.exe -f tutorials.sed ..\..\..\examples\12.TerrainRendering\main.cpp >>tut.txt
|
||||
..\sed.exe -f tutorials.sed ..\..\..\examples\13.RenderToTexture\main.cpp >>tut.txt
|
||||
..\sed.exe -f tutorials.sed ..\..\..\examples\14.Win32Window\main.cpp >>tut.txt
|
||||
..\sed.exe -f tutorials.sed ..\..\..\examples\15.LoadIrrFile\main.cpp >>tut.txt
|
||||
..\sed.exe -f tutorials.sed ..\..\..\examples\16.Quake3MapShader\main.cpp >>tut.txt
|
||||
..\sed.exe -f tutorials.sed ..\..\..\examples\17.SplitScreen\main.cpp >>tut.txt
|
||||
|
||||
..\doxygen.exe doxygen.cfg
|
||||
|
||||
pause
|
||||
pause
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
doxygen doxygen.cfg
|
||||
rm tut.txt || true;
|
||||
for i in ../../../examples/[01]*/main.cpp; do
|
||||
sed -f tutorials.sed $i >>tut.txt;
|
||||
done
|
||||
|
||||
doxygen doxygen-pdf.cfg
|
||||
|
||||
cp doxygen.css irrlicht.png logobig.png ../../../doctemp/html
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# Page start and end are delimited by /** and **/
|
||||
# we keep the end unchanged, the header is extended
|
||||
s/\/\*\* Example \(0*\)\([0-9]*\) \(.*\)$/\/\*\* \\page example\1\2 Tutorial \2: \3\n \\image html \"\1\2shot.jpg\"\n \\image latex \"\1\2shot.jpg\"/
|
||||
|
||||
# All other comments start and end code sections
|
||||
s/\([^\*]\)\*\//\1\\code/
|
||||
s/^\*\//\\code/
|
||||
|
||||
s/\/\*\([^\*]\)/\\endcode \1/
|
||||
s/\/\*$/\\endcode\n/
|
||||
|
||||
#remove DOS line endings
|
||||
s/\r//g
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue