Merged revisions 3172:3197 from 1.7 branch. Some more bug fixes and doc updates from the 1.7 beta phase.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3198 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2010-02-02 20:53:57 +00:00
parent 675fd7637e
commit 96310b964d
62 changed files with 1385 additions and 1026 deletions

View File

@ -1,11 +1,33 @@
Changes in 1.7
- Implement minimize and deminimize under OSX.
- Define sorting order for vector2d and vector3d in operators <, <=, > and >= to fix bugs 2783509 and 2783510. Operators order now by X,Y,Z and use float tolerances.
- Ogre mesh 32bit indices fixed.
- Fix tooltips for gui-elements with sub-element like IGUISpinBox (id: 2927079, found by ArakisTheKitsune)
- ITimer no longer stops when started twice
- wchar_t filesystem updates under Windows.
- Joystick POV fixed under Windows, ids fixed under OSX.
- Some updates to skinned mesh for better bones support and scaling animations.
- OSX supports external window id in creation parameters now.
- Fix bbox collision tests.
- Updates for win32 key handling
- new convenience method for flat plane creation.
- Sky dome and other meshes use VBOs by default now.
- Speed up b3d loading for files with many frames, material color flags and vertex color support enhanced.
- Add hasType to IGUIElement as a dynamic_cast substitute.
- Add another parameter to IGUISkin::draw3DWindowBackground to allow getting the client area without actually drawing
@ -26,6 +48,10 @@ Changes in 1.7
- Add clearSystemMessages to devices (implemented only for Linux and Win32 so far).
- Support changing the render window from beginScene also with OpenGL driver.
- Add getMaterial2D which allows to alter the 2d render state settings, such as filtering, anti-aliasing, thickness, etc.
- Fix incorrect cursorpos for resizable windows on Windows Vista (found and patched by buffer)
- Change the beginScene window parameter from void* to SExposedVideoData&. This will allow to manage contexts for OpenGL at some point.
@ -38,6 +64,8 @@ Changes in 1.7
- Bugfix: Mousewheel no longer sends EMIE_MOUSE_WHEEL messages twice on Linux.
- Use latest jpeglib
- refactoring: E_ATTRIBUTE_TYPE and IAttribute have now own headers
- CStringWArrayAttribute speedup
@ -48,12 +76,16 @@ Changes in 1.7
- Support AES-encrypted zip files. Should work with 128, 196, and 256 bit AES. This addition also adds a new PRNG, SHA, and other algorithms to the engine, though no interface is yet added for them. The implementation of the encryption algorithms is provided by Dr Brian Gladman.
- flattenFilename and getAbsolutePath fixed and properly added at several places.
- Added geometry shaders for OpenGL. A first version of the code was submitted by Matthew Kielan (devsh).
- Bugfix: irrArray should no longer crash when using other allocators.
- Add MaterialViewer example.
- Texture activation now back in setMaterial, which simplifies writing external material renderers (OpenGL only).
- Checkbox uses now disabled text color when disabled.
- Changed colors for window-title caption to keep them readable when not active.
@ -92,6 +124,18 @@ Changes in 1.7
New function findItemWithCommandId
New function insertItem
- new vector3d::getSphericalCoordinateAngles method.
- new triangle3d::isTotalOutsideBox method.
- Newly introduced VertexManipulator interface. This allows for very easy creation of vertex manipulation algorithms. Several manipulators, e.g. vertex color changer and transformation algorithms are already available.
- createMeshWith1TCoords avoids vertex duplication
- getRotation now handles matrices with scaling as well
- Ogre format animations now supported.
- irrArray: Fixed issues with push_front and reallocation
Changed behavior for set_pointer and clear, when free_when_destroyed is false

View File

@ -2499,3 +2499,393 @@ IGUISkin.h
new enum value
EGST_COUNT
Changes for Version 1.7
-------------------------
This version has less API-breaking changes than the previous major changes. It has many new features, which simply add methods. All those changes, which affect old methods or structures are mostly put in parallel to the old (and now deprecated) methods. Only a few things are changed without backward compatibility: The texture wrap mode is split into separate U and V modes. The beginScene void* parameter has been replaced by an SExposedVideoData. Simply wrap the pointer with this struct and it should work again.
EMIE_LMOUSE_DOUBLE_CLICK replaces EMIE_MOUSE_DOUBLE_CLICK and EMIE_LMOUSE_TRIPLE_CLICK replaces EMIE_MOUSE_TRIPLE_CLICK
Elements used in the array container need now to have an operator=
Here comes the full list:
path.h
New type
struct SNamedPath
triangle3d.h
New method
bool isTotalOutsideBox(const aabbox3d<T>& box) const
ESceneNodeTypes.h
Changed enum value (from octt)
ESNT_OCTREE = MAKE_IRR_ID('o','c','t','r'),
SColor.h
New method
f32 getLightness() const
driverChoice.h
New method
static irr::video::E_DRIVER_TYPE driverChoiceConsole(bool allDrivers=true)
ITexture.h
New parameter
virtual void regenerateMipMapLevels(void* mipmapData=0) = 0;
Changed return value (from io:path)
const io::SNamedPath& getName() const { return NamedPath; }
SceneParameters.h
New scene parameters
const c8* const OBJ_TEXTURE_PATH = "OBJ_TexturePath";
const c8* const B3D_TEXTURE_PATH = "B3D_TexturePath";
IMeshManipulator.h
Not virtual anymore
void setVertexColorAlpha(IMesh* mesh, s32 alpha) const
void setVertexColors(IMesh* mesh, video::SColor color) const
void scale(IMeshBuffer* buffer, const core::vector3df& factor) const
void scaleMesh(IMesh* mesh, const core::vector3df& factor) const
void scaleTCoords(scene::IMesh* mesh, const core::vector2df& factor, u32 level=1) const
void scaleTCoords(scene::IMeshBuffer* buffer, const core::vector2df& factor, u32 level=1) const
void transform(IMesh* mesh, const core::matrix4& m) const
void transform(IMeshBuffer* buffer, const core::matrix4& m) const
New method
template <typename Functor>
bool apply(const Functor& func, IMeshBuffer* buffer, bool boundingBoxUpdate=false) const
template <typename Functor>
bool apply(const Functor& func, IMesh* mesh, bool boundingBoxUpdate=false) const
virtual void recalculateTangents(IMesh* mesh, bool recalculateNormals=false,
bool smooth=false, bool angleWeighted=false) const=0;
void scale(IMesh* mesh, const core::vector3df& factor) const
New parameter
virtual IMesh* createMeshWithTangents(IMesh* mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false, bool recalculateTangents=true) const = 0;
coreutil.h
Changed return type and parameters (from stringc/w)
inline io::path& cutFilenameExtension ( io::path &dest, const io::path &source )
inline io::path& getFileNameExtension ( io::path &dest, const io::path &source )
inline io::path& deletePathFromFilename(io::path& filename)
Fixed behavior
inline io::path& deletePathFromPath(io::path& filename, s32 pathCount)
ICursorControl.h
Return const-ref
virtual const core::position2d<s32>& getPosition() = 0;
irrArray.h
Fixed allocator template usage
array(const array<T, TAlloc>& other) : data(0)
const array<T, TAlloc>& operator=(const array<T, TAlloc>& other)
bool operator == (const array<T, TAlloc>& other) const
bool operator != (const array<T, TAlloc>& other) const
Changed behavior for free_when_destroyed
void set_pointer(T* newPointer, u32 size, bool _is_sorted=false, bool _free_when_destroyed=true)
void set_free_when_destroyed(bool f)
irrMap.h
Renamed method (from isEmpty)
bool empty() const
New method
void swap(map<KeyType, ValueType>& other)
IAnimatedMesh.h
virtual f32 getAnimationSpeed() const =0;
IAttributes.h
Made parameters const-ref
virtual void addArray(const c8* attributeName, const core::array<core::stringw>& value) = 0;
virtual void setAttribute(const c8* attributeName, const core::array<core::stringw>& value) = 0;
virtual void setAttribute(s32 index, const core::array<core::stringw>& value) = 0;
ISceneManager.h
Renamed method (from OctTree)
virtual IMeshSceneNode* addOctreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0,
s32 id=-1, s32 minimalPolysPerNode=512, bool alsoAddIfMeshPointerZero=false) = 0;
virtual IMeshSceneNode* addOctreeSceneNode(IMesh* mesh, ISceneNode* parent=0,
s32 id=-1, s32 minimalPolysPerNode=256, bool alsoAddIfMeshPointerZero=false) = 0;
virtual ITriangleSelector* createOctreeTriangleSelector(IMesh* mesh,
ISceneNode* node, s32 minimalPolysPerNode=32) = 0;
New parameter (makeActive)
virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0,
const core::vector3df& position = core::vector3df(0,0,0),
const core::vector3df& lookat = core::vector3df(0,0,100),
s32 id=-1, bool makeActive=true) = 0;
virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent = 0,
f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f,
f32 translationSpeed = 1500.0f, s32 id=-1,
bool makeActive=true) = 0;
virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0,
f32 rotateSpeed = 100.0f, f32 moveSpeed = 0.5f, s32 id=-1,
SKeyMap* keyMapArray=0, s32 keyMapSize=0, bool noVerticalMovement=false,
f32 jumpSpeed = 0.f, bool invertMouse=false,
bool makeActive=true) = 0;
Make parameter const
virtual IMeshSceneNode* addQuake3SceneNode(const IMeshBuffer* meshBuffer, const quake3::IShader * shader,
ISceneNode* parent=0, s32 id=-1) = 0;
New parameter (loop, pingpong)
virtual ISceneNodeAnimator* createFollowSplineAnimator(s32 startTime,
const core::array< core::vector3df >& points,
f32 speed = 1.0f, f32 tightness = 0.5f, bool loop=true, bool pingpong=false) = 0;
SMaterialLayer.h
New clamp modes
ETC_MIRROR_CLAMP, ETC_MIRROR_CLAMP_TO_EDGE, ETC_MIRROR_CLAMP_TO_BORDER
New material layer modes (replaces TextureWrap)
TextureWrapU(ETC_REPEAT), TextureWrapV(ETC_REPEAT)
vector3d.h
Use tolerance to compare, changed order function to total order
bool operator<=(const vector3d<T>&other) const
bool operator>=(const vector3d<T>&other) const
bool operator<(const vector3d<T>&other) const
bool operator>(const vector3d<T>&other) const
New method
vector3d<T> getSphericalCoordinateAngles()
New method specializations
template <>
inline vector3d<s32> vector3d<s32>::operator /(s32 val) const {return core::vector3d<s32>(X/val,Y/val,Z/val);}
template <>
inline vector3d<s32>& vector3d<s32>::operator /=(s32 val) {X/=val;Y/=val;Z/=val; return *this;}
SExposedVideoData.h
New constructors
SExposedVideoData() {OpenGLWin32.HDc=0; OpenGLWin32.HRc=0; OpenGLWin32.HWnd=0;}
explicit SExposedVideoData(void* Window) {OpenGLWin32.HDc=0; OpenGLWin32.HRc=0; OpenGLWin32.HWnd=Window;}
IGUIEnvironment.h
New method
virtual IGUIFont* addFont(const io::path& name, IGUIFont* font) = 0;
New parameter (image)
virtual IGUIWindow* addMessageBox(const wchar_t* caption, const wchar_t* text=0,
bool modal = true, s32 flags = EMBF_OK, IGUIElement* parent=0, s32 id=-1, video::ITexture* image=0) = 0;
IGeometryCreator.h
New method
IMesh* createPlaneMesh(const core::dimension2d<f32>& tileSize,
const core::dimension2d<u32>& tileCount,
video::SMaterial* material,
const core::dimension2d<f32>& textureRepeatCount) const
IFileArchive.h
New archive type
EFAT_NPK = MAKE_IRR_ID('N','P','K', 0),
New member for storing the password of AES-encrypted archives
core::stringc Password;
IFileSystem.h
New parameter (password)
virtual bool addFileArchive(const path& filename, bool ignoreCase=true,
bool ignorePaths=true,
E_FILE_ARCHIVE_TYPE archiveType=EFAT_UNKNOWN,
const core::stringc& password="") =0;
IrrlichtDevice.h
New method
virtual void clearSystemMessages() = 0;
irrMath.h
Changed constant (from 1)
const s32 ROUNDING_ERROR_S32 = 0;
New method
template <class T>
inline void swap(T& a, T& b)
IGPUProgrammingServices.h
New parameters (for geometry shaders)
virtual s32 addHighLevelShaderMaterial
virtual s32 addHighLevelShaderMaterialFromFiles
virtual s32 addHighLevelShaderMaterialFromFiles
New overload (for calling with geometry shaders)
s32 addHighLevelShaderMaterial
s32 addHighLevelShaderMaterialFromFiles
s32 addHighLevelShaderMaterialFromFiles
ISceneNode.h
New types
typedef core::list<ISceneNode*> ISceneNodeList;
typedef core::list<ISceneNodeAnimator*> ISceneNodeAnimatorList;
IEventReceiver.h
Renamed events (split from EMIE_MOUSE_*)
EMIE_LMOUSE_DOUBLE_CLICK,
EMIE_RMOUSE_DOUBLE_CLICK,
EMIE_MMOUSE_DOUBLE_CLICK,
EMIE_LMOUSE_TRIPLE_CLICK,
EMIE_RMOUSE_TRIPLE_CLICK,
EMIE_MMOUSE_TRIPLE_CLICK,
IGUISpriteBank.h
New method
virtual s32 addTextureAsSprite(video::ITexture* texture) = 0;
virtual void clear() = 0;
SMaterial.h
Changed binary packing (non-visible from user calls)
inline f32 pack_texureBlendFunc ( const E_BLEND_FACTOR srcFact, const E_BLEND_FACTOR dstFact, const E_MODULATE_FUNC modulate=EMFN_MODULATE_1X, const u32 alphaSource=EAS_TEXTURE )
IGUISkin.h
New values
EGDS_MESSAGE_BOX_GAP_SPACE,
EGDS_MESSAGE_BOX_MIN_TEXT_WIDTH,
EGDS_MESSAGE_BOX_MAX_TEST_WIDTH,
EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT,
EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT,
New parameter (checkClientArea)
virtual core::rect<s32> draw3DWindowBackground(IGUIElement* element,
bool drawTitleBar, video::SColor titleBarColor,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0,
core::rect<s32>* checkClientArea=0) = 0;
quaternion.h
New operator
bool operator!=(const quaternion& other) const;
New method
inline quaternion& set(const core::quaternion& quat);
inline bool equals(const quaternion& other,
const f32 tolerance = ROUNDING_ERROR_f32 ) const;
irrList.h
New method
u32 size() const
void swap(list<T>& other)
IVideoDriver.h
New render targets
ERT_MULTI_RENDER_TEXTURES
New class
struct IRenderTarget
Changed parameter (from void*)
virtual bool beginScene(bool backBuffer=true, bool zBuffer=true,
SColor color=SColor(255,0,0,0),
const SExposedVideoData& videoData=SExposedVideoData(),
core::rect<s32>* sourceRect=0) =0;
New parameter (mipmapData)
virtual ITexture* addTexture(const io::path& name, IImage* image, void* mipmapData=0) = 0;
New method
virtual bool setRenderTarget(const core::array<video::IRenderTarget>& texture,
bool clearBackBuffer=true, bool clearZBuffer=true,
SColor color=video::SColor(0,0,0,0)) =0;
void drawIndexedTriangleFan(const S3DVertexTangents* vertices,
u32 vertexCount, const u16* indexList, u32 triangleCount)
virtual void getFog(SColor& color, E_FOG_TYPE& fogType,
f32& start, f32& end, f32& density,
bool& pixelFog, bool& rangeFog) = 0;
virtual SMaterial& getMaterial2D() =0;
virtual void enableMaterial2D(bool enable=true) =0;
virtual core::dimension2du getMaxTextureSize() const =0;
Made non-virtual
void drawIndexedTriangleList(const S3DVertex* vertices,
u32 vertexCount, const u16* indexList, u32 triangleCount)
void drawIndexedTriangleList(const S3DVertex2TCoords* vertices,
u32 vertexCount, const u16* indexList, u32 triangleCount)
void drawIndexedTriangleList(const S3DVertexTangents* vertices,
u32 vertexCount, const u16* indexList, u32 triangleCount)
void drawIndexedTriangleFan(const S3DVertex* vertices,
u32 vertexCount, const u16* indexList, u32 triangleCount)
void drawIndexedTriangleFan(const S3DVertex2TCoords* vertices,
u32 vertexCount, const u16* indexList, u32 triangleCount)
EDriverFeatures.h
New driver feature enums
EVDF_MULTIPLE_RENDER_TARGETS,
EVDF_MRT_BLEND,
EVDF_MRT_COLOR_MASK,
EVDF_MRT_BLEND_FUNC,
EVDF_GEOMETRY_SHADER,
IGUIWindow.h
New method
virtual core::rect<s32> getClientRect() const = 0;
IGUIContextMenu.h
New enum
enum ECONTEXT_MENU_CLOSE
New method
virtual void setCloseHandling(ECONTEXT_MENU_CLOSE onClose) = 0;
virtual ECONTEXT_MENU_CLOSE getCloseHandling() const = 0;
virtual u32 insertItem(u32 idx, const wchar_t* text, s32 commandId=-1, bool enabled=true,
bool hasSubMenu=false, bool checked=false, bool autoChecking=false) = 0;
virtual s32 findItemWithCommandId(s32 commandId, u32 idxStartSearch=0) const = 0;
virtual void setItemAutoChecking(u32 idx, bool autoChecking) = 0;
virtual bool getItemAutoChecking(u32 idx) const = 0;
virtual void setEventParent(IGUIElement *parent) = 0;
New parameter
virtual u32 addItem(const wchar_t* text, s32 commandId=-1, bool enabled=true,
bool hasSubMenu=false, bool checked=false, bool autoChecking=false) = 0;
SIrrCreationParameters.h
New parameter (LoggingLevel)
createDevice
matrix4.h
New method
bool equals(const core::CMatrix4<T>& other, const T tolerance=(T)ROUNDING_ERROR_f64) const;
SSkinMeshBuffer.h
Renamed method (from MoveTo_2TCoords)
virtual void convertTo2TCoords()
Renamed method (from MoveTo_Tangents)
virtual void convertToTangents()
SVertexManipulator.h
New classes (for vertex manipulation)
class SVertexColorSetManipulator : public IVertexManipulator
class SVertexColorSetAlphaManipulator : public IVertexManipulator
class SVertexColorInvertManipulator : public IVertexManipulator
class SVertexColorThresholdManipulator : public IVertexManipulator
class SVertexColorBrightnessManipulator : public IVertexManipulator
class SVertexColorContrastManipulator : public IVertexManipulator
class SVertexColorContrastBrightnessManipulator : public IVertexManipulator
class SVertexColorGammaManipulator : public IVertexManipulator
;
class SVertexColorScaleManipulator : public IVertexManipulator
class SVertexColorDesaturateToLightnessManipulator : public IVertexManipulator
class SVertexColorDesaturateToAverageManipulator : public IVertexManipulator
class SVertexColorDesaturateToLuminanceManipulator : public IVertexManipulator
class SVertexColorInterpolateLinearManipulator : public IVertexManipulator
class SVertexColorInterpolateQuadraticManipulator : public IVertexManipulator
class SVertexPositionScaleManipulator : public IVertexManipulator
;
class SVertexPositionScaleAlongNormalsManipulator : public IVertexManipulator
class SVertexPositionTransformManipulator : public IVertexManipulator
class SVertexTCoordsScaleManipulator : public IVertexManipulator
IMeshCache.h
Renamed method (from getMeshByFilename)
virtual IAnimatedMesh* getMeshByName(const io::path& name) = 0;
Renamed method and changed return type (from getMeshFilename/io::path)
virtual const io::SNamedPath& getMeshName(u32 index) const = 0;
virtual const io::SNamedPath& getMeshName(const IAnimatedMesh* const mesh) const = 0;
virtual const io::SNamedPath& getMeshName(const IMesh* const mesh) const = 0;
Renamed method (from setMeshFilename)
virtual bool renameMesh(u32 index, const io::path& name) = 0;
virtual bool renameMesh(const IAnimatedMesh* const mesh, const io::path& name) = 0;
virtual bool renameMesh(const IMesh* const mesh, const io::path& name) = 0;
IGUIElement.h
Changed parameter (to const-ref)
IGUIElement(EGUI_ELEMENT_TYPE type, IGUIEnvironment* environment, IGUIElement* parent,
s32 id, const core::rect<s32>& rectangle)
New method
virtual bool hasType(EGUI_ELEMENT_TYPE type) const
irrString.h
Changed parameter (to template with allocator) in all methods with templates
Made destructor non-virtual
~string()
Added parameter
s32 find(const B* const str, const u32 start = 0) const
New method
void remove(T c)
void remove(const string<T,TAlloc> toRemove)
void removeChars(const string<T,TAlloc> & characters)
template<class container>
u32 split(container& ret, const T* const c, u32 count=1, bool ignoreEmptyTokens=true, bool keepSeparators=false) const
vector2d.h
Use tolerance to compare, changed order function to total order
bool operator<=(const vector2d<T>&other) const
bool operator>=(const vector2d<T>&other) const
bool operator<(const vector2d<T>&other) const
bool operator>(const vector2d<T>&other) const

View File

@ -47,6 +47,9 @@ int main()
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.
Instead of copying this whole code into your app, you can simply include
driverChoice.h from Irrlicht's include directory. The function
driverChoiceConsole does exactly the same.
*/
// ask user for driver
@ -54,8 +57,8 @@ int main()
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"\
" (a) OpenGL 1.5\n (b) Direct3D 9.0c\n (c) Direct3D 8.1\n"\
" (d) Burning's Software Renderer\n (e) Software Renderer\n"\
" (f) NullDevice\n (otherKey) exit\n\n");
char i;
@ -63,11 +66,11 @@ int main()
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 'a': driverType = video::EDT_OPENGL; break;
case 'b': driverType = video::EDT_DIRECT3D9;break;
case 'c': driverType = video::EDT_DIRECT3D8;break;
case 'd': driverType = video::EDT_BURNINGSVIDEO;break;
case 'e': driverType = video::EDT_SOFTWARE; break;
case 'f': driverType = video::EDT_NULL; break;
default: return 1;
}

View File

@ -20,7 +20,7 @@ To start, I include the header files, use the irr namespace,
and tell the linker to link with the .lib file.
*/
#include <irrlicht.h>
#include <iostream>
#include "driverChoice.h"
using namespace irr;
@ -166,28 +166,10 @@ the engine, create the scene node and a camera, and look at the result.
*/
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;
}
// ask user for driver
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
// create device

View File

@ -18,7 +18,7 @@ and tell the linker to link with the .lib file.
#endif
#include <irrlicht.h>
#include <iostream>
#include "driverChoice.h"
using namespace irr;
@ -70,28 +70,10 @@ 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;
}
// ask user for driver
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
// create device
MyEventReceiver receiver;

View File

@ -11,7 +11,7 @@ a counter variable for changing the creation position of a window,
and a pointer to a listbox.
*/
#include <irrlicht.h>
#include <iostream>
#include "driverChoice.h"
using namespace irr;
@ -159,27 +159,9 @@ example:
int main()
{
// ask user for driver
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 1;
}
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
// create device and exit if creation failed

View File

@ -10,7 +10,7 @@ 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>
#include "driverChoice.h"
using namespace irr;
@ -24,28 +24,10 @@ 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;
}
// ask user for driver
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
// create device

View File

@ -1,17 +1,17 @@
/** Example 007 Collision
We will describe 2 methods: Automatic collision detection for moving through 3d worlds
with stair climbing and sliding, and manual scene node and triangle picking using a
ray. In this case, we will use a ray coming out from the camera, but you can use
any ray.
We will describe 2 methods: Automatic collision detection for moving through
3d worlds with stair climbing and sliding, and manual scene node and triangle
picking using a ray. In this case, we will use a ray coming out from the
camera, but you can use any ray.
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. In
addition we'll place 3 animated models into it for triangle picking. The
following code starts up the engine and loads a quake 3 level, as per 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.
In addition we'll place 3 animated models into it for triangle picking. The
following code starts up the engine and loads the level, as per tutorial 2.
*/
#include <irrlicht.h>
#include <iostream>
#include "driverChoice.h"
using namespace irr;
@ -37,28 +37,10 @@ enum
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;
}
// ask user for driver
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
// create device

View File

@ -14,6 +14,7 @@ runs slow on your hardware.
#include <irrlicht.h>
#include <iostream>
#include "driverChoice.h"
using namespace irr;
@ -33,26 +34,9 @@ int main()
const bool shadows = (i == 'y');
// ask user for driver
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");
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 1;
}
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
/*
Create device and exit if creation failed. We make the stencil flag

View File

@ -14,7 +14,7 @@ statements, so we do not need to write the whole names of all classes. In this
tutorial, we use a lot stuff from the gui namespace.
*/
#include <irrlicht.h>
#include <iostream>
#include "driverChoice.h"
using namespace irr;
using namespace gui;
@ -648,27 +648,9 @@ is quite useful for a mesh viewer.
int main(int argc, char* argv[])
{
// ask user for driver
video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D8;
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 key;
std::cin >> key;
switch(key)
{
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 1;
}
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
// create device and exit if creation failed
MyEventReceiver receiver;

View File

@ -14,6 +14,7 @@ nearly all other tutorials:
*/
#include <irrlicht.h>
#include <iostream>
#include "driverChoice.h"
using namespace irr;
@ -114,33 +115,16 @@ in this example, if he selected a driver which is capable of doing so.
*/
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 1;
}
// ask user for driver
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
// ask the user if we should use high level shaders for this example
if (driverType == video::EDT_DIRECT3D9 ||
driverType == video::EDT_OPENGL)
{
char i;
printf("Please press 'y' if you want to use high level shaders.\n");
std::cin >> i;
if (i == 'y')

View File

@ -9,7 +9,7 @@ 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>
#include "driverChoice.h"
using namespace irr;
@ -277,8 +277,8 @@ int main()
EMF_FOG_ENABLE to true to enable fog in the room.
*/
scene::IMesh* tangentMesh = smgr->getMeshManipulator()->createMeshWithTangents(
roomMesh->getMesh(0));
scene::IMesh* tangentMesh = smgr->getMeshManipulator()->
createMeshWithTangents(roomMesh->getMesh(0));
room = smgr->addMeshSceneNode(tangentMesh);
room->setMaterialTexture(0,

View File

@ -15,7 +15,7 @@ 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>
#include "driverChoice.h"
using namespace irr;
@ -79,33 +79,16 @@ private:
/*
The start of the main function starts like in most other example. We ask the user
for the desired renderer and start it up. This time with the advanced parameter handling.
The start of the main function starts like in most other example. We ask the
user for the desired renderer and start it up. This time with the advanced
parameter handling.
*/
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 1;
}
// ask user for driver
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
// create device with full flexibility over creation parameters
// you can add more parameters if desired, check irr::SIrrlichtCreationParameters

View File

@ -9,7 +9,7 @@ for the rendering driver, create the Irrlicht Device:
*/
#include <irrlicht.h>
#include <iostream>
#include "driverChoice.h"
using namespace irr;
@ -19,28 +19,10 @@ using namespace irr;
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 1;
}
// ask user for driver
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
// create device and exit if creation failed

View File

@ -15,6 +15,7 @@ windows book for details.
#else
#include <windows.h> // this example only runs with windows
#include <iostream>
#include "driverChoice.h"
using namespace irr;
@ -55,30 +56,11 @@ static LRESULT CALLBACK CustomWndProc(HWND hWnd, UINT message,
Now ask for the driver and create the Windows specific window.
*/
int main()
//int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hpre, LPSTR cmd, int cc)
{
// ask user for driver
video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D8;
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 key;
std::cin >> key;
switch(key)
{
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 1;
}
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
printf("Select the render window (some dead window may exist too):\n"\
" (a) Window with button (via CreationParam)\n"\
@ -86,6 +68,7 @@ int main()
" (c) Own Irrlicht window (default behavior)\n"\
" (otherKey) exit\n\n");
char key;
std::cin >> key;
if (key != 'a' && key != 'b' && key != 'c')
return 1;

View File

@ -11,7 +11,8 @@ Lets start: Create an Irrlicht device and setup the window.
*/
#include <irrlicht.h>
#include <iostream>
#include "driverChoice.h"
using namespace irr;
#ifdef _MSC_VER
@ -21,27 +22,9 @@ using namespace irr;
int main(int argc, char** argv)
{
// ask user for driver
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 1;
}
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
// create device and exit if creation failed

View File

@ -9,7 +9,7 @@ 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>
#include "driverChoice.h"
/*
define which Quake3 Level should be loaded
@ -36,20 +36,6 @@ to ask the user for a driver type using the console.
#define QUAKE3_MAP_NAME "maps/20kdm2.bsp"
#endif
/*
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.
*/
using namespace irr;
using namespace scene;
@ -63,7 +49,9 @@ to make it easy, we use a pragma comment lib:
#endif
//! produces a serie of screenshots
/*
A class to produce a series of screenshots
*/
class CScreenShotFactory : public IEventReceiver
{
public:
@ -129,27 +117,9 @@ int IRRCALLCONV main(int argc, char* argv[])
*/
// ask user for driver
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 1;
}
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
// create device and exit if creation failed
const core::dimension2du videoDim(800,600);
@ -222,7 +192,7 @@ int IRRCALLCONV main(int argc, char* argv[])
if (mesh)
{
scene::IMesh * const geometry = mesh->getMesh(quake3::E_Q3_MESH_GEOMETRY);
node = smgr->addOctreeSceneNode(geometry, 0, -1, 1024);
node = smgr->addOctreeSceneNode(geometry, 0, -1, 4096);
}
// create an event receiver for making screenshots

View File

@ -11,7 +11,7 @@ nothing to say about it)
*/
#include <irrlicht.h>
#include <iostream>
#include "driverChoice.h"
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
@ -75,26 +75,10 @@ Just take care of the maps position.
*/
int main(int argc, char** argv)
{
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 1;
}
// ask user for driver
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
//Instance of the EventReceiver
MyEventReceiver receiver;

View File

@ -14,7 +14,7 @@ devices.
#endif
#include <irrlicht.h>
#include <iostream>
#include "driverChoice.h"
using namespace irr;
@ -102,28 +102,10 @@ 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;
}
// ask user for driver
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
// create device
MyEventReceiver receiver;

View File

@ -7,14 +7,10 @@ node callbacks, are left out for simplicity of the example.
*/
#include <irrlicht.h>
#include <iostream>
#include "driverChoice.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#if defined(_MSC_VER)
#pragma comment(lib, "Irrlicht.lib")
@ -51,7 +47,7 @@ using namespace gui;
This light manager is also an event receiver; this is purely for simplicity in this example,
it's neither necessary nor recommended for a real application.
*/
class CMyLightManager : public ILightManager, public IEventReceiver
class CMyLightManager : public scene::ILightManager, public IEventReceiver
{
typedef enum
{
@ -66,16 +62,16 @@ class CMyLightManager : public ILightManager, public IEventReceiver
// These data represent the state information that this light manager
// is interested in.
ISceneManager * SceneManager;
core::array<ILightSceneNode*> * SceneLightList;
E_SCENE_NODE_RENDER_PASS CurrentRenderPass;
ISceneNode * CurrentSceneNode;
scene::ISceneManager * SceneManager;
core::array<scene::ILightSceneNode*> * SceneLightList;
scene::E_SCENE_NODE_RENDER_PASS CurrentRenderPass;
scene::ISceneNode * CurrentSceneNode;
public:
CMyLightManager(ISceneManager* sceneManager)
CMyLightManager(scene::ISceneManager* sceneManager)
: Mode(NO_MANAGEMENT), RequestedMode(NO_MANAGEMENT),
SceneManager(sceneManager), SceneLightList(0),
CurrentRenderPass(ESNRP_NONE), CurrentSceneNode(0)
CurrentRenderPass(scene::ESNRP_NONE), CurrentSceneNode(0)
{ }
virtual ~CMyLightManager(void) { }
@ -115,7 +111,7 @@ public:
// This is called before the first scene node is rendered.
virtual void OnPreRender(core::array<ILightSceneNode*> & lightList)
virtual void OnPreRender(core::array<scene::ILightSceneNode*> & lightList)
{
// Update the mode; changing it here ensures that it's consistent throughout a render
Mode = RequestedMode;
@ -135,16 +131,16 @@ public:
(*SceneLightList)[i]->setVisible(true);
}
virtual void OnRenderPassPreRender(E_SCENE_NODE_RENDER_PASS renderPass)
virtual void OnRenderPassPreRender(scene::E_SCENE_NODE_RENDER_PASS renderPass)
{
// I don't have to do anything here except remember which render pass I am in.
CurrentRenderPass = renderPass;
}
virtual void OnRenderPassPostRender(E_SCENE_NODE_RENDER_PASS renderPass)
virtual void OnRenderPassPostRender(scene::E_SCENE_NODE_RENDER_PASS renderPass)
{
// I only want solid nodes to be lit, so after the solid pass, turn all lights off.
if(ESNRP_SOLID == renderPass)
if(scene::ESNRP_SOLID == renderPass)
{
for(u32 i = 0; i < SceneLightList->size(); ++i)
(*SceneLightList)[i]->setVisible(false);
@ -152,22 +148,22 @@ public:
}
// This is called before the specified scene node is rendered
virtual void OnNodePreRender(ISceneNode* node)
virtual void OnNodePreRender(scene::ISceneNode* node)
{
CurrentSceneNode = node;
// This light manager only considers solid objects, but you are free to manipulate
// lights during any phase, depending on your requirements.
if(ESNRP_SOLID != CurrentRenderPass)
if (scene::ESNRP_SOLID != CurrentRenderPass)
return;
// And in fact for this example, I only want to consider lighting for cube scene
// nodes. You will probably want to deal with lighting for (at least) mesh /
// animated mesh scene nodes as well.
if(node->getType() != ESNT_CUBE)
if (node->getType() != scene::ESNT_CUBE)
return;
if(LIGHTS_NEAREST_NODE == Mode)
if (LIGHTS_NEAREST_NODE == Mode)
{
// This is a naive implementation that prioritises every light in the scene
// by its proximity to the node being rendered. This produces some flickering
@ -182,7 +178,7 @@ public:
u32 i;
for(i = 0; i < SceneLightList->size(); ++i)
{
ILightSceneNode* lightNode = (*SceneLightList)[i];
scene::ILightSceneNode* lightNode = (*SceneLightList)[i];
f64 distance = lightNode->getAbsolutePosition().getDistanceFromSQ(nodePosition);
sortingArray.push_back(LightDistanceElement(lightNode, distance));
}
@ -202,23 +198,23 @@ public:
// on all lights that are found under that node in the scene graph.
// This is a general purpose algorithm that doesn't use any special
// knowledge of how this particular scene graph is organised.
for(u32 i = 0; i < SceneLightList->size(); ++i)
for (u32 i = 0; i < SceneLightList->size(); ++i)
{
ILightSceneNode* lightNode = (*SceneLightList)[i];
SLight & lightData = lightNode->getLightData();
scene::ILightSceneNode* lightNode = (*SceneLightList)[i];
video::SLight & lightData = lightNode->getLightData();
if(ELT_DIRECTIONAL != lightData.Type)
if (video::ELT_DIRECTIONAL != lightData.Type)
lightNode->setVisible(false);
}
ISceneNode * parentZone = findZone(node);
if(parentZone)
scene::ISceneNode * parentZone = findZone(node);
if (parentZone)
turnOnZoneLights(parentZone);
}
}
// Called after the specified scene node is rendered
virtual void OnNodePostRender(ISceneNode* node)
virtual void OnNodePostRender(scene::ISceneNode* node)
{
// I don't need to do any light management after individual node rendering.
}
@ -226,12 +222,12 @@ public:
private:
// Find the empty scene node that is the parent of the specified node
ISceneNode * findZone(ISceneNode * node)
scene::ISceneNode * findZone(scene::ISceneNode * node)
{
if(!node)
return 0;
if(node->getType() == ESNT_EMPTY)
if(node->getType() == scene::ESNT_EMPTY)
return node;
return findZone(node->getParent());
@ -239,15 +235,15 @@ private:
// Turn on all lights that are children (directly or indirectly) of the
// specified scene node.
void turnOnZoneLights(ISceneNode * node)
void turnOnZoneLights(scene::ISceneNode * node)
{
core::list<ISceneNode*> const & children = node->getChildren();
for (core::list<ISceneNode*>::ConstIterator child = children.begin();
core::list<scene::ISceneNode*> const & children = node->getChildren();
for (core::list<scene::ISceneNode*>::ConstIterator child = children.begin();
child != children.end();
++child)
{
if((*child)->getType() == ESNT_LIGHT)
static_cast<ILightSceneNode*>(*child)->setVisible(true);
if((*child)->getType() == scene::ESNT_LIGHT)
static_cast<scene::ILightSceneNode*>(*child)->setVisible(true);
else // Assume that lights don't have any children that are also lights
turnOnZoneLights(*child);
}
@ -260,10 +256,10 @@ private:
public:
LightDistanceElement() {};
LightDistanceElement(ILightSceneNode* n, f64 d)
LightDistanceElement(scene::ILightSceneNode* n, f64 d)
: node(n), distance(d) { }
ILightSceneNode* node;
scene::ILightSceneNode* node;
f64 distance;
// Lower distance elements are sorted to the start of the array
@ -279,48 +275,27 @@ private:
*/
int main(int argumentCount, char * argumentValues[])
{
char driverChoice;
// ask user for driver
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
if(argumentCount > 1)
driverChoice = argumentValues[1][0];
else
{
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");
IrrlichtDevice *device = createDevice(driverType,
dimension2d<u32>(640, 480), 32);
std::cin >> driverChoice;
}
video::E_DRIVER_TYPE driverType;
switch(driverChoice)
{
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;
}
IrrlichtDevice *device = createDevice(driverType, dimension2d<u32>(640, 480), 32,
false, false, false, 0);
if(!device)
return -1;
f32 const lightRadius = 60.f; // Enough to reach the far side of each 'zone'
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* guienv = device->getGUIEnvironment();
gui::IGUISkin* skin = guienv->getSkin();
if (skin)
{
skin->setColor(EGDC_BUTTON_TEXT, SColor(255, 255, 255, 255));
skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255, 255, 255, 255));
gui::IGUIFont* font = guienv->getFont("../../media/fontlucida.png");
if(font)
skin->setFont(font);
@ -337,38 +312,38 @@ Add several "zones". You could use this technique to light individual rooms, fo
for(f32 zoneY = -60.f; zoneY <= 60.f; zoneY += 60.f)
{
// Start with an empty scene node, which we will use to represent a zone.
ISceneNode * zoneRoot = smgr->addEmptySceneNode();
scene::ISceneNode * zoneRoot = smgr->addEmptySceneNode();
zoneRoot->setPosition(vector3df(zoneX, zoneY, 0));
// Each zone contains a rotating cube
IMeshSceneNode * node = smgr->addCubeSceneNode(15, zoneRoot);
ISceneNodeAnimator * rotation = smgr->createRotationAnimator(vector3df(0.25f, 0.5f, 0.75f));
scene::IMeshSceneNode * node = smgr->addCubeSceneNode(15, zoneRoot);
scene::ISceneNodeAnimator * rotation = smgr->createRotationAnimator(vector3df(0.25f, 0.5f, 0.75f));
node->addAnimator(rotation);
rotation->drop();
// And each cube has three lights attached to it. The lights are attached to billboards so
// that we can see where they are. The billboards are attached to the cube, so that the
// lights are indirect descendents of the same empty scene node as the cube.
IBillboardSceneNode * billboard = smgr->addBillboardSceneNode(node);
scene::IBillboardSceneNode * billboard = smgr->addBillboardSceneNode(node);
billboard->setPosition(vector3df(0, -14, 30));
billboard->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );
billboard->setMaterialTexture(0, driver->getTexture("../../media/particle.bmp"));
billboard->setMaterialFlag(video::EMF_LIGHTING, false);
ILightSceneNode * light = smgr->addLightSceneNode(billboard, vector3df(0, 0, 0), SColorf(1, 0, 0), lightRadius);
scene::ILightSceneNode * light = smgr->addLightSceneNode(billboard, vector3df(0, 0, 0), video::SColorf(1, 0, 0), lightRadius);
billboard = smgr->addBillboardSceneNode(node);
billboard->setPosition(vector3df(-21, -14, -21));
billboard->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );
billboard->setMaterialTexture(0, driver->getTexture("../../media/particle.bmp"));
billboard->setMaterialFlag(video::EMF_LIGHTING, false);
light = smgr->addLightSceneNode(billboard, vector3df(0, 0, 0), SColorf(0, 1, 0), lightRadius);
light = smgr->addLightSceneNode(billboard, vector3df(0, 0, 0), video::SColorf(0, 1, 0), lightRadius);
billboard = smgr->addBillboardSceneNode(node);
billboard->setPosition(vector3df(21, -14, -21));
billboard->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );
billboard->setMaterialTexture(0, driver->getTexture("../../media/particle.bmp"));
billboard->setMaterialFlag(video::EMF_LIGHTING, false);
light = smgr->addLightSceneNode(billboard, vector3df(0, 0, 0), SColorf(0, 0, 1), lightRadius);
light = smgr->addLightSceneNode(billboard, vector3df(0, 0, 0), video::SColorf(0, 0, 1), lightRadius);
// Each cube also has a smaller cube rotating around it, to show that the cubes are being
// lit by the lights in their 'zone', not just lights that are their direct children.
@ -386,7 +361,7 @@ Add several "zones". You could use this technique to light individual rooms, fo
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
driver->beginScene(true, true, video::SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();

View File

@ -21,7 +21,7 @@ Copyright 2006-2009 Burningwater, Thomas Alten
#include "q3factory.h"
#include "sound.h"
#include <iostream>
#include "driverChoice.h"
/*
Game Data is used to hold Data which is needed to drive the game
@ -1771,6 +1771,7 @@ void CQuake3EventHandler::useItem( Q3Player * player)
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMaterialTexture(0, Game->Device->getVideoDriver()->getTexture("fireball.bmp"));
node->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
node->setMaterialType(EMT_TRANSPARENT_ADD_COLOR);
f32 length = (f32)(end - start).getLength();
@ -1884,6 +1885,7 @@ void CQuake3EventHandler::createParticleImpacts( u32 now )
anim->drop();
pas->setMaterialFlag(video::EMF_LIGHTING, false);
pas->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
pas->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA );
pas->setMaterialTexture(0, Game->Device->getVideoDriver()->getTexture( smoke[g].texture ));
}
@ -1923,8 +1925,85 @@ void CQuake3EventHandler::Render()
if ( 0 == driver )
return;
driver->beginScene(true, true, SColor(0,0,0,0));
Game->Device->getSceneManager ()->drawAll();
// TODO: This does not work, yet.
const bool anaglyph=false;
if (anaglyph)
{
scene::ICameraSceneNode* cameraOld = Game->Device->getSceneManager()->getActiveCamera();
driver->beginScene(true, true, SColor(0,0,0,0));
driver->getOverrideMaterial().Material.ColorMask = ECP_NONE;
driver->getOverrideMaterial().EnableFlags = EMF_COLOR_MASK;
driver->getOverrideMaterial().EnablePasses = ESNRP_SKY_BOX +
ESNRP_SOLID +
ESNRP_TRANSPARENT +
ESNRP_TRANSPARENT_EFFECT +
ESNRP_SHADOW;
Game->Device->getSceneManager()->drawAll();
driver->clearZBuffer();
const vector3df oldPosition = cameraOld->getPosition();
const vector3df oldTarget = cameraOld->getTarget();
const matrix4 startMatrix = cameraOld->getAbsoluteTransformation();
const vector3df focusPoint = (oldTarget -
cameraOld->getAbsolutePosition()).setLength(10000) +
cameraOld->getAbsolutePosition() ;
scene::ICameraSceneNode* camera = cameraOld;//Game->Device->getSceneManager()->addCameraSceneNode();
//Left eye...
vector3df pos;
matrix4 move;
move.setTranslation( vector3df(-1.5f,0.0f,0.0f) );
pos=(startMatrix*move).getTranslation();
driver->getOverrideMaterial().Material.ColorMask = ECP_RED;
driver->getOverrideMaterial().EnableFlags = EMF_COLOR_MASK;
driver->getOverrideMaterial().EnablePasses =
ESNRP_SKY_BOX|ESNRP_SOLID|ESNRP_TRANSPARENT|
ESNRP_TRANSPARENT_EFFECT|ESNRP_SHADOW;
camera->setPosition(pos);
camera->setTarget(focusPoint);
Game->Device->getSceneManager()->drawAll();
driver->clearZBuffer();
//Right eye...
move.setTranslation( vector3df(1.5f,0.0f,0.0f) );
pos=(startMatrix*move).getTranslation();
driver->getOverrideMaterial().Material.ColorMask = ECP_GREEN + ECP_BLUE;
driver->getOverrideMaterial().EnableFlags = EMF_COLOR_MASK;
driver->getOverrideMaterial().EnablePasses =
ESNRP_SKY_BOX|ESNRP_SOLID|ESNRP_TRANSPARENT|
ESNRP_TRANSPARENT_EFFECT|ESNRP_SHADOW;
camera->setPosition(pos);
camera->setTarget(focusPoint);
Game->Device->getSceneManager()->drawAll();
driver->getOverrideMaterial().Material.ColorMask=ECP_ALL;
driver->getOverrideMaterial().EnableFlags=0;
driver->getOverrideMaterial().EnablePasses=0;
if (camera != cameraOld)
{
Game->Device->getSceneManager()->setActiveCamera(cameraOld);
camera->remove();
}
else
{
camera->setPosition(oldPosition);
camera->setTarget(oldTarget);
}
}
else
{
driver->beginScene(true, true, SColor(0,0,0,0));
Game->Device->getSceneManager()->drawAll();
}
Game->Device->getGUIEnvironment()->drawAll();
driver->endScene();
}
@ -2083,23 +2162,10 @@ int IRRCALLCONV main(int argc, char* argv[])
if ( game.retVal == 0 )
{
game.setDefault ();
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 Video (TM) Thomas Alten\n"\
" (otherKey) exit\n\n");
char i = 'a';
std::cin >> i;
switch(i)
{
case 'a': game.deviceParam.DriverType = EDT_DIRECT3D9;break;
case 'b': game.deviceParam.DriverType = EDT_DIRECT3D8;break;
case 'c': game.deviceParam.DriverType = EDT_OPENGL; break;
case 'd': game.deviceParam.DriverType = EDT_SOFTWARE; break;
case 'e': game.deviceParam.DriverType = EDT_BURNINGSVIDEO;break;
default: game.retVal = 3; break;
}
// ask user for driver
game.deviceParam.DriverType=driverChoiceConsole();
if (game.deviceParam.DriverType==video::EDT_COUNT)
game.retVal = 3;
}
runGame ( &game );
} while ( game.retVal < 3 );
@ -2109,4 +2175,3 @@ int IRRCALLCONV main(int argc, char* argv[])
/*
**/

View File

@ -5,11 +5,10 @@ Only the default non-shader materials are used in here.
You have two nodes to make it easier to see which difference your settings will make.
Additionally you have one lightscenenode and you can set the global ambient values.
*/
#include <irrlicht.h>
#include <iostream>
#include "driverChoice.h"
using namespace irr;
@ -791,9 +790,9 @@ protected:
// returns true when it was succesful initialized, otherwise false.
bool init(int argc, char *argv[])
{
// ask user for the driver which should be used
Config.DriverType = getDriverTypeFromConsole();
if ( (int)Config.DriverType < 0 )
// ask user for driver
Config.DriverType=driverChoiceConsole();
if (Config.DriverType==video::EDT_COUNT)
return false;
// create the device with the settings from our config
@ -870,30 +869,6 @@ protected:
return true;
}
// Ask the user which driver to use
video::E_DRIVER_TYPE getDriverTypeFromConsole()
{
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': return video::EDT_DIRECT3D9;
case 'b': return video::EDT_DIRECT3D8;
case 'c': return video::EDT_OPENGL;
case 'd': return video::EDT_SOFTWARE;
case 'e': return video::EDT_BURNINGSVIDEO;
case 'f': return video::EDT_NULL;
default: return video::E_DRIVER_TYPE(-1);
}
}
// Update one frame
bool update()
{

View File

@ -11,7 +11,7 @@ Ok, let's start with the headers (I think there's nothing to say about it)
*/
#include <irrlicht.h>
#include <iostream>
#include "driverChoice.h"
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
@ -327,26 +327,9 @@ the user to navigate around it.
int main(int argc, char* argv[])
{
// ask user for driver
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 1;
}
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
MyEventReceiver receiver;
IrrlichtDevice* device = createDevice(driverType,

View File

@ -714,6 +714,7 @@ void CDemo::createParticleImpacts()
paf->drop();
pas->setMaterialFlag(video::EMF_LIGHTING, false);
pas->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
pas->setMaterialTexture(0, device->getVideoDriver()->getTexture("../../media/smoke.bmp"));
pas->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);

View File

@ -50,7 +50,10 @@ namespace video
//! OpenGL device, available on most platforms.
/** Performs hardware accelerated rendering of 3D and 2D
primitives. */
EDT_OPENGL
EDT_OPENGL,
//! No driver, just for counting the elements
EDT_COUNT
};
} // end namespace video

View File

@ -180,10 +180,12 @@ namespace irr
//! A checkbox has changed its check state.
EGET_CHECKBOX_CHANGED,
//! A new item in a listbox was seleted.
//! A new item in a listbox was selected.
/** NOTE: You also get this event currently when the same item was clicked again after more than 500 ms. */
EGET_LISTBOX_CHANGED,
//! An item in the listbox was selected, which was already selected.
/** NOTE: You get the event currently only if the item was clicked again within 500 ms or selected by "enter" or "space". */
EGET_LISTBOX_SELECTED_AGAIN,
//! A file has been selected in the file dialog

View File

@ -35,7 +35,7 @@ public:
//! Opens a file for read access.
/** \param filename: Name of file to open.
\return Returns a pointer to the created file interface.
\return Pointer to the created file interface.
The returned pointer should be dropped when no longer needed.
See IReferenceCounted::drop() for more information. */
virtual IReadFile* createAndOpenFile(const path& filename) =0;
@ -47,7 +47,7 @@ public:
\param fileName: The name given to this file
\param deleteMemoryWhenDropped: True if the memory should be deleted
along with the IReadFile when it is dropped.
\return Returns a pointer to the created file interface.
\return Pointer to the created file interface.
The returned pointer should be dropped when no longer needed.
See IReferenceCounted::drop() for more information.
*/
@ -74,7 +74,7 @@ public:
\param fileName: The name given to this file
\param deleteMemoryWhenDropped: True if the memory should be deleted
along with the IWriteFile when it is dropped.
\return Returns a pointer to the created file interface.
\return Pointer to the created file interface.
The returned pointer should be dropped when no longer needed.
See IReferenceCounted::drop() for more information.
*/
@ -85,7 +85,7 @@ public:
/** \param filename: Name of file to open.
\param append: If the file already exist, all write operations are
appended to the file.
\return Returns a pointer to the created file interface. 0 is returned, if the
\return Pointer to the created file interface. 0 is returned, if the
file could not created or opened for writing.
The returned pointer should be dropped when no longer needed.
See IReferenceCounted::drop() for more information. */
@ -99,6 +99,8 @@ public:
default Irrlicht supports ZIP, PAK, TAR, PNK, and directories as
archives. You can provide your own archive types by implementing
IArchiveLoader and passing an instance to addArchiveLoader.
Irrlicht supports AES-encrypted zip files, and the advanced compression
techniques lzma and bzip2.
\param filename: Filename of the archive to add to the file system.
\param ignoreCase: If set to true, files in the archive can be accessed without
writing all letters in the right case.
@ -109,7 +111,7 @@ public:
you use a different extension then you can use this parameter to force
a specific type of archive.
\param password An optional password, which is used in case of encrypted archives.
\return Returns true if the archive was added successfully, false if not. */
\return True if the archive was added successfully, false if not. */
virtual bool addFileArchive(const path& filename, bool ignoreCase=true,
bool ignorePaths=true,
E_FILE_ARCHIVE_TYPE archiveType=EFAT_UNKNOWN,
@ -120,14 +122,14 @@ public:
engine, for example proprietary or encrypted file storage. */
virtual void addArchiveLoader(IArchiveLoader* loader) =0;
//! Returns the number of archives currently attached to the file system
//! Get the number of archives currently attached to the file system
virtual u32 getFileArchiveCount() const =0;
//! Removes an archive from the file system.
/** This will close the archive and free any file handles, but will not close resources which have already
been loaded and are now cached, for example textures and meshes.
\param index: The index of the archive to remove
\return Returns true on success, false on failure */
\return True on success, false on failure */
virtual bool removeFileArchive(u32 index) =0;
//! Removes an archive from the file system.
@ -135,7 +137,7 @@ public:
close resources which have already been loaded and are now cached, for
example textures and meshes.
\param filename The archive of the given name will be removed
\return Returns true on success, false on failure */
\return True on success, false on failure */
virtual bool removeFileArchive(const path& filename) =0;
//! Changes the search order of attached archives.
@ -144,7 +146,7 @@ public:
\param relative: The relative change in position, archives with a lower index are searched first */
virtual bool moveFileArchive(u32 sourceIndex, s32 relative) =0;
//! Returns the archive at a given index.
//! Get the archive at a given index.
virtual IFileArchive* getFileArchive(u32 index) =0;
//! Adds a zip archive to the file system.
@ -159,7 +161,7 @@ public:
writing all letters in the right case.
\param ignorePaths: If set to true, files in the added archive can be accessed
without its complete path.
\return Returns true if the archive was added successfully, false if not. */
\return True if the archive was added successfully, false if not. */
virtual bool addZipFileArchive(const c8* filename, bool ignoreCase=true, bool ignorePaths=true)
{
return addFileArchive(filename, ignoreCase, ignorePaths, EFAT_ZIP);
@ -175,7 +177,7 @@ public:
writing all letters in the right case.
\param ignorePaths: If set to true, files in the added archive can be accessed
without its complete path.
\return Returns true if the archive was added successful, false if not. */
\return True if the archive was added successful, false if not. */
virtual bool addFolderFileArchive(const c8* filename, bool ignoreCase=true, bool ignorePaths=true)
{
return addFileArchive(filename, ignoreCase, ignorePaths, EFAT_FOLDER);
@ -193,7 +195,7 @@ public:
writing all letters in the right case.
\param ignorePaths: If set to true, files in the added archive can be accessed
without its complete path.(should not use with Quake2 paks
\return Returns true if the archive was added successful, false if not. */
\return True if the archive was added successful, false if not. */
virtual bool addPakFileArchive(const c8* filename, bool ignoreCase=true, bool ignorePaths=true)
{
return addFileArchive(filename, ignoreCase, ignorePaths, EFAT_PAK);
@ -215,12 +217,12 @@ public:
\result Absolute filename which points to the same file. */
virtual path getAbsolutePath(const path& filename) const =0;
//! Returns the directory a file is located in.
//! Get the directory a file is located in.
/** \param filename: The file to get the directory from.
\return String containing the directory of the file. */
virtual path getFileDir(const path& filename) const =0;
//! Returns the base part of a filename, i.e. the name without the directory part.
//! Get the base part of a filename, i.e. the name without the directory part.
/** If no directory is prefixed, the full name is returned.
\param filename: The file to get the basename from
\param keepExtension True if filename with extension is returned otherwise everything
@ -247,7 +249,7 @@ public:
//! 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. */
\return True if file exists, and false if it does not exist or an error occured. */
virtual bool existFile(const path& filename) const =0;
//! Creates a XML Reader from a file which returns all parsed strings as wide characters (wchar_t*).

View File

@ -78,7 +78,7 @@ namespace gui
//! sets the selected item. Set this to 0 if no item should be selected
virtual void setSelected(const wchar_t *item) = 0;
//! set whether the listbox should scroll to new or newly selected items
//! set whether the listbox should scroll to newly selected items
virtual void setAutoScrollEnabled(bool scroll) = 0;
//! returns true if automatic scrolling is enabled, false if not.

View File

@ -64,6 +64,16 @@ namespace scene
\param angleWeighted: If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision. */
virtual void recalculateNormals(IMeshBuffer* buffer, bool smooth = false, bool angleWeighted = false) const = 0;
//! Recalculates tangents, requires a tangent mesh
/** \param mesh Mesh on which the operation is performed.
\param recalculateNormals If the normals shall be recalculated, otherwise original normals of the mesh are used unchanged.
\param smooth If the normals shall be smoothed.
\param angleWeighted If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision.
*/
virtual void recalculateTangents(IMesh* mesh,
bool recalculateNormals=false, bool smooth=false,
bool angleWeighted=false) const=0;
//! Scales the actual mesh, not a scene node.
/** \param mesh Mesh on which the operation is performed.
\param factor Scale factor for each axis. */
@ -171,11 +181,12 @@ namespace scene
\param smooth The normals/tangents are smoothed across the
meshbuffer's faces if this flag is set.
\param angleWeighted Improved smoothing calculation used
\param recalculateTangents Whether are actually calculated, or just the mesh with proper type is created.
\return Mesh consisting only of S3DVertexTangents vertices. If
you no longer need the cloned mesh, you should call
IMesh::drop(). See IReferenceCounted::drop() for more
information. */
virtual IMesh* createMeshWithTangents(IMesh* mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const = 0;
virtual IMesh* createMeshWithTangents(IMesh* mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false, bool recalculateTangents=true) const = 0;
//! Creates a copy of the mesh, which will only consist of S3DVertex2TCoord vertices.
/** \param mesh Input mesh

42
include/driverChoice.h Normal file
View File

@ -0,0 +1,42 @@
// Copyright (C) 2009-2010 Christian Stehno
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __E_DRIVER_CHOICE_H_INCLUDED__
#define __E_DRIVER_CHOICE_H_INCLUDED__
#include <iostream>
#include "EDriverTypes.h"
namespace irr
{
//! ask user for driver
static irr::video::E_DRIVER_TYPE driverChoiceConsole(bool allDrivers=true)
{
const char* const names[] = {"NullDriver","Software Renderer","Burning's Video","Direct3D 8.1","Direct3D 9.0c","OpenGL 1.x/2.x/3.x"};
printf("Please select the driver you want:\n");
irr::u32 i=0;
for (i=irr::video::EDT_COUNT; i>0; --i)
{
if (allDrivers || (irr::IrrlichtDevice::isDriverSupported(irr::video::E_DRIVER_TYPE(i-1))))
printf(" (%c) %s\n", 'a'+irr::video::EDT_COUNT-i, names[i-1]);
}
char c;
std::cin >> c;
c = irr::video::EDT_COUNT+'a'-c;
for (i=irr::video::EDT_COUNT; i>0; --i)
{
if (!(allDrivers || (irr::IrrlichtDevice::isDriverSupported(irr::video::E_DRIVER_TYPE(i-1)))))
--c;
if ((char)i==c)
return irr::video::E_DRIVER_TYPE(i-1);
}
return irr::video::EDT_COUNT;
}
} // end namespace irr
#endif

View File

@ -82,6 +82,10 @@ class quaternion
//! Sets new quaternion from other quaternion
inline quaternion& set(const core::quaternion& quat);
//! returns if this quaternion equals the other one, taking floating point rounding errors into account
inline bool equals(const quaternion& other,
const f32 tolerance = ROUNDING_ERROR_f32 ) const;
//! Normalizes the quaternion
inline quaternion& normalize();
@ -462,6 +466,17 @@ inline quaternion& quaternion::set(const core::quaternion& quat)
return (*this=quat);
}
//! returns if this quaternion equals the other one, taking floating point rounding errors into account
inline bool quaternion::equals(const quaternion& other, const f32 tolerance) const
{
return core::equals(X, other.X, tolerance) &&
core::equals(Y, other.Y, tolerance) &&
core::equals(Z, other.Z, tolerance) &&
core::equals(W, other.W, tolerance);
}
// normalizes the quaternion
inline quaternion& quaternion::normalize()
{
@ -613,6 +628,17 @@ inline core::quaternion& quaternion::rotationFromTo(const vector3df& from, const
{
return makeIdentity();
}
else if (d <= -1.0f) // exactly opposite
{
core::vector3df axis(1.0f, 0.f, 0.f);
axis = axis.crossProduct(core::vector3df(X,Y,Z));
if (axis.getLength()==0)
{
axis.set(0.f,1.f,0.f);
axis.crossProduct(core::vector3df(X,Y,Z));
}
return this->fromAngleAxis(core::PI, axis);
}
const f32 s = sqrtf( (1+d)*2 ); // optimize inv_sqrt
const f32 invs = 1.f / s;

View File

@ -350,23 +350,6 @@ void CAnimatedMeshMD2::updateInterpolationBuffer(s32 frame, s32 startFrameLoop,
InterpolationBuffer->setDirty();
}
//! calculates the bounding box
void CAnimatedMeshMD2::calculateBoundingBox()
{
InterpolationBuffer->BoundingBox.reset(0,0,0);
if (FrameCount)
{
u32 defaultFrame = 1;
if (defaultFrame>=FrameCount)
defaultFrame = 0;
// for (u32 j=0; j<FrameList[defaultFrame].size(); ++j)
// InterpolationBuffer->BoundingBox.addInternalPoint(FrameList[defaultFrame].pointer()[j].Pos);
}
}
//! sets a flag of all contained materials to a new value
void CAnimatedMeshMD2::setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue)
@ -375,7 +358,6 @@ void CAnimatedMeshMD2::setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalu
}
//! set the hardware mapping hint, for driver
void CAnimatedMeshMD2::setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint,
E_BUFFER_TYPE buffer)

View File

@ -122,9 +122,6 @@ namespace scene
//! named animations
core::array< SAnimationData > AnimationData;
//! calculates the bounding box
virtual void calculateBoundingBox();
u32 FrameCount;
private:

View File

@ -440,9 +440,12 @@ bool CD3D8Driver::beginScene(bool backBuffer, bool zBuffer, SColor color,
if (StencilBuffer)
flags |= D3DCLEAR_STENCIL;
hr = pID3DDevice->Clear( 0, NULL, flags, color.color, 1.0, 0);
if (FAILED(hr))
os::Printer::log("Direct3D8 clear failed.", ELL_WARNING);
if (flags)
{
hr = pID3DDevice->Clear( 0, NULL, flags, color.color, 1.0, 0);
if (FAILED(hr))
os::Printer::log("Direct3D8 clear failed.", ELL_WARNING);
}
hr = pID3DDevice->BeginScene();
if (FAILED(hr))

View File

@ -513,9 +513,12 @@ bool CD3D9Driver::beginScene(bool backBuffer, bool zBuffer, SColor color,
if (StencilBuffer)
flags |= D3DCLEAR_STENCIL;
hr = pID3DDevice->Clear( 0, NULL, flags, color.color, 1.0, 0);
if (FAILED(hr))
os::Printer::log("DIRECT3D9 clear failed.", ELL_WARNING);
if (flags)
{
hr = pID3DDevice->Clear( 0, NULL, flags, color.color, 1.0, 0);
if (FAILED(hr))
os::Printer::log("DIRECT3D9 clear failed.", ELL_WARNING);
}
hr = pID3DDevice->BeginScene();
if (FAILED(hr))

View File

@ -194,6 +194,7 @@ bool CGUIFileOpenDialog::OnEvent(const SEvent& event)
FileDirectory = L"";
FileName = FileList->getFullFileName(selected);
}
return true;
}
}
break;
@ -213,8 +214,8 @@ bool CGUIFileOpenDialog::OnEvent(const SEvent& event)
else
{
FileName = FileList->getFullFileName(selected);
return true;
}
return true;
}
}
break;

View File

@ -76,7 +76,7 @@ namespace gui
//! skin through getIcon
virtual void setSpriteBank(IGUISpriteBank* bank);
//! sets if automatic scrolling is enabled or not. Default is true.
//! set whether the listbox should scroll to newly selected items
virtual void setAutoScrollEnabled(bool scroll);
//! returns true if automatic scrolling is enabled, false if not.

View File

@ -452,19 +452,11 @@ void CGUISkin::draw3DSunkenPane(IGUIElement* element, video::SColor bgcolor,
//! draws a window background
/** Used for drawing the background of dialogs and windows.
\param element: Pointer to the element which wishes to draw this. This parameter
is usually not used by ISkin, but can be used for example by more complex
implementations to find out how to draw the part exactly.
\param titleBarColor: Title color.
\param drawTitleBar: True to enable title drawing.
\param rect: Defining area where to draw.
\param clip: Clip area.
\return Returns rect where to draw title bar text. */
// return where to draw title bar text.
core::rect<s32> CGUISkin::draw3DWindowBackground(IGUIElement* element,
bool drawTitleBar, video::SColor titleBarColor,
const core::rect<s32>& r,
const core::rect<s32>* cl,
const core::rect<s32>* clip,
core::rect<s32>* checkClientArea)
{
if (!Driver)
@ -482,7 +474,7 @@ core::rect<s32> CGUISkin::draw3DWindowBackground(IGUIElement* element,
rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1;
if ( !checkClientArea )
{
Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, cl);
Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip);
}
// left border
@ -490,7 +482,7 @@ core::rect<s32> CGUISkin::draw3DWindowBackground(IGUIElement* element,
rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1;
if ( !checkClientArea )
{
Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, cl);
Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip);
}
// right border dark outer line
@ -500,7 +492,7 @@ core::rect<s32> CGUISkin::draw3DWindowBackground(IGUIElement* element,
rect.LowerRightCorner.Y = r.LowerRightCorner.Y;
if ( !checkClientArea )
{
Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, cl);
Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip);
}
// right border bright innner line
@ -510,7 +502,7 @@ core::rect<s32> CGUISkin::draw3DWindowBackground(IGUIElement* element,
rect.LowerRightCorner.Y -= 1;
if ( !checkClientArea )
{
Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, cl);
Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip);
}
// bottom border dark outer line
@ -520,7 +512,7 @@ core::rect<s32> CGUISkin::draw3DWindowBackground(IGUIElement* element,
rect.LowerRightCorner.X = r.LowerRightCorner.X;
if ( !checkClientArea )
{
Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, cl);
Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip);
}
// bottom border bright inner line
@ -530,7 +522,7 @@ core::rect<s32> CGUISkin::draw3DWindowBackground(IGUIElement* element,
rect.LowerRightCorner.Y -= 1;
if ( !checkClientArea )
{
Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, cl);
Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip);
}
// client area for background
@ -548,20 +540,20 @@ core::rect<s32> CGUISkin::draw3DWindowBackground(IGUIElement* element,
{
if (!UseGradient)
{
Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, cl);
Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip);
}
else if ( Type == EGST_BURNING_SKIN )
{
const video::SColor c1 = getColor(EGDC_WINDOW).getInterpolated ( 0xFFFFFFFF, 0.9f );
const video::SColor c2 = getColor(EGDC_WINDOW).getInterpolated ( 0xFFFFFFFF, 0.8f );
Driver->draw2DRectangle(rect, c1, c1, c2, c2, cl);
Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip);
}
else
{
const video::SColor c2 = getColor(EGDC_3D_SHADOW);
const video::SColor c1 = getColor(EGDC_3D_FACE);
Driver->draw2DRectangle(rect, c1, c1, c1, c2, cl);
Driver->draw2DRectangle(rect, c1, c1, c1, c2, clip);
}
}
@ -582,17 +574,17 @@ core::rect<s32> CGUISkin::draw3DWindowBackground(IGUIElement* element,
{
// draw title bar
//if (!UseGradient)
// Driver->draw2DRectangle(titleBarColor, rect, cl);
// Driver->draw2DRectangle(titleBarColor, rect, clip);
//else
if ( Type == EGST_BURNING_SKIN )
{
const video::SColor c = titleBarColor.getInterpolated( 0xffffffff, 0.8f);
Driver->draw2DRectangle(rect, titleBarColor, titleBarColor, c, c, cl);
Driver->draw2DRectangle(rect, titleBarColor, titleBarColor, c, c, clip);
}
else
{
const video::SColor c = titleBarColor.getInterpolated(video::SColor(255,0,0,0), 0.2f);
Driver->draw2DRectangle(rect, titleBarColor, c, titleBarColor, c, cl);
Driver->draw2DRectangle(rect, titleBarColor, c, titleBarColor, c, clip);
}
}
}

View File

@ -178,7 +178,7 @@ bool CGUIWindow::OnEvent(const SEvent& event)
Dragging = false;
return true;
case EMIE_MOUSE_MOVED:
if ( !event.MouseInput.isLeftPressed() )
if (!event.MouseInput.isLeftPressed())
Dragging = false;
if (Dragging)
@ -219,7 +219,7 @@ void CGUIWindow::updateAbsolutePosition()
//! draws the element and its children
void CGUIWindow::draw()
{
if ( IsVisible )
if (IsVisible)
{
IGUISkin* skin = Environment->getSkin();
@ -229,27 +229,27 @@ void CGUIWindow::draw()
core::rect<s32> rect = AbsoluteRect;
// draw body fast
if ( DrawBackground )
{
rect = skin->draw3DWindowBackground(this, DrawTitlebar,
skin->getColor(IsActive ? EGDC_ACTIVE_BORDER : EGDC_INACTIVE_BORDER),
AbsoluteRect, &AbsoluteClippingRect);
if (DrawBackground)
{
rect = skin->draw3DWindowBackground(this, DrawTitlebar,
skin->getColor(IsActive ? EGDC_ACTIVE_BORDER : EGDC_INACTIVE_BORDER),
AbsoluteRect, &AbsoluteClippingRect);
if (DrawTitlebar && Text.size())
{
rect.UpperLeftCorner.X += skin->getSize(EGDS_TITLEBARTEXT_DISTANCE_X);
rect.UpperLeftCorner.Y += skin->getSize(EGDS_TITLEBARTEXT_DISTANCE_Y);
rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5;
if (DrawTitlebar && Text.size())
{
rect.UpperLeftCorner.X += skin->getSize(EGDS_TITLEBARTEXT_DISTANCE_X);
rect.UpperLeftCorner.Y += skin->getSize(EGDS_TITLEBARTEXT_DISTANCE_Y);
rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5;
IGUIFont* font = skin->getFont(EGDF_WINDOW);
if (font)
{
font->draw(Text.c_str(), rect,
skin->getColor(IsActive ? EGDC_ACTIVE_CAPTION:EGDC_INACTIVE_CAPTION),
false, true, &AbsoluteClippingRect);
}
}
}
IGUIFont* font = skin->getFont(EGDF_WINDOW);
if (font)
{
font->draw(Text.c_str(), rect,
skin->getColor(IsActive ? EGDC_ACTIVE_CAPTION:EGDC_INACTIVE_CAPTION),
false, true, &AbsoluteClippingRect);
}
}
}
}
IGUIElement::draw();
@ -276,12 +276,14 @@ IGUIButton* CGUIWindow::getMaximizeButton() const
return RestoreButton;
}
//! Returns true if the window is draggable, false if not
bool CGUIWindow::isDraggable() const
{
return IsDraggable;
}
//! Sets whether the window is draggable
void CGUIWindow::setDraggable(bool draggable)
{
@ -291,30 +293,35 @@ void CGUIWindow::setDraggable(bool draggable)
Dragging = false;
}
//! Set if the window background will be drawn
void CGUIWindow::setDrawBackground(bool draw)
{
DrawBackground = draw;
DrawBackground = draw;
}
//! Get if the window background will be drawn
bool CGUIWindow::getDrawBackground() const
{
return DrawBackground;
return DrawBackground;
}
//! Set if the window titlebar will be drawn
void CGUIWindow::setDrawTitlebar(bool draw)
{
DrawTitlebar = draw;
DrawTitlebar = draw;
}
//! Get if the window titlebar will be drawn
bool CGUIWindow::getDrawTitlebar() const
{
return DrawTitlebar;
return DrawTitlebar;
}
void CGUIWindow::updateClientRect()
{
if (! DrawBackground )
@ -323,58 +330,60 @@ void CGUIWindow::updateClientRect()
return;
}
IGUISkin* skin = Environment->getSkin();
skin->draw3DWindowBackground(this,
DrawTitlebar,
skin->getColor(IsActive ? EGDC_ACTIVE_BORDER : EGDC_INACTIVE_BORDER),
AbsoluteRect, &AbsoluteClippingRect, &ClientRect);
skin->draw3DWindowBackground(this, DrawTitlebar,
skin->getColor(IsActive ? EGDC_ACTIVE_BORDER : EGDC_INACTIVE_BORDER),
AbsoluteRect, &AbsoluteClippingRect, &ClientRect);
ClientRect -= AbsoluteRect.UpperLeftCorner;
}
//! Returns the rectangle of the drawable area (without border, without titlebar and without scrollbars)
core::rect<s32> CGUIWindow::getClientRect() const
{
return ClientRect;
}
//! Writes attributes of the element.
void CGUIWindow::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
{
IGUIWindow::serializeAttributes(out,options);
out->addBool("IsDraggable", IsDraggable);
out->addBool("DrawBackground", DrawBackground);
out->addBool("DrawTitlebar", DrawTitlebar);
out->addBool("IsDraggable", IsDraggable);
out->addBool("DrawBackground", DrawBackground);
out->addBool("DrawTitlebar", DrawTitlebar);
// Currently we can't just serialize attributes of sub-elements.
// To do this we either
// a) allow further serialization after attribute serialiation (second function, callback or event)
// b) add an IGUIElement attribute
// c) extend the attribute system to allow attributes to have sub-attributes
// We just serialize the most important info for now until we can do one of the above solutions.
out->addBool("IsCloseVisible", CloseButton->isVisible());
out->addBool("IsMinVisible", MinButton->isVisible());
out->addBool("IsRestoreVisible", RestoreButton->isVisible());
// Currently we can't just serialize attributes of sub-elements.
// To do this we either
// a) allow further serialization after attribute serialiation (second function, callback or event)
// b) add an IGUIElement attribute
// c) extend the attribute system to allow attributes to have sub-attributes
// We just serialize the most important info for now until we can do one of the above solutions.
out->addBool("IsCloseVisible", CloseButton->isVisible());
out->addBool("IsMinVisible", MinButton->isVisible());
out->addBool("IsRestoreVisible", RestoreButton->isVisible());
}
//! Reads attributes of the element
void CGUIWindow::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
{
IGUIWindow::deserializeAttributes(in,options);
IGUIWindow::deserializeAttributes(in,options);
Dragging = false;
Dragging = false;
IsActive = false;
IsDraggable = in->getAttributeAsBool("IsDraggable");
DrawBackground = in->getAttributeAsBool("DrawBackground");
DrawTitlebar = in->getAttributeAsBool("DrawTitlebar");
IsDraggable = in->getAttributeAsBool("IsDraggable");
DrawBackground = in->getAttributeAsBool("DrawBackground");
DrawTitlebar = in->getAttributeAsBool("DrawTitlebar");
CloseButton->setVisible( in->getAttributeAsBool("IsCloseVisible") );
MinButton->setVisible( in->getAttributeAsBool("IsMinVisible") );
RestoreButton->setVisible( in->getAttributeAsBool("IsRestoreVisible") );
CloseButton->setVisible(in->getAttributeAsBool("IsCloseVisible"));
MinButton->setVisible(in->getAttributeAsBool("IsMinVisible"));
RestoreButton->setVisible(in->getAttributeAsBool("IsRestoreVisible"));
updateClientRect();
updateClientRect();
}
} // end namespace gui
} // end namespace irr

View File

@ -359,10 +359,8 @@ bool CMD2MeshFileLoader::loadFile(io::IReadFile* file, CAnimatedMeshMD2* mesh)
delete [] triangles;
delete [] textureCoords;
// return
mesh->calculateBoundingBox();
// init buffer with start frame.
mesh->getMesh(0);
return true;
}

View File

@ -126,6 +126,167 @@ void CMeshManipulator::recalculateNormals(scene::IMesh* mesh, bool smooth, bool
}
//! Recalculates tangents, requires a tangent mesh
void CMeshManipulator::recalculateTangents(IMesh* mesh, bool recalculateNormals, bool smooth, bool angleWeighted) const
{
if (!mesh || !mesh->getMeshBufferCount() || (mesh->getMeshBuffer(0)->getVertexType()!= video::EVT_TANGENTS))
return;
const u32 meshBufferCount = mesh->getMeshBufferCount();
for (u32 b=0; b<meshBufferCount; ++b)
{
IMeshBuffer* clone = mesh->getMeshBuffer(b);
const u32 vtxCnt = clone->getVertexCount();
const u32 idxCnt = clone->getIndexCount();
u16* idx = clone->getIndices();
video::S3DVertexTangents* v =
(video::S3DVertexTangents*)clone->getVertices();
if (smooth)
{
u32 i;
for ( i = 0; i!= vtxCnt; ++i )
{
if (recalculateNormals)
v[i].Normal.set( 0.f, 0.f, 0.f );
v[i].Tangent.set( 0.f, 0.f, 0.f );
v[i].Binormal.set( 0.f, 0.f, 0.f );
}
//Each vertex gets the sum of the tangents and binormals from the faces around it
for ( i=0; i<idxCnt; i+=3)
{
// if this triangle is degenerate, skip it!
if (v[idx[i+0]].Pos == v[idx[i+1]].Pos ||
v[idx[i+0]].Pos == v[idx[i+2]].Pos ||
v[idx[i+1]].Pos == v[idx[i+2]].Pos
/*||
v[idx[i+0]].TCoords == v[idx[i+1]].TCoords ||
v[idx[i+0]].TCoords == v[idx[i+2]].TCoords ||
v[idx[i+1]].TCoords == v[idx[i+2]].TCoords */
)
continue;
//Angle-weighted normals look better, but are slightly more CPU intensive to calculate
core::vector3df weight(1.f,1.f,1.f);
if (angleWeighted)
weight = getAngleWeight(v[i+0].Pos,v[i+1].Pos,v[i+2].Pos);
core::vector3df localNormal;
core::vector3df localTangent;
core::vector3df localBinormal;
calculateTangents(
localNormal,
localTangent,
localBinormal,
v[idx[i+0]].Pos,
v[idx[i+1]].Pos,
v[idx[i+2]].Pos,
v[idx[i+0]].TCoords,
v[idx[i+1]].TCoords,
v[idx[i+2]].TCoords);
if (recalculateNormals)
v[idx[i+0]].Normal += localNormal * weight.X;
v[idx[i+0]].Tangent += localTangent * weight.X;
v[idx[i+0]].Binormal += localBinormal * weight.X;
calculateTangents(
localNormal,
localTangent,
localBinormal,
v[idx[i+1]].Pos,
v[idx[i+2]].Pos,
v[idx[i+0]].Pos,
v[idx[i+1]].TCoords,
v[idx[i+2]].TCoords,
v[idx[i+0]].TCoords);
if (recalculateNormals)
v[idx[i+1]].Normal += localNormal * weight.Y;
v[idx[i+1]].Tangent += localTangent * weight.Y;
v[idx[i+1]].Binormal += localBinormal * weight.Y;
calculateTangents(
localNormal,
localTangent,
localBinormal,
v[idx[i+2]].Pos,
v[idx[i+0]].Pos,
v[idx[i+1]].Pos,
v[idx[i+2]].TCoords,
v[idx[i+0]].TCoords,
v[idx[i+1]].TCoords);
if (recalculateNormals)
v[idx[i+2]].Normal += localNormal * weight.Z;
v[idx[i+2]].Tangent += localTangent * weight.Z;
v[idx[i+2]].Binormal += localBinormal * weight.Z;
}
// Normalize the tangents and binormals
if (recalculateNormals)
{
for ( i = 0; i!= vtxCnt; ++i )
v[i].Normal.normalize();
}
for ( i = 0; i!= vtxCnt; ++i )
{
v[i].Tangent.normalize();
v[i].Binormal.normalize();
}
}
else
{
core::vector3df localNormal;
for (u32 i=0; i<idxCnt; i+=3)
{
calculateTangents(
localNormal,
v[idx[i+0]].Tangent,
v[idx[i+0]].Binormal,
v[idx[i+0]].Pos,
v[idx[i+1]].Pos,
v[idx[i+2]].Pos,
v[idx[i+0]].TCoords,
v[idx[i+1]].TCoords,
v[idx[i+2]].TCoords);
if (recalculateNormals)
v[idx[i+0]].Normal=localNormal;
calculateTangents(
localNormal,
v[idx[i+1]].Tangent,
v[idx[i+1]].Binormal,
v[idx[i+1]].Pos,
v[idx[i+2]].Pos,
v[idx[i+0]].Pos,
v[idx[i+1]].TCoords,
v[idx[i+2]].TCoords,
v[idx[i+0]].TCoords);
if (recalculateNormals)
v[idx[i+1]].Normal=localNormal;
calculateTangents(
localNormal,
v[idx[i+2]].Tangent,
v[idx[i+2]].Binormal,
v[idx[i+2]].Pos,
v[idx[i+0]].Pos,
v[idx[i+1]].Pos,
v[idx[i+2]].TCoords,
v[idx[i+0]].TCoords,
v[idx[i+1]].TCoords);
if (recalculateNormals)
v[idx[i+2]].Normal=localNormal;
}
}
}
}
//! Clones a static IMesh into a modifyable SMesh.
SMesh* CMeshManipulator::createMeshCopy(scene::IMesh* mesh) const
{
@ -564,7 +725,7 @@ IMesh* CMeshManipulator::createMeshWelded(IMesh *mesh, f32 tolerance) const
//! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices.
IMesh* CMeshManipulator::createMeshWithTangents(IMesh* mesh, bool recalculateNormals, bool smooth, bool angleWeighted) const
IMesh* CMeshManipulator::createMeshWithTangents(IMesh* mesh, bool recalculateNormals, bool smooth, bool angleWeighted, bool calculateTangents) const
{
if (!mesh)
return 0;
@ -573,221 +734,79 @@ IMesh* CMeshManipulator::createMeshWithTangents(IMesh* mesh, bool recalculateNor
SMesh* clone = new SMesh();
const u32 meshBufferCount = mesh->getMeshBufferCount();
u32 b;
for (b=0; b<meshBufferCount; ++b)
for (u32 b=0; b<meshBufferCount; ++b)
{
const u32 idxCnt = mesh->getMeshBuffer(b)->getIndexCount();
const u16* idx = mesh->getMeshBuffer(b)->getIndices();
const IMeshBuffer* original = mesh->getMeshBuffer(b);
const u32 idxCnt = original->getIndexCount();
const u16* idx = original->getIndices();
SMeshBufferTangents* buffer = new SMeshBufferTangents();
buffer->Material = mesh->getMeshBuffer(b)->getMaterial();
buffer->Material = original->getMaterial();
buffer->Vertices.reallocate(idxCnt);
buffer->Indices.set_used(idxCnt);
core::map<video::S3DVertexTangents, int> vertMap;
int vertLocation;
// copy vertices
buffer->Vertices.reallocate(idxCnt);
switch(mesh->getMeshBuffer(b)->getVertexType())
{
case video::EVT_STANDARD:
{
video::S3DVertex* v =
(video::S3DVertex*)mesh->getMeshBuffer(b)->getVertices();
for (u32 i=0; i<idxCnt; ++i)
buffer->Vertices.push_back(
video::S3DVertexTangents(
v[idx[i]].Pos, v[idx[i]].Normal, v[idx[i]].Color, v[idx[i]].TCoords));
}
break;
case video::EVT_2TCOORDS:
{
video::S3DVertex2TCoords* v =
(video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices();
for (u32 i=0; i<idxCnt; ++i)
buffer->Vertices.push_back(video::S3DVertexTangents(
v[idx[i]].Pos, v[idx[i]].Normal, v[idx[i]].Color, v[idx[i]].TCoords));
}
break;
case video::EVT_TANGENTS:
{
video::S3DVertexTangents* v =
(video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices();
for (u32 i=0; i<idxCnt; ++i)
buffer->Vertices.push_back(v[idx[i]]);
}
break;
}
// create new indices
buffer->Indices.set_used(idxCnt);
const video::E_VERTEX_TYPE vType = original->getVertexType();
video::S3DVertexTangents vNew;
for (u32 i=0; i<idxCnt; ++i)
buffer->Indices[i] = i;
{
switch(vType)
{
case video::EVT_STANDARD:
{
const video::S3DVertex* v =
(const video::S3DVertex*)original->getVertices();
vNew = video::S3DVertexTangents(
v[idx[i]].Pos, v[idx[i]].Normal, v[idx[i]].Color, v[idx[i]].TCoords);
}
break;
case video::EVT_2TCOORDS:
{
const video::S3DVertex2TCoords* v =
(const video::S3DVertex2TCoords*)original->getVertices();
vNew = video::S3DVertexTangents(
v[idx[i]].Pos, v[idx[i]].Normal, v[idx[i]].Color, v[idx[i]].TCoords);
}
break;
case video::EVT_TANGENTS:
{
const video::S3DVertexTangents* v =
(const video::S3DVertexTangents*)original->getVertices();
vNew = v[idx[i]];
}
break;
}
core::map<video::S3DVertexTangents, int>::Node* n = vertMap.find(vNew);
if (n)
{
vertLocation = n->getValue();
}
else
{
vertLocation = buffer->Vertices.size();
buffer->Vertices.push_back(vNew);
vertMap.insert(vNew, vertLocation);
}
//buffer->setBoundingBox(mesh->getMeshBuffer(b)->getBoundingBox());
buffer->recalculateBoundingBox ();
// create new indices
buffer->Indices[i] = vertLocation;
}
buffer->recalculateBoundingBox();
// add new buffer
clone->addMeshBuffer(buffer);
buffer->drop();
}
clone->recalculateBoundingBox ();
//clone->BoundingBox = mesh->getBoundingBox();
// now calculate tangents
for (b=0; b<meshBufferCount; ++b)
{
const u32 vtxCnt = mesh->getMeshBuffer(b)->getVertexCount();
const u32 idxCnt = clone->getMeshBuffer(b)->getIndexCount();
u16* idx = clone->getMeshBuffer(b)->getIndices();
video::S3DVertexTangents* v =
(video::S3DVertexTangents*)clone->getMeshBuffer(b)->getVertices();
if (smooth)
{
u32 i;
for ( i = 0; i!= vtxCnt; ++i )
{
if (recalculateNormals)
v[i].Normal.set( 0.f, 0.f, 0.f );
v[i].Tangent.set( 0.f, 0.f, 0.f );
v[i].Binormal.set( 0.f, 0.f, 0.f );
}
//Each vertex gets the sum of the tangents and binormals from the faces around it
for ( i=0; i<idxCnt; i+=3)
{
// if this triangle is degenerate, skip it!
if (v[idx[i+0]].Pos == v[idx[i+1]].Pos ||
v[idx[i+0]].Pos == v[idx[i+2]].Pos ||
v[idx[i+1]].Pos == v[idx[i+2]].Pos
/*||
v[idx[i+0]].TCoords == v[idx[i+1]].TCoords ||
v[idx[i+0]].TCoords == v[idx[i+2]].TCoords ||
v[idx[i+1]].TCoords == v[idx[i+2]].TCoords */
)
continue;
//Angle-weighted normals look better, but are slightly more CPU intensive to calculate
core::vector3df weight(1.f,1.f,1.f);
if (angleWeighted)
weight = getAngleWeight(v[i+0].Pos,v[i+1].Pos,v[i+2].Pos);
core::vector3df localNormal;
core::vector3df localTangent;
core::vector3df localBinormal;
calculateTangents(
localNormal,
localTangent,
localBinormal,
v[idx[i+0]].Pos,
v[idx[i+1]].Pos,
v[idx[i+2]].Pos,
v[idx[i+0]].TCoords,
v[idx[i+1]].TCoords,
v[idx[i+2]].TCoords);
if (recalculateNormals)
v[idx[i+0]].Normal += localNormal * weight.X;
v[idx[i+0]].Tangent += localTangent * weight.X;
v[idx[i+0]].Binormal += localBinormal * weight.X;
calculateTangents(
localNormal,
localTangent,
localBinormal,
v[idx[i+1]].Pos,
v[idx[i+2]].Pos,
v[idx[i+0]].Pos,
v[idx[i+1]].TCoords,
v[idx[i+2]].TCoords,
v[idx[i+0]].TCoords);
if (recalculateNormals)
v[idx[i+1]].Normal += localNormal * weight.Y;
v[idx[i+1]].Tangent += localTangent * weight.Y;
v[idx[i+1]].Binormal += localBinormal * weight.Y;
calculateTangents(
localNormal,
localTangent,
localBinormal,
v[idx[i+2]].Pos,
v[idx[i+0]].Pos,
v[idx[i+1]].Pos,
v[idx[i+2]].TCoords,
v[idx[i+0]].TCoords,
v[idx[i+1]].TCoords);
if (recalculateNormals)
v[idx[i+2]].Normal += localNormal * weight.Z;
v[idx[i+2]].Tangent += localTangent * weight.Z;
v[idx[i+2]].Binormal += localBinormal * weight.Z;
}
// Normalize the tangents and binormals
if (recalculateNormals)
{
for ( i = 0; i!= vtxCnt; ++i )
v[i].Normal.normalize();
}
for ( i = 0; i!= vtxCnt; ++i )
{
v[i].Tangent.normalize();
v[i].Binormal.normalize();
}
}
else
{
core::vector3df localNormal;
for (u32 i=0; i<idxCnt; i+=3)
{
calculateTangents(
localNormal,
v[idx[i+0]].Tangent,
v[idx[i+0]].Binormal,
v[idx[i+0]].Pos,
v[idx[i+1]].Pos,
v[idx[i+2]].Pos,
v[idx[i+0]].TCoords,
v[idx[i+1]].TCoords,
v[idx[i+2]].TCoords);
if (recalculateNormals)
v[idx[i+0]].Normal=localNormal;
calculateTangents(
localNormal,
v[idx[i+1]].Tangent,
v[idx[i+1]].Binormal,
v[idx[i+1]].Pos,
v[idx[i+2]].Pos,
v[idx[i+0]].Pos,
v[idx[i+1]].TCoords,
v[idx[i+2]].TCoords,
v[idx[i+0]].TCoords);
if (recalculateNormals)
v[idx[i+1]].Normal=localNormal;
calculateTangents(
localNormal,
v[idx[i+2]].Tangent,
v[idx[i+2]].Binormal,
v[idx[i+2]].Pos,
v[idx[i+0]].Pos,
v[idx[i+1]].Pos,
v[idx[i+2]].TCoords,
v[idx[i+0]].TCoords,
v[idx[i+1]].TCoords);
if (recalculateNormals)
v[idx[i+2]].Normal=localNormal;
}
}
}
clone->recalculateBoundingBox();
if (calculateTangents)
recalculateTangents(clone, recalculateNormals, smooth, angleWeighted);
return clone;
}
@ -803,70 +822,76 @@ IMesh* CMeshManipulator::createMeshWith2TCoords(IMesh* mesh) const
SMesh* clone = new SMesh();
const u32 meshBufferCount = mesh->getMeshBufferCount();
u32 b;
for (b=0; b<meshBufferCount; ++b)
for (u32 b=0; b<meshBufferCount; ++b)
{
const u32 idxCnt = mesh->getMeshBuffer(b)->getIndexCount();
const u16* idx = mesh->getMeshBuffer(b)->getIndices();
const IMeshBuffer* original = mesh->getMeshBuffer(b);
const u32 idxCnt = original->getIndexCount();
const u16* idx = original->getIndices();
SMeshBufferLightMap* buffer = new SMeshBufferLightMap();
buffer->Material = mesh->getMeshBuffer(b)->getMaterial();
buffer->Material = original->getMaterial();
buffer->Vertices.reallocate(idxCnt);
buffer->Indices.set_used(idxCnt);
core::map<video::S3DVertex2TCoords, int> vertMap;
int vertLocation;
// copy vertices
buffer->Vertices.reallocate(idxCnt);
switch(mesh->getMeshBuffer(b)->getVertexType())
{
case video::EVT_STANDARD:
{
video::S3DVertex* v =
(video::S3DVertex*)mesh->getMeshBuffer(b)->getVertices();
for (u32 i=0; i<idxCnt; ++i)
buffer->Vertices.push_back(
video::S3DVertex2TCoords(
v[idx[i]].Pos, v[idx[i]].Normal, v[idx[i]].Color, v[idx[i]].TCoords, v[idx[i]].TCoords));
}
break;
case video::EVT_2TCOORDS:
{
video::S3DVertex2TCoords* v =
(video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices();
for (u32 i=0; i<idxCnt; ++i)
buffer->Vertices.push_back(v[idx[i]]);
}
break;
case video::EVT_TANGENTS:
{
video::S3DVertexTangents* v =
(video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices();
for (u32 i=0; i<idxCnt; ++i)
buffer->Vertices.push_back(video::S3DVertex2TCoords(
v[idx[i]].Pos, v[idx[i]].Normal, v[idx[i]].Color, v[idx[i]].TCoords, v[idx[i]].TCoords));
}
break;
}
// create new indices
buffer->Indices.set_used(idxCnt);
const video::E_VERTEX_TYPE vType = original->getVertexType();
video::S3DVertex2TCoords vNew;
for (u32 i=0; i<idxCnt; ++i)
buffer->Indices[i] = i;
{
switch(vType)
{
case video::EVT_STANDARD:
{
const video::S3DVertex* v =
(const video::S3DVertex*)original->getVertices();
vNew = video::S3DVertex2TCoords(
v[idx[i]].Pos, v[idx[i]].Normal, v[idx[i]].Color, v[idx[i]].TCoords, v[idx[i]].TCoords);
}
break;
case video::EVT_2TCOORDS:
{
const video::S3DVertex2TCoords* v =
(const video::S3DVertex2TCoords*)original->getVertices();
vNew = v[idx[i]];
}
break;
case video::EVT_TANGENTS:
{
const video::S3DVertexTangents* v =
(const video::S3DVertexTangents*)original->getVertices();
vNew = video::S3DVertex2TCoords(
v[idx[i]].Pos, v[idx[i]].Normal, v[idx[i]].Color, v[idx[i]].TCoords, v[idx[i]].TCoords);
}
break;
}
core::map<video::S3DVertex2TCoords, int>::Node* n = vertMap.find(vNew);
if (n)
{
vertLocation = n->getValue();
}
else
{
vertLocation = buffer->Vertices.size();
buffer->Vertices.push_back(vNew);
vertMap.insert(vNew, vertLocation);
}
//buffer->setBoundingBox(mesh->getMeshBuffer(b)->getBoundingBox());
buffer->recalculateBoundingBox ();
// create new indices
buffer->Indices[i] = vertLocation;
}
buffer->recalculateBoundingBox();
// add new buffer
clone->addMeshBuffer(buffer);
buffer->drop();
}
clone->recalculateBoundingBox ();
//clone->BoundingBox = mesh->getBoundingBox();
clone->recalculateBoundingBox();
return clone;
}
@ -879,9 +904,8 @@ IMesh* CMeshManipulator::createMeshWith1TCoords(IMesh* mesh) const
// copy mesh and fill data into SMeshBuffer
SMesh* clone = new SMesh();
const u32 meshBufferCount = mesh->getMeshBufferCount();
u32 b;
for (b=0; b<meshBufferCount; ++b)
for (u32 b=0; b<meshBufferCount; ++b)
{
const IMeshBuffer* original = mesh->getMeshBuffer(b);
const u32 idxCnt = original->getIndexCount();
@ -941,9 +965,7 @@ IMesh* CMeshManipulator::createMeshWith1TCoords(IMesh* mesh) const
// create new indices
buffer->Indices[i] = vertLocation;
}
//buffer->setBoundingBox(mesh->getMeshBuffer(b)->getBoundingBox());
buffer->recalculateBoundingBox ();
buffer->recalculateBoundingBox();
// add new buffer
clone->addMeshBuffer(buffer);

View File

@ -51,8 +51,11 @@ public:
//! Creates a planar texture mapping on the meshbuffer
void makePlanarTextureMapping(scene::IMeshBuffer* buffer, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df& offset) const;
//! Recalculates tangents, requires a tangent mesh
virtual void recalculateTangents(IMesh* mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const;
//! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices.
virtual IMesh* createMeshWithTangents(IMesh* mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const;
virtual IMesh* createMeshWithTangents(IMesh* mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false, bool recalculateTangents=true) const;
//! Creates a copy of the mesh, which will only consist of S3D2TCoords vertices.
virtual IMesh* createMeshWith2TCoords(IMesh* mesh) const;

View File

@ -165,7 +165,7 @@ void CSceneNodeAnimatorCollisionResponse::animateNode(ISceneNode* node, u32 time
FirstUpdate = false;
}
u32 diff = timeMs - LastTime;
const u32 diff = timeMs - LastTime;
LastTime = timeMs;
CollisionResultPosition = Object->getPosition();

View File

@ -17,8 +17,8 @@
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="..\obj\IrrDebug"
IntermediateDirectory="..\obj\IrrDebug"
OutputDirectory="obj\$(ConfigurationName)"
IntermediateDirectory="obj\$(ConfigurationName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
@ -115,8 +115,8 @@
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="obj\IrrRelease"
IntermediateDirectory="obj\IrrRelease"
OutputDirectory="obj\$(ConfigurationName)"
IntermediateDirectory="obj\$(ConfigurationName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
@ -214,8 +214,8 @@
</Configuration>
<Configuration
Name="Release - Fast FPU|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
OutputDirectory="obj\$(ConfigurationName)"
IntermediateDirectory="obj\$(ConfigurationName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
@ -323,8 +323,8 @@
</Configuration>
<Configuration
Name="Static lib - Debug|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
OutputDirectory="obj\$(ConfigurationName)"
IntermediateDirectory="obj\$(ConfigurationName)"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
@ -404,8 +404,8 @@
</Configuration>
<Configuration
Name="Static lib - Release|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
OutputDirectory="obj\$(ConfigurationName)"
IntermediateDirectory="obj\$(ConfigurationName)"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
@ -488,8 +488,8 @@
</Configuration>
<Configuration
Name="Static lib - Release - Fast FPU|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
OutputDirectory="obj\$(ConfigurationName)"
IntermediateDirectory="obj\$(ConfigurationName)"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
@ -577,8 +577,8 @@
</Configuration>
<Configuration
Name="SDL-Debug|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
OutputDirectory="obj\$(ConfigurationName)"
IntermediateDirectory="obj\$(ConfigurationName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"

View File

@ -430,6 +430,7 @@ void CIrrDeviceMacOSX::closeDevice()
CGLSetCurrentContext(NULL);
CGLClearDrawable(CGLContext);
CGLDestroyContext(CGLContext);
CGReleaseAllDisplays();
}
}
}

View File

@ -3,7 +3,7 @@ import sys
USE_GCC = 1;
NDEBUG = 1;
PROFILE = 1;
PROFILE = 0;
APPLICATION_NAME = 'Irrlicht';
LIBRARIES = ['gdi32', 'opengl32', 'd3dx9d', 'winmm'];
@ -86,9 +86,9 @@ env.Append(LIBS = LIBRARIES, LIBPATH = CXXINCS);
CXXFLAGS = ['-Wall'];
if NDEBUG:
CXXFLAGS += ['-g', '-D_DEBUG'];
else:
CXXFLAGS += ['-fexpensive-optimizations', '-O3'];
else:
CXXFLAGS += ['-g', '-D_DEBUG'];
if PROFILE:
CXXFLAGS += ['-pg'];

View File

@ -63,6 +63,7 @@ int main(int argumentCount, char * arguments[])
TEST(testDimension2d);
TEST(testVector2d);
TEST(testVector3d);
TEST(testQuaternion);
TEST(testS3DVertex);
TEST(testaabbox3d);
// TODO: Needs to be fixed first

View File

@ -27,6 +27,7 @@ bool md2Animation(void)
IAnimatedMeshSceneNode* node;
assert(mesh);
bool result = (mesh != 0);
if(mesh)
{
node = smgr->addAnimatedMeshSceneNode(mesh);
@ -44,14 +45,33 @@ bool md2Animation(void)
// Just jump to the last frame since that's all we're interested in.
node->setMD2Animation(EMAT_DEATH_FALLBACK);
node->setCurrentFrame((f32)(node->getEndFrame()));
node->setAnimationSpeed(0);
device->run();
driver->beginScene(true, true, SColor(255, 255, 255, 0));
smgr->drawAll();
driver->endScene();
if (mesh->getBoundingBox() != mesh->getMesh(node->getEndFrame())->getBoundingBox())
{
logTestString("bbox of md2 mesh not updated.\n");
result = false;
}
//TODO: Does not yet work, not sure if this is correct or not
#if 0
if (node->getBoundingBox() != mesh->getMesh(node->getFrameNr())->getBoundingBox())
{
logTestString("bbox of md2 scene node not updated.\n");
result = false;
}
#endif
if (node->getTransformedBoundingBox() == core::aabbox3df())
{
logTestString("md2 node returns empty bbox.\n");
result = false;
}
}
}
bool result = takeScreenshotAndCompareAgainstReference(driver, "-md2Animation.png");
result &= takeScreenshotAndCompareAgainstReference(driver, "-md2Animation.png");
device->drop();
return result;

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

74
tests/testQuaternion.cpp Normal file
View File

@ -0,0 +1,74 @@
// Copyright (C) 2008-2009 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
bool testQuaternion(void)
{
bool result = true;
core::quaternion q1;
if ((q1.W != 1.f)||(q1.X != 0.f)||(q1.Y != 0.f)||(q1.Z != 0.f))
{
logTestString("Default constructor did not create proper quaternion.\n");
result = false;
}
core::quaternion q2(1.f,2.f,3.f,4.f);
if ((q2.W != 4.f)||(q2.X != 1.f)||(q2.Y != 2.f)||(q2.Z != 3.f))
{
logTestString("Element constructor did not create proper quaternion.\n");
result = false;
}
q2.set(0.f,0.f,0.f,1.f);
if ((q1.W != 1.f)||(q1.X != 0.f)||(q1.Y != 0.f)||(q1.Z != 0.f))
{
logTestString("Quaternion set method not working.\n");
result = false;
}
if (q1 != q2)
{
logTestString("Quaternion equals method not working.\n");
result = false;
}
core::quaternion q3(1.f,2.f,3.f);
core::matrix4 mat;
core::quaternion q4(mat);
q4.rotationFromTo(core::vector3df(1.f,0.f,0.f), core::vector3df(1.f,0.f,0.f));
if (q4 != q1)
{
logTestString("Quaternion rotationFromTo method did not yield identity.\n");
result = false;
}
q1.set(0.f,0.f,core::PI);
q2.set(0.f,core::PI,0.f);
q4.rotationFromTo(core::vector3df(1.f,0.f,0.f), core::vector3df(-1.f,0.f,0.f));
if ((q4 != q1)&&(q4 != q2))
{
logTestString("Quaternion rotationFromTo method did not yield x flip.\n");
result = false;
}
q4.rotationFromTo(core::vector3df(10.f,20.f,30.f), core::vector3df(-10.f,-20.f,-30.f));
if ((q4 != q1)&&(q4 != q2))
{
logTestString("Quaternion rotationFromTo method did not yield x flip for non-axis.\n");
result = false;
}
q1.set(0.f,0.f,core::PI/2);
q4.rotationFromTo(core::vector3df(1.f,0.f,0.f), core::vector3df(0.f,1.f,0.f));
if (!q4.equals(q1))
{
logTestString("Quaternion rotationFromTo method did not yield 90 degree rotation.\n");
result = false;
}
return result;
}

View File

@ -2,8 +2,6 @@
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
#include "irrlicht.h"
#include <assert.h>
using namespace irr;
using namespace core;

View File

@ -1,4 +1,4 @@
Tests finished. 50 tests of 50 passed.
Tests finished. 51 tests of 51 passed.
Compiled as DEBUG
Test suite pass at GMT Thu Jan 21 13:53:33 2010
Test suite pass at GMT Tue Jan 26 11:59:00 2010

View File

@ -335,6 +335,10 @@
RelativePath=".\testGeometryCreator.cpp"
>
</File>
<File
RelativePath=".\testQuaternion.cpp"
>
</File>
<File
RelativePath=".\testS3DVertex.cpp"
>

View File

@ -5,13 +5,9 @@
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
//! Tests locking miplevels
static bool lockAllMipLevels(E_DRIVER_TYPE driverType)
static bool lockAllMipLevels(video::E_DRIVER_TYPE driverType)
{
bool result=true;
@ -19,8 +15,8 @@ static bool lockAllMipLevels(E_DRIVER_TYPE driverType)
if (!device)
return result; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
IVideoDriver* driver = device->getVideoDriver();
ISceneManager * smgr = device->getSceneManager();
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager * smgr = device->getSceneManager();
scene::ISceneNode* n = smgr->addCubeSceneNode();
@ -43,7 +39,7 @@ static bool lockAllMipLevels(E_DRIVER_TYPE driverType)
}
}
ITexture* tex = driver->addTexture("miptest", image, mipdata);
video::ITexture* tex = driver->addTexture("miptest", image, mipdata);
if (!tex)
// is probably an error in the mipdata handling
return false;
@ -54,7 +50,7 @@ static bool lockAllMipLevels(E_DRIVER_TYPE driverType)
(void)smgr->addCameraSceneNode();
driver->beginScene(true, true, SColor(255,100,101,140));
driver->beginScene(true, true, video::SColor(255,100,101,140));
smgr->drawAll();
driver->endScene();
@ -85,11 +81,11 @@ bool textureFeatures(void)
{
bool passed = true;
passed &= lockAllMipLevels(EDT_OPENGL);
passed &= lockAllMipLevels(EDT_SOFTWARE);
passed &= lockAllMipLevels(EDT_BURNINGSVIDEO);
passed &= lockAllMipLevels(EDT_DIRECT3D9);
passed &= lockAllMipLevels(EDT_DIRECT3D8);
passed &= lockAllMipLevels(video::EDT_OPENGL);
passed &= lockAllMipLevels(video::EDT_SOFTWARE);
passed &= lockAllMipLevels(video::EDT_BURNINGSVIDEO);
passed &= lockAllMipLevels(video::EDT_DIRECT3D9);
passed &= lockAllMipLevels(video::EDT_DIRECT3D8);
return passed;
}

View File

@ -5,35 +5,31 @@
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
//! Tests interleaved loading and rendering of textures
/** The test loads a texture, renders it using draw2dimage, loads another
texture and renders the first one again. Due to the texture cache this
can lead to rendering of the second texture in second place. */
static bool renderAndLoad(E_DRIVER_TYPE driverType)
static bool renderAndLoad(video::E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device = createDevice( driverType, dimension2d<u32>(160, 120), 32);
if (!device)
return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
IVideoDriver* driver = device->getVideoDriver();
ISceneManager * smgr = device->getSceneManager();
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager * smgr = device->getSceneManager();
ITexture* tex1 = driver->getTexture("../media/wall.bmp");
video::ITexture* tex1 = driver->getTexture("../media/wall.bmp");
(void)smgr->addCameraSceneNode();
driver->beginScene(true, true, SColor(255,100,101,140));
driver->beginScene(true, true, video::SColor(255,100,101,140));
driver->draw2DImage(tex1, position2di(0,0));
driver->endScene();
driver->getTexture("../media/tools.png");
driver->beginScene(true, true, SColor(255,100,101,140));
driver->beginScene(true, true, video::SColor(255,100,101,140));
driver->draw2DImage(tex1, position2di(0,0));
driver->endScene();
@ -47,37 +43,37 @@ static bool renderAndLoad(E_DRIVER_TYPE driverType)
// This test would cause a crash if it does not work
// in 1.5.1 and 1.6 an illegal access in the OpenGL driver caused this
static bool renderAndRemove(E_DRIVER_TYPE driverType)
static bool renderAndRemove(video::E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device = createDevice( driverType, dimension2d<u32>(160, 120), 32);
if (!device)
return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
IVideoDriver* driver = device->getVideoDriver();
ISceneManager * smgr = device->getSceneManager();
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager * smgr = device->getSceneManager();
driver->beginScene (true, true, irr::video::SColor (255, 0, 255, 0));
smgr->drawAll ();
driver->endScene ();
driver->beginScene (true, true, video::SColor(255, 0, 255, 0));
smgr->drawAll();
driver->endScene();
smgr->addCameraSceneNode();
ITexture* texture = driver->getTexture ("media/tools.png");
ISceneNode * img = smgr->addCubeSceneNode();
video::ITexture* texture = driver->getTexture ("media/tools.png");
scene::ISceneNode * img = smgr->addCubeSceneNode();
img->setMaterialTexture(0, texture);
driver->beginScene (true, true, irr::video::SColor (255, 0, 255, 0));
driver->beginScene (true, true, video::SColor (255, 0, 255, 0));
smgr->drawAll();
driver->endScene();
smgr->clear(); // Remove anything that used the texture
driver->removeTexture(texture);
driver->beginScene(true, true, SColor(255,100,101,140));
driver->beginScene(true, true, video::SColor(255,100,101,140));
smgr->drawAll();
driver->endScene();
smgr->addCameraSceneNode();
texture = driver->getTexture ("media/tools.png");
texture = driver->getTexture("media/tools.png");
img = smgr->addCubeSceneNode();
img->setMaterialTexture(0, texture);
@ -105,28 +101,28 @@ static bool testTextureMatrixInMixedScenes(video::E_DRIVER_TYPE driverType)
scene::ISceneManager* sceneManager = device->getSceneManager();
gui::IGUIEnvironment* gui = device->getGUIEnvironment();
ICameraSceneNode* camera = sceneManager->addCameraSceneNode();
scene::ICameraSceneNode* camera = sceneManager->addCameraSceneNode();
camera->setPosition(vector3df(0,10,0));
IGUIStaticText* stext = gui->addStaticText(L" ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 ",
gui::IGUIStaticText* stext = gui->addStaticText(L" ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 ",
rect<s32>(5,100,150,125),false,false,0,false);
stext->setBackgroundColor(SColor(255,128,0,0));
stext->setOverrideColor(SColor(255,255,255,255));
stext->setBackgroundColor(video::SColor(255,128,0,0));
stext->setOverrideColor(video::SColor(255,255,255,255));
gui->addEditBox(L"Test edit box", rect<s32>(5,50,150,75));
gui->addCheckBox(true, rect<s32>(5, 20, 150, 45),0,-1,L"Test CheckBox");
video::SMaterial mat;
mat.MaterialType = EMT_SOLID;
mat.setFlag(EMF_LIGHTING, false);
mat.MaterialType = video::EMT_SOLID;
mat.setFlag(video::EMF_LIGHTING, false);
// problem doesn't occur if the scale defaults: (1.f,1.f).
mat.getTextureMatrix(0).setTextureScale(2.0,2.0);
scene::IAnimatedMesh* pmesh = sceneManager->addHillPlaneMesh("testMesh",dimension2d<f32>(50,50),dimension2d<u32>(6,6),&mat);
sceneManager->addAnimatedMeshSceneNode(pmesh);
driver->beginScene(true, true, SColor(255,100,101,140));
driver->beginScene(true, true, video::SColor(255,100,101,140));
sceneManager->drawAll();
gui->drawAll();
driver->endScene();
@ -142,23 +138,23 @@ bool textureRenderStates(void)
{
bool passed = true;
passed &= renderAndLoad(EDT_OPENGL);
passed &= renderAndLoad(EDT_SOFTWARE);
passed &= renderAndLoad(EDT_BURNINGSVIDEO);
passed &= renderAndLoad(EDT_DIRECT3D9);
passed &= renderAndLoad(EDT_DIRECT3D8);
passed &= renderAndLoad(video::EDT_OPENGL);
passed &= renderAndLoad(video::EDT_SOFTWARE);
passed &= renderAndLoad(video::EDT_BURNINGSVIDEO);
passed &= renderAndLoad(video::EDT_DIRECT3D9);
passed &= renderAndLoad(video::EDT_DIRECT3D8);
passed &= renderAndRemove(EDT_OPENGL);
passed &= renderAndRemove(EDT_SOFTWARE);
passed &= renderAndRemove(EDT_BURNINGSVIDEO);
passed &= renderAndRemove(EDT_DIRECT3D9);
passed &= renderAndRemove(EDT_DIRECT3D8);
passed &= renderAndRemove(video::EDT_OPENGL);
passed &= renderAndRemove(video::EDT_SOFTWARE);
passed &= renderAndRemove(video::EDT_BURNINGSVIDEO);
passed &= renderAndRemove(video::EDT_DIRECT3D9);
passed &= renderAndRemove(video::EDT_DIRECT3D8);
passed &= testTextureMatrixInMixedScenes(EDT_OPENGL);
passed &= testTextureMatrixInMixedScenes(EDT_SOFTWARE);
passed &= testTextureMatrixInMixedScenes(EDT_BURNINGSVIDEO);
passed &= testTextureMatrixInMixedScenes(EDT_DIRECT3D9);
passed &= testTextureMatrixInMixedScenes(EDT_DIRECT3D8);
passed &= testTextureMatrixInMixedScenes(video::EDT_OPENGL);
passed &= testTextureMatrixInMixedScenes(video::EDT_SOFTWARE);
passed &= testTextureMatrixInMixedScenes(video::EDT_BURNINGSVIDEO);
passed &= testTextureMatrixInMixedScenes(video::EDT_DIRECT3D9);
passed &= testTextureMatrixInMixedScenes(video::EDT_DIRECT3D8);
return passed;
}

View File

@ -50,6 +50,7 @@ bool testWithDriver(video::E_DRIVER_TYPE driverType)
bool transparentAlphaChannelRef(void)
{
bool result = testWithDriver(EDT_DIRECT3D9);
result &= testWithDriver(EDT_OPENGL);
// FIXME Rogerborg 8-January-2009. Burning's video currently produces unexpected results,
// blending using the full alpha value instead of using a boolean mask. This test is being

View File

@ -23,7 +23,7 @@ namespace gui
core::rect<s32> r0(getAbsolutePosition()),
r2(0, fh + 5, r0.getWidth() - 5, fh*2 + 10 ),
r3(r2),
r3(r2),
r4(r2.getWidth() - 20, 3, r2.getWidth() - 3, r2.getHeight()-3);
AttribColor = Environment->addTab(r4, this, 0);
@ -116,7 +116,7 @@ namespace gui
Attribs->setAttribute(Index, AttribEditBox->getText());
video::SColor col = Attribs->getAttributeAsColor(Index);
AttribSliderA->setPos(col.getAlpha());
AttribSliderR->setPos(col.getRed());
AttribSliderR->setPos(col.getRed());
AttribSliderG->setPos(col.getGreen());
AttribSliderB->setPos(col.getBlue());
// update colour
@ -126,7 +126,7 @@ namespace gui
case EGET_SCROLL_BAR_CHANGED:
{
// update editbox from scrollbars
video::SColor col( AttribSliderA->getPos(), AttribSliderR->getPos(),
video::SColor col( AttribSliderA->getPos(), AttribSliderR->getPos(),
AttribSliderG->getPos(), AttribSliderB->getPos());
Attribs->setAttribute(Index, col);
@ -135,8 +135,12 @@ namespace gui
AttribColor->setBackgroundColor(col);
}
return updateAttrib();
default:
break;
}
break;
default:
break;
}
return CGUIAttribute::OnEvent(e);
}
@ -154,8 +158,8 @@ namespace gui
//! this shoudln't be serialized, but this is included as it's an example
virtual const c8* getTypeName() const
{
return "color_attribute";
{
return "color_attribute";
}
private:

View File

@ -186,6 +186,8 @@ bool CGUIEditWindow::OnEvent(const SEvent &event)
Resizing = false;
}
break;
default:
break;
}
break;
@ -254,7 +256,11 @@ bool CGUIEditWindow::OnEvent(const SEvent &event)
return true;
}
break;
default:
break;
}
default:
break;
}
return Parent ? Parent->OnEvent(event) : false;

View File

@ -79,7 +79,7 @@ CGUIEditWorkspace::EGUIEDIT_MODE CGUIEditWorkspace::getModeFromPos(core::positio
{
core::rect<s32> r = SelectedElement->getAbsolutePosition();
if (TLRect.isPointInside(p))
if (TLRect.isPointInside(p))
return EGUIEDM_RESIZE_TL;
else if (TRRect.isPointInside(p))
@ -106,7 +106,7 @@ CGUIEditWorkspace::EGUIEDIT_MODE CGUIEditWorkspace::getModeFromPos(core::positio
else if (getEditableElementFromPoint(SelectedElement, p) == SelectedElement)
return EGUIEDM_MOVE;
else
else
return EGUIEDM_SELECT;
}
@ -296,6 +296,8 @@ bool CGUIEditWorkspace::OnEvent(const SEvent &e)
PasteXMLToSelectedElement();
}
break;
default:
break;
}
return true;
@ -389,7 +391,7 @@ bool CGUIEditWorkspace::OnEvent(const SEvent &e)
sub = mnu->getSubMenu(1);
sub->addItem(L"Cut (ctrl+x)", MenuCommandStart + EGUIEDMC_CUT_ELEMENT, (SelectedElement != 0));
sub->addItem(L"Copy (ctrl+c)", MenuCommandStart + EGUIEDMC_COPY_ELEMENT, (SelectedElement != 0));
sub->addItem(L"Paste (ctrl+v)", MenuCommandStart + EGUIEDMC_PASTE_ELEMENT,
sub->addItem(L"Paste (ctrl+v)", MenuCommandStart + EGUIEDMC_PASTE_ELEMENT,
(core::stringc(Environment->getOSOperator()->getTextFromClipboard()) != ""));
sub->addItem(L"Delete (del)", MenuCommandStart + EGUIEDMC_DELETE_ELEMENT, (SelectedElement != 0));
sub->addSeparator();
@ -446,7 +448,7 @@ bool CGUIEditWorkspace::OnEvent(const SEvent &e)
{
if (SelectedElement)
{
MouseOverElement = getEditableElementFromPoint(Parent,
MouseOverElement = getEditableElementFromPoint(Parent,
core::position2di(e.MouseInput.X,e.MouseInput.Y));
if (MouseOverElement)
{
@ -554,9 +556,13 @@ bool CGUIEditWorkspace::OnEvent(const SEvent &e)
case EGUIEDM_RESIZE_BR:
SelectedArea.LowerRightCorner = p;
break;
default:
break;
}
}
break;
default:
break;
}
break;
@ -571,7 +577,7 @@ bool CGUIEditWorkspace::OnEvent(const SEvent &e)
break;
case EGET_MENU_ITEM_SELECTED:
{
IGUIContextMenu *menu = (IGUIContextMenu*)e.GUIEvent.Caller;
s32 cmdID = menu->getItemCommandId(menu->getSelectedItem()) - MenuCommandStart;
@ -671,13 +677,19 @@ bool CGUIEditWorkspace::OnEvent(const SEvent &e)
}
}
break;
}
}
return true;
default:
break;
}
break;
default:
break;
}
// even if we didn't absorb the event,
// even if we didn't absorb the event,
// we never pass events back to the GUI we're editing!
return false;
}
@ -741,9 +753,9 @@ void CGUIEditWorkspace::draw()
TopRect = core::rect<s32>(r.getCenter().X-2, r.UpperLeftCorner.Y,r.getCenter().X+2, r.UpperLeftCorner.Y+4 );
BLRect = core::rect<s32>(r.UpperLeftCorner.X, r.LowerRightCorner.Y-4, r.UpperLeftCorner.X+4, r.LowerRightCorner.Y);
LRect = core::rect<s32>(r.UpperLeftCorner.X,r.getCenter().Y-2, r.UpperLeftCorner.X+4, r.getCenter().Y+2 );
RRect = core::rect<s32>(r.LowerRightCorner.X-4,r.getCenter().Y-2, r.LowerRightCorner.X, r.getCenter().Y+2 );
RRect = core::rect<s32>(r.LowerRightCorner.X-4,r.getCenter().Y-2, r.LowerRightCorner.X, r.getCenter().Y+2 );
BRRect = core::rect<s32>(r.LowerRightCorner-d, r.LowerRightCorner);
BRect = core::rect<s32>(r.getCenter().X-2, r.LowerRightCorner.Y-4,r.getCenter().X+2, r.LowerRightCorner.Y );
BRect = core::rect<s32>(r.getCenter().X-2, r.LowerRightCorner.Y-4,r.getCenter().X+2, r.LowerRightCorner.Y );
// top left
if (m == EGUIEDM_RESIZE_T || m == EGUIEDM_RESIZE_L || m == EGUIEDM_RESIZE_TL || m == EGUIEDM_MOVE )
@ -868,7 +880,7 @@ void CGUIEditWorkspace::PasteXMLToSelectedElement()
// reset focus
Environment->setFocus(this);
// drop the read file
memWrite->drop();
}

View File

@ -31,7 +31,7 @@ namespace gui
AttribImage->setSubElement(true);
AttribImage->setScaleImage(true);
AttribImage->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
topy += 105;
core::rect<s32> r2(0, topy, r.getWidth() - 15 - skin->getSize(EGDS_CHECK_BOX_WIDTH), topy + h);
@ -81,15 +81,19 @@ namespace gui
break;
case EGET_FILE_SELECTED:
// file selected: change editbox value and set event
return true;
case EGET_FILE_CHOOSE_DIALOG_CANCELLED:
return true;
default:
break;
}
break;
case EET_KEY_INPUT_EVENT:
return true;
default:
break;
}
}
return CGUIAttribute::OnEvent(e);

View File

@ -14,7 +14,7 @@ namespace irr
namespace gui
{
CGUITextureCacheBrowser::CGUITextureCacheBrowser(IGUIEnvironment* environment, s32 id, IGUIElement *parent)
CGUITextureCacheBrowser::CGUITextureCacheBrowser(IGUIEnvironment* environment, s32 id, IGUIElement *parent)
: IGUIWindow(environment, parent, id, core::rect<s32>(0,0,300,200)),
CloseButton(0), Panel(0), SelectedTexture(-1), Dragging(false), IsDraggable(true)
{
@ -28,7 +28,7 @@ CGUITextureCacheBrowser::CGUITextureCacheBrowser(IGUIEnvironment* environment, s
if (environment)
skin = environment->getSkin();
s32 buttonw = 15;
if (skin)
{
@ -38,7 +38,7 @@ CGUITextureCacheBrowser::CGUITextureCacheBrowser(IGUIEnvironment* environment, s
}
s32 posx = RelativeRect.getWidth() - buttonw - 4;
CloseButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1,
CloseButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1,
L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close" );
CloseButton->setSubElement(true);
CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
@ -62,7 +62,7 @@ CGUITextureCacheBrowser::CGUITextureCacheBrowser(IGUIEnvironment* environment, s
Panel->setSubElement(true);
// some buttons
// add images from texture cache
updateImageList();
@ -75,7 +75,7 @@ CGUITextureCacheBrowser::~CGUITextureCacheBrowser()
CloseButton->drop();
if (Panel)
Panel->drop();
// drop images
u32 i;
for (i=0; i<Images.size(); ++i)
@ -105,7 +105,7 @@ void CGUITextureCacheBrowser::updateImageList()
s32 h = Panel->getClientArea().getWidth()-10;
s32 hw = h/2;
core::rect<s32> pos(Panel->getClientArea().getCenter().X - Panel->getAbsolutePosition().UpperLeftCorner.X - hw, 5,
core::rect<s32> pos(Panel->getClientArea().getCenter().X - Panel->getAbsolutePosition().UpperLeftCorner.X - hw, 5,
Panel->getClientArea().getCenter().X - Panel->getAbsolutePosition().UpperLeftCorner.X + hw, h+5);
core::position2di moveDist(0, h+5);
@ -257,7 +257,7 @@ bool CGUITextureCacheBrowser::OnEvent(const SEvent &event)
event.MouseInput.Y > Parent->getAbsolutePosition().LowerRightCorner.Y -1)
return true;
move(core::position2d<s32>(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y));
DragStart.X = event.MouseInput.X;
@ -265,7 +265,11 @@ bool CGUITextureCacheBrowser::OnEvent(const SEvent &event)
return true;
}
break;
default:
break;
}
default:
break;
}
return Parent ? Parent->OnEvent(event) : false;

View File

@ -1,5 +1,5 @@
#include <irrlicht.h>
#include <iostream>
#include "driverChoice.h"
// include the gui creator element factory
#include "CGUIEditFactory.h"
@ -14,30 +14,11 @@ using namespace gui;
int main()
{
// ask user for driver
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
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='a';
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 1;
}
IrrlichtDevice *device =createDevice(driverType, core::dimension2du(800, 600));
IrrlichtDevice *device = createDevice(driverType, core::dimension2du(800, 600));
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment *env = device->getGUIEnvironment();
@ -93,5 +74,3 @@ int main()
return 0;
}