Merged some older revisions which seemed to be missing, namely 3986-4057 from trunk

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@4490 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2013-04-02 16:01:12 +00:00
parent 0753afac9d
commit 4f4ca75a4f
40 changed files with 2940 additions and 1884 deletions

View File

@ -641,7 +641,7 @@ Changes in 1.7.4 (not yet released)
- Yield on Linux now uses nanosleep with 1ns as 0 isn't guaranteed to yield (thx @ hendu for finding + fix)
-----------------------------
Changes in 1.7.3 (??.??.2011)
Changes in 1.7.3 (20.02.2012)
- SceneNodeAnimatorFlyCircle fixes serialization of RadiusEllipsoid (was writing Radius). Thx @ wing64 for reporting.
@ -683,14 +683,20 @@ Changes in 1.7.3 (??.??.2011)
- Fix crash in editbox when scrolling up with empty first lines caused by textwrapping.
- triangle3d::isPointInside can now work with larger integers, old version failed already with values in the 3-digit range. It got also faster. (thx @ Eigen for report + testcase and REDDemon for patch proposal).
- Fix endianess conversions
- Changes to isPointInside
- Fix focus problem when removing an unfocused modal dialog reported by Reiko here: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=44358
- Fix md2 normals problem again
- Add integer template specialization for vector3d::getSphericalCoordinateAngles which rounds angles to nearest integer now.
- Recalculate FrameRect and ScrollPos in CGUIEditBox when AbsoluteRect gets changed (thx @ serengeor for report + testcase)
- Fix crash in editbox
- Fix 'k' in bigfont.png (thx @ Scrappi for reporting)
- fix serialization for CBillboardSceneNode, it had missed 2 color (thx for finding + patch from pc0de)
@ -701,6 +707,10 @@ Changes in 1.7.3 (??.??.2011)
- Fix crash in collada (.dae) loading
- Fix bug handling in case RTT is not properly created
- Fix SColorf interpolation
- Fix memory-leaks in example 22 MaterialViewer
- Fix array::erase which did destroy objects more than once when used with a range (thx @ RedDragCZ for reporting + testcase).
@ -711,6 +721,8 @@ Changes in 1.7.3 (??.??.2011)
- CGUIScrollBar passes unused mousemove-events now to parent element. Fixes focus-bug in ComboBox reported by REDDemon here: http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=43474&highlight=
- Fix getAngle and getAngleWith
- Fix clipping in CGUITabControl
- Fix clipping in CGUITable, reported by ceyron
@ -1953,6 +1965,8 @@ Changes in version 1.5 (15.12.2008)
- Fixed LMTS problems with extra data in files.
- Removed VS6 .dsw / .dsp project files - VS6 is no longer supported.
- Particles can be scaled during animations. Particle scaling needs to happen in the emitter now, instead of in the Particle system scene node. Deprecation methods will guide the user.
- ISceneNode::setParent and addChild now updates node SceneManager pointers if the node was from another SceneManager.
@ -1986,7 +2000,7 @@ Changes in version 1.5 (15.12.2008)
- Added minimize button to win32 window (if resizable)
- Major API change: RTTs are now created via addRenderTargetTexture instead of createRenderTargetTexture, which allows to retrieve them from the texture cache, but also changes the way of removing the RTTs, and especially one must not drop the pointer anymore.
- WindowsCE-Bugfix
- disableFeature can be used to override feature support of the video driver.
@ -2296,7 +2310,7 @@ Changes in version 1.4.1 (04 Jun 2008)
- Fixed bug in CBillboardSceneNode::setColor, reported by rogerborg
- Fixed clipping of menu, toolbar and combo box GUI elements, reported by greenya
- setNotClipped now applies all the way up to the root of the GUI environment, rather than just to the next parent
- setNotClipped now applies all the way up to the root of the GUI environment, rather than just to the next parent
- Made new scene managers use the original manager's GUIEnvironment, reported by MasterGod
@ -2361,14 +2375,14 @@ Changes in version 1.4 (30 Nov 2007)
- Added IMeshManipulator::createMeshWelded which creates a copy of the mesh with similar vertices welded together.
- Irrlicht now has its own file format for static meshes. It is based on xml and has the
- Irrlicht now has its own file format for static meshes. It is based on xml and has the
extension .irrmesh. Irrlicht is able to write every IMesh to this file format, and of course to
read it back again.
- Irrlicht is now able to write Meshes out into files. Use ISceneManager::createMeshWriter()
to obtain an interface with which you can write out meshes. Currently, an own .irrmesh
file format is supported as well as the COLLADA file format.
- fixed the keyboard autorepeat difference betwenn Linux and Windows. Thanks to denton we now have only KeyPressed events on both systems in case of autorepeat.
- Added several new particle emitters and affectors from IrrSpintz. Also some new getter and setter methods were added.
@ -2408,11 +2422,11 @@ Changes in version 1.4 (30 Nov 2007)
- Fixed the hillplane mesh to work with non-quadratic dimensions as well. Changed the interface also, so use a u32 dimension to specify the tilecount now.
- Hires timers are disabled on windows systems with more than one CPU, due to bugs
in the BIOS of many multi-core motherboards. To enable hires timers in your project,
in the BIOS of many multi-core motherboards. To enable hires timers in your project,
use SetProcessAffinityMask to set to use only one CPU before creating the device.
- OpenGL render targets now the same way up as the other drivers. If you have
written opengl shaders that use render targets then you'll need to change your
written opengl shaders that use render targets then you'll need to change your
texture coordinates accordingly.
- Fixed some OpenGL renderstate stuff. setBasicRenderstate returns with
@ -2429,21 +2443,21 @@ Changes in version 1.4 (30 Nov 2007)
- Fixed bugs in MY3D and OBJ loader.
- Added IMeshCache::clearUnusedMeshes(). This allows the user to remove
meshes that are sitting in the mesh cache but aren't used by any scene nodes.
- Added IMeshCache::clearUnusedMeshes(). This allows the user to remove
meshes that are sitting in the mesh cache but aren't used by any scene nodes.
This is useful for example when changing levels.
- Added IUnknown::getReferenceCount()
- createDevice now reports errors if the driverType is unknown, previously it
- createDevice now reports errors if the driverType is unknown, previously it
created a window but populated it with a null driver without any warning.
- Fixed a bug in CBillboardTextSceneNode::setText where the old text was not
- Fixed a bug in CBillboardTextSceneNode::setText where the old text was not
cleared.
- Changed irrArray::linear_search to use the == operator rather than <
This may be slower in some cases, but it no longer returns false positives
when searching arrays of classes that override the < operator but
when searching arrays of classes that override the < operator but
!(x<y) && !(y<x) does not necessarily mean x==y (vectors, positions etc).
- Fixed getSize/getOriginalSize method inversion in OpenGL textures.
@ -2470,8 +2484,8 @@ GUI:
- Added EGET_ELEMENT_CLOSED GUI event type. Absorb this event to cancel closing a window.
- Added _IRR_COMPILE_WITH_GUI_ to allow compiling without the GUI.
This is useful if you use another GUI system (ie CEGUI) or are using Irrlicht
- Added _IRR_COMPILE_WITH_GUI_ to allow compiling without the GUI.
This is useful if you use another GUI system (ie CEGUI) or are using Irrlicht
inside another window. You will have to supply an external IGUIFont if you wish
to use font scene nodes as there will be no GUI environment available to load fonts.
@ -2484,26 +2498,26 @@ GUI:
- Added IGUISkin::draw2dRectangle, so skins can override the default highlight.
- EGET_ELEMENT_FOCUS_LOST and EGET_ELEMENT_FOCUSED events can now be absorbed
by returning true in OnEvent. Absorbing these events will cancel the focus
- EGET_ELEMENT_FOCUS_LOST and EGET_ELEMENT_FOCUSED events can now be absorbed
by returning true in OnEvent. Absorbing these events will cancel the focus
change.
- IGUIEnvironment::setFocus and removeFocus now return bools.
- New SEvent.GUIEvent.Element. Points to a second element that is being
- New SEvent.GUIEvent.Element. Points to a second element that is being
used in the event. During a EGET_ELEMENT_FOCUS_LOST event it points
to the element which would like the focus.
- Fixed the default font icons so they have a black border and are not
- Fixed the default font icons so they have a black border and are not
invisible in default listboxes. Old font tool textures now keep their color
so colorful fonts are possible by editing the font's texture. The colors of
so colorful fonts are possible by editing the font's texture. The colors of
completely transparent areas are no longer kept when generating the texture
from an image. Added builtInFont.bmp for ease of editing.
- IGUIElement changes:
Most elements can now be accessed using the keyboard. Use space and return
to select or deselect, escape to cancel selection (ie while pressing a
to select or deselect, escape to cancel selection (ie while pressing a
button with space or return), and the cursor keys where appropriate.
Added navigation through the GUI using tab and the shift and control keys.
@ -2513,12 +2527,12 @@ GUI:
setTabOrder - Sets the order of focus within this tab group,
Only one element in each group should have the same TabOrder number.
Set to -1 to add to the end of the group.
setTabGroup - set this to true if the element is a group that contains
setTabGroup - set this to true if the element is a group that contains
other elements, and can be navigated with ctrl+tab/ctrl+shift+tab.
isTabGroup - returns true if the element is a tab group.
getTabGroup - returns the tab group that the element belongs to.
getNextElement - searches for the next element which would be focused
within the element's children, only useful if you are doing your own
getNextElement - searches for the next element which would be focused
within the element's children, only useful if you are doing your own
custom navigation.
Added isMychild, to check if an element is descended from this one.
@ -2546,8 +2560,8 @@ GUI:
- IGUIStaticText new methods setDrawBorder and setTextAlignment.
- IGUIListBox changes:
Added setAutoScrollEnabled and isAutoScrollEnabled, for automatic scrolling
when selecting or adding an item.
Added setAutoScrollEnabled and isAutoScrollEnabled, for automatic scrolling
when selecting or adding an item.
Scrollbars are now only visible when the list doesn't fit in the visible area.
You can now type an item's text to select it.
@ -2581,7 +2595,7 @@ Changes in version 1.3.1 (20 Jun 2007)
- CSphereSceneNode is now texture wrapped with sphere mapping by exactly one
texture. Only a small error on the top remained.
- The Sky box scene node now clamps its textures by default (meaning no
more ugly artifacts at the borders).
@ -2593,7 +2607,7 @@ Changes in version 1.3.1 (20 Jun 2007)
triangle3d.isOnSameSide is now private - it's just a helper class not
intended for further use.
- Added IFileSystem::getFileDir, to get the directory when given a file
- Added IFileSystem::getFileDir, to get the directory when given a file
name. Submitted by Jeff Myers
- Updated to latest PNG library (1.2.18), fixing a vulnerability.
@ -2648,17 +2662,17 @@ Changes in version 1.3.1 (20 Jun 2007)
- Added scissor test to opengl draw2DImage method that ignored clip.
- Fixed a bug in rect::isValid, it was almost always true.
- Fixed wrong particle emission.
- Added LinuxDevice setResizeAble implementation.
- Enumeration values of the ESCENE_NODE_TYPE enum are no longer ints but four
character codes. If you were using them as index previously, this is no longer possible.
- There is now a way to set which scene manager should recieve user input, when working
with multiple scene managers: IrrlichtDevice::setInputReceivingSceneManager().
- ICursorControl now supports setting a reference rectangle.
If this rect is set, the cursor position is not being calculated relative to
the rendering window but to this rect. You can set the rect pointer to 0 to disable
@ -2676,11 +2690,11 @@ Changes in version 1.3.1 (20 Jun 2007)
- Added min and max functions with 3 values: core::min_ and core::max_
- Fixed a crash when using Octtrees caused by unnecessary dropping of meshes when
- Fixed a crash when using Octtrees caused by unnecessary dropping of meshes when
deserializing the scene node.
- Removed an array::erase from Octtrees and Octtree triangle selector.
- Removed a bug which caused irrlicht to crash when using animated .x files as static meshes.
GUI:
@ -2706,7 +2720,7 @@ GUI:
- Can now load/save gui environment from/to an element.
- Most element set functions now have a corresponding get or is function.
- Most element set functions now have a corresponding get or is function.
(API change) IGUIButton::getUseAlphaChannel is now isAlphaChannelUsed, to fit with other is* functions.
- Fixed a bug with resizing the gui environment when the device is resized
@ -2723,7 +2737,7 @@ GUI:
GUI Editor:
- Added cut/copy/paste using clipboard and xml (via memory file). Will have problems in Linux due
- Added cut/copy/paste using clipboard and xml (via memory file). Will have problems in Linux due
to no clipboard support
- Added texture attribute element
@ -2747,13 +2761,13 @@ Changes in version 1.3 (15 Mar 2007)
nodes work again, it should be enough to rename OnPreRender()
to OnRegisterSceneNode() and OnPostRender() to OnAnimate() in most cases.
- ISceneNode::getMaterialCount and getMaterial now use u32 instead of s32. You will also need
- ISceneNode::getMaterialCount and getMaterial now use u32 instead of s32. You will also need
to update this in your custom scene nodes.
- matrix4 speed enhancement, testing for identity before multiply. faster check for identity
for the positive case using an additional boolean flag.
The internal array M is now private, changing the API. Use mat[x] instead of mat.M[x].
The pointer to M is acquired by mat.pointer(), some methods take a matrix4 reference
The pointer to M is acquired by mat.pointer(), some methods take a matrix4 reference
instead of a f32*.
- Some more suppport for tangent meshes
@ -2767,8 +2781,8 @@ Font improvements:
- Started a font tool for creating the new XML fonts, including generating vector fonts
(currently not backward compatible with old fonts, only works for Win2K+, some bugs still)
- Font interface now supports kerning- kerning pairs, per letter and global kerning widths,
- Font interface now supports kerning- kerning pairs, per letter and global kerning widths,
although he internal font only supports global and per-letter.
- added _IRR_COMPILE_WITH_SOFTWARE_ and _IRR_COMPILE_WITH_BURNINGSVIDEO_ to compile config
@ -2780,13 +2794,13 @@ Font improvements:
- Started a GUI Editor as a GUI element factory example (work in progress)
- New IGUIElement functions: isSubElement & setSubElement for child elements created by their parents
- New IGUIElement functions: isSubElement & setSubElement for child elements created by their parents
(eg. a scrollbar on a list box). Set it if you don't want an element to be serialized
- New GUI event, EGET_ELEMENT_FOCUSED
- GUI environment ELEMENT_FOCUS_LOST event now sets the element as the caller, focus_lost events
are now usually passed to parent elements, so elements now check if they are the caller before
- GUI environment ELEMENT_FOCUS_LOST event now sets the element as the caller, focus_lost events
are now usually passed to parent elements, so elements now check if they are the caller before
updating (so users can catch focus lost events without them being eaten by the elements)
- Buttons, checkboxes and tab controls now only activate when the mouse is released over them.
@ -2795,21 +2809,21 @@ Font improvements:
could cause problems with draggable user windows, as they may now be dragged off screen.
- Elements can now automatically resize to fit their parents, or align themselves to an edge:
setAlignment(left, right, top, bottom) - sets how each edge aligns to its parent,
setAlignment(left, right, top, bottom) - sets how each edge aligns to its parent,
through EGUI_ALIGNMENT enum
EGUIA_UPPERLEFT - default behavior, aligns to top or left edge
EGUIA_LOWERRIGHT - aligns to the lower or right edge
EGUIA_CENTER - moves relative to the center of its parent
EGUIA_SCALE - uses relative scale
- setMaxSize, setMinSize - sets the maximum and minimum sizes for automatic resizing,
- setMaxSize, setMinSize - sets the maximum and minimum sizes for automatic resizing,
use 0 for no maximum size.
- setRelativePosition now takes a rect<f32> for relative positioning within their parents
- getFileSystem added to the GUI environment
- New IGUISpriteBank, used to hold 2d image data like fonts and GUI icons.
- New IGUISpriteBank, used to hold 2d image data like fonts and GUI icons.
Icons provided by the built-in font are now accessed through the skin's sprite bank.
Users can override the icons by setting a different sprite bank and setting new sprites.
@ -2825,10 +2839,10 @@ Font improvements:
- New Compile Config BURNINGVIDEO_RENDERER_FAST
touching the 20fps border in the demo ( P4 mobile 2Ghz ). 15fps average.
( Compile config Release Fast-FPU )
- VertexCache for Tansformed & Light Vertices
boost small drawPrimitive Calls ( 2DRectangle, Billboard ) and Real Index Triangles
- Bilinear Dither
- clipping test ( compare instead of generic plane normal )
- support for NOT using vertexcolor
@ -2837,7 +2851,7 @@ Font improvements:
- added vertex to color to billboard.
shade top & shade down.
to support some static lighting effect on billboards
- Implemented line rendering for SoftwareDriver
- XMLWriter fix for 32bit wchar_t (esp. for big endian)
@ -2862,7 +2876,7 @@ Font improvements:
- Fixed 16bit depth screens under Windows.
- Implemented getMeshBuffer(SMaterial) for all AnimatedMeshes.
- Implemented getMeshBuffer(SMaterial) for all AnimatedMeshes.
It was returning 0 for all implementations previously. User defined IMesh derivates
will also have to implement it now due to the removed empty implementation.
@ -2870,7 +2884,7 @@ Font improvements:
a very short time. This allows other processes to execute without a major
penalty for the Irrlicht application.
- Added sleep() methd to IrrlichtDevice, for pausing the Irrlicht process for a longer
- Added sleep() methd to IrrlichtDevice, for pausing the Irrlicht process for a longer
amount of time.
- Auto-split mesh to 16bit buffers in 3ds loader
@ -2881,13 +2895,13 @@ Font improvements:
- Fixed(?) the glXGetProcAddress problems with different drivers
- B3D changes by Luke:
Texture scaling bugfix, support for alpha blending, new option to normalise weights,
- B3D changes by Luke:
Texture scaling bugfix, support for alpha blending, new option to normalise weights,
animation code optimization, fixed memory leak
- ROUNDING_ERROR is now ROUNDING_ERROR_f32 or ROUNDING_ERROR_f64
- Material ZBuffer flag changed to a u32 value
- Material ZBuffer flag changed to a u32 value
Reason: change ( off or on ) to , off, lequal, equal
Necessary for multi-pass if previous stage has had transparency
@ -2914,7 +2928,7 @@ Font improvements:
so it feel's more like common browers
- added a Texture transform to IVideoDriver::setTransform
- quaternion::getmatrix
in fact the getmatrix version is returning the transposed.
i'm quite sure that this is the wrong implementation.
@ -2931,7 +2945,7 @@ Font improvements:
- The Example Quake3Map shows how to continue applying the Q3Shaders with SceneNodes
( for example animmap converts to TextureAnimator.)
TODO: use the Irrlicht Variable Syntax to remove redundant code..
- added getVertexPitch() to IMeshBuffer interface
- added generic isupper, isspace.. functions to coreutil.h to remove dependencies for ctype.h
@ -2942,12 +2956,12 @@ Font improvements:
- moved fast_atof.h to the public include
added strtol10 to remove dependencies for stdlib.h
anyway math.h is needed for powf
- core::vector3d
added getInterpolated_quadratic.
vector3d<T> getInterpolated_quadratic(const vector3d<T>& v2, const vector3d<T>& v3, const T d) const
// this*(1-d)*(1-d) + 2 * v2 * (1-d) + v3 * d * d;
- irrstring: added param start to findLast(T c, s32 start = -1 )
reason: to continue searching reverse on a specific position
(parameter is checked against boundaries )
@ -2957,8 +2971,8 @@ Font improvements:
changed the core::vector3df normalize vector.
specialized templates are not allowed in irrlicht currently, so it's only for f32 for now.
a C function and a NVidia Version are in irrmath.h
- add Primitives to CFPSCounter
- add Primitives to CFPSCounter
and changed interpolation to 1500ms instead of 2000ms
and rounding to ceiling..
@ -2973,7 +2987,7 @@ Font improvements:
this is quite useful if you want to use more artistic fonts.
default = 0
better kerning would need a seperate coordinate set for each symbol.
- changed MD2_FRAME_SHIFT to lower framerate
-> lower IPol
problems can occur if somebody uses hardcoded frame-numbers instead
@ -2982,14 +2996,14 @@ Font improvements:
- changed spelling "frustrum" to "frustum"
-> changed also SViewFrustrum.h to SViewFrustum.h
- changed Parameter AutomaticCulling from bool to enum E_CULLING_TYPE
to support more than two culling modes.
added Frustum culling ( it's a copy & paste from the octree )
added initial bounding sphere
used for culling point lights..
- Added getSystemMemory and getProcessorSpeedMHz for Windows and Linux to the OSOperator, submitted by Vitek.
-------------------------------------------
@ -3015,7 +3029,7 @@ Changes in version 1.2 (29 Nov 2006)
- Split ESNRP_LIGHT_AND_CAMERA passes into ESNRP_LIGHT and ESNRP_CAMERA to fix a problem with lights being rendered before cameras in OpenGL (thanks again to Vitek for finding this). ESNRP_LIGHT_AND_CAMERA is now deprecated.
- Fixed many OpenGL render state problems which were related to wrong texture states. The textures are now enabled and disabled by the material renderers in OnSetMaterial. Also enabled the texture state cache which helps preventing texture changes just as the one for D3Dx. Thanks to hey_i_am_real for some good hints on where the problem was located.
- Fixed many OpenGL render state problems which were related to wrong texture states. The textures are now enabled and disabled by the material renderers in OnSetMaterial. Also enabled the texture state cache which helps preventing texture changes just as the one for D3Dx. Thanks to hey_i_am_real for some good hints on where the problem was located.
- Added compile flag _IRR_COMPILE_WITH_X11_ which is by default enabled. Disabling the flag removes all X11 dependencies from Irrlicht and allows for a headless Linux Irrlicht server - added by request :-)
@ -3078,7 +3092,7 @@ Changes in version 1.2 (29 Nov 2006)
You can influence this by calling ISceneManager::setAmbientLight(). That light color
is also stored when saving .irr files via ISceneManager::saveScene().
- Loaded COLLADA files which contained only one single mesh now behave like all the
- Loaded COLLADA files which contained only one single mesh now behave like all the
other loaded meshes, and the #meshname workaround has been removed.
- File lists are now sorted.

View File

@ -136,7 +136,11 @@ public:
case GUI_ID_FILE_OPEN_BUTTON:
Context.listbox->addItem(L"File open");
env->addFileOpenDialog(L"Please choose a file.");
// There are some options for the file open dialog
// We set the title, make it a modal window, and make sure
// that the working directory is restored after the dialog
// is finished.
env->addFileOpenDialog(L"Please choose a file.", true, 0, -1, true);
return true;
default:
@ -144,6 +148,15 @@ public:
}
break;
case EGET_FILE_SELECTED:
{
// show the model filename, selected in the file dialog
IGUIFileOpenDialog* dialog =
(IGUIFileOpenDialog*)event.GUIEvent.Caller;
Context.listbox->addItem(dialog->getFileName());
}
break;
default:
break;
}

View File

@ -147,8 +147,7 @@ void updateScaleInfo(scene::ISceneNode* model)
}
/*
The three following functions do several stuff used by the mesh viewer. The
first function showAboutText() simply displays a messagebox with a caption and
Function showAboutText() displays a messagebox with a caption and
a message text. The texts will be stored in the MessageText and Caption
variables at startup.
*/
@ -162,7 +161,7 @@ void showAboutText()
/*
The second function loadModel() loads a model and displays it using an
Function loadModel() loads a model and displays it using an
addAnimatedMeshSceneNode and the scene manager. Nothing difficult. It also
displays a short message box, if the model could not be loaded.
*/
@ -259,7 +258,7 @@ void loadModel(const c8* fn)
/*
Finally, the third function creates a toolbox window. In this simple mesh
Function createToolBox() creates a toolbox window. In this simple mesh
viewer, this toolbox only contains a tab control with three edit boxes for
changing the scale of the displayed model.
*/
@ -323,6 +322,10 @@ void createToolBox()
scrollbar->setSmallStep(1);
}
/*
Function updateToolBox() is called each frame to update dynamic information in
the toolbox.
*/
void updateToolBox()
{
IGUIEnvironment* env = Device->getGUIEnvironment();
@ -397,7 +400,7 @@ bool hasModalDialog()
To get all the events sent by the GUI Elements, we need to create an event
receiver. This one is really simple. If an event occurs, it checks the id of
the caller and the event type, and starts an action based on these values. For
example, if a menu item with id GUI_ID_OPEN_MODEL was selected, if opens a file-open-dialog.
example, if a menu item with id GUI_ID_OPEN_MODEL was selected, it opens a file-open-dialog.
*/
class MyEventReceiver : public IEventReceiver
{
@ -521,6 +524,11 @@ public:
*/
bool OnKeyUp(irr::EKEY_CODE keyCode)
{
// Don't handle keys if we have a modal dialog open as it would lead
// to unexpected application behaviour for the user.
if ( hasModalDialog() )
return false;
if (keyCode == irr::KEY_ESCAPE)
{
if (Device)

View File

@ -376,7 +376,7 @@ int main()
anim->drop();
// attach billboard to the light
scene::ISceneNode* bill =
scene::IBillboardSceneNode* bill =
smgr->addBillboardSceneNode(light1, core::dimension2d<f32>(60, 60));
bill->setMaterialFlag(video::EMF_LIGHTING, false);

View File

@ -783,7 +783,7 @@ funcptr_createDeviceEx load_createDeviceEx ( const c8 * filename)
#endif
/*
get the current collision respone camera animator
get the current collision response camera animator
*/
ISceneNodeAnimatorCollisionResponse* camCollisionResponse( IrrlichtDevice * device )
{

View File

@ -1,4 +1,4 @@
/** Example 024 Cursor Control
/** Example 024 CursorControl
Show how to modify cursors and offer some useful tool-functions for creating cursors.
It can also be used for experiments with the mouse in general.

View File

@ -1,8 +1,13 @@
/** Example 025 Xml Handling
*
* Demonstrates loading and saving of configurations via XML
* @author Y.M. Bosman <yoran.bosman@gmail.com>
*/
Demonstrates loading and saving of configurations via XML
@author Y.M. Bosman \<yoran.bosman@gmail.com\>
This demo features a fully usable system for configuration handling. The code
can easily be intergrated into own apps.
*/
#include <irrlicht.h>
@ -18,24 +23,20 @@ using namespace gui;
#endif
/**
* SettingManager class
* This class loads and writes the settings
* and manages the options.
*
*
* The class makes use of irrMap which is a an associative arrays using a red-black tree
* it allows easy mapping of a key to a value, along the way there is some information on how to use it
*
*/
/* SettingManager class.
This class loads and writes the settings and manages the options.
The class makes use of irrMap which is a an associative arrays using a
red-black tree it allows easy mapping of a key to a value, along the way there
is some information on how to use it.
*/
class SettingManager
{
public:
/**
* Construct setting managers and set default settings
*/
// Construct setting managers and set default settings
SettingManager(const stringw& settings_file): SettingsFile(settings_file), NullDevice(0)
{
// Irrlicht null device, we want to load settings before we actually created our device, therefore, nulldevice
@ -59,10 +60,9 @@ public:
SettingMap.insert(L"fullscreen", L"0"); //0 is false
}
/**
* Destructor, you could store settings automatically on exit of your application if you wanted to
* in our case we simply drop the nulldevice
*/
// Destructor, you could store settings automatically on exit of your
// application if you wanted to in our case we simply drop the
// nulldevice
~SettingManager()
{
if (NullDevice)
@ -72,20 +72,21 @@ public:
}
};
/**
* Load xml from disk, overwrite default settings
* The xml we are trying to load has the following structure
* settings nested in sections nested in the root node, like so
*
* <?xml version="1.0"?>
* <mygame>
* <video>
* <setting name="driver" value="Direct3D9" />
* <setting name="fullscreen" value="0" />
* <setting name="resolution" value="1024x768" />
* </video>
* </mygame>
*/
/*
Load xml from disk, overwrite default settings
The xml we are trying to load has the following structure
settings nested in sections nested in the root node, like so
<pre>
<?xml version="1.0"?>
<mygame>
<video>
<setting name="driver" value="Direct3D9" />
<setting name="fullscreen" value="0" />
<setting name="resolution" value="1024x768" />
</video>
</mygame>
</pre>
*/
bool load()
{
//if not able to create device dont attempt to load
@ -149,10 +150,7 @@ public:
return true;
}
/**
* Save the xml to disk
* We use the nulldevice
*/
// Save the xml to disk. We use the nulldevice.
bool save()
{
@ -206,27 +204,19 @@ public:
return true;
}
/**
* Set setting in our manager
*/
// Set setting in our manager
void setSetting(const stringw& name, const stringw& value)
{
SettingMap[name]=value;
}
/**
* set setting overload to quickly assign integers to our setting map
*/
// set setting overload to quickly assign integers to our setting map
void setSetting(const stringw& name, s32 value)
{
SettingMap[name]=stringw(value);
}
/**
* Get setting as string
* @param key Name of setting
* @return Empty string if the settings is not found, else value of the setting
*/
// Get setting as string
stringw getSetting(const stringw& key) const
{
//the find function or irrmap returns a pointer to a map Node
@ -239,11 +229,7 @@ public:
return L"";
}
/**
* Get setting as bool
* @param key Name of setting
* @return False if the key cannot be found, else true if the setting == 1
*/
//
bool getSettingAsBoolean(const stringw& key ) const
{
stringw s = getSetting(key);
@ -252,11 +238,7 @@ public:
return s.equals_ignore_case(L"1");
}
/**
* Get setting as integer NOTE: function is not used in example but provided for completeness
* @param key name of setting
* @return 0 if the key cannot be found, else the setting converted to an integer
*/
//
s32 getSettingAsInteger(const stringw& key) const
{
//we implicitly cast to string instead of stringw because strtol10 does not accept wide strings
@ -280,9 +262,9 @@ private:
irr::IrrlichtDevice* NullDevice;
};
/**
* Application context for global variables
*/
/*
Application context for global variables
*/
struct SAppContext
{
SAppContext()
@ -372,10 +354,10 @@ private:
};
/**
* Function to create a video settings dialog
* This dialog shows the current settings from the configuration xml and allows them to be changed
*/
/*
Function to create a video settings dialog
This dialog shows the current settings from the configuration xml and allows them to be changed
*/
void createSettingsDialog(SAppContext& app)
{
// first get rid of alpha in gui
@ -431,6 +413,9 @@ void createSettingsDialog(SAppContext& app)
L"Cancel and exit");
}
/*
The main function. Creates all objects and does the XML handling.
*/
int main()
{
//create new application context
@ -441,11 +426,9 @@ int main()
param.DriverType = EDT_SOFTWARE;
param.WindowSize.set(640,480);
/**
* Try to load config.
* I leave it as an exercise of the reader to store the configuration in the local application data folder,
* the only logical place to store config data for games. For all other operating systems I redirect to your manuals
*/
// Try to load config.
// I leave it as an exercise of the reader to store the configuration in the local application data folder,
// the only logical place to store config data for games. For all other operating systems I redirect to your manuals
app.Settings = new SettingManager("../../media/settings.xml");
if ( !app.Settings->load() )
{
@ -518,3 +501,5 @@ int main()
return 0;
}
/*
**/

View File

@ -540,12 +540,7 @@ void CDemo::loadSceneData()
campFire->setMaterialFlag(video::EMF_LIGHTING, false);
campFire->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
campFire->setMaterialTexture(0, driver->getTexture("../../media/fireball.bmp"));
campFire->setMaterialType(video::EMT_ONETEXTURE_BLEND);
campFire->getMaterial(0).MaterialTypeParam=
video::pack_textureBlendFunc(video::EBF_ONE,
video::EBF_ONE_MINUS_SRC_ALPHA,
video::EMFN_MODULATE_1X,
video::EAS_VERTEX_COLOR);
campFire->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
// load music

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 10 KiB

BIN
media/024shot.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
media/025shot.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

BIN
media/026shot.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -90,9 +90,10 @@ The Irrlicht Engine SDK version 1.8
* Linux:
* Needed: XServer with include files
* Optional: OpenGL headers and libraries (libGL.so), for OpenGL support
* GLX + XF86VidMode or XRandr extension (X11 support libraries,
the latter two for fullscreen mode)
* Optional: OpenGL headers and libraries (libGL.so) for OpenGL support
GLX +
XF86VidMode [package x11proto-xf86vidmode-dev] or XRandr
(X11 support libraries, the latter two for fullscreen mode)
* OSX:
* Needed: XCode and Cocoa framework

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,314 +0,0 @@
table.irrlicht {
width: 100%;
background-color: #9395C1;
text-align: center;
margin: 0px;
padding: 0px;
border-spacing: 4px 2px;
border-color: #b0b0b0;
border-width: 1px;
border-style: solid;
}
table.memname {
background-color: #f5f5f5;
border: 1px solid #b0b0b0;
}
BODY,H1,H2,H3,H4,H5,H6,P,CENTER,TD,TH,UL,DL,DIV {
font-family: Geneva, Arial, Helvetica, sans-serif;
}
BODY,TD {
font-size: 90%;
}
H1 {
text-align: center;
font-size: 160%;
}
H2 {
font-size: 120%;
}
H3 {
font-size: 110%;
}
CAPTION { font-weight: bold }
DIV.qindex {
width: 100%;
background-color: #eeeeff;
border: 1px solid #b0b0b0;
text-align: center;
margin: 2px;
padding: 2px;
line-height: 140%;
}
DIV.nav {
width: 100%;
background-color: #eeeeff;
border: 1px solid #b0b0b0;
text-align: center;
margin: 2px;
padding: 2px;
line-height: 140%;
}
A.qindex {
text-decoration: none;
font-weight: bold;
color: #1A419D;
}
A.qindex:visited {
text-decoration: none;
font-weight: bold;
color: #1A419D
}
A.qindex:hover {
text-decoration: none;
background-color: #ddddff;
}
A.qindexHL {
text-decoration: none;
font-weight: bold;
background-color: #6666cc;
color: #ffffff;
border: 1px double #9295C2;
}
A.qindexHL:hover {
text-decoration: none;
background-color: #6666cc;
color: #ffffff;
}
A.qindexHL:visited { text-decoration: none; background-color: #6666cc; color: #ffffff }
A.el { text-decoration: none; font-weight: bold }
A.elRef { font-weight: bold }
A.code:link { text-decoration: none; font-weight: normal; color: #0000FF}
A.code:visited { text-decoration: none; font-weight: normal; color: #0000FF}
A.codeRef:link { font-weight: normal; color: #0000FF}
A.codeRef:visited { font-weight: normal; color: #0000FF}
A:hover { text-decoration: none; background-color: #f2f2ff }
DL.el { margin-left: -1cm }
.fragment {
font-family: monospace
}
PRE.fragment {
border: 1px solid #CCCCCC;
background-color: #f5f5f5;
margin-top: 4px;
margin-bottom: 4px;
margin-left: 2px;
margin-right: 8px;
padding-left: 6px;
padding-right: 6px;
padding-top: 4px;
padding-bottom: 4px;
}
DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px }
TD.md { background-color: #F4F4FB; font-weight: bold; }
TD.mdPrefix {
background-color: #F4F4FB;
color: #606060;
font-size: 80%;
}
TD.mdname1 { background-color: #F4F4FB; font-weight: bold; color: #602020; }
TD.mdname { background-color: #F4F4FB; font-weight: bold; color: #602020; width: 600px; }
DIV.groupHeader {
margin-left: 16px;
margin-top: 12px;
margin-bottom: 6px;
font-weight: bold;
}
DIV.groupText { margin-left: 16px; font-style: italic; font-size: 90% }
BODY {
background: white;
color: black;
margin-right: 20px;
margin-left: 20px;
}
TD.indexkey {
background-color: #eeeeff;
font-weight: bold;
padding-right : 10px;
padding-top : 2px;
padding-left : 10px;
padding-bottom : 2px;
margin-left : 0px;
margin-right : 0px;
margin-top : 2px;
margin-bottom : 2px;
border: 1px solid #CCCCCC;
}
TD.indexvalue {
background-color: #eeeeff;
font-style: italic;
padding-right : 10px;
padding-top : 2px;
padding-left : 10px;
padding-bottom : 2px;
margin-left : 0px;
margin-right : 0px;
margin-top : 2px;
margin-bottom : 2px;
border: 1px solid #CCCCCC;
}
TR.memlist {
background-color: #f0f0f0;
}
P.formulaDsp { text-align: center; }
IMG.formulaDsp { }
IMG.formulaInl { vertical-align: middle; }
SPAN.keyword { color: #008000 }
SPAN.keywordtype { color: #604020 }
SPAN.keywordflow { color: #e08000 }
SPAN.comment { color: #800000 }
SPAN.preprocessor { color: #806020 }
SPAN.stringliteral { color: #002080 }
SPAN.charliteral { color: #008080 }
.mdTable {
border: 1px solid #868686;
background-color: #F4F4FB;
}
.mdRow {
padding: 8px 10px;
}
.mdescLeft {
padding: 0px 8px 4px 8px;
font-size: 80%;
font-style: italic;
background-color: #FAFAFA;
border-top: 1px none #E0E0E0;
border-right: 1px none #E0E0E0;
border-bottom: 1px none #E0E0E0;
border-left: 1px none #E0E0E0;
margin: 0px;
}
.mdescRight {
padding: 0px 8px 4px 8px;
font-size: 80%;
font-style: italic;
background-color: #FAFAFA;
border-top: 1px none #E0E0E0;
border-right: 1px none #E0E0E0;
border-bottom: 1px none #E0E0E0;
border-left: 1px none #E0E0E0;
margin: 0px;
}
.memItemLeft {
padding: 1px 0px 0px 8px;
margin: 4px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-color: #E0E0E0;
border-right-color: #E0E0E0;
border-bottom-color: #E0E0E0;
border-left-color: #E0E0E0;
border-top-style: solid;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
background-color: #FAFAFA;
font-size: 80%;
}
.memItemRight {
padding: 1px 8px 0px 8px;
margin: 4px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-color: #E0E0E0;
border-right-color: #E0E0E0;
border-bottom-color: #E0E0E0;
border-left-color: #E0E0E0;
border-top-style: solid;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
background-color: #FAFAFA;
font-size: 80%;
}
.memTemplItemLeft {
padding: 1px 0px 0px 8px;
margin: 4px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-color: #E0E0E0;
border-right-color: #E0E0E0;
border-bottom-color: #E0E0E0;
border-left-color: #E0E0E0;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
background-color: #FAFAFA;
font-size: 80%;
}
.memTemplItemRight {
padding: 1px 8px 0px 8px;
margin: 4px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-color: #E0E0E0;
border-right-color: #E0E0E0;
border-bottom-color: #E0E0E0;
border-left-color: #E0E0E0;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
background-color: #FAFAFA;
font-size: 80%;
}
.memTemplParams {
padding: 1px 0px 0px 8px;
margin: 4px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-color: #E0E0E0;
border-right-color: #E0E0E0;
border-bottom-color: #E0E0E0;
border-left-color: #E0E0E0;
border-top-style: solid;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
color: #606060;
background-color: #FAFAFA;
font-size: 80%;
}
.search { color: #003399;
font-weight: bold;
}
FORM.search {
margin-bottom: 0px;
margin-top: 0px;
}
INPUT.search { font-size: 75%;
color: #000080;
font-weight: normal;
background-color: #eeeeff;
}
TD.tiny { font-size: 75%;
}
a {
color: #252E78;
}
a:visited {
color: #3D2185;
}
.dirtab { padding: 4px;
border-collapse: collapse;
border: 1px solid #b0b0b0;
}
TH.dirtab { background: #eeeeff;
font-weight: bold;
}
HR { height: 1px;
border: none;
border-top: 1px solid black;
}

View File

@ -1,19 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>$title</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<table class="irrlicht" >
<tr valign="middle">
<td><font size="2"><a class="qindex" href="index.html"><font color="#FFFFFF">Home</font></a>
| <a class="qindex" href="namespaces.html"><font color="#FFFFFF">Namespaces</font></a>
| <a class="qindex" href="hierarchy.html"><font color="#FFFFFF">Hierarchy</font></a>
| <a class="qindex" href="classes.html"><font color="#FFFFFF">Alphabetical
List</font></a> | <a class="qindex" href="annotated.html"><font color="#FFFFFF">
Class list</font></a> | <a class="qindex" href="files.html"><font color="#FFFFFF">Files</font></a>
| <a class="qindex" href="namespacemembers.html"><font color="#FFFFFF">
Namespace&nbsp;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> | <a class="qindex" href="pages.html"><font color="#FFFFFF">Tutorials</font></a></font> </td>
</tr>
</table>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -31,6 +31,9 @@ rem for /F %%i in ('dir ..\..\..\examples\[01]*\main.cpp') DO ..\sed.exe -f tuto
..\sed.exe -f tutorials.sed ..\..\..\examples\21.Quake3Explorer\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\22.MaterialViewer\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\23.SMeshHandling\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\24.CursorControl\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\25.XmlHandling\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\26.OcclusionQuery\main.cpp >>tut.txt
:SKIP_TUTS

View File

@ -361,6 +361,8 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
if (Driver->testGLError())
os::Printer::log("Could not bind Texture", ELL_ERROR);
bool mipmapLegacyMode = true;
// mipmap handling for main texture
if (!level && newTexture)
{
@ -482,6 +484,17 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
}
}
if (!mipmapLegacyMode)
{
glEnable(GL_TEXTURE_2D);
Driver->extGlGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
AutomaticMipmapUpdate=true;
}
if (Driver->testGLError())
os::Printer::log("Could not glTexImage2D", ELL_ERROR);
}

View File

@ -77,10 +77,10 @@ namespace irr
//! Minimizes the window if possible
virtual void minimizeWindow();
//! Maximizes the window if possible.
virtual void maximizeWindow();
//! Restore the window to normal size if possible.
virtual void restoreWindow();
@ -234,21 +234,21 @@ namespace irr
void postKeyEvent(void *event, irr::SEvent &ievent, bool pressed);
void pollJoysticks();
NSWindow *Window;
CGLContextObj CGLContext;
NSOpenGLContext *OGLContext;
int DeviceWidth,
DeviceHeight;
std::map<int,int> KeyCodes;
int ScreenWidth,
ScreenHeight;
bool IsActive;
NSBitmapImageRep *SoftwareDriverTarget;
bool IsSoftwareRenderer,
IsShiftDown,
IsControlDown,
IsResizable;
u32 MouseButtonStates;
NSWindow *Window;
CGLContextObj CGLContext;
NSOpenGLContext *OGLContext;
NSBitmapImageRep *SoftwareDriverTarget;
std::map<int,int> KeyCodes;
int DeviceWidth;
int DeviceHeight;
int ScreenWidth;
int ScreenHeight;
u32 MouseButtonStates;
bool IsActive;
bool IsSoftwareRenderer;
bool IsShiftDown;
bool IsControlDown;
bool IsResizable;
};

View File

@ -43,14 +43,153 @@
#include <IOKit/hid/IOHIDLib.h>
#include <IOKit/hid/IOHIDKeys.h>
// Contents from Events.h from Carbon/HIToolbox but we need it with Cocoa too
// and for some reason no Cocoa equivalent of these constants seems provided.
// So I'm doing like everyone else and using copy-and-paste.
/*
* Summary:
* Virtual keycodes
*
* Discussion:
* These constants are the virtual keycodes defined originally in
* Inside Mac Volume V, pg. V-191. They identify physical keys on a
* keyboard. Those constants with "ANSI" in the name are labeled
* according to the key position on an ANSI-standard US keyboard.
* For example, kVK_ANSI_A indicates the virtual keycode for the key
* with the letter 'A' in the US keyboard layout. Other keyboard
* layouts may have the 'A' key label on a different physical key;
* in this case, pressing 'A' will generate a different virtual
* keycode.
*/
enum {
kVK_ANSI_A = 0x00,
kVK_ANSI_S = 0x01,
kVK_ANSI_D = 0x02,
kVK_ANSI_F = 0x03,
kVK_ANSI_H = 0x04,
kVK_ANSI_G = 0x05,
kVK_ANSI_Z = 0x06,
kVK_ANSI_X = 0x07,
kVK_ANSI_C = 0x08,
kVK_ANSI_V = 0x09,
kVK_ANSI_B = 0x0B,
kVK_ANSI_Q = 0x0C,
kVK_ANSI_W = 0x0D,
kVK_ANSI_E = 0x0E,
kVK_ANSI_R = 0x0F,
kVK_ANSI_Y = 0x10,
kVK_ANSI_T = 0x11,
kVK_ANSI_1 = 0x12,
kVK_ANSI_2 = 0x13,
kVK_ANSI_3 = 0x14,
kVK_ANSI_4 = 0x15,
kVK_ANSI_6 = 0x16,
kVK_ANSI_5 = 0x17,
kVK_ANSI_Equal = 0x18,
kVK_ANSI_9 = 0x19,
kVK_ANSI_7 = 0x1A,
kVK_ANSI_Minus = 0x1B,
kVK_ANSI_8 = 0x1C,
kVK_ANSI_0 = 0x1D,
kVK_ANSI_RightBracket = 0x1E,
kVK_ANSI_O = 0x1F,
kVK_ANSI_U = 0x20,
kVK_ANSI_LeftBracket = 0x21,
kVK_ANSI_I = 0x22,
kVK_ANSI_P = 0x23,
kVK_ANSI_L = 0x25,
kVK_ANSI_J = 0x26,
kVK_ANSI_Quote = 0x27,
kVK_ANSI_K = 0x28,
kVK_ANSI_Semicolon = 0x29,
kVK_ANSI_Backslash = 0x2A,
kVK_ANSI_Comma = 0x2B,
kVK_ANSI_Slash = 0x2C,
kVK_ANSI_N = 0x2D,
kVK_ANSI_M = 0x2E,
kVK_ANSI_Period = 0x2F,
kVK_ANSI_Grave = 0x32,
kVK_ANSI_KeypadDecimal = 0x41,
kVK_ANSI_KeypadMultiply = 0x43,
kVK_ANSI_KeypadPlus = 0x45,
kVK_ANSI_KeypadClear = 0x47,
kVK_ANSI_KeypadDivide = 0x4B,
kVK_ANSI_KeypadEnter = 0x4C,
kVK_ANSI_KeypadMinus = 0x4E,
kVK_ANSI_KeypadEquals = 0x51,
kVK_ANSI_Keypad0 = 0x52,
kVK_ANSI_Keypad1 = 0x53,
kVK_ANSI_Keypad2 = 0x54,
kVK_ANSI_Keypad3 = 0x55,
kVK_ANSI_Keypad4 = 0x56,
kVK_ANSI_Keypad5 = 0x57,
kVK_ANSI_Keypad6 = 0x58,
kVK_ANSI_Keypad7 = 0x59,
kVK_ANSI_Keypad8 = 0x5B,
kVK_ANSI_Keypad9 = 0x5C
};
/* keycodes for keys that are independent of keyboard layout*/
enum {
kVK_Return = 0x24,
kVK_Tab = 0x30,
kVK_Space = 0x31,
kVK_Delete = 0x33,
kVK_Escape = 0x35,
kVK_Command = 0x37,
kVK_Shift = 0x38,
kVK_CapsLock = 0x39,
kVK_Option = 0x3A,
kVK_Control = 0x3B,
kVK_RightShift = 0x3C,
kVK_RightOption = 0x3D,
kVK_RightControl = 0x3E,
kVK_Function = 0x3F,
kVK_F17 = 0x40,
kVK_VolumeUp = 0x48,
kVK_VolumeDown = 0x49,
kVK_Mute = 0x4A,
kVK_F18 = 0x4F,
kVK_F19 = 0x50,
kVK_F20 = 0x5A,
kVK_F5 = 0x60,
kVK_F6 = 0x61,
kVK_F7 = 0x62,
kVK_F3 = 0x63,
kVK_F8 = 0x64,
kVK_F9 = 0x65,
kVK_F11 = 0x67,
kVK_F13 = 0x69,
kVK_F16 = 0x6A,
kVK_F14 = 0x6B,
kVK_F10 = 0x6D,
kVK_F12 = 0x6F,
kVK_F15 = 0x71,
kVK_Help = 0x72,
kVK_Home = 0x73,
kVK_PageUp = 0x74,
kVK_ForwardDelete = 0x75,
kVK_F4 = 0x76,
kVK_End = 0x77,
kVK_F2 = 0x78,
kVK_PageDown = 0x79,
kVK_F1 = 0x7A,
kVK_LeftArrow = 0x7B,
kVK_RightArrow = 0x7C,
kVK_DownArrow = 0x7D,
kVK_UpArrow = 0x7E
};
struct JoystickComponent
{
IOHIDElementCookie cookie; // unique value which identifies element, will NOT change
long min; // reported min value possible
long max; // reported max value possible
IOHIDElementCookie cookie; // unique value which identifies element, will NOT change
long min; // reported min value possible
long max; // reported max value possible
long minRead; //min read value
long maxRead; //max read value
long minRead; //min read value
long maxRead; //max read value
JoystickComponent() : min(0), minRead(0), max(0), maxRead(0)
{
@ -63,10 +202,9 @@ struct JoystickInfo
irr::core::array <JoystickComponent> buttonComp;
irr::core::array <JoystickComponent> hatComp;
int hats;
int axes;
int buttons;
int hats;
int axes;
int buttons;
int numActiveJoysticks;
irr::SEvent persistentData;
@ -74,8 +212,8 @@ struct JoystickInfo
IOHIDDeviceInterface ** interface;
bool removed;
char joystickName[256];
long usage; // usage page from IOUSBHID Parser.h which defines general usage
long usagePage; // usage within above page from IOUSBHID Parser.h which defines specific usage
long usage; // usage page from IOUSBHID Parser.h which defines general usage
long usagePage; // usage within above page from IOUSBHID Parser.h which defines specific usage
JoystickInfo() : hats(0), axes(0), buttons(0), interface(0), removed(false), usage(0), usagePage(0), numActiveJoysticks(0)
{
@ -140,7 +278,6 @@ static void addJoystickComponent (CFTypeRef refElement, JoystickInfo* joyInfo)
CFTypeRef refUsagePage = CFDictionaryGetValue ((CFDictionaryRef)refElement, CFSTR(kIOHIDElementUsagePageKey));
CFTypeRef refUsage = CFDictionaryGetValue ((CFDictionaryRef)refElement, CFSTR(kIOHIDElementUsageKey));
if ((refElementType) && (CFNumberGetValue ((CFNumberRef)refElementType, kCFNumberLongType, &elementType)))
{
/* look at types of interest */
@ -211,7 +348,6 @@ static void addJoystickComponent (CFTypeRef refElement, JoystickInfo* joyInfo)
}
}
}
}
static void getJoystickComponentArrayHandler (const void * value, void * parameter)
@ -337,12 +473,14 @@ namespace irr
{
//! constructor
CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
: CIrrDeviceStub(param), Window(NULL), IsActive(true), OGLContext(NULL), CGLContext(NULL),
SoftwareDriverTarget(0), IsSoftwareRenderer(false), IsResizable(false),
IsShiftDown(false), IsControlDown(false), MouseButtonStates(0)
: CIrrDeviceStub(param), Window(NULL), CGLContext(NULL), OGLContext(NULL),
SoftwareDriverTarget(0), DeviceWidth(0), DeviceHeight(0),
ScreenWidth(0), ScreenHeight(0), MouseButtonStates(0),
IsActive(true), IsSoftwareRenderer(false),
IsShiftDown(false), IsControlDown(false), IsResizable(false)
{
struct utsname name;
NSString *path;
NSString *path;
#ifdef _DEBUG
setDebugName("CIrrDeviceMacOSX");
@ -376,13 +514,14 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
bool success = true;
if (CreationParams.DriverType != video::EDT_NULL)
createWindow();
success = createWindow();
// in case of failure, one can check VideoDriver for initialization
if (!success)
return;
setResizable(false);
CursorControl = new CCursorControl(CreationParams.WindowSize, this);
createDriver();
createGUIAndScene();
}
@ -461,9 +600,11 @@ bool CIrrDeviceMacOSX::createWindow()
VideoModeList.setDesktop(CreationParams.Bits, core::dimension2d<u32>(ScreenWidth, ScreenHeight));
if (!CreationParams.Fullscreen)
// we need to check where the exceptions may happen and work at them
// for now we will just catch them to be able to avoid an app exit
@try
{
if(!CreationParams.WindowId) //create another window when WindowId is null
if (!CreationParams.Fullscreen)
{
const NSBackingStoreType type = (CreationParams.DriverType == video::EDT_OPENGL) ? NSBackingStoreBuffered : NSBackingStoreNonretained;
int x = std::max(0, CreationParams.WindowPosition.X);
@ -482,89 +623,94 @@ bool CIrrDeviceMacOSX::createWindow()
{
NSOpenGLPixelFormatAttribute windowattribs[] =
{
NSOpenGLPFANoRecovery,
NSOpenGLPFAAccelerated,
NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)depthSize,
NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)CreationParams.Bits,
NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)alphaSize,
NSOpenGLPFASampleBuffers, (NSOpenGLPixelFormatAttribute)1,
NSOpenGLPFASamples, (NSOpenGLPixelFormatAttribute)CreationParams.AntiAlias,
NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)(CreationParams.Stencilbuffer?1:0),
NSOpenGLPFADoubleBuffer,
(NSOpenGLPixelFormatAttribute)nil
};
if (CreationParams.AntiAlias<2)
{
windowattribs[ 9] = (NSOpenGLPixelFormatAttribute)0;
windowattribs[11] = (NSOpenGLPixelFormatAttribute)0;
Window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,CreationParams.WindowSize.Width,CreationParams.WindowSize.Height) styleMask:NSTitledWindowMask+NSClosableWindowMask+NSResizableWindowMask backing:NSBackingStoreBuffered defer:FALSE];
}
NSOpenGLPixelFormat *format;
for (int i=0; i<3; ++i)
if (Window != NULL || CreationParams.WindowId)
{
if (1==i)
NSOpenGLPixelFormatAttribute windowattribs[] =
{
// Second try without stencilbuffer
if (CreationParams.Stencilbuffer)
{
windowattribs[13]=(NSOpenGLPixelFormatAttribute)0;
}
else
continue;
}
else if (2==i)
NSOpenGLPFANoRecovery,
NSOpenGLPFAAccelerated,
NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)depthSize,
NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)CreationParams.Bits,
NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)alphaSize,
NSOpenGLPFASampleBuffers, (NSOpenGLPixelFormatAttribute)1,
NSOpenGLPFASamples, (NSOpenGLPixelFormatAttribute)CreationParams.AntiAlias,
NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)(CreationParams.Stencilbuffer?1:0),
NSOpenGLPFADoubleBuffer,
(NSOpenGLPixelFormatAttribute)nil
};
if (CreationParams.AntiAlias<2)
{
// Third try without Doublebuffer
os::Printer::log("No doublebuffering available.", ELL_WARNING);
windowattribs[14]=(NSOpenGLPixelFormatAttribute)nil;
windowattribs[ 9] = (NSOpenGLPixelFormatAttribute)0;
windowattribs[11] = (NSOpenGLPixelFormatAttribute)0;
}
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs];
if (format == NULL)
NSOpenGLPixelFormat *format;
for (int i=0; i<3; ++i)
{
if (CreationParams.AntiAlias>1)
if (1==i)
{
while (!format && windowattribs[12]>1)
// Second try without stencilbuffer
if (CreationParams.Stencilbuffer)
{
windowattribs[12] = (NSOpenGLPixelFormatAttribute)((int)windowattribs[12]-1);
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs];
windowattribs[13]=(NSOpenGLPixelFormatAttribute)0;
}
else
continue;
}
else if (2==i)
{
// Third try without Doublebuffer
os::Printer::log("No doublebuffering available.", ELL_WARNING);
windowattribs[14]=(NSOpenGLPixelFormatAttribute)nil;
}
if (!format)
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs];
if (format == NULL)
{
if (CreationParams.AntiAlias>1)
{
windowattribs[9] = (NSOpenGLPixelFormatAttribute)0;
windowattribs[11] = (NSOpenGLPixelFormatAttribute)0;
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs];
while (!format && windowattribs[12]>1)
{
windowattribs[12] = (NSOpenGLPixelFormatAttribute)((int)windowattribs[12]-1);
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs];
}
if (!format)
{
// reset values for next try
windowattribs[9] = (NSOpenGLPixelFormatAttribute)1;
windowattribs[11] = (NSOpenGLPixelFormatAttribute)CreationParams.AntiAlias;
}
else
{
os::Printer::log("No FSAA available.", ELL_WARNING);
}
windowattribs[9] = (NSOpenGLPixelFormatAttribute)0;
windowattribs[11] = (NSOpenGLPixelFormatAttribute)0;
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs];
if (!format)
{
// reset values for next try
windowattribs[9] = (NSOpenGLPixelFormatAttribute)1;
windowattribs[11] = (NSOpenGLPixelFormatAttribute)CreationParams.AntiAlias;
}
else
{
os::Printer::log("No FSAA available.", ELL_WARNING);
}
}
}
}
else
break;
}
else
break;
}
CreationParams.AntiAlias = windowattribs[11];
CreationParams.Stencilbuffer=(windowattribs[13]==1);
CreationParams.AntiAlias = windowattribs[11];
CreationParams.Stencilbuffer=(windowattribs[13]==1);
if (format != NULL)
{
OGLContext = [[NSOpenGLContext alloc] initWithFormat:format shareContext:NULL];
[format release];
}
if (format != NULL)
{
OGLContext = [[NSOpenGLContext alloc] initWithFormat:format shareContext:NULL];
[format release];
}
if (OGLContext != NULL)
{
if (!CreationParams.WindowId)
if (OGLContext != NULL)
{
if (CreationParams.WindowPosition.X == -1 && CreationParams.WindowPosition.Y == -1)
{
@ -576,68 +722,66 @@ bool CIrrDeviceMacOSX::createWindow()
[Window setIsVisible:TRUE];
[Window makeKeyAndOrderFront:nil];
}
else //use another window for drawing
[OGLContext setView:(NSView*)CreationParams.WindowId];
}
}
else
{
displaymode = CGDisplayBestModeForParameters(display,CreationParams.Bits,CreationParams.WindowSize.Width,CreationParams.WindowSize.Height,NULL);
if (displaymode != NULL)
{
olddisplaymode = CGDisplayCurrentMode(display);
error = CGCaptureAllDisplays();
if (error == CGDisplayNoErr)
{
error = CGDisplaySwitchToMode(display,displaymode);
if (error == CGDisplayNoErr)
{
CGLPixelFormatAttribute fullattribs[] =
{
kCGLPFAFullScreen,
kCGLPFADisplayMask, (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(display),
kCGLPFADoubleBuffer,
kCGLPFANoRecovery,
kCGLPFAAccelerated,
kCGLPFADepthSize, (CGLPixelFormatAttribute)depthSize,
kCGLPFAColorSize, (CGLPixelFormatAttribute)CreationParams.Bits,
kCGLPFAAlphaSize, (CGLPixelFormatAttribute)alphaSize,
kCGLPFASampleBuffers, (CGLPixelFormatAttribute)(CreationParams.AntiAlias?1:0),
kCGLPFASamples, (CGLPixelFormatAttribute)CreationParams.AntiAlias,
kCGLPFAStencilSize, (CGLPixelFormatAttribute)(CreationParams.Stencilbuffer?1:0),
(CGLPixelFormatAttribute)NULL
};
CGLContext = (CGLContextObj) [OGLContext CGLContextObj];
DeviceWidth = CreationParams.WindowSize.Width;
DeviceHeight = CreationParams.WindowSize.Height;
result = true;
pixelFormat = NULL;
numPixelFormats = 0;
CGLChoosePixelFormat(fullattribs,&pixelFormat,&numPixelFormats);
if (pixelFormat != NULL)
{
CGLCreateContext(pixelFormat,NULL,&CGLContext);
CGLDestroyPixelFormat(pixelFormat);
}
if (CGLContext != NULL)
{
CGLSetFullScreen(CGLContext);
displayRect = CGDisplayBounds(display);
ScreenWidth = DeviceWidth = (int)displayRect.size.width;
ScreenHeight = DeviceHeight = (int)displayRect.size.height;
CreationParams.WindowSize.set(ScreenWidth, ScreenHeight);
result = true;
}
}
if (!result)
CGReleaseAllDisplays();
}
}
}
}
else
@catch (NSException *exception)
{
displaymode = CGDisplayBestModeForParameters(display,CreationParams.Bits,CreationParams.WindowSize.Width,CreationParams.WindowSize.Height,NULL);
if (displaymode != NULL)
{
olddisplaymode = CGDisplayCurrentMode(display);
error = CGCaptureAllDisplays();
if (error == CGDisplayNoErr)
{
error = CGDisplaySwitchToMode(display,displaymode);
if (error == CGDisplayNoErr)
{
CGLPixelFormatAttribute fullattribs[] =
{
kCGLPFAFullScreen,
kCGLPFADisplayMask, (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(display),
kCGLPFADoubleBuffer,
kCGLPFANoRecovery,
kCGLPFAAccelerated,
kCGLPFADepthSize, (CGLPixelFormatAttribute)depthSize,
kCGLPFAColorSize, (CGLPixelFormatAttribute)CreationParams.Bits,
kCGLPFAAlphaSize, (CGLPixelFormatAttribute)alphaSize,
kCGLPFASampleBuffers, (CGLPixelFormatAttribute)(CreationParams.AntiAlias?1:0),
kCGLPFASamples, (CGLPixelFormatAttribute)CreationParams.AntiAlias,
kCGLPFAStencilSize, (CGLPixelFormatAttribute)(CreationParams.Stencilbuffer?1:0),
(CGLPixelFormatAttribute)NULL
};
pixelFormat = NULL;
numPixelFormats = 0;
CGLChoosePixelFormat(fullattribs,&pixelFormat,&numPixelFormats);
if (pixelFormat != NULL)
{
CGLCreateContext(pixelFormat,NULL,&CGLContext);
CGLDestroyPixelFormat(pixelFormat);
}
if (CGLContext != NULL)
{
CGLSetFullScreen(CGLContext);
displayRect = CGDisplayBounds(display);
ScreenWidth = DeviceWidth = (int)displayRect.size.width;
ScreenHeight = DeviceHeight = (int)displayRect.size.height;
CreationParams.WindowSize.set(ScreenWidth, ScreenHeight);
result = true;
}
}
if (!result)
CGReleaseAllDisplays();
}
}
closeDevice();
result = false;
}
if (result)
@ -947,10 +1091,13 @@ void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed
mkey = mchar = 0;
skipCommand = false;
c = [str characterAtIndex:0];
mchar = c;
iter = KeyCodes.find(c);
iter = KeyCodes.find([(NSEvent *)event keyCode]);
if (iter != KeyCodes.end())
mkey = (*iter).second;
else if ((iter = KeyCodes.find(c)) != KeyCodes.end())
mkey = (*iter).second;
else
{
// workaround for period character
@ -1010,8 +1157,14 @@ void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent)
}
else
{
ievent.MouseInput.X = (int)[NSEvent mouseLocation].x;
ievent.MouseInput.Y = DeviceHeight - (int)[NSEvent mouseLocation].y;
CGEventRef ourEvent = CGEventCreate(NULL);
CGPoint point = CGEventGetLocation(ourEvent);
ievent.MouseInput.X = (int)point.x;
ievent.MouseInput.Y = (int)point.y;
if (ievent.MouseInput.Y < 0)
post = false;
}
if (post)
@ -1023,22 +1176,35 @@ void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent)
void CIrrDeviceMacOSX::storeMouseLocation()
{
NSPoint p;
int x,y;
p = [NSEvent mouseLocation];
int x,y;
if (Window != NULL)
{
NSPoint p;
p = [NSEvent mouseLocation];
p = [Window convertScreenToBase:p];
x = (int)p.x;
y = DeviceHeight - (int)p.y;
}
else
{
x = (int)p.x;
y = (int)p.y;
y -= (ScreenHeight - DeviceHeight);
CGEventRef ourEvent = CGEventCreate(NULL);
CGPoint point = CGEventGetLocation(ourEvent);
x = (int)point.x;
y = (int)point.y;
const core::position2di& curr = ((CCursorControl *)CursorControl)->getPosition();
if (curr.X != x || curr.Y != y)
{
// In fullscreen mode, events are not sent regularly so rely on polling
irr::SEvent ievent;
ievent.EventType = irr::EET_MOUSE_INPUT_EVENT;
ievent.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN;
ievent.MouseInput.X = x;
ievent.MouseInput.Y = y;
postEventFromUser(ievent);
}
}
((CCursorControl *)CursorControl)->updateInternalCursorPosition(x,y);
@ -1082,42 +1248,115 @@ void CIrrDeviceMacOSX::setCursorVisible(bool visible)
void CIrrDeviceMacOSX::initKeycodes()
{
KeyCodes[NSUpArrowFunctionKey] = irr::KEY_UP;
KeyCodes[NSDownArrowFunctionKey] = irr::KEY_DOWN;
KeyCodes[NSLeftArrowFunctionKey] = irr::KEY_LEFT;
KeyCodes[NSRightArrowFunctionKey] = irr::KEY_RIGHT;
KeyCodes[NSF1FunctionKey] = irr::KEY_F1;
KeyCodes[NSF2FunctionKey] = irr::KEY_F2;
KeyCodes[NSF3FunctionKey] = irr::KEY_F3;
KeyCodes[NSF4FunctionKey] = irr::KEY_F4;
KeyCodes[NSF5FunctionKey] = irr::KEY_F5;
KeyCodes[NSF6FunctionKey] = irr::KEY_F6;
KeyCodes[NSF7FunctionKey] = irr::KEY_F7;
KeyCodes[NSF8FunctionKey] = irr::KEY_F8;
KeyCodes[NSF9FunctionKey] = irr::KEY_F9;
KeyCodes[NSF10FunctionKey] = irr::KEY_F10;
KeyCodes[NSF11FunctionKey] = irr::KEY_F11;
KeyCodes[NSF12FunctionKey] = irr::KEY_F12;
KeyCodes[NSF13FunctionKey] = irr::KEY_F13;
KeyCodes[NSF14FunctionKey] = irr::KEY_F14;
KeyCodes[NSF15FunctionKey] = irr::KEY_F15;
KeyCodes[NSF16FunctionKey] = irr::KEY_F16;
KeyCodes[NSHomeFunctionKey] = irr::KEY_HOME;
KeyCodes[NSEndFunctionKey] = irr::KEY_END;
KeyCodes[kVK_UpArrow] = irr::KEY_UP;
KeyCodes[kVK_DownArrow] = irr::KEY_DOWN;
KeyCodes[kVK_LeftArrow] = irr::KEY_LEFT;
KeyCodes[kVK_RightArrow] = irr::KEY_RIGHT;
KeyCodes[kVK_F1] = irr::KEY_F1;
KeyCodes[kVK_F2] = irr::KEY_F2;
KeyCodes[kVK_F3] = irr::KEY_F3;
KeyCodes[kVK_F4] = irr::KEY_F4;
KeyCodes[kVK_F5] = irr::KEY_F5;
KeyCodes[kVK_F6] = irr::KEY_F6;
KeyCodes[kVK_F7] = irr::KEY_F7;
KeyCodes[kVK_F8] = irr::KEY_F8;
KeyCodes[kVK_F9] = irr::KEY_F9;
KeyCodes[kVK_F10] = irr::KEY_F10;
KeyCodes[kVK_F11] = irr::KEY_F11;
KeyCodes[kVK_F12] = irr::KEY_F12;
KeyCodes[kVK_F13] = irr::KEY_F13;
KeyCodes[kVK_F14] = irr::KEY_F14;
KeyCodes[kVK_F15] = irr::KEY_F15;
KeyCodes[kVK_F16] = irr::KEY_F16;
KeyCodes[kVK_F17] = irr::KEY_F17;
KeyCodes[kVK_F18] = irr::KEY_F18;
KeyCodes[kVK_F19] = irr::KEY_F19;
KeyCodes[kVK_F20] = irr::KEY_F20;
KeyCodes[kVK_Home] = irr::KEY_HOME;
KeyCodes[kVK_End] = irr::KEY_END;
KeyCodes[NSInsertFunctionKey] = irr::KEY_INSERT;
KeyCodes[NSDeleteFunctionKey] = irr::KEY_DELETE;
KeyCodes[NSHelpFunctionKey] = irr::KEY_HELP;
KeyCodes[kVK_ForwardDelete] = irr::KEY_DELETE;
KeyCodes[kVK_Help] = irr::KEY_HELP;
KeyCodes[NSSelectFunctionKey] = irr::KEY_SELECT;
KeyCodes[NSPrintFunctionKey] = irr::KEY_PRINT;
KeyCodes[NSExecuteFunctionKey] = irr::KEY_EXECUT;
KeyCodes[NSPrintScreenFunctionKey] = irr::KEY_SNAPSHOT;
KeyCodes[NSPauseFunctionKey] = irr::KEY_PAUSE;
KeyCodes[NSScrollLockFunctionKey] = irr::KEY_SCROLL;
KeyCodes[0x7F] = irr::KEY_BACK;
KeyCodes[0x09] = irr::KEY_TAB;
KeyCodes[0x0D] = irr::KEY_RETURN;
KeyCodes[0x03] = irr::KEY_RETURN;
KeyCodes[0x1B] = irr::KEY_ESCAPE;
KeyCodes[kVK_Delete] = irr::KEY_BACK;
KeyCodes[kVK_Tab] = irr::KEY_TAB;
KeyCodes[kVK_Return] = irr::KEY_RETURN;
KeyCodes[kVK_Escape] = irr::KEY_ESCAPE;
KeyCodes[kVK_Control] = irr::KEY_CONTROL;
KeyCodes[kVK_RightControl] = irr::KEY_RCONTROL;
KeyCodes[kVK_Command] = irr::KEY_MENU;
KeyCodes[kVK_Shift] = irr::KEY_SHIFT;
KeyCodes[kVK_RightShift] = irr::KEY_RSHIFT;
KeyCodes[kVK_Space] = irr::KEY_SPACE;
KeyCodes[kVK_ANSI_A] = irr::KEY_KEY_A;
KeyCodes[kVK_ANSI_B] = irr::KEY_KEY_B;
KeyCodes[kVK_ANSI_C] = irr::KEY_KEY_C;
KeyCodes[kVK_ANSI_D] = irr::KEY_KEY_D;
KeyCodes[kVK_ANSI_E] = irr::KEY_KEY_E;
KeyCodes[kVK_ANSI_F] = irr::KEY_KEY_F;
KeyCodes[kVK_ANSI_G] = irr::KEY_KEY_G;
KeyCodes[kVK_ANSI_H] = irr::KEY_KEY_H;
KeyCodes[kVK_ANSI_I] = irr::KEY_KEY_I;
KeyCodes[kVK_ANSI_J] = irr::KEY_KEY_J;
KeyCodes[kVK_ANSI_K] = irr::KEY_KEY_K;
KeyCodes[kVK_ANSI_L] = irr::KEY_KEY_L;
KeyCodes[kVK_ANSI_M] = irr::KEY_KEY_M;
KeyCodes[kVK_ANSI_N] = irr::KEY_KEY_N;
KeyCodes[kVK_ANSI_O] = irr::KEY_KEY_O;
KeyCodes[kVK_ANSI_P] = irr::KEY_KEY_P;
KeyCodes[kVK_ANSI_Q] = irr::KEY_KEY_Q;
KeyCodes[kVK_ANSI_R] = irr::KEY_KEY_R;
KeyCodes[kVK_ANSI_S] = irr::KEY_KEY_S;
KeyCodes[kVK_ANSI_T] = irr::KEY_KEY_T;
KeyCodes[kVK_ANSI_U] = irr::KEY_KEY_U;
KeyCodes[kVK_ANSI_V] = irr::KEY_KEY_V;
KeyCodes[kVK_ANSI_W] = irr::KEY_KEY_W;
KeyCodes[kVK_ANSI_X] = irr::KEY_KEY_X;
KeyCodes[kVK_ANSI_X] = irr::KEY_KEY_X;
KeyCodes[kVK_ANSI_Y] = irr::KEY_KEY_Y;
KeyCodes[kVK_ANSI_Z] = irr::KEY_KEY_Z;
KeyCodes[kVK_ANSI_0] = irr::KEY_KEY_0;
KeyCodes[kVK_ANSI_1] = irr::KEY_KEY_1;
KeyCodes[kVK_ANSI_2] = irr::KEY_KEY_2;
KeyCodes[kVK_ANSI_3] = irr::KEY_KEY_3;
KeyCodes[kVK_ANSI_4] = irr::KEY_KEY_4;
KeyCodes[kVK_ANSI_5] = irr::KEY_KEY_5;
KeyCodes[kVK_ANSI_6] = irr::KEY_KEY_6;
KeyCodes[kVK_ANSI_7] = irr::KEY_KEY_7;
KeyCodes[kVK_ANSI_8] = irr::KEY_KEY_8;
KeyCodes[kVK_ANSI_9] = irr::KEY_KEY_9;
KeyCodes[kVK_ANSI_Slash] = irr::KEY_DIVIDE;
KeyCodes[kVK_ANSI_Comma] = irr::KEY_COMMA;
KeyCodes[kVK_ANSI_Period] = irr::KEY_PERIOD;
KeyCodes[kVK_PageUp] = irr::KEY_PRIOR;
KeyCodes[kVK_PageDown] = irr::KEY_NEXT;
KeyCodes[kVK_ANSI_Keypad0] = irr::KEY_NUMPAD0;
KeyCodes[kVK_ANSI_Keypad1] = irr::KEY_NUMPAD1;
KeyCodes[kVK_ANSI_Keypad2] = irr::KEY_NUMPAD2;
KeyCodes[kVK_ANSI_Keypad3] = irr::KEY_NUMPAD3;
KeyCodes[kVK_ANSI_Keypad4] = irr::KEY_NUMPAD4;
KeyCodes[kVK_ANSI_Keypad5] = irr::KEY_NUMPAD5;
KeyCodes[kVK_ANSI_Keypad6] = irr::KEY_NUMPAD6;
KeyCodes[kVK_ANSI_Keypad7] = irr::KEY_NUMPAD7;
KeyCodes[kVK_ANSI_Keypad8] = irr::KEY_NUMPAD8;
KeyCodes[kVK_ANSI_Keypad9] = irr::KEY_NUMPAD9;
KeyCodes[kVK_ANSI_KeypadDecimal] = irr::KEY_DECIMAL;
KeyCodes[kVK_ANSI_KeypadMultiply] = irr::KEY_MULTIPLY;
KeyCodes[kVK_ANSI_KeypadPlus] = irr::KEY_PLUS;
KeyCodes[kVK_ANSI_KeypadClear] = irr::KEY_OEM_CLEAR;
KeyCodes[kVK_ANSI_KeypadDivide] = irr::KEY_DIVIDE;
KeyCodes[kVK_ANSI_KeypadEnter] = irr::KEY_RETURN;
KeyCodes[kVK_ANSI_KeypadMinus] = irr::KEY_SUBTRACT;
}
@ -1139,14 +1378,14 @@ bool CIrrDeviceMacOSX::isResizable() const
return IsResizable;
}
void CIrrDeviceMacOSX::minimizeWindow()
{
if (Window != NULL)
[Window miniaturize:[NSApp self]];
}
//! Maximizes the window if possible.
void CIrrDeviceMacOSX::maximizeWindow()
{

View File

@ -261,6 +261,7 @@ bool testEncryptedZip(IFileSystem* fs)
char tmp[13] = {'\0'};
readFile->read(tmp, 12);
readFile->drop();
if (strncmp(tmp, "Linux Users:", 12))
{
logTestString("Read bad data from archive: %s\n", tmp);
@ -278,8 +279,6 @@ bool testEncryptedZip(IFileSystem* fs)
if ( fs->getFileArchiveCount() )
return false;
readFile->drop();
return true;
}

View File

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

View File

@ -50,6 +50,7 @@ int main(int argumentCount, char * arguments[])
// (temporarily) to the beginning of the list, since each test runs in its own
// process.
TEST(disambiguateTextures); // Normally you should run this first, since it validates the working directory.
// Now the simple tests without device
TEST(testIrrArray);
@ -67,8 +68,7 @@ int main(int argumentCount, char * arguments[])
TEST(testS3DVertex);
TEST(testaabbox3d);
TEST(color);
// TODO: Needs to be fixed first
// TEST(testTriangle3d);
TEST(testTriangle3d);
TEST(vectorPositionDimension2d);
// file system checks (with null driver)
TEST(filesystem);
@ -89,6 +89,7 @@ int main(int argumentCount, char * arguments[])
TEST(softwareDevice);
TEST(b3dAnimation);
TEST(burningsVideo);
TEST(billboards);
TEST(createImage);
TEST(cursorSetVisible);
TEST(flyCircleAnimator);
@ -126,7 +127,8 @@ int main(int argumentCount, char * arguments[])
// q3 maps are slow
TEST(planeMatrix);
TEST(terrainSceneNode);
TEST(lightMaps);
TEST(lightMaps);
TEST(triangleSelector);
unsigned int numberOfTests = tests.size();
unsigned int testToRun = 0;

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -42,6 +42,8 @@ public:
out->addColor("ValColor", ValColor);
out->addColorf("ValColorf", ValColorf);
out->addVector3d("ValVector3df", ValVector3df);
out->addVector2d("ValVector2df", ValVector2df);
out->addDimension2d("ValDimension2du", ValDimension2du);
out->addPosition2d("ValPosition2di", ValPosition2di);
out->addRect("ValRect", ValRect);
out->addMatrix("ValMatrix", ValMatrix);
@ -68,6 +70,8 @@ public:
ValColor = in->getAttributeAsColor("ValColor");
ValColorf = in->getAttributeAsColorf("ValColorf");
ValVector3df = in->getAttributeAsVector3d("ValVector3df");
ValVector2df = in->getAttributeAsVector2d("ValVector2df");
ValDimension2du = in->getAttributeAsDimension2d("ValDimension2du");
ValPosition2di = in->getAttributeAsPosition2d("ValPosition2di");
ValRect = in->getAttributeAsRect("ValRect");
ValMatrix = in->getAttributeAsMatrix("ValMatrix");
@ -102,6 +106,8 @@ public:
return false;
}
COMPARE(ValVector3df, other.ValVector3df);
COMPARE(ValVector2df, other.ValVector2df);
COMPARE(ValDimension2du, other.ValDimension2du);
COMPARE(ValPosition2di, other.ValPosition2di);
COMPARE(ValRect, other.ValRect);
COMPARE(ValMatrix, other.ValMatrix);
@ -130,6 +136,8 @@ public:
ValColor.set(0,0,0,0);
ValColorf.set(0.f, 0.f, 0.f, 0.f);
ValVector3df.set(0.f, 0.f, 0.f);
ValVector2df.set(0.f, 0.f);
ValDimension2du.set(0, 0);
ValPosition2di.set(0,0);
ValRect = core::rect<s32>(0,0,0,0);
ValMatrix.makeIdentity();
@ -158,6 +166,8 @@ public:
ValColor.set(1,2,3,4);
ValColorf.set(1.f, 2.f, 3.f, 4.f);
ValVector3df.set(1.f, 2.f, 3.f);
ValVector2df.set(1.f, 2.f);
ValDimension2du.set(1, 2);
ValPosition2di.set(1,2);
ValRect = core::rect<s32>(1,2,3,4);
ValMatrix = 99.9f;
@ -182,6 +192,8 @@ public:
video::SColor ValColor;
video::SColorf ValColorf;
core::vector3df ValVector3df;
core::vector2df ValVector2df;
core::dimension2du ValDimension2du;
core::position2di ValPosition2di;
core::rect<s32> ValRect;
core::matrix4 ValMatrix;

View File

@ -44,6 +44,7 @@
<Unit filename="anti-aliasing.cpp" />
<Unit filename="archiveReader.cpp" />
<Unit filename="b3dAnimation.cpp" />
<Unit filename="billboards.cpp" />
<Unit filename="burningsVideo.cpp" />
<Unit filename="collisionResponseAnimator.cpp" />
<Unit filename="color.cpp" />
@ -103,6 +104,7 @@
<Unit filename="textureRenderStates.cpp" />
<Unit filename="timer.cpp" />
<Unit filename="transparentMaterials.cpp" />
<Unit filename="triangleSelector.cpp" />
<Unit filename="userClipPlane.cpp" />
<Unit filename="vectorPositionDimension2d.cpp" />
<Unit filename="videoDriver.cpp" />

View File

@ -149,6 +149,7 @@
<ClCompile Include="anti-aliasing.cpp" />
<ClCompile Include="archiveReader.cpp" />
<ClCompile Include="b3dAnimation.cpp" />
<ClCompile Include="billboards.cpp" />
<ClCompile Include="burningsVideo.cpp" />
<ClCompile Include="collisionResponseAnimator.cpp" />
<ClCompile Include="color.cpp" />
@ -209,6 +210,7 @@
<ClCompile Include="textureRenderStates.cpp" />
<ClCompile Include="timer.cpp" />
<ClCompile Include="transparentMaterials.cpp" />
<ClCompile Include="triangleSelector.cpp" />
<ClCompile Include="userClipPlane.cpp" />
<ClCompile Include="vectorPositionDimension2d.cpp" />
<ClCompile Include="videoDriver.cpp" />
@ -227,4 +229,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -188,6 +188,10 @@
RelativePath=".\b3dAnimation.cpp"
>
</File>
<File
RelativePath=".\billboards.cpp"
>
</File>
<File
RelativePath=".\burningsVideo.cpp"
>
@ -428,6 +432,10 @@
RelativePath=".\transparentMaterials.cpp"
>
</File>
<File
RelativePath=".\triangleSelector.cpp"
>
</File>
<File
RelativePath=".\userClipPlane.cpp"
>

View File

@ -187,6 +187,10 @@
RelativePath=".\b3dAnimation.cpp"
>
</File>
<File
RelativePath=".\billboards.cpp"
>
</File>
<File
RelativePath=".\burningsVideo.cpp"
>

View File

@ -3,27 +3,17 @@
#include "testUtils.h"
#include <irrlicht.h>
#include <assert.h>
using namespace irr;
using namespace core;
template<class T>
static bool isOnSameSide(const vector3d<T>& p1, const vector3d<T>& p2,
const vector3d<T>& a, const vector3d<T>& b)
{
vector3d<T> bminusa = b - a;
vector3d<T> cp1 = bminusa.crossProduct(p1 - a);
vector3d<T> cp2 = bminusa.crossProduct(p2 - a);
return (cp1.dotProduct(cp2)+core::ROUNDING_ERROR_f64 >= 0.0f);
}
template<class T>
static bool testGetIntersectionWithLine(core::triangle3d<T>& triangle, const core::line3d<T>& ray)
{
bool allExpected=true;
const vector3d<T> linevect = ray.getVector().normalize();
vector3d<T> intersection;
// When we just raise Y parallel to the ray then either all should fail or all succeed (the latter in our case).
for (u32 i=0; i<100; ++i)
{
if (!triangle.getIntersectionOfPlaneWithLine(ray.start, linevect, intersection))
@ -31,6 +21,7 @@ static bool testGetIntersectionWithLine(core::triangle3d<T>& triangle, const cor
allExpected=false;
logTestString("triangle3d plane test %d failed\n", i);
}
//logTestString("intersection: %f %f %f\n", intersection.X, intersection.Y, intersection.Z);
if (!triangle.isPointInsideFast(intersection))
{
allExpected=false;
@ -40,12 +31,6 @@ static bool testGetIntersectionWithLine(core::triangle3d<T>& triangle, const cor
{
allExpected=false;
logTestString("triangle3d point test %d failed\n", i);
if (!isOnSameSide(intersection, triangle.pointA, triangle.pointB, triangle.pointC))
logTestString("triangle3d side1 test %d failed\n", i);
if (!isOnSameSide(intersection, triangle.pointB, triangle.pointA, triangle.pointC))
logTestString("triangle3d side2 test %d failed\n", i);
if (!isOnSameSide(intersection, triangle.pointC, triangle.pointA, triangle.pointB))
logTestString("triangle3d side3 test %d failed\n", i);
}
if (!triangle.getIntersectionWithLine(ray.start, linevect, intersection))
@ -102,44 +87,50 @@ static void stageModifications(int stage, vector3d<T>& point)
}
template<class T>
static bool isPointInside(triangle3d<T> triangleOrig)
static bool isPointInside(triangle3d<T> triangleOrig, bool testIsInside, bool testIsInsideFast)
{
bool allExpected=true;
array< vector3d<T> > pointsInside;
pointsInside.push_back( vector3d<T>(0,0,0) );
pointsInside.push_back( (triangleOrig.pointA + triangleOrig.pointB + triangleOrig.pointC) / 3 );
pointsInside.push_back( (triangleOrig.pointA + triangleOrig.pointB)/2 + vector3d<T>(0,1,0) );
pointsInside.push_back( (triangleOrig.pointA + triangleOrig.pointC)/2 + vector3d<T>(1,0,0) );
pointsInside.push_back( (triangleOrig.pointB + triangleOrig.pointC)/2 - vector3d<T>(1,0,0) );
for (u32 stage=0; ; ++stage)
{
triangle3d<T> triangle = triangleOrig;
if ( !stageModifications(stage, triangle) )
break;
for ( u32 i=0; i < pointsInside.size(); ++i )
{
vector3d<T> point = pointsInside[i];
stageModifications(stage, point);
allExpected &= triangle.isPointInside( point );
if ( !allExpected )
if ( testIsInside )
{
logTestString("triangle3d::isPointInside pointsInside test failed in stage %d point %d\n", stage, i);
return false;
allExpected &= triangle.isPointInside( point );
if ( !allExpected )
{
logTestString("triangle3d::isPointInside pointsInside test failed in stage %d point %d\n", stage, i);
return false;
}
}
allExpected &= triangle.isPointInsideFast( point );
if ( !allExpected )
if ( testIsInsideFast )
{
logTestString("triangle3d::isPointInsideFast pointsInside test failed in stage %d point %d\n", stage, i);
return false;
allExpected &= triangle.isPointInsideFast( point );
if ( !allExpected )
{
logTestString("triangle3d::isPointInsideFast pointsInside test failed in stage %d point %d\n", stage, i);
return false;
}
}
}
}
array< vector3d<T> > pointsOutside;
pointsOutside.push_back( triangleOrig.pointA - vector3d<T>(1,0,0) );
pointsOutside.push_back( triangleOrig.pointA - vector3d<T>(0,1,0) );
@ -151,34 +142,40 @@ static bool isPointInside(triangle3d<T> triangleOrig)
pointsOutside.push_back( (triangleOrig.pointA + triangleOrig.pointB)/2 - vector3d<T>(0,1,0) );
pointsOutside.push_back( (triangleOrig.pointA + triangleOrig.pointC)/2 - vector3d<T>(1,0,0) );
pointsOutside.push_back( (triangleOrig.pointB + triangleOrig.pointC)/2 + vector3d<T>(1,0,0) );
for (u32 stage=0; ; ++stage)
{
triangle3d<T> triangle = triangleOrig;
if ( !stageModifications(stage, triangle) )
break;
for ( u32 i=0; i < pointsOutside.size(); ++i )
{
vector3d<T> point = pointsOutside[i];
stageModifications(stage, point);
allExpected &= !triangle.isPointInside( point );
if ( !allExpected )
if ( testIsInside )
{
logTestString("triangle3d::isPointInside pointsOutside test failed in stage %d point %d\n", stage, i);
return false;
allExpected &= !triangle.isPointInside( point );
if ( !allExpected )
{
logTestString("triangle3d::isPointInside pointsOutside test failed in stage %d point %d\n", stage, i);
return false;
}
}
allExpected &= !triangle.isPointInsideFast( point );
if ( !allExpected )
if ( testIsInsideFast )
{
logTestString("triangle3d::isPointInsideFast pointsOutside test failed in stage %d point %d\n", stage, i);
return false;
allExpected &= !triangle.isPointInsideFast( point );
if ( !allExpected )
{
logTestString("triangle3d::isPointInsideFast pointsOutside test failed in stage %d point %d\n", stage, i);
return false;
}
}
}
}
array< vector3d<T> > pointsBorder;
pointsBorder.push_back( triangleOrig.pointA );
pointsBorder.push_back( triangleOrig.pointB );
@ -186,31 +183,37 @@ static bool isPointInside(triangle3d<T> triangleOrig)
pointsBorder.push_back( (triangleOrig.pointA + triangleOrig.pointB)/2 );
pointsBorder.push_back( (triangleOrig.pointA + triangleOrig.pointC)/2 );
pointsBorder.push_back( (triangleOrig.pointB + triangleOrig.pointC)/2 );
for (u32 stage=0; ; ++stage)
{
triangle3d<T> triangle = triangleOrig;
if ( !stageModifications(stage, triangle) )
break;
for ( u32 i=0; i < pointsBorder.size(); ++i )
{
vector3d<T> point = pointsBorder[i];
stageModifications(stage, point);
allExpected &= triangle.isPointInside( point );
if ( !allExpected )
if ( testIsInside )
{
logTestString("triangle3d::isPointInside pointsBorder test failed in stage %d point %d\n", stage, i);
return false;
allExpected &= triangle.isPointInside( point );
if ( !allExpected )
{
logTestString("triangle3d::isPointInside pointsBorder test failed in stage %d point %d\n", stage, i);
return false;
}
}
if ( testIsInsideFast )
{
allExpected &= triangle.isPointInsideFast( point );
if ( !allExpected )
{
logTestString("triangle3d::isPointInsideFast pointsBorder test failed in stage %d point %d\n", stage, i);
return false;
}
}
/* results for isPointInsideFast are mixed for border cases, but I guess that's fine.
if ( triangle.isPointInsideFast( point ) )
logTestString("+ triangle3d::isPointInsideFast pointsBorder stage %d point %d is INSIDE\n", stage, i);
else
logTestString("- triangle3d::isPointInsideFast pointsBorder stage %d point %d is NOT inside\n", stage, i);
*/
}
}
@ -218,7 +221,6 @@ static bool isPointInside(triangle3d<T> triangleOrig)
}
// Test the functionality of triangle3d<T>
/** Validation is done with asserts() against expected results. */
bool testTriangle3d(void)
{
bool allExpected = true;
@ -226,23 +228,23 @@ bool testTriangle3d(void)
logTestString("Test getIntersectionWithLine with f32\n");
{
triangle3df triangle(
vector3df(11300.000000f, 129.411758f, 200.000000f),
vector3df(11200.000000f, 94.117645f, 300.000000f),
vector3df(11300.000000f, 129.411758f, 300.000000f));
vector3df(11300.f, 129.411758f, 200.f),
vector3df(11200.f, 94.117645f, 300.f),
vector3df(11300.f, 129.411758f, 300.f));
line3df ray;
ray.start = vector3df(11250.000000f, 329.000000f, 250.000000f);
ray.end = vector3df(11250.000000, -1000.000000, 250.000000);
ray.start = vector3df(11250.f, 329.f, 250.f);
ray.end = vector3df(11250.f, -1000.f, 250.f);
allExpected &= testGetIntersectionWithLine(triangle, ray);
}
logTestString("Test getIntersectionWithLine with f64\n");
{
triangle3d<f64> triangle(
vector3d<f64>(11300.000000f, 129.411758f, 200.000000f),
vector3d<f64>(11200.000000f, 94.117645f, 300.000000f),
vector3d<f64>(11300.000000f, 129.411758f, 300.000000f));
vector3d<f64>(11300., 129.411758, 200.),
vector3d<f64>(11200., 94.117645, 300.),
vector3d<f64>(11300., 129.411758, 300.));
line3d<f64> ray;
ray.start = vector3d<f64>(11250.000000f, 329.000000f, 250.000000f);
ray.end = vector3d<f64>(11250.000000, -1000.000000, 250.000000);
ray.start = vector3d<f64>(11250., 329., 250.);
ray.end = vector3d<f64>(11250., -1000., 250.);
allExpected &= testGetIntersectionWithLine(triangle, ray);
}
@ -250,23 +252,23 @@ bool testTriangle3d(void)
if ( !testEigen ) // test from Eigen from here: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=44372&p=254331#p254331
logTestString("Test isPointInside fails with integers\n");
allExpected &= testEigen;
logTestString("Test isPointInside with f32\n");
{
triangle3d<f32> t(vector3d<f32>(-1000,-1000,0), vector3d<f32>(1000,-1000,0), vector3d<f32>(0,1000,0));
allExpected &= isPointInside(t);
triangle3d<f32> t(vector3d<f32>(-1000,-1000,0), vector3d<f32>(1000,-1000,0), vector3d<f32>(0,1000,0));
allExpected &= isPointInside(t, true, true);
}
logTestString("Test isPointInside with f64\n");
{
triangle3d<f64> t(vector3d<f64>(-1000,-1000,0), vector3d<f64>(1000,-1000,0), vector3d<f64>(0,1000,0));
allExpected &= isPointInside(t);
triangle3d<f64> t(vector3d<f64>(-1000,-1000,0), vector3d<f64>(1000,-1000,0), vector3d<f64>(0,1000,0));
allExpected &= isPointInside(t, true, true);
}
logTestString("Test isPointInside with s32\n");
{
triangle3d<s32> t(vector3d<s32>(-1000,-1000,0), vector3d<s32>(1000,-1000,0), vector3d<s32>(0,1000,0));
allExpected &= isPointInside(t);
triangle3d<s32> t(vector3d<s32>(-1000,-1000,0), vector3d<s32>(1000,-1000,0), vector3d<s32>(0,1000,0));
allExpected &= isPointInside(t, false, true);
}
if(allExpected)