Reset all line endings to Windows-style CRLF
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2268 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
22bf412ce9
commit
2a5a21fce4
|
@ -1,103 +1,103 @@
|
|||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __E_DRIVER_FEATURES_H_INCLUDED__
|
||||
#define __E_DRIVER_FEATURES_H_INCLUDED__
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
//! enumeration for querying features of the video driver.
|
||||
enum E_VIDEO_DRIVER_FEATURE
|
||||
{
|
||||
//! Is driver able to render to a surface?
|
||||
EVDF_RENDER_TO_TARGET = 0,
|
||||
|
||||
//! Is hardeware transform and lighting supported?
|
||||
EVDF_HARDWARE_TL,
|
||||
|
||||
//! Are multiple textures per material possible?
|
||||
EVDF_MULTITEXTURE,
|
||||
|
||||
//! Is driver able to render with a bilinear filter applied?
|
||||
EVDF_BILINEAR_FILTER,
|
||||
|
||||
//! Can the driver handle mip maps?
|
||||
EVDF_MIP_MAP,
|
||||
|
||||
//! Can the driver update mip maps automatically?
|
||||
EVDF_MIP_MAP_AUTO_UPDATE,
|
||||
|
||||
//! Are stencilbuffers switched on and does the device support stencil buffers?
|
||||
EVDF_STENCIL_BUFFER,
|
||||
|
||||
//! Is Vertex Shader 1.1 supported?
|
||||
EVDF_VERTEX_SHADER_1_1,
|
||||
|
||||
//! Is Vertex Shader 2.0 supported?
|
||||
EVDF_VERTEX_SHADER_2_0,
|
||||
|
||||
//! Is Vertex Shader 3.0 supported?
|
||||
EVDF_VERTEX_SHADER_3_0,
|
||||
|
||||
//! Is Pixel Shader 1.1 supported?
|
||||
EVDF_PIXEL_SHADER_1_1,
|
||||
|
||||
//! Is Pixel Shader 1.2 supported?
|
||||
EVDF_PIXEL_SHADER_1_2,
|
||||
|
||||
//! Is Pixel Shader 1.3 supported?
|
||||
EVDF_PIXEL_SHADER_1_3,
|
||||
|
||||
//! Is Pixel Shader 1.4 supported?
|
||||
EVDF_PIXEL_SHADER_1_4,
|
||||
|
||||
//! Is Pixel Shader 2.0 supported?
|
||||
EVDF_PIXEL_SHADER_2_0,
|
||||
|
||||
//! Is Pixel Shader 3.0 supported?
|
||||
EVDF_PIXEL_SHADER_3_0,
|
||||
|
||||
//! Are ARB vertex programs v1.0 supported?
|
||||
EVDF_ARB_VERTEX_PROGRAM_1,
|
||||
|
||||
//! Are ARB fragment programs v1.0 supported?
|
||||
EVDF_ARB_FRAGMENT_PROGRAM_1,
|
||||
|
||||
//! Is GLSL supported?
|
||||
EVDF_ARB_GLSL,
|
||||
|
||||
//! Is HLSL supported?
|
||||
EVDF_HLSL,
|
||||
|
||||
//! Are non-square textures supported?
|
||||
EVDF_TEXTURE_NSQUARE,
|
||||
|
||||
//! Are non-power-of-two textures supported?
|
||||
EVDF_TEXTURE_NPOT,
|
||||
|
||||
//! Are framebuffer objects supported?
|
||||
EVDF_FRAMEBUFFER_OBJECT,
|
||||
|
||||
//! Are vertex buffer objects supported?
|
||||
EVDF_VERTEX_BUFFER_OBJECT,
|
||||
|
||||
//! Supports Alpha To Coverage
|
||||
EVDF_ALPHA_TO_COVERAGE,
|
||||
|
||||
//! Supports Color masks (disabling color planes in output)
|
||||
EVDF_COLOR_MASK,
|
||||
|
||||
//! Only used for counting the elements of this enum
|
||||
EVDF_COUNT
|
||||
};
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __E_DRIVER_FEATURES_H_INCLUDED__
|
||||
#define __E_DRIVER_FEATURES_H_INCLUDED__
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
//! enumeration for querying features of the video driver.
|
||||
enum E_VIDEO_DRIVER_FEATURE
|
||||
{
|
||||
//! Is driver able to render to a surface?
|
||||
EVDF_RENDER_TO_TARGET = 0,
|
||||
|
||||
//! Is hardeware transform and lighting supported?
|
||||
EVDF_HARDWARE_TL,
|
||||
|
||||
//! Are multiple textures per material possible?
|
||||
EVDF_MULTITEXTURE,
|
||||
|
||||
//! Is driver able to render with a bilinear filter applied?
|
||||
EVDF_BILINEAR_FILTER,
|
||||
|
||||
//! Can the driver handle mip maps?
|
||||
EVDF_MIP_MAP,
|
||||
|
||||
//! Can the driver update mip maps automatically?
|
||||
EVDF_MIP_MAP_AUTO_UPDATE,
|
||||
|
||||
//! Are stencilbuffers switched on and does the device support stencil buffers?
|
||||
EVDF_STENCIL_BUFFER,
|
||||
|
||||
//! Is Vertex Shader 1.1 supported?
|
||||
EVDF_VERTEX_SHADER_1_1,
|
||||
|
||||
//! Is Vertex Shader 2.0 supported?
|
||||
EVDF_VERTEX_SHADER_2_0,
|
||||
|
||||
//! Is Vertex Shader 3.0 supported?
|
||||
EVDF_VERTEX_SHADER_3_0,
|
||||
|
||||
//! Is Pixel Shader 1.1 supported?
|
||||
EVDF_PIXEL_SHADER_1_1,
|
||||
|
||||
//! Is Pixel Shader 1.2 supported?
|
||||
EVDF_PIXEL_SHADER_1_2,
|
||||
|
||||
//! Is Pixel Shader 1.3 supported?
|
||||
EVDF_PIXEL_SHADER_1_3,
|
||||
|
||||
//! Is Pixel Shader 1.4 supported?
|
||||
EVDF_PIXEL_SHADER_1_4,
|
||||
|
||||
//! Is Pixel Shader 2.0 supported?
|
||||
EVDF_PIXEL_SHADER_2_0,
|
||||
|
||||
//! Is Pixel Shader 3.0 supported?
|
||||
EVDF_PIXEL_SHADER_3_0,
|
||||
|
||||
//! Are ARB vertex programs v1.0 supported?
|
||||
EVDF_ARB_VERTEX_PROGRAM_1,
|
||||
|
||||
//! Are ARB fragment programs v1.0 supported?
|
||||
EVDF_ARB_FRAGMENT_PROGRAM_1,
|
||||
|
||||
//! Is GLSL supported?
|
||||
EVDF_ARB_GLSL,
|
||||
|
||||
//! Is HLSL supported?
|
||||
EVDF_HLSL,
|
||||
|
||||
//! Are non-square textures supported?
|
||||
EVDF_TEXTURE_NSQUARE,
|
||||
|
||||
//! Are non-power-of-two textures supported?
|
||||
EVDF_TEXTURE_NPOT,
|
||||
|
||||
//! Are framebuffer objects supported?
|
||||
EVDF_FRAMEBUFFER_OBJECT,
|
||||
|
||||
//! Are vertex buffer objects supported?
|
||||
EVDF_VERTEX_BUFFER_OBJECT,
|
||||
|
||||
//! Supports Alpha To Coverage
|
||||
EVDF_ALPHA_TO_COVERAGE,
|
||||
|
||||
//! Supports Color masks (disabling color planes in output)
|
||||
EVDF_COLOR_MASK,
|
||||
|
||||
//! Only used for counting the elements of this enum
|
||||
EVDF_COUNT
|
||||
};
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,40 +1,40 @@
|
|||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __E_HARDWARE_BUFFER_FLAGS_INCLUDED__
|
||||
#define __E_HARDWARE_BUFFER_FLAGS_INCLUDED__
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
enum E_HARDWARE_MAPPING
|
||||
{
|
||||
//! Don't load in hardware
|
||||
EHM_NEVER=0,
|
||||
|
||||
//! Rarely changed
|
||||
EHM_STATIC,
|
||||
|
||||
//! Sometimes changed
|
||||
EHM_DYNAMIC,
|
||||
|
||||
//! Always changed
|
||||
EHM_STREAM
|
||||
};
|
||||
|
||||
enum E_BUFFER_TYPE
|
||||
{
|
||||
EBT_NONE=0,
|
||||
EBT_VERTEX,
|
||||
EBT_INDEX,
|
||||
EBT_VERTEX_AND_INDEX
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __E_HARDWARE_BUFFER_FLAGS_INCLUDED__
|
||||
#define __E_HARDWARE_BUFFER_FLAGS_INCLUDED__
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
enum E_HARDWARE_MAPPING
|
||||
{
|
||||
//! Don't load in hardware
|
||||
EHM_NEVER=0,
|
||||
|
||||
//! Rarely changed
|
||||
EHM_STATIC,
|
||||
|
||||
//! Sometimes changed
|
||||
EHM_DYNAMIC,
|
||||
|
||||
//! Always changed
|
||||
EHM_STREAM
|
||||
};
|
||||
|
||||
enum E_BUFFER_TYPE
|
||||
{
|
||||
EBT_NONE=0,
|
||||
EBT_VERTEX,
|
||||
EBT_INDEX,
|
||||
EBT_VERTEX_AND_INDEX
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,36 +1,36 @@
|
|||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __E_TERRAIN_ELEMENTS_H__
|
||||
#define __E_TERRAIN_ELEMENTS_H__
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
//! enumeration for patch sizes specifying the size of patches in the TerrainSceneNode
|
||||
enum E_TERRAIN_PATCH_SIZE
|
||||
{
|
||||
//! patch size of 9, at most, use 4 levels of detail with this patch size.
|
||||
ETPS_9 = 9,
|
||||
|
||||
//! patch size of 17, at most, use 5 levels of detail with this patch size.
|
||||
ETPS_17 = 17,
|
||||
|
||||
//! patch size of 33, at most, use 6 levels of detail with this patch size.
|
||||
ETPS_33 = 33,
|
||||
|
||||
//! patch size of 65, at most, use 7 levels of detail with this patch size.
|
||||
ETPS_65 = 65,
|
||||
|
||||
//! patch size of 129, at most, use 8 levels of detail with this patch size.
|
||||
ETPS_129 = 129
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __E_TERRAIN_ELEMENTS_H__
|
||||
#define __E_TERRAIN_ELEMENTS_H__
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
//! enumeration for patch sizes specifying the size of patches in the TerrainSceneNode
|
||||
enum E_TERRAIN_PATCH_SIZE
|
||||
{
|
||||
//! patch size of 9, at most, use 4 levels of detail with this patch size.
|
||||
ETPS_9 = 9,
|
||||
|
||||
//! patch size of 17, at most, use 5 levels of detail with this patch size.
|
||||
ETPS_17 = 17,
|
||||
|
||||
//! patch size of 33, at most, use 6 levels of detail with this patch size.
|
||||
ETPS_33 = 33,
|
||||
|
||||
//! patch size of 65, at most, use 7 levels of detail with this patch size.
|
||||
ETPS_65 = 65,
|
||||
|
||||
//! patch size of 129, at most, use 8 levels of detail with this patch size.
|
||||
ETPS_129 = 129
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,65 +1,65 @@
|
|||
// Copyright (C) 2006-2009 Michael Zeilfelder
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __I_GUI_SPIN_BOX_H_INCLUDED__
|
||||
#define __I_GUI_SPIN_BOX_H_INCLUDED__
|
||||
|
||||
#include "IGUIElement.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace gui
|
||||
{
|
||||
class IGUIEditBox;
|
||||
|
||||
//! Single line edit box + spin buttons
|
||||
class IGUISpinBox : public IGUIElement
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
IGUISpinBox(IGUIEnvironment* environment, IGUIElement* parent,
|
||||
s32 id, core::rect<s32> rectangle)
|
||||
: IGUIElement(EGUIET_SPIN_BOX, environment, parent, id, rectangle) {}
|
||||
|
||||
//! Access the edit box used in the spin control
|
||||
virtual IGUIEditBox* getEditBox() const = 0;
|
||||
|
||||
//! set the current value of the spinbox
|
||||
/** \param val: value to be set in the spinbox */
|
||||
virtual void setValue(f32 val) = 0;
|
||||
|
||||
//! Get the current value of the spinbox
|
||||
virtual f32 getValue() const = 0;
|
||||
|
||||
//! set the range of values which can be used in the spinbox
|
||||
/** \param min: minimum value
|
||||
\param max: maximum value */
|
||||
virtual void setRange(f32 min, f32 max) = 0;
|
||||
|
||||
//! get the minimum value which can be used in the spinbox
|
||||
virtual f32 getMin() const = 0;
|
||||
|
||||
//! get the maximum value which can be used in the spinbox
|
||||
virtual f32 getMax() const = 0;
|
||||
|
||||
//! Step size by which values are changed when pressing the spinbuttons
|
||||
/** The step size also determines the number of decimal places to display
|
||||
\param step: stepsize used for value changes when pressing spinbuttons */
|
||||
virtual void setStepSize(f32 step=1.f) = 0;
|
||||
|
||||
//! Sets the number of decimal places to display.
|
||||
/** \param places: The number of decimal places to display, use -1 to reset */
|
||||
virtual void setDecimalPlaces(s32 places) = 0;
|
||||
|
||||
//! get the current step size
|
||||
virtual f32 getStepSize() const = 0;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
#endif // __I_GUI_SPIN_BOX_H_INCLUDED__
|
||||
|
||||
// Copyright (C) 2006-2009 Michael Zeilfelder
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __I_GUI_SPIN_BOX_H_INCLUDED__
|
||||
#define __I_GUI_SPIN_BOX_H_INCLUDED__
|
||||
|
||||
#include "IGUIElement.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace gui
|
||||
{
|
||||
class IGUIEditBox;
|
||||
|
||||
//! Single line edit box + spin buttons
|
||||
class IGUISpinBox : public IGUIElement
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
IGUISpinBox(IGUIEnvironment* environment, IGUIElement* parent,
|
||||
s32 id, core::rect<s32> rectangle)
|
||||
: IGUIElement(EGUIET_SPIN_BOX, environment, parent, id, rectangle) {}
|
||||
|
||||
//! Access the edit box used in the spin control
|
||||
virtual IGUIEditBox* getEditBox() const = 0;
|
||||
|
||||
//! set the current value of the spinbox
|
||||
/** \param val: value to be set in the spinbox */
|
||||
virtual void setValue(f32 val) = 0;
|
||||
|
||||
//! Get the current value of the spinbox
|
||||
virtual f32 getValue() const = 0;
|
||||
|
||||
//! set the range of values which can be used in the spinbox
|
||||
/** \param min: minimum value
|
||||
\param max: maximum value */
|
||||
virtual void setRange(f32 min, f32 max) = 0;
|
||||
|
||||
//! get the minimum value which can be used in the spinbox
|
||||
virtual f32 getMin() const = 0;
|
||||
|
||||
//! get the maximum value which can be used in the spinbox
|
||||
virtual f32 getMax() const = 0;
|
||||
|
||||
//! Step size by which values are changed when pressing the spinbuttons
|
||||
/** The step size also determines the number of decimal places to display
|
||||
\param step: stepsize used for value changes when pressing spinbuttons */
|
||||
virtual void setStepSize(f32 step=1.f) = 0;
|
||||
|
||||
//! Sets the number of decimal places to display.
|
||||
/** \param places: The number of decimal places to display, use -1 to reset */
|
||||
virtual void setDecimalPlaces(s32 places) = 0;
|
||||
|
||||
//! get the current step size
|
||||
virtual f32 getStepSize() const = 0;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
#endif // __I_GUI_SPIN_BOX_H_INCLUDED__
|
||||
|
||||
|
|
|
@ -1,51 +1,51 @@
|
|||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
//
|
||||
// created by Dean Wadsworth aka Varmint Dec 31 2007
|
||||
|
||||
#ifndef __I_VOLUME_LIGHT_SCENE_NODE_H_INCLUDED__
|
||||
#define __I_VOLUME_LIGHT_SCENE_NODE_H_INCLUDED__
|
||||
|
||||
#include "ISceneNode.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
class IMeshBuffer;
|
||||
|
||||
class IVolumeLightSceneNode : public ISceneNode
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
IVolumeLightSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
|
||||
const core::vector3df& position,
|
||||
const core::vector3df& rotation,
|
||||
const core::vector3df& scale)
|
||||
: ISceneNode(parent, mgr, id, position, rotation, scale) {};
|
||||
|
||||
//! Returns type of the scene node
|
||||
virtual ESCENE_NODE_TYPE getType() const { return ESNT_CUBE; }
|
||||
|
||||
virtual void setSubDivideU (const u32 inU) =0;
|
||||
virtual void setSubDivideV (const u32 inV) =0;
|
||||
|
||||
virtual u32 getSubDivideU () const =0;
|
||||
virtual u32 getSubDivideV () const =0;
|
||||
|
||||
virtual void setFootColour(const video::SColor inColour) =0;
|
||||
virtual void setTailColour(const video::SColor inColour) =0;
|
||||
|
||||
virtual video::SColor getFootColour () const =0;
|
||||
virtual video::SColor getTailColour () const =0;
|
||||
|
||||
virtual IMeshBuffer * getMeshBuffer(void) const =0;
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
//
|
||||
// created by Dean Wadsworth aka Varmint Dec 31 2007
|
||||
|
||||
#ifndef __I_VOLUME_LIGHT_SCENE_NODE_H_INCLUDED__
|
||||
#define __I_VOLUME_LIGHT_SCENE_NODE_H_INCLUDED__
|
||||
|
||||
#include "ISceneNode.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
class IMeshBuffer;
|
||||
|
||||
class IVolumeLightSceneNode : public ISceneNode
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
IVolumeLightSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
|
||||
const core::vector3df& position,
|
||||
const core::vector3df& rotation,
|
||||
const core::vector3df& scale)
|
||||
: ISceneNode(parent, mgr, id, position, rotation, scale) {};
|
||||
|
||||
//! Returns type of the scene node
|
||||
virtual ESCENE_NODE_TYPE getType() const { return ESNT_CUBE; }
|
||||
|
||||
virtual void setSubDivideU (const u32 inU) =0;
|
||||
virtual void setSubDivideV (const u32 inV) =0;
|
||||
|
||||
virtual u32 getSubDivideU () const =0;
|
||||
virtual u32 getSubDivideV () const =0;
|
||||
|
||||
virtual void setFootColour(const video::SColor inColour) =0;
|
||||
virtual void setTailColour(const video::SColor inColour) =0;
|
||||
|
||||
virtual video::SColor getFootColour () const =0;
|
||||
virtual video::SColor getTailColour () const =0;
|
||||
|
||||
virtual IMeshBuffer * getMeshBuffer(void) const =0;
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,237 +1,237 @@
|
|||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __I_IRRLICHT_DEVICE_H_INCLUDED__
|
||||
#define __I_IRRLICHT_DEVICE_H_INCLUDED__
|
||||
|
||||
#include "IReferenceCounted.h"
|
||||
#include "dimension2d.h"
|
||||
#include "IVideoDriver.h"
|
||||
#include "EDriverTypes.h"
|
||||
#include "IEventReceiver.h"
|
||||
#include "ICursorControl.h"
|
||||
#include "IVideoModeList.h"
|
||||
#include "ITimer.h"
|
||||
#include "IOSOperator.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
class ILogger;
|
||||
class IEventReceiver;
|
||||
|
||||
namespace io {
|
||||
class IFileSystem;
|
||||
} // end namespace io
|
||||
|
||||
namespace gui {
|
||||
class IGUIEnvironment;
|
||||
} // end namespace gui
|
||||
|
||||
namespace scene {
|
||||
class ISceneManager;
|
||||
} // end namespace scene
|
||||
|
||||
//! The Irrlicht device. You can create it with createDevice() or createDeviceEx().
|
||||
/** This is the most important class of the Irrlicht Engine. You can access everything
|
||||
in the engine if you have a pointer to an instance of this class.
|
||||
There should be only one instance of this class at any time.
|
||||
*/
|
||||
class IrrlichtDevice : public virtual IReferenceCounted
|
||||
{
|
||||
public:
|
||||
|
||||
//! Runs the device.
|
||||
/** Also increments the virtual timer by calling
|
||||
ITimer::tick();. You can prevent this
|
||||
by calling ITimer::stop(); before and ITimer::start() after
|
||||
calling IrrlichtDevice::run(). Returns false if device wants
|
||||
to be deleted. Use it in this way:
|
||||
\code
|
||||
while(device->run())
|
||||
{
|
||||
// draw everything here
|
||||
}
|
||||
\endcode
|
||||
If you want the device to do nothing if the window is inactive
|
||||
(recommended), use the slightly enhanced code shown at isWindowActive().
|
||||
|
||||
Note if you are running Irrlicht inside an external, custom
|
||||
created window: Calling Device->run() will cause Irrlicht to
|
||||
dispatch windows messages internally.
|
||||
If you are running Irrlicht in your own custom window, you can
|
||||
also simply use your own message loop using GetMessage,
|
||||
DispatchMessage and whatever and simply don't use this method.
|
||||
But note that Irrlicht will not be able to fetch user input
|
||||
then. See irr::SIrrlichtCreationParameters::WindowId for more
|
||||
informations and example code.
|
||||
*/
|
||||
virtual bool run() = 0;
|
||||
|
||||
//! Cause the device to temporarily pause execution and let other processes run.
|
||||
/** This should bring down processor usage without major
|
||||
performance loss for Irrlicht */
|
||||
virtual void yield() = 0;
|
||||
|
||||
//! Pause execution and let other processes to run for a specified amount of time.
|
||||
/** It may not wait the full given time, as sleep may be interrupted
|
||||
\param timeMs: Time to sleep for in milisecs.
|
||||
\param pauseTimer: If true, pauses the device timer while sleeping
|
||||
*/
|
||||
virtual void sleep(u32 timeMs, bool pauseTimer=false) = 0;
|
||||
|
||||
//! Provides access to the video driver for drawing 3d and 2d geometry.
|
||||
/** \return Pointer the video driver. */
|
||||
virtual video::IVideoDriver* getVideoDriver() = 0;
|
||||
|
||||
//! Provides access to the virtual file system.
|
||||
/** \return Pointer to the file system. */
|
||||
virtual io::IFileSystem* getFileSystem() = 0;
|
||||
|
||||
//! Provides access to the 2d user interface environment.
|
||||
/** \return Pointer to the gui environment. */
|
||||
virtual gui::IGUIEnvironment* getGUIEnvironment() = 0;
|
||||
|
||||
//! Provides access to the scene manager.
|
||||
/** \return Pointer to the scene manager. */
|
||||
virtual scene::ISceneManager* getSceneManager() = 0;
|
||||
|
||||
//! Provides access to the cursor control.
|
||||
/** \return Pointer to the mouse cursor control interface. */
|
||||
virtual gui::ICursorControl* getCursorControl() = 0;
|
||||
|
||||
//! Provides access to the message logger.
|
||||
/** \return Pointer to the logger. */
|
||||
virtual ILogger* getLogger() = 0;
|
||||
|
||||
//! Gets a list with all video modes available.
|
||||
/** If you are confused now, because you think you have to
|
||||
create an Irrlicht Device with a video mode before being able
|
||||
to get the video mode list, let me tell you that there is no
|
||||
need to start up an Irrlicht Device with EDT_DIRECT3D8,
|
||||
EDT_OPENGL or EDT_SOFTWARE: For this (and for lots of other
|
||||
reasons) the null driver, EDT_NULL exists.
|
||||
\return Pointer to a list with all video modes supported
|
||||
by the gfx adapter. */
|
||||
virtual video::IVideoModeList* getVideoModeList() = 0;
|
||||
|
||||
//! Provides access to the operation system operator object.
|
||||
/** The OS operator provides methods for
|
||||
getting system specific informations and doing system
|
||||
specific operations, such as exchanging data with the clipboard
|
||||
or reading the operation system version.
|
||||
\return Pointer to the OS operator. */
|
||||
virtual IOSOperator* getOSOperator() = 0;
|
||||
|
||||
//! Provides access to the engine's timer.
|
||||
/** The system time can be retrieved by it as
|
||||
well as the virtual time, which also can be manipulated.
|
||||
\return Pointer to the ITimer object. */
|
||||
virtual ITimer* getTimer() = 0;
|
||||
|
||||
//! Sets the caption of the window.
|
||||
/** \param text: New text of the window caption. */
|
||||
virtual void setWindowCaption(const wchar_t* text) = 0;
|
||||
|
||||
//! Returns if the window is active.
|
||||
/** If the window is inactive,
|
||||
nothing needs to be drawn. So if you don't want to draw anything
|
||||
when the window is inactive, create your drawing loop this way:
|
||||
\code
|
||||
while(device->run())
|
||||
{
|
||||
if (device->isWindowActive())
|
||||
{
|
||||
// draw everything here
|
||||
}
|
||||
else
|
||||
device->yield();
|
||||
}
|
||||
\endcode
|
||||
\return True if window is active. */
|
||||
virtual bool isWindowActive() const = 0;
|
||||
|
||||
//! Checks if the Irrlicht window has focus
|
||||
/** \return True if window has focus. */
|
||||
virtual bool isWindowFocused() const = 0;
|
||||
|
||||
//! Checks if the Irrlicht window is minimized
|
||||
/** \return True if window is minimized. */
|
||||
virtual bool isWindowMinimized() const = 0;
|
||||
|
||||
//! Checks if the Irrlicht window is running in fullscreen mode
|
||||
/** \return True if window is fullscreen. */
|
||||
virtual bool isFullscreen() const = 0;
|
||||
|
||||
//! Get the current color format of the window
|
||||
/** \return Color format of the window. */
|
||||
virtual video::ECOLOR_FORMAT getColorFormat() const = 0;
|
||||
|
||||
//! Notifies the device that it should close itself.
|
||||
/** IrrlichtDevice::run() will always return false after closeDevice() was called. */
|
||||
virtual void closeDevice() = 0;
|
||||
|
||||
//! Get the version of the engine.
|
||||
/** The returned string
|
||||
will look like this: "1.2.3" or this: "1.2".
|
||||
\return String which contains the version. */
|
||||
virtual const c8* getVersion() const = 0;
|
||||
|
||||
//! Sets a new user event receiver which will receive events from the engine.
|
||||
/** Return true in IEventReceiver::OnEvent to prevent the event from continuing along
|
||||
the chain of event receivers. The path that an event takes through the system depends
|
||||
on its type. See irr::EEVENT_TYPE for details.
|
||||
\param receiver New receiver to be used. */
|
||||
virtual void setEventReceiver(IEventReceiver* receiver) = 0;
|
||||
|
||||
//! Provides access to the current event receiver.
|
||||
/** \return Pointer to the current event receiver. Returns 0 if there is none. */
|
||||
virtual IEventReceiver* getEventReceiver() = 0;
|
||||
|
||||
//! Sends a user created event to the engine.
|
||||
/** Is is usually not necessary to use this. However, if you
|
||||
are using an own input library for example for doing joystick
|
||||
input, you can use this to post key or mouse input events to
|
||||
the engine. Internally, this method only delegates the events
|
||||
further to the scene manager and the GUI environment. */
|
||||
virtual bool postEventFromUser(const SEvent& event) = 0;
|
||||
|
||||
//! Sets the input receiving scene manager.
|
||||
/** If set to null, the main scene manager (returned by
|
||||
GetSceneManager()) will receive the input
|
||||
\param sceneManager New scene manager to be used. */
|
||||
virtual void setInputReceivingSceneManager(scene::ISceneManager* sceneManager) = 0;
|
||||
|
||||
//! Sets if the window should be resizable in windowed mode.
|
||||
/** The default is false. This method only works in windowed
|
||||
mode.
|
||||
\param resize Flag whether the window should be resizable. */
|
||||
virtual void setResizable(bool resize=false) = 0;
|
||||
|
||||
//! Minimizes the window if possible.
|
||||
virtual void minimizeWindow() =0;
|
||||
|
||||
//! Activate any joysticks, and generate events for them.
|
||||
/** Irrlicht contains support for joysticks, but does not generate joystick events by default,
|
||||
as this would consume joystick info that 3rd party libraries might rely on. Call this method to
|
||||
activate joystick support in Irrlicht and to receive irr::SJoystickEvent events.
|
||||
\param joystickInfo On return, this will contain an array of each joystick that was found and activated.
|
||||
\return true if joysticks are supported on this device and _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
||||
is defined, false if joysticks are not supported or support is compiled out.
|
||||
*/
|
||||
virtual bool activateJoysticks(core::array<SJoystickInfo>& joystickInfo) =0;
|
||||
|
||||
//! Set the current Gamma Value for the Display
|
||||
virtual bool setGammaRamp(f32 red, f32 green, f32 blue,
|
||||
f32 relativebrightness, f32 relativecontrast) =0;
|
||||
|
||||
//! Get the current Gamma Value for the Display
|
||||
virtual bool getGammaRamp(f32 &red, f32 &green, f32 &blue,
|
||||
f32 &brightness, f32 &contrast) =0;
|
||||
|
||||
};
|
||||
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __I_IRRLICHT_DEVICE_H_INCLUDED__
|
||||
#define __I_IRRLICHT_DEVICE_H_INCLUDED__
|
||||
|
||||
#include "IReferenceCounted.h"
|
||||
#include "dimension2d.h"
|
||||
#include "IVideoDriver.h"
|
||||
#include "EDriverTypes.h"
|
||||
#include "IEventReceiver.h"
|
||||
#include "ICursorControl.h"
|
||||
#include "IVideoModeList.h"
|
||||
#include "ITimer.h"
|
||||
#include "IOSOperator.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
class ILogger;
|
||||
class IEventReceiver;
|
||||
|
||||
namespace io {
|
||||
class IFileSystem;
|
||||
} // end namespace io
|
||||
|
||||
namespace gui {
|
||||
class IGUIEnvironment;
|
||||
} // end namespace gui
|
||||
|
||||
namespace scene {
|
||||
class ISceneManager;
|
||||
} // end namespace scene
|
||||
|
||||
//! The Irrlicht device. You can create it with createDevice() or createDeviceEx().
|
||||
/** This is the most important class of the Irrlicht Engine. You can access everything
|
||||
in the engine if you have a pointer to an instance of this class.
|
||||
There should be only one instance of this class at any time.
|
||||
*/
|
||||
class IrrlichtDevice : public virtual IReferenceCounted
|
||||
{
|
||||
public:
|
||||
|
||||
//! Runs the device.
|
||||
/** Also increments the virtual timer by calling
|
||||
ITimer::tick();. You can prevent this
|
||||
by calling ITimer::stop(); before and ITimer::start() after
|
||||
calling IrrlichtDevice::run(). Returns false if device wants
|
||||
to be deleted. Use it in this way:
|
||||
\code
|
||||
while(device->run())
|
||||
{
|
||||
// draw everything here
|
||||
}
|
||||
\endcode
|
||||
If you want the device to do nothing if the window is inactive
|
||||
(recommended), use the slightly enhanced code shown at isWindowActive().
|
||||
|
||||
Note if you are running Irrlicht inside an external, custom
|
||||
created window: Calling Device->run() will cause Irrlicht to
|
||||
dispatch windows messages internally.
|
||||
If you are running Irrlicht in your own custom window, you can
|
||||
also simply use your own message loop using GetMessage,
|
||||
DispatchMessage and whatever and simply don't use this method.
|
||||
But note that Irrlicht will not be able to fetch user input
|
||||
then. See irr::SIrrlichtCreationParameters::WindowId for more
|
||||
informations and example code.
|
||||
*/
|
||||
virtual bool run() = 0;
|
||||
|
||||
//! Cause the device to temporarily pause execution and let other processes run.
|
||||
/** This should bring down processor usage without major
|
||||
performance loss for Irrlicht */
|
||||
virtual void yield() = 0;
|
||||
|
||||
//! Pause execution and let other processes to run for a specified amount of time.
|
||||
/** It may not wait the full given time, as sleep may be interrupted
|
||||
\param timeMs: Time to sleep for in milisecs.
|
||||
\param pauseTimer: If true, pauses the device timer while sleeping
|
||||
*/
|
||||
virtual void sleep(u32 timeMs, bool pauseTimer=false) = 0;
|
||||
|
||||
//! Provides access to the video driver for drawing 3d and 2d geometry.
|
||||
/** \return Pointer the video driver. */
|
||||
virtual video::IVideoDriver* getVideoDriver() = 0;
|
||||
|
||||
//! Provides access to the virtual file system.
|
||||
/** \return Pointer to the file system. */
|
||||
virtual io::IFileSystem* getFileSystem() = 0;
|
||||
|
||||
//! Provides access to the 2d user interface environment.
|
||||
/** \return Pointer to the gui environment. */
|
||||
virtual gui::IGUIEnvironment* getGUIEnvironment() = 0;
|
||||
|
||||
//! Provides access to the scene manager.
|
||||
/** \return Pointer to the scene manager. */
|
||||
virtual scene::ISceneManager* getSceneManager() = 0;
|
||||
|
||||
//! Provides access to the cursor control.
|
||||
/** \return Pointer to the mouse cursor control interface. */
|
||||
virtual gui::ICursorControl* getCursorControl() = 0;
|
||||
|
||||
//! Provides access to the message logger.
|
||||
/** \return Pointer to the logger. */
|
||||
virtual ILogger* getLogger() = 0;
|
||||
|
||||
//! Gets a list with all video modes available.
|
||||
/** If you are confused now, because you think you have to
|
||||
create an Irrlicht Device with a video mode before being able
|
||||
to get the video mode list, let me tell you that there is no
|
||||
need to start up an Irrlicht Device with EDT_DIRECT3D8,
|
||||
EDT_OPENGL or EDT_SOFTWARE: For this (and for lots of other
|
||||
reasons) the null driver, EDT_NULL exists.
|
||||
\return Pointer to a list with all video modes supported
|
||||
by the gfx adapter. */
|
||||
virtual video::IVideoModeList* getVideoModeList() = 0;
|
||||
|
||||
//! Provides access to the operation system operator object.
|
||||
/** The OS operator provides methods for
|
||||
getting system specific informations and doing system
|
||||
specific operations, such as exchanging data with the clipboard
|
||||
or reading the operation system version.
|
||||
\return Pointer to the OS operator. */
|
||||
virtual IOSOperator* getOSOperator() = 0;
|
||||
|
||||
//! Provides access to the engine's timer.
|
||||
/** The system time can be retrieved by it as
|
||||
well as the virtual time, which also can be manipulated.
|
||||
\return Pointer to the ITimer object. */
|
||||
virtual ITimer* getTimer() = 0;
|
||||
|
||||
//! Sets the caption of the window.
|
||||
/** \param text: New text of the window caption. */
|
||||
virtual void setWindowCaption(const wchar_t* text) = 0;
|
||||
|
||||
//! Returns if the window is active.
|
||||
/** If the window is inactive,
|
||||
nothing needs to be drawn. So if you don't want to draw anything
|
||||
when the window is inactive, create your drawing loop this way:
|
||||
\code
|
||||
while(device->run())
|
||||
{
|
||||
if (device->isWindowActive())
|
||||
{
|
||||
// draw everything here
|
||||
}
|
||||
else
|
||||
device->yield();
|
||||
}
|
||||
\endcode
|
||||
\return True if window is active. */
|
||||
virtual bool isWindowActive() const = 0;
|
||||
|
||||
//! Checks if the Irrlicht window has focus
|
||||
/** \return True if window has focus. */
|
||||
virtual bool isWindowFocused() const = 0;
|
||||
|
||||
//! Checks if the Irrlicht window is minimized
|
||||
/** \return True if window is minimized. */
|
||||
virtual bool isWindowMinimized() const = 0;
|
||||
|
||||
//! Checks if the Irrlicht window is running in fullscreen mode
|
||||
/** \return True if window is fullscreen. */
|
||||
virtual bool isFullscreen() const = 0;
|
||||
|
||||
//! Get the current color format of the window
|
||||
/** \return Color format of the window. */
|
||||
virtual video::ECOLOR_FORMAT getColorFormat() const = 0;
|
||||
|
||||
//! Notifies the device that it should close itself.
|
||||
/** IrrlichtDevice::run() will always return false after closeDevice() was called. */
|
||||
virtual void closeDevice() = 0;
|
||||
|
||||
//! Get the version of the engine.
|
||||
/** The returned string
|
||||
will look like this: "1.2.3" or this: "1.2".
|
||||
\return String which contains the version. */
|
||||
virtual const c8* getVersion() const = 0;
|
||||
|
||||
//! Sets a new user event receiver which will receive events from the engine.
|
||||
/** Return true in IEventReceiver::OnEvent to prevent the event from continuing along
|
||||
the chain of event receivers. The path that an event takes through the system depends
|
||||
on its type. See irr::EEVENT_TYPE for details.
|
||||
\param receiver New receiver to be used. */
|
||||
virtual void setEventReceiver(IEventReceiver* receiver) = 0;
|
||||
|
||||
//! Provides access to the current event receiver.
|
||||
/** \return Pointer to the current event receiver. Returns 0 if there is none. */
|
||||
virtual IEventReceiver* getEventReceiver() = 0;
|
||||
|
||||
//! Sends a user created event to the engine.
|
||||
/** Is is usually not necessary to use this. However, if you
|
||||
are using an own input library for example for doing joystick
|
||||
input, you can use this to post key or mouse input events to
|
||||
the engine. Internally, this method only delegates the events
|
||||
further to the scene manager and the GUI environment. */
|
||||
virtual bool postEventFromUser(const SEvent& event) = 0;
|
||||
|
||||
//! Sets the input receiving scene manager.
|
||||
/** If set to null, the main scene manager (returned by
|
||||
GetSceneManager()) will receive the input
|
||||
\param sceneManager New scene manager to be used. */
|
||||
virtual void setInputReceivingSceneManager(scene::ISceneManager* sceneManager) = 0;
|
||||
|
||||
//! Sets if the window should be resizable in windowed mode.
|
||||
/** The default is false. This method only works in windowed
|
||||
mode.
|
||||
\param resize Flag whether the window should be resizable. */
|
||||
virtual void setResizable(bool resize=false) = 0;
|
||||
|
||||
//! Minimizes the window if possible.
|
||||
virtual void minimizeWindow() =0;
|
||||
|
||||
//! Activate any joysticks, and generate events for them.
|
||||
/** Irrlicht contains support for joysticks, but does not generate joystick events by default,
|
||||
as this would consume joystick info that 3rd party libraries might rely on. Call this method to
|
||||
activate joystick support in Irrlicht and to receive irr::SJoystickEvent events.
|
||||
\param joystickInfo On return, this will contain an array of each joystick that was found and activated.
|
||||
\return true if joysticks are supported on this device and _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
||||
is defined, false if joysticks are not supported or support is compiled out.
|
||||
*/
|
||||
virtual bool activateJoysticks(core::array<SJoystickInfo>& joystickInfo) =0;
|
||||
|
||||
//! Set the current Gamma Value for the Display
|
||||
virtual bool setGammaRamp(f32 red, f32 green, f32 blue,
|
||||
f32 relativebrightness, f32 relativecontrast) =0;
|
||||
|
||||
//! Get the current Gamma Value for the Display
|
||||
virtual bool getGammaRamp(f32 &red, f32 &green, f32 &blue,
|
||||
f32 &brightness, f32 &contrast) =0;
|
||||
|
||||
};
|
||||
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,397 +1,397 @@
|
|||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __I_SKIN_MESH_BUFFER_H_INCLUDED__
|
||||
#define __I_SKIN_MESH_BUFFER_H_INCLUDED__
|
||||
|
||||
#include "IMeshBuffer.h"
|
||||
#include "S3DVertex.h"
|
||||
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
|
||||
//! A mesh buffer able to choose between S3DVertex2TCoords, S3DVertex and S3DVertexTangents at runtime
|
||||
struct SSkinMeshBuffer : public IMeshBuffer
|
||||
{
|
||||
//! Default constructor
|
||||
SSkinMeshBuffer(video::E_VERTEX_TYPE vt=video::EVT_STANDARD) :
|
||||
ChangedID_Vertex(1),ChangedID_Index(1),MappingHint_Vertex(EHM_NEVER),
|
||||
MappingHint_Index(EHM_NEVER),VertexType(vt),BoundingBoxNeedsRecalculated(true)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("SSkinMeshBuffer");
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Get Material of this buffer.
|
||||
virtual const video::SMaterial& getMaterial() const
|
||||
{
|
||||
return Material;
|
||||
}
|
||||
|
||||
//! Get Material of this buffer.
|
||||
virtual video::SMaterial& getMaterial()
|
||||
{
|
||||
return Material;
|
||||
}
|
||||
|
||||
//! Get standard vertex at given index
|
||||
virtual video::S3DVertex *getVertex(u32 index)
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return (video::S3DVertex*)&Vertices_2TCoords[index];
|
||||
case video::EVT_TANGENTS:
|
||||
return (video::S3DVertex*)&Vertices_Tangents[index];
|
||||
default:
|
||||
return &Vertices_Standard[index];
|
||||
}
|
||||
}
|
||||
|
||||
//! Get pointer to vertex array
|
||||
virtual const void* getVertices() const
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return Vertices_2TCoords.const_pointer();
|
||||
case video::EVT_TANGENTS:
|
||||
return Vertices_Tangents.const_pointer();
|
||||
default:
|
||||
return Vertices_Standard.const_pointer();
|
||||
}
|
||||
}
|
||||
|
||||
//! Get pointer to vertex array
|
||||
virtual void* getVertices()
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return Vertices_2TCoords.pointer();
|
||||
case video::EVT_TANGENTS:
|
||||
return Vertices_Tangents.pointer();
|
||||
default:
|
||||
return Vertices_Standard.pointer();
|
||||
}
|
||||
}
|
||||
|
||||
//! Get vertex count
|
||||
virtual u32 getVertexCount() const
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return Vertices_2TCoords.size();
|
||||
case video::EVT_TANGENTS:
|
||||
return Vertices_Tangents.size();
|
||||
default:
|
||||
return Vertices_Standard.size();
|
||||
}
|
||||
}
|
||||
|
||||
//! Get type of index data which is stored in this meshbuffer.
|
||||
/** \return Index type of this buffer. */
|
||||
virtual video::E_INDEX_TYPE getIndexType() const { return video::EIT_16BIT; }
|
||||
|
||||
//! Get pointer to index array
|
||||
virtual const u16* getIndices() const
|
||||
{
|
||||
return Indices.const_pointer();
|
||||
}
|
||||
|
||||
//! Get pointer to index array
|
||||
virtual u16* getIndices()
|
||||
{
|
||||
return Indices.pointer();
|
||||
}
|
||||
|
||||
//! Get index count
|
||||
virtual u32 getIndexCount() const
|
||||
{
|
||||
return Indices.size();
|
||||
}
|
||||
|
||||
//! Get bounding box
|
||||
virtual const core::aabbox3d<f32>& getBoundingBox() const
|
||||
{
|
||||
return BoundingBox;
|
||||
}
|
||||
|
||||
//! Set bounding box
|
||||
virtual void setBoundingBox( const core::aabbox3df& box)
|
||||
{
|
||||
BoundingBox = box;
|
||||
}
|
||||
|
||||
//! Recalculate bounding box
|
||||
virtual void recalculateBoundingBox()
|
||||
{
|
||||
if(!BoundingBoxNeedsRecalculated)
|
||||
return;
|
||||
|
||||
BoundingBoxNeedsRecalculated = false;
|
||||
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_STANDARD:
|
||||
{
|
||||
if (Vertices_Standard.empty())
|
||||
BoundingBox.reset(0,0,0);
|
||||
else
|
||||
{
|
||||
BoundingBox.reset(Vertices_Standard[0].Pos);
|
||||
for (u32 i=1; i<Vertices_Standard.size(); ++i)
|
||||
BoundingBox.addInternalPoint(Vertices_Standard[i].Pos);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case video::EVT_2TCOORDS:
|
||||
{
|
||||
if (Vertices_2TCoords.empty())
|
||||
BoundingBox.reset(0,0,0);
|
||||
else
|
||||
{
|
||||
BoundingBox.reset(Vertices_2TCoords[0].Pos);
|
||||
for (u32 i=1; i<Vertices_2TCoords.size(); ++i)
|
||||
BoundingBox.addInternalPoint(Vertices_2TCoords[i].Pos);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case video::EVT_TANGENTS:
|
||||
{
|
||||
if (Vertices_Tangents.empty())
|
||||
BoundingBox.reset(0,0,0);
|
||||
else
|
||||
{
|
||||
BoundingBox.reset(Vertices_Tangents[0].Pos);
|
||||
for (u32 i=1; i<Vertices_Tangents.size(); ++i)
|
||||
BoundingBox.addInternalPoint(Vertices_Tangents[i].Pos);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! Get vertex type
|
||||
virtual video::E_VERTEX_TYPE getVertexType() const
|
||||
{
|
||||
return VertexType;
|
||||
}
|
||||
|
||||
//! Convert to 2tcoords vertex type
|
||||
virtual void MoveTo_2TCoords()
|
||||
{
|
||||
if (VertexType==video::EVT_STANDARD)
|
||||
{
|
||||
for(u32 n=0;n<Vertices_Standard.size();++n)
|
||||
{
|
||||
video::S3DVertex2TCoords Vertex;
|
||||
Vertex.Color=Vertices_Standard[n].Color;
|
||||
Vertex.Pos=Vertices_Standard[n].Pos;
|
||||
Vertex.Normal=Vertices_Standard[n].Normal;
|
||||
Vertex.TCoords=Vertices_Standard[n].TCoords;
|
||||
Vertices_2TCoords.push_back(Vertex);
|
||||
}
|
||||
Vertices_Standard.clear();
|
||||
VertexType=video::EVT_2TCOORDS;
|
||||
}
|
||||
}
|
||||
|
||||
//! Convert to tangents vertex type
|
||||
virtual void MoveTo_Tangents()
|
||||
{
|
||||
if (VertexType==video::EVT_STANDARD)
|
||||
{
|
||||
for(u32 n=0;n<Vertices_Standard.size();++n)
|
||||
{
|
||||
video::S3DVertexTangents Vertex;
|
||||
Vertex.Color=Vertices_Standard[n].Color;
|
||||
Vertex.Pos=Vertices_Standard[n].Pos;
|
||||
Vertex.Normal=Vertices_Standard[n].Normal;
|
||||
Vertex.TCoords=Vertices_Standard[n].TCoords;
|
||||
Vertices_Tangents.push_back(Vertex);
|
||||
}
|
||||
Vertices_Standard.clear();
|
||||
VertexType=video::EVT_TANGENTS;
|
||||
}
|
||||
else if (VertexType==video::EVT_2TCOORDS)
|
||||
{
|
||||
for(u32 n=0;n<Vertices_2TCoords.size();++n)
|
||||
{
|
||||
video::S3DVertexTangents Vertex;
|
||||
Vertex.Color=Vertices_2TCoords[n].Color;
|
||||
Vertex.Pos=Vertices_2TCoords[n].Pos;
|
||||
Vertex.Normal=Vertices_2TCoords[n].Normal;
|
||||
Vertex.TCoords=Vertices_2TCoords[n].TCoords;
|
||||
Vertices_Tangents.push_back(Vertex);
|
||||
}
|
||||
Vertices_2TCoords.clear();
|
||||
VertexType=video::EVT_TANGENTS;
|
||||
}
|
||||
}
|
||||
|
||||
//! returns position of vertex i
|
||||
virtual const core::vector3df& getPosition(u32 i) const
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return Vertices_2TCoords[i].Pos;
|
||||
case video::EVT_TANGENTS:
|
||||
return Vertices_Tangents[i].Pos;
|
||||
default:
|
||||
return Vertices_Standard[i].Pos;
|
||||
}
|
||||
}
|
||||
|
||||
//! returns position of vertex i
|
||||
virtual core::vector3df& getPosition(u32 i)
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return Vertices_2TCoords[i].Pos;
|
||||
case video::EVT_TANGENTS:
|
||||
return Vertices_Tangents[i].Pos;
|
||||
default:
|
||||
return Vertices_Standard[i].Pos;
|
||||
}
|
||||
}
|
||||
|
||||
//! returns normal of vertex i
|
||||
virtual const core::vector3df& getNormal(u32 i) const
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return Vertices_2TCoords[i].Normal;
|
||||
case video::EVT_TANGENTS:
|
||||
return Vertices_Tangents[i].Normal;
|
||||
default:
|
||||
return Vertices_Standard[i].Normal;
|
||||
}
|
||||
}
|
||||
|
||||
//! returns normal of vertex i
|
||||
virtual core::vector3df& getNormal(u32 i)
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return Vertices_2TCoords[i].Normal;
|
||||
case video::EVT_TANGENTS:
|
||||
return Vertices_Tangents[i].Normal;
|
||||
default:
|
||||
return Vertices_Standard[i].Normal;
|
||||
}
|
||||
}
|
||||
|
||||
//! returns texture coords of vertex i
|
||||
virtual const core::vector2df& getTCoords(u32 i) const
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return Vertices_2TCoords[i].TCoords;
|
||||
case video::EVT_TANGENTS:
|
||||
return Vertices_Tangents[i].TCoords;
|
||||
default:
|
||||
return Vertices_Standard[i].TCoords;
|
||||
}
|
||||
}
|
||||
|
||||
//! returns texture coords of vertex i
|
||||
virtual core::vector2df& getTCoords(u32 i)
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return Vertices_2TCoords[i].TCoords;
|
||||
case video::EVT_TANGENTS:
|
||||
return Vertices_Tangents[i].TCoords;
|
||||
default:
|
||||
return Vertices_Standard[i].TCoords;
|
||||
}
|
||||
}
|
||||
|
||||
//! append the vertices and indices to the current buffer
|
||||
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) {}
|
||||
|
||||
//! append the meshbuffer to the current buffer
|
||||
virtual void append(const IMeshBuffer* const other) {}
|
||||
|
||||
//! get the current hardware mapping hint for vertex buffers
|
||||
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const
|
||||
{
|
||||
return MappingHint_Vertex;
|
||||
}
|
||||
|
||||
//! get the current hardware mapping hint for index buffers
|
||||
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const
|
||||
{
|
||||
return MappingHint_Index;
|
||||
}
|
||||
|
||||
//! set the hardware mapping hint, for driver
|
||||
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX )
|
||||
{
|
||||
if (Buffer==EBT_VERTEX)
|
||||
MappingHint_Vertex=NewMappingHint;
|
||||
else if (Buffer==EBT_INDEX)
|
||||
MappingHint_Index=NewMappingHint;
|
||||
else if (Buffer==EBT_VERTEX_AND_INDEX)
|
||||
{
|
||||
MappingHint_Vertex=NewMappingHint;
|
||||
MappingHint_Index=NewMappingHint;
|
||||
}
|
||||
}
|
||||
|
||||
//! flags the mesh as changed, reloads hardware buffers
|
||||
virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX)
|
||||
{
|
||||
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX)
|
||||
++ChangedID_Vertex;
|
||||
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX)
|
||||
++ChangedID_Index;
|
||||
}
|
||||
|
||||
virtual u32 getChangedID_Vertex() const {return ChangedID_Vertex;}
|
||||
|
||||
virtual u32 getChangedID_Index() const {return ChangedID_Index;}
|
||||
|
||||
//! Call this after changing the positions of any vertex.
|
||||
void boundingBoxNeedsRecalculated(void) { BoundingBoxNeedsRecalculated = true; }
|
||||
|
||||
u32 ChangedID_Vertex;
|
||||
u32 ChangedID_Index;
|
||||
|
||||
// hardware mapping hint
|
||||
E_HARDWARE_MAPPING MappingHint_Vertex;
|
||||
E_HARDWARE_MAPPING MappingHint_Index;
|
||||
|
||||
//ISkinnedMesh::SJoint *AttachedJoint;
|
||||
core::matrix4 Transformation;
|
||||
|
||||
video::SMaterial Material;
|
||||
video::E_VERTEX_TYPE VertexType;
|
||||
core::array<video::S3DVertexTangents> Vertices_Tangents;
|
||||
core::array<video::S3DVertex2TCoords> Vertices_2TCoords;
|
||||
core::array<video::S3DVertex> Vertices_Standard;
|
||||
core::array<u16> Indices;
|
||||
core::aabbox3d<f32> BoundingBox;
|
||||
bool BoundingBoxNeedsRecalculated;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __I_SKIN_MESH_BUFFER_H_INCLUDED__
|
||||
#define __I_SKIN_MESH_BUFFER_H_INCLUDED__
|
||||
|
||||
#include "IMeshBuffer.h"
|
||||
#include "S3DVertex.h"
|
||||
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
|
||||
//! A mesh buffer able to choose between S3DVertex2TCoords, S3DVertex and S3DVertexTangents at runtime
|
||||
struct SSkinMeshBuffer : public IMeshBuffer
|
||||
{
|
||||
//! Default constructor
|
||||
SSkinMeshBuffer(video::E_VERTEX_TYPE vt=video::EVT_STANDARD) :
|
||||
ChangedID_Vertex(1),ChangedID_Index(1),MappingHint_Vertex(EHM_NEVER),
|
||||
MappingHint_Index(EHM_NEVER),VertexType(vt),BoundingBoxNeedsRecalculated(true)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("SSkinMeshBuffer");
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Get Material of this buffer.
|
||||
virtual const video::SMaterial& getMaterial() const
|
||||
{
|
||||
return Material;
|
||||
}
|
||||
|
||||
//! Get Material of this buffer.
|
||||
virtual video::SMaterial& getMaterial()
|
||||
{
|
||||
return Material;
|
||||
}
|
||||
|
||||
//! Get standard vertex at given index
|
||||
virtual video::S3DVertex *getVertex(u32 index)
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return (video::S3DVertex*)&Vertices_2TCoords[index];
|
||||
case video::EVT_TANGENTS:
|
||||
return (video::S3DVertex*)&Vertices_Tangents[index];
|
||||
default:
|
||||
return &Vertices_Standard[index];
|
||||
}
|
||||
}
|
||||
|
||||
//! Get pointer to vertex array
|
||||
virtual const void* getVertices() const
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return Vertices_2TCoords.const_pointer();
|
||||
case video::EVT_TANGENTS:
|
||||
return Vertices_Tangents.const_pointer();
|
||||
default:
|
||||
return Vertices_Standard.const_pointer();
|
||||
}
|
||||
}
|
||||
|
||||
//! Get pointer to vertex array
|
||||
virtual void* getVertices()
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return Vertices_2TCoords.pointer();
|
||||
case video::EVT_TANGENTS:
|
||||
return Vertices_Tangents.pointer();
|
||||
default:
|
||||
return Vertices_Standard.pointer();
|
||||
}
|
||||
}
|
||||
|
||||
//! Get vertex count
|
||||
virtual u32 getVertexCount() const
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return Vertices_2TCoords.size();
|
||||
case video::EVT_TANGENTS:
|
||||
return Vertices_Tangents.size();
|
||||
default:
|
||||
return Vertices_Standard.size();
|
||||
}
|
||||
}
|
||||
|
||||
//! Get type of index data which is stored in this meshbuffer.
|
||||
/** \return Index type of this buffer. */
|
||||
virtual video::E_INDEX_TYPE getIndexType() const { return video::EIT_16BIT; }
|
||||
|
||||
//! Get pointer to index array
|
||||
virtual const u16* getIndices() const
|
||||
{
|
||||
return Indices.const_pointer();
|
||||
}
|
||||
|
||||
//! Get pointer to index array
|
||||
virtual u16* getIndices()
|
||||
{
|
||||
return Indices.pointer();
|
||||
}
|
||||
|
||||
//! Get index count
|
||||
virtual u32 getIndexCount() const
|
||||
{
|
||||
return Indices.size();
|
||||
}
|
||||
|
||||
//! Get bounding box
|
||||
virtual const core::aabbox3d<f32>& getBoundingBox() const
|
||||
{
|
||||
return BoundingBox;
|
||||
}
|
||||
|
||||
//! Set bounding box
|
||||
virtual void setBoundingBox( const core::aabbox3df& box)
|
||||
{
|
||||
BoundingBox = box;
|
||||
}
|
||||
|
||||
//! Recalculate bounding box
|
||||
virtual void recalculateBoundingBox()
|
||||
{
|
||||
if(!BoundingBoxNeedsRecalculated)
|
||||
return;
|
||||
|
||||
BoundingBoxNeedsRecalculated = false;
|
||||
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_STANDARD:
|
||||
{
|
||||
if (Vertices_Standard.empty())
|
||||
BoundingBox.reset(0,0,0);
|
||||
else
|
||||
{
|
||||
BoundingBox.reset(Vertices_Standard[0].Pos);
|
||||
for (u32 i=1; i<Vertices_Standard.size(); ++i)
|
||||
BoundingBox.addInternalPoint(Vertices_Standard[i].Pos);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case video::EVT_2TCOORDS:
|
||||
{
|
||||
if (Vertices_2TCoords.empty())
|
||||
BoundingBox.reset(0,0,0);
|
||||
else
|
||||
{
|
||||
BoundingBox.reset(Vertices_2TCoords[0].Pos);
|
||||
for (u32 i=1; i<Vertices_2TCoords.size(); ++i)
|
||||
BoundingBox.addInternalPoint(Vertices_2TCoords[i].Pos);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case video::EVT_TANGENTS:
|
||||
{
|
||||
if (Vertices_Tangents.empty())
|
||||
BoundingBox.reset(0,0,0);
|
||||
else
|
||||
{
|
||||
BoundingBox.reset(Vertices_Tangents[0].Pos);
|
||||
for (u32 i=1; i<Vertices_Tangents.size(); ++i)
|
||||
BoundingBox.addInternalPoint(Vertices_Tangents[i].Pos);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! Get vertex type
|
||||
virtual video::E_VERTEX_TYPE getVertexType() const
|
||||
{
|
||||
return VertexType;
|
||||
}
|
||||
|
||||
//! Convert to 2tcoords vertex type
|
||||
virtual void MoveTo_2TCoords()
|
||||
{
|
||||
if (VertexType==video::EVT_STANDARD)
|
||||
{
|
||||
for(u32 n=0;n<Vertices_Standard.size();++n)
|
||||
{
|
||||
video::S3DVertex2TCoords Vertex;
|
||||
Vertex.Color=Vertices_Standard[n].Color;
|
||||
Vertex.Pos=Vertices_Standard[n].Pos;
|
||||
Vertex.Normal=Vertices_Standard[n].Normal;
|
||||
Vertex.TCoords=Vertices_Standard[n].TCoords;
|
||||
Vertices_2TCoords.push_back(Vertex);
|
||||
}
|
||||
Vertices_Standard.clear();
|
||||
VertexType=video::EVT_2TCOORDS;
|
||||
}
|
||||
}
|
||||
|
||||
//! Convert to tangents vertex type
|
||||
virtual void MoveTo_Tangents()
|
||||
{
|
||||
if (VertexType==video::EVT_STANDARD)
|
||||
{
|
||||
for(u32 n=0;n<Vertices_Standard.size();++n)
|
||||
{
|
||||
video::S3DVertexTangents Vertex;
|
||||
Vertex.Color=Vertices_Standard[n].Color;
|
||||
Vertex.Pos=Vertices_Standard[n].Pos;
|
||||
Vertex.Normal=Vertices_Standard[n].Normal;
|
||||
Vertex.TCoords=Vertices_Standard[n].TCoords;
|
||||
Vertices_Tangents.push_back(Vertex);
|
||||
}
|
||||
Vertices_Standard.clear();
|
||||
VertexType=video::EVT_TANGENTS;
|
||||
}
|
||||
else if (VertexType==video::EVT_2TCOORDS)
|
||||
{
|
||||
for(u32 n=0;n<Vertices_2TCoords.size();++n)
|
||||
{
|
||||
video::S3DVertexTangents Vertex;
|
||||
Vertex.Color=Vertices_2TCoords[n].Color;
|
||||
Vertex.Pos=Vertices_2TCoords[n].Pos;
|
||||
Vertex.Normal=Vertices_2TCoords[n].Normal;
|
||||
Vertex.TCoords=Vertices_2TCoords[n].TCoords;
|
||||
Vertices_Tangents.push_back(Vertex);
|
||||
}
|
||||
Vertices_2TCoords.clear();
|
||||
VertexType=video::EVT_TANGENTS;
|
||||
}
|
||||
}
|
||||
|
||||
//! returns position of vertex i
|
||||
virtual const core::vector3df& getPosition(u32 i) const
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return Vertices_2TCoords[i].Pos;
|
||||
case video::EVT_TANGENTS:
|
||||
return Vertices_Tangents[i].Pos;
|
||||
default:
|
||||
return Vertices_Standard[i].Pos;
|
||||
}
|
||||
}
|
||||
|
||||
//! returns position of vertex i
|
||||
virtual core::vector3df& getPosition(u32 i)
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return Vertices_2TCoords[i].Pos;
|
||||
case video::EVT_TANGENTS:
|
||||
return Vertices_Tangents[i].Pos;
|
||||
default:
|
||||
return Vertices_Standard[i].Pos;
|
||||
}
|
||||
}
|
||||
|
||||
//! returns normal of vertex i
|
||||
virtual const core::vector3df& getNormal(u32 i) const
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return Vertices_2TCoords[i].Normal;
|
||||
case video::EVT_TANGENTS:
|
||||
return Vertices_Tangents[i].Normal;
|
||||
default:
|
||||
return Vertices_Standard[i].Normal;
|
||||
}
|
||||
}
|
||||
|
||||
//! returns normal of vertex i
|
||||
virtual core::vector3df& getNormal(u32 i)
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return Vertices_2TCoords[i].Normal;
|
||||
case video::EVT_TANGENTS:
|
||||
return Vertices_Tangents[i].Normal;
|
||||
default:
|
||||
return Vertices_Standard[i].Normal;
|
||||
}
|
||||
}
|
||||
|
||||
//! returns texture coords of vertex i
|
||||
virtual const core::vector2df& getTCoords(u32 i) const
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return Vertices_2TCoords[i].TCoords;
|
||||
case video::EVT_TANGENTS:
|
||||
return Vertices_Tangents[i].TCoords;
|
||||
default:
|
||||
return Vertices_Standard[i].TCoords;
|
||||
}
|
||||
}
|
||||
|
||||
//! returns texture coords of vertex i
|
||||
virtual core::vector2df& getTCoords(u32 i)
|
||||
{
|
||||
switch (VertexType)
|
||||
{
|
||||
case video::EVT_2TCOORDS:
|
||||
return Vertices_2TCoords[i].TCoords;
|
||||
case video::EVT_TANGENTS:
|
||||
return Vertices_Tangents[i].TCoords;
|
||||
default:
|
||||
return Vertices_Standard[i].TCoords;
|
||||
}
|
||||
}
|
||||
|
||||
//! append the vertices and indices to the current buffer
|
||||
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) {}
|
||||
|
||||
//! append the meshbuffer to the current buffer
|
||||
virtual void append(const IMeshBuffer* const other) {}
|
||||
|
||||
//! get the current hardware mapping hint for vertex buffers
|
||||
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const
|
||||
{
|
||||
return MappingHint_Vertex;
|
||||
}
|
||||
|
||||
//! get the current hardware mapping hint for index buffers
|
||||
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const
|
||||
{
|
||||
return MappingHint_Index;
|
||||
}
|
||||
|
||||
//! set the hardware mapping hint, for driver
|
||||
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX )
|
||||
{
|
||||
if (Buffer==EBT_VERTEX)
|
||||
MappingHint_Vertex=NewMappingHint;
|
||||
else if (Buffer==EBT_INDEX)
|
||||
MappingHint_Index=NewMappingHint;
|
||||
else if (Buffer==EBT_VERTEX_AND_INDEX)
|
||||
{
|
||||
MappingHint_Vertex=NewMappingHint;
|
||||
MappingHint_Index=NewMappingHint;
|
||||
}
|
||||
}
|
||||
|
||||
//! flags the mesh as changed, reloads hardware buffers
|
||||
virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX)
|
||||
{
|
||||
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX)
|
||||
++ChangedID_Vertex;
|
||||
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX)
|
||||
++ChangedID_Index;
|
||||
}
|
||||
|
||||
virtual u32 getChangedID_Vertex() const {return ChangedID_Vertex;}
|
||||
|
||||
virtual u32 getChangedID_Index() const {return ChangedID_Index;}
|
||||
|
||||
//! Call this after changing the positions of any vertex.
|
||||
void boundingBoxNeedsRecalculated(void) { BoundingBoxNeedsRecalculated = true; }
|
||||
|
||||
u32 ChangedID_Vertex;
|
||||
u32 ChangedID_Index;
|
||||
|
||||
// hardware mapping hint
|
||||
E_HARDWARE_MAPPING MappingHint_Vertex;
|
||||
E_HARDWARE_MAPPING MappingHint_Index;
|
||||
|
||||
//ISkinnedMesh::SJoint *AttachedJoint;
|
||||
core::matrix4 Transformation;
|
||||
|
||||
video::SMaterial Material;
|
||||
video::E_VERTEX_TYPE VertexType;
|
||||
core::array<video::S3DVertexTangents> Vertices_Tangents;
|
||||
core::array<video::S3DVertex2TCoords> Vertices_2TCoords;
|
||||
core::array<video::S3DVertex> Vertices_Standard;
|
||||
core::array<u16> Indices;
|
||||
core::aabbox3d<f32> BoundingBox;
|
||||
bool BoundingBoxNeedsRecalculated;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,187 +1,187 @@
|
|||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __IRR_CORE_UTIL_H_INCLUDED__
|
||||
#define __IRR_CORE_UTIL_H_INCLUDED__
|
||||
|
||||
#include "irrString.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
/*! \file irrxml.h
|
||||
\brief File containing useful basic utility functions
|
||||
*/
|
||||
|
||||
// ----------- some basic quite often used string functions -----------------
|
||||
|
||||
//! search if a filename has a proper extension
|
||||
inline s32 isFileExtension ( const core::string<c16>& filename,
|
||||
const core::string<c16>& ext0,
|
||||
const core::string<c16>& ext1,
|
||||
const core::string<c16>& ext2
|
||||
)
|
||||
{
|
||||
s32 extPos = filename.findLast ( '.' );
|
||||
if ( extPos < 0 )
|
||||
return 0;
|
||||
|
||||
extPos += 1;
|
||||
if ( filename.equals_substring_ignore_case ( ext0, extPos ) ) return 1;
|
||||
if ( filename.equals_substring_ignore_case ( ext1, extPos ) ) return 2;
|
||||
if ( filename.equals_substring_ignore_case ( ext2, extPos ) ) return 3;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! search if a filename has a proper extension
|
||||
inline bool hasFileExtension ( const core::string<c16>& filename,
|
||||
const core::string<c16>& ext0,
|
||||
const core::string<c16>& ext1 = "",
|
||||
const core::string<c16>& ext2 = ""
|
||||
)
|
||||
{
|
||||
return isFileExtension ( filename, ext0, ext1, ext2 ) > 0;
|
||||
}
|
||||
|
||||
//! cut the filename extension from a source string and stores in the dest string
|
||||
inline stringc& cutFilenameExtension ( stringc &dest, const stringc &source )
|
||||
{
|
||||
s32 endPos = source.findLast ( '.' );
|
||||
dest = source.subString ( 0, endPos < 0 ? source.size () : endPos );
|
||||
return dest;
|
||||
}
|
||||
|
||||
//! cut the filename extension from a source string and stores in the dest string
|
||||
inline stringw& cutFilenameExtension ( stringw &dest, const stringw &source )
|
||||
{
|
||||
s32 endPos = source.findLast ( '.' );
|
||||
dest = source.subString ( 0, endPos < 0 ? source.size () : endPos );
|
||||
return dest;
|
||||
}
|
||||
|
||||
//! get the filename extension from a string
|
||||
inline stringc& getFileNameExtension ( stringc &dest, const stringc &source )
|
||||
{
|
||||
s32 endPos = source.findLast ( '.' );
|
||||
if ( endPos < 0 )
|
||||
dest = "";
|
||||
else
|
||||
dest = source.subString ( endPos, source.size () );
|
||||
return dest;
|
||||
}
|
||||
|
||||
//! delete path from filename
|
||||
inline core::stringw& deletePathFromFilename(core::stringw& filename)
|
||||
{
|
||||
// delete path from filename
|
||||
const wchar_t *s = filename.c_str();
|
||||
const wchar_t* p = s + filename.size();
|
||||
|
||||
// search for path separator or beginning
|
||||
while ( *p != '/' && *p != '\\' && p != s )
|
||||
p--;
|
||||
|
||||
if ( p != s )
|
||||
{
|
||||
++p;
|
||||
filename = p;
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
//! delete path from filename
|
||||
inline core::stringc& deletePathFromFilename(core::stringc& filename)
|
||||
{
|
||||
// delete path from filename
|
||||
const c8 *s = filename.c_str();
|
||||
const c8* p = s + filename.size();
|
||||
|
||||
// search for path separator or beginning
|
||||
while ( *p != '/' && *p != '\\' && p != s )
|
||||
p--;
|
||||
|
||||
if ( p != s )
|
||||
{
|
||||
++p;
|
||||
filename = p;
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
//! trim paths
|
||||
inline core::string<c16>& deletePathFromPath(core::string<c16>& filename, s32 pathCount)
|
||||
{
|
||||
// delete path from filename
|
||||
s32 i = filename.size();
|
||||
|
||||
// search for path separator or beginning
|
||||
while ( i )
|
||||
{
|
||||
if ( filename[i] == '/' || filename[i] == '\\' )
|
||||
{
|
||||
if ( --pathCount <= 0 )
|
||||
break;
|
||||
}
|
||||
i -= 1;
|
||||
}
|
||||
|
||||
if ( i )
|
||||
{
|
||||
filename [ i + 1 ] = 0;
|
||||
filename.validate();
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
//! gets the last char of a string or null
|
||||
inline c16 lastChar( const core::string<c16>& s)
|
||||
{
|
||||
return s.size() ? s [ s.size() - 1 ] : 0;
|
||||
}
|
||||
|
||||
//! looks if file is in the same directory of path. returns offset of directory.
|
||||
//! 0 means in same directory. 1 means file is direct child of path
|
||||
inline s32 isInSameDirectory ( const core::string<c16>& path, const core::string<c16>& file )
|
||||
{
|
||||
s32 subA = 0;
|
||||
s32 subB = 0;
|
||||
s32 pos;
|
||||
|
||||
if ( path.size() && !path.equalsn ( file, path.size() ) )
|
||||
return -1;
|
||||
|
||||
pos = 0;
|
||||
while ( (pos = path.findNext ( '/', pos )) >= 0 )
|
||||
{
|
||||
subA += 1;
|
||||
pos += 1;
|
||||
}
|
||||
|
||||
pos = 0;
|
||||
while ( (pos = file.findNext ( '/', pos )) >= 0 )
|
||||
{
|
||||
subB += 1;
|
||||
pos += 1;
|
||||
}
|
||||
|
||||
return subB - subA;
|
||||
}
|
||||
|
||||
|
||||
//! some standard function ( to remove dependencies )
|
||||
#undef isdigit
|
||||
#undef isspace
|
||||
#undef isupper
|
||||
inline s32 isdigit(s32 c) { return c >= '0' && c <= '9'; }
|
||||
inline s32 isspace(s32 c) { return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v'; }
|
||||
inline s32 isupper(s32 c) { return c >= 'A' && c <= 'Z'; }
|
||||
|
||||
|
||||
} // end namespace core
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __IRR_CORE_UTIL_H_INCLUDED__
|
||||
#define __IRR_CORE_UTIL_H_INCLUDED__
|
||||
|
||||
#include "irrString.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
/*! \file irrxml.h
|
||||
\brief File containing useful basic utility functions
|
||||
*/
|
||||
|
||||
// ----------- some basic quite often used string functions -----------------
|
||||
|
||||
//! search if a filename has a proper extension
|
||||
inline s32 isFileExtension ( const core::string<c16>& filename,
|
||||
const core::string<c16>& ext0,
|
||||
const core::string<c16>& ext1,
|
||||
const core::string<c16>& ext2
|
||||
)
|
||||
{
|
||||
s32 extPos = filename.findLast ( '.' );
|
||||
if ( extPos < 0 )
|
||||
return 0;
|
||||
|
||||
extPos += 1;
|
||||
if ( filename.equals_substring_ignore_case ( ext0, extPos ) ) return 1;
|
||||
if ( filename.equals_substring_ignore_case ( ext1, extPos ) ) return 2;
|
||||
if ( filename.equals_substring_ignore_case ( ext2, extPos ) ) return 3;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! search if a filename has a proper extension
|
||||
inline bool hasFileExtension ( const core::string<c16>& filename,
|
||||
const core::string<c16>& ext0,
|
||||
const core::string<c16>& ext1 = "",
|
||||
const core::string<c16>& ext2 = ""
|
||||
)
|
||||
{
|
||||
return isFileExtension ( filename, ext0, ext1, ext2 ) > 0;
|
||||
}
|
||||
|
||||
//! cut the filename extension from a source string and stores in the dest string
|
||||
inline stringc& cutFilenameExtension ( stringc &dest, const stringc &source )
|
||||
{
|
||||
s32 endPos = source.findLast ( '.' );
|
||||
dest = source.subString ( 0, endPos < 0 ? source.size () : endPos );
|
||||
return dest;
|
||||
}
|
||||
|
||||
//! cut the filename extension from a source string and stores in the dest string
|
||||
inline stringw& cutFilenameExtension ( stringw &dest, const stringw &source )
|
||||
{
|
||||
s32 endPos = source.findLast ( '.' );
|
||||
dest = source.subString ( 0, endPos < 0 ? source.size () : endPos );
|
||||
return dest;
|
||||
}
|
||||
|
||||
//! get the filename extension from a string
|
||||
inline stringc& getFileNameExtension ( stringc &dest, const stringc &source )
|
||||
{
|
||||
s32 endPos = source.findLast ( '.' );
|
||||
if ( endPos < 0 )
|
||||
dest = "";
|
||||
else
|
||||
dest = source.subString ( endPos, source.size () );
|
||||
return dest;
|
||||
}
|
||||
|
||||
//! delete path from filename
|
||||
inline core::stringw& deletePathFromFilename(core::stringw& filename)
|
||||
{
|
||||
// delete path from filename
|
||||
const wchar_t *s = filename.c_str();
|
||||
const wchar_t* p = s + filename.size();
|
||||
|
||||
// search for path separator or beginning
|
||||
while ( *p != '/' && *p != '\\' && p != s )
|
||||
p--;
|
||||
|
||||
if ( p != s )
|
||||
{
|
||||
++p;
|
||||
filename = p;
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
//! delete path from filename
|
||||
inline core::stringc& deletePathFromFilename(core::stringc& filename)
|
||||
{
|
||||
// delete path from filename
|
||||
const c8 *s = filename.c_str();
|
||||
const c8* p = s + filename.size();
|
||||
|
||||
// search for path separator or beginning
|
||||
while ( *p != '/' && *p != '\\' && p != s )
|
||||
p--;
|
||||
|
||||
if ( p != s )
|
||||
{
|
||||
++p;
|
||||
filename = p;
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
//! trim paths
|
||||
inline core::string<c16>& deletePathFromPath(core::string<c16>& filename, s32 pathCount)
|
||||
{
|
||||
// delete path from filename
|
||||
s32 i = filename.size();
|
||||
|
||||
// search for path separator or beginning
|
||||
while ( i )
|
||||
{
|
||||
if ( filename[i] == '/' || filename[i] == '\\' )
|
||||
{
|
||||
if ( --pathCount <= 0 )
|
||||
break;
|
||||
}
|
||||
i -= 1;
|
||||
}
|
||||
|
||||
if ( i )
|
||||
{
|
||||
filename [ i + 1 ] = 0;
|
||||
filename.validate();
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
//! gets the last char of a string or null
|
||||
inline c16 lastChar( const core::string<c16>& s)
|
||||
{
|
||||
return s.size() ? s [ s.size() - 1 ] : 0;
|
||||
}
|
||||
|
||||
//! looks if file is in the same directory of path. returns offset of directory.
|
||||
//! 0 means in same directory. 1 means file is direct child of path
|
||||
inline s32 isInSameDirectory ( const core::string<c16>& path, const core::string<c16>& file )
|
||||
{
|
||||
s32 subA = 0;
|
||||
s32 subB = 0;
|
||||
s32 pos;
|
||||
|
||||
if ( path.size() && !path.equalsn ( file, path.size() ) )
|
||||
return -1;
|
||||
|
||||
pos = 0;
|
||||
while ( (pos = path.findNext ( '/', pos )) >= 0 )
|
||||
{
|
||||
subA += 1;
|
||||
pos += 1;
|
||||
}
|
||||
|
||||
pos = 0;
|
||||
while ( (pos = file.findNext ( '/', pos )) >= 0 )
|
||||
{
|
||||
subB += 1;
|
||||
pos += 1;
|
||||
}
|
||||
|
||||
return subB - subA;
|
||||
}
|
||||
|
||||
|
||||
//! some standard function ( to remove dependencies )
|
||||
#undef isdigit
|
||||
#undef isspace
|
||||
#undef isupper
|
||||
inline s32 isdigit(s32 c) { return c >= '0' && c <= '9'; }
|
||||
inline s32 isspace(s32 c) { return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v'; }
|
||||
inline s32 isupper(s32 c) { return c >= 'A' && c <= 'Z'; }
|
||||
|
||||
|
||||
} // end namespace core
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
|
|
1968
include/irrString.h
1968
include/irrString.h
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,38 +1,38 @@
|
|||
// This file is part of the "Irrlicht Engine".
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de
|
||||
|
||||
#ifndef __C_GUI_IMAGE_LIST_H_INCLUDED__
|
||||
#define __C_GUI_IMAGE_LIST_H_INCLUDED__
|
||||
|
||||
#include "IGUIImageList.h"
|
||||
#include "IVideoDriver.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace gui
|
||||
{
|
||||
|
||||
class CGUIImageList : public IGUIImageList
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
CGUIImageList( video::IVideoDriver* Driver );
|
||||
|
||||
//! destructor
|
||||
virtual ~CGUIImageList();
|
||||
|
||||
//! Creates the image list from texture.
|
||||
//! \param texture: The texture to use
|
||||
//! \param imageSize: Size of a single image
|
||||
//! \param useAlphaChannel: true if the alpha channel from the texture should be used
|
||||
//! \return
|
||||
//! true if the image list was created
|
||||
bool createImageList(
|
||||
video::ITexture* texture,
|
||||
core::dimension2d<s32> imageSize,
|
||||
bool useAlphaChannel );
|
||||
|
||||
|
||||
#ifndef __C_GUI_IMAGE_LIST_H_INCLUDED__
|
||||
#define __C_GUI_IMAGE_LIST_H_INCLUDED__
|
||||
|
||||
#include "IGUIImageList.h"
|
||||
#include "IVideoDriver.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace gui
|
||||
{
|
||||
|
||||
class CGUIImageList : public IGUIImageList
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
CGUIImageList( video::IVideoDriver* Driver );
|
||||
|
||||
//! destructor
|
||||
virtual ~CGUIImageList();
|
||||
|
||||
//! Creates the image list from texture.
|
||||
//! \param texture: The texture to use
|
||||
//! \param imageSize: Size of a single image
|
||||
//! \param useAlphaChannel: true if the alpha channel from the texture should be used
|
||||
//! \return
|
||||
//! true if the image list was created
|
||||
bool createImageList(
|
||||
video::ITexture* texture,
|
||||
core::dimension2d<s32> imageSize,
|
||||
bool useAlphaChannel );
|
||||
|
||||
//! Draws an image and clips it to the specified rectangle if wanted
|
||||
//! \param index: Index of the image
|
||||
//! \param destPos: Position of the image to draw
|
||||
|
@ -50,19 +50,19 @@ public:
|
|||
//! \return Returns the size of the images in the list.
|
||||
virtual core::dimension2d<s32> getImageSize() const
|
||||
{ return ImageSize; }
|
||||
|
||||
private:
|
||||
|
||||
video::IVideoDriver* Driver;
|
||||
video::ITexture* Texture;
|
||||
s32 ImageCount;
|
||||
core::dimension2d<s32> ImageSize;
|
||||
s32 ImagesPerRow;
|
||||
bool UseAlphaChannel;
|
||||
};
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
private:
|
||||
|
||||
video::IVideoDriver* Driver;
|
||||
video::ITexture* Texture;
|
||||
s32 ImageCount;
|
||||
core::dimension2d<s32> ImageSize;
|
||||
s32 ImagesPerRow;
|
||||
bool UseAlphaChannel;
|
||||
};
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -689,6 +689,9 @@ s32 CGUITabControl::getTabExtraWidth() const
|
|||
|
||||
void CGUITabControl::recalculateScrollBar()
|
||||
{
|
||||
if (!UpButton || !DownButton)
|
||||
return;
|
||||
|
||||
ScrollControl = needScrollControl() || CurrentScrollTabIndex > 0;
|
||||
|
||||
if (ScrollControl)
|
||||
|
@ -702,8 +705,8 @@ void CGUITabControl::recalculateScrollBar()
|
|||
DownButton->setVisible( false );
|
||||
}
|
||||
|
||||
this->bringToFront( UpButton );
|
||||
this->bringToFront( DownButton );
|
||||
bringToFront( UpButton );
|
||||
bringToFront( DownButton );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,266 +1,266 @@
|
|||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "CGUIWindow.h"
|
||||
#ifdef _IRR_COMPILE_WITH_GUI_
|
||||
|
||||
#include "IGUISkin.h"
|
||||
#include "IGUIEnvironment.h"
|
||||
#include "IVideoDriver.h"
|
||||
#include "IGUIButton.h"
|
||||
#include "IGUIFont.h"
|
||||
#include "IGUIFontBitmap.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace gui
|
||||
{
|
||||
|
||||
//! constructor
|
||||
CGUIWindow::CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
|
||||
: IGUIWindow(environment, parent, id, rectangle), Dragging(false)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CGUIWindow");
|
||||
#endif
|
||||
|
||||
IGUISkin* skin = 0;
|
||||
if (environment)
|
||||
skin = environment->getSkin();
|
||||
|
||||
IGUISpriteBank* sprites = 0;
|
||||
video::SColor color(255,255,255,255);
|
||||
|
||||
s32 buttonw = 15;
|
||||
if (skin)
|
||||
{
|
||||
buttonw = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH);
|
||||
sprites = skin->getSpriteBank();
|
||||
color = skin->getColor(EGDC_WINDOW_SYMBOL);
|
||||
}
|
||||
s32 posx = RelativeRect.getWidth() - buttonw - 4;
|
||||
|
||||
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->setTabStop(false);
|
||||
CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
|
||||
if (sprites)
|
||||
{
|
||||
CloseButton->setSpriteBank(sprites);
|
||||
CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), color);
|
||||
CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), color);
|
||||
}
|
||||
posx -= buttonw + 2;
|
||||
|
||||
RestoreButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1,
|
||||
L"", skin ? skin->getDefaultText(EGDT_WINDOW_RESTORE) : L"Restore" );
|
||||
RestoreButton->setVisible(false);
|
||||
RestoreButton->setSubElement(true);
|
||||
RestoreButton->setTabStop(false);
|
||||
RestoreButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
|
||||
if (sprites)
|
||||
{
|
||||
RestoreButton->setSpriteBank(sprites);
|
||||
RestoreButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_RESTORE), color);
|
||||
RestoreButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_RESTORE), color);
|
||||
}
|
||||
posx -= buttonw + 2;
|
||||
|
||||
MinButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1,
|
||||
L"", skin ? skin->getDefaultText(EGDT_WINDOW_MINIMIZE) : L"Minimize" );
|
||||
MinButton->setVisible(false);
|
||||
MinButton->setSubElement(true);
|
||||
MinButton->setTabStop(false);
|
||||
MinButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
|
||||
if (sprites)
|
||||
{
|
||||
MinButton->setSpriteBank(sprites);
|
||||
MinButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_MINIMIZE), color);
|
||||
MinButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_MINIMIZE), color);
|
||||
}
|
||||
|
||||
MinButton->grab();
|
||||
RestoreButton->grab();
|
||||
CloseButton->grab();
|
||||
|
||||
// this element is a tab group
|
||||
setTabGroup(true);
|
||||
setTabStop(true);
|
||||
setTabOrder(-1);
|
||||
}
|
||||
|
||||
|
||||
//! destructor
|
||||
CGUIWindow::~CGUIWindow()
|
||||
{
|
||||
if (MinButton)
|
||||
MinButton->drop();
|
||||
|
||||
if (RestoreButton)
|
||||
RestoreButton->drop();
|
||||
|
||||
if (CloseButton)
|
||||
CloseButton->drop();
|
||||
}
|
||||
|
||||
|
||||
//! called if an event happened.
|
||||
bool CGUIWindow::OnEvent(const SEvent& event)
|
||||
{
|
||||
if (IsEnabled)
|
||||
{
|
||||
|
||||
switch(event.EventType)
|
||||
{
|
||||
case EET_GUI_EVENT:
|
||||
if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST)
|
||||
{
|
||||
Dragging = false;
|
||||
}
|
||||
else
|
||||
if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUSED)
|
||||
{
|
||||
if (Parent && ((event.GUIEvent.Caller == this) || isMyChild(event.GUIEvent.Caller)))
|
||||
Parent->bringToFront(this);
|
||||
}
|
||||
else
|
||||
if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED)
|
||||
{
|
||||
if (event.GUIEvent.Caller == CloseButton)
|
||||
{
|
||||
if (Parent)
|
||||
{
|
||||
// send close event to parent
|
||||
SEvent e;
|
||||
e.EventType = EET_GUI_EVENT;
|
||||
e.GUIEvent.Caller = this;
|
||||
e.GUIEvent.Element = 0;
|
||||
e.GUIEvent.EventType = EGET_ELEMENT_CLOSED;
|
||||
|
||||
// if the event was not absorbed
|
||||
if (!Parent->OnEvent(e))
|
||||
remove();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EET_MOUSE_INPUT_EVENT:
|
||||
switch(event.MouseInput.Event)
|
||||
{
|
||||
case EMIE_LMOUSE_PRESSED_DOWN:
|
||||
DragStart.X = event.MouseInput.X;
|
||||
DragStart.Y = event.MouseInput.Y;
|
||||
Dragging = true;
|
||||
if (Parent)
|
||||
Parent->bringToFront(this);
|
||||
return true;
|
||||
case EMIE_LMOUSE_LEFT_UP:
|
||||
Dragging = false;
|
||||
return true;
|
||||
case EMIE_MOUSE_MOVED:
|
||||
if ( !event.MouseInput.isLeftPressed() )
|
||||
Dragging = false;
|
||||
|
||||
if (Dragging)
|
||||
{
|
||||
// gui window should not be dragged outside its parent
|
||||
if (Parent &&
|
||||
(event.MouseInput.X < Parent->getAbsolutePosition().UpperLeftCorner.X +1 ||
|
||||
event.MouseInput.Y < Parent->getAbsolutePosition().UpperLeftCorner.Y +1 ||
|
||||
event.MouseInput.X > Parent->getAbsolutePosition().LowerRightCorner.X -1 ||
|
||||
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;
|
||||
DragStart.Y = event.MouseInput.Y;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return IGUIElement::OnEvent(event);
|
||||
}
|
||||
|
||||
|
||||
//! Updates the absolute position.
|
||||
void CGUIWindow::updateAbsolutePosition()
|
||||
{
|
||||
IGUIElement::updateAbsolutePosition();
|
||||
}
|
||||
|
||||
|
||||
//! draws the element and its children
|
||||
void CGUIWindow::draw()
|
||||
{
|
||||
if ( IsVisible )
|
||||
{
|
||||
IGUISkin* skin = Environment->getSkin();
|
||||
|
||||
core::rect<s32> rect = AbsoluteRect;
|
||||
|
||||
// draw body fast
|
||||
rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER),
|
||||
AbsoluteRect, &AbsoluteClippingRect);
|
||||
|
||||
if (Text.size())
|
||||
{
|
||||
rect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X);
|
||||
rect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_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(EGDC_ACTIVE_CAPTION), false, true, &AbsoluteClippingRect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IGUIElement::draw();
|
||||
}
|
||||
|
||||
|
||||
//! Returns pointer to the close button
|
||||
IGUIButton* CGUIWindow::getCloseButton() const
|
||||
{
|
||||
return CloseButton;
|
||||
}
|
||||
|
||||
|
||||
//! Returns pointer to the minimize button
|
||||
IGUIButton* CGUIWindow::getMinimizeButton() const
|
||||
{
|
||||
return MinButton;
|
||||
}
|
||||
|
||||
|
||||
//! Returns pointer to the maximize button
|
||||
IGUIButton* CGUIWindow::getMaximizeButton() const
|
||||
{
|
||||
return RestoreButton;
|
||||
}
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_GUI_
|
||||
|
||||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "CGUIWindow.h"
|
||||
#ifdef _IRR_COMPILE_WITH_GUI_
|
||||
|
||||
#include "IGUISkin.h"
|
||||
#include "IGUIEnvironment.h"
|
||||
#include "IVideoDriver.h"
|
||||
#include "IGUIButton.h"
|
||||
#include "IGUIFont.h"
|
||||
#include "IGUIFontBitmap.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace gui
|
||||
{
|
||||
|
||||
//! constructor
|
||||
CGUIWindow::CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
|
||||
: IGUIWindow(environment, parent, id, rectangle), Dragging(false)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CGUIWindow");
|
||||
#endif
|
||||
|
||||
IGUISkin* skin = 0;
|
||||
if (environment)
|
||||
skin = environment->getSkin();
|
||||
|
||||
IGUISpriteBank* sprites = 0;
|
||||
video::SColor color(255,255,255,255);
|
||||
|
||||
s32 buttonw = 15;
|
||||
if (skin)
|
||||
{
|
||||
buttonw = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH);
|
||||
sprites = skin->getSpriteBank();
|
||||
color = skin->getColor(EGDC_WINDOW_SYMBOL);
|
||||
}
|
||||
s32 posx = RelativeRect.getWidth() - buttonw - 4;
|
||||
|
||||
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->setTabStop(false);
|
||||
CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
|
||||
if (sprites)
|
||||
{
|
||||
CloseButton->setSpriteBank(sprites);
|
||||
CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), color);
|
||||
CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), color);
|
||||
}
|
||||
posx -= buttonw + 2;
|
||||
|
||||
RestoreButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1,
|
||||
L"", skin ? skin->getDefaultText(EGDT_WINDOW_RESTORE) : L"Restore" );
|
||||
RestoreButton->setVisible(false);
|
||||
RestoreButton->setSubElement(true);
|
||||
RestoreButton->setTabStop(false);
|
||||
RestoreButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
|
||||
if (sprites)
|
||||
{
|
||||
RestoreButton->setSpriteBank(sprites);
|
||||
RestoreButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_RESTORE), color);
|
||||
RestoreButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_RESTORE), color);
|
||||
}
|
||||
posx -= buttonw + 2;
|
||||
|
||||
MinButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1,
|
||||
L"", skin ? skin->getDefaultText(EGDT_WINDOW_MINIMIZE) : L"Minimize" );
|
||||
MinButton->setVisible(false);
|
||||
MinButton->setSubElement(true);
|
||||
MinButton->setTabStop(false);
|
||||
MinButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
|
||||
if (sprites)
|
||||
{
|
||||
MinButton->setSpriteBank(sprites);
|
||||
MinButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_MINIMIZE), color);
|
||||
MinButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_MINIMIZE), color);
|
||||
}
|
||||
|
||||
MinButton->grab();
|
||||
RestoreButton->grab();
|
||||
CloseButton->grab();
|
||||
|
||||
// this element is a tab group
|
||||
setTabGroup(true);
|
||||
setTabStop(true);
|
||||
setTabOrder(-1);
|
||||
}
|
||||
|
||||
|
||||
//! destructor
|
||||
CGUIWindow::~CGUIWindow()
|
||||
{
|
||||
if (MinButton)
|
||||
MinButton->drop();
|
||||
|
||||
if (RestoreButton)
|
||||
RestoreButton->drop();
|
||||
|
||||
if (CloseButton)
|
||||
CloseButton->drop();
|
||||
}
|
||||
|
||||
|
||||
//! called if an event happened.
|
||||
bool CGUIWindow::OnEvent(const SEvent& event)
|
||||
{
|
||||
if (IsEnabled)
|
||||
{
|
||||
|
||||
switch(event.EventType)
|
||||
{
|
||||
case EET_GUI_EVENT:
|
||||
if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST)
|
||||
{
|
||||
Dragging = false;
|
||||
}
|
||||
else
|
||||
if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUSED)
|
||||
{
|
||||
if (Parent && ((event.GUIEvent.Caller == this) || isMyChild(event.GUIEvent.Caller)))
|
||||
Parent->bringToFront(this);
|
||||
}
|
||||
else
|
||||
if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED)
|
||||
{
|
||||
if (event.GUIEvent.Caller == CloseButton)
|
||||
{
|
||||
if (Parent)
|
||||
{
|
||||
// send close event to parent
|
||||
SEvent e;
|
||||
e.EventType = EET_GUI_EVENT;
|
||||
e.GUIEvent.Caller = this;
|
||||
e.GUIEvent.Element = 0;
|
||||
e.GUIEvent.EventType = EGET_ELEMENT_CLOSED;
|
||||
|
||||
// if the event was not absorbed
|
||||
if (!Parent->OnEvent(e))
|
||||
remove();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EET_MOUSE_INPUT_EVENT:
|
||||
switch(event.MouseInput.Event)
|
||||
{
|
||||
case EMIE_LMOUSE_PRESSED_DOWN:
|
||||
DragStart.X = event.MouseInput.X;
|
||||
DragStart.Y = event.MouseInput.Y;
|
||||
Dragging = true;
|
||||
if (Parent)
|
||||
Parent->bringToFront(this);
|
||||
return true;
|
||||
case EMIE_LMOUSE_LEFT_UP:
|
||||
Dragging = false;
|
||||
return true;
|
||||
case EMIE_MOUSE_MOVED:
|
||||
if ( !event.MouseInput.isLeftPressed() )
|
||||
Dragging = false;
|
||||
|
||||
if (Dragging)
|
||||
{
|
||||
// gui window should not be dragged outside its parent
|
||||
if (Parent &&
|
||||
(event.MouseInput.X < Parent->getAbsolutePosition().UpperLeftCorner.X +1 ||
|
||||
event.MouseInput.Y < Parent->getAbsolutePosition().UpperLeftCorner.Y +1 ||
|
||||
event.MouseInput.X > Parent->getAbsolutePosition().LowerRightCorner.X -1 ||
|
||||
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;
|
||||
DragStart.Y = event.MouseInput.Y;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return IGUIElement::OnEvent(event);
|
||||
}
|
||||
|
||||
|
||||
//! Updates the absolute position.
|
||||
void CGUIWindow::updateAbsolutePosition()
|
||||
{
|
||||
IGUIElement::updateAbsolutePosition();
|
||||
}
|
||||
|
||||
|
||||
//! draws the element and its children
|
||||
void CGUIWindow::draw()
|
||||
{
|
||||
if ( IsVisible )
|
||||
{
|
||||
IGUISkin* skin = Environment->getSkin();
|
||||
|
||||
core::rect<s32> rect = AbsoluteRect;
|
||||
|
||||
// draw body fast
|
||||
rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER),
|
||||
AbsoluteRect, &AbsoluteClippingRect);
|
||||
|
||||
if (Text.size())
|
||||
{
|
||||
rect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X);
|
||||
rect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_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(EGDC_ACTIVE_CAPTION), false, true, &AbsoluteClippingRect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IGUIElement::draw();
|
||||
}
|
||||
|
||||
|
||||
//! Returns pointer to the close button
|
||||
IGUIButton* CGUIWindow::getCloseButton() const
|
||||
{
|
||||
return CloseButton;
|
||||
}
|
||||
|
||||
|
||||
//! Returns pointer to the minimize button
|
||||
IGUIButton* CGUIWindow::getMinimizeButton() const
|
||||
{
|
||||
return MinButton;
|
||||
}
|
||||
|
||||
|
||||
//! Returns pointer to the maximize button
|
||||
IGUIButton* CGUIWindow::getMaximizeButton() const
|
||||
{
|
||||
return RestoreButton;
|
||||
}
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_GUI_
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,216 +1,216 @@
|
|||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
// This device code is based on the original SDL device implementation
|
||||
// contributed by Shane Parker (sirshane).
|
||||
|
||||
#ifndef __C_IRR_DEVICE_SDL_H_INCLUDED__
|
||||
#define __C_IRR_DEVICE_SDL_H_INCLUDED__
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
|
||||
#ifdef _IRR_USE_SDL_DEVICE_
|
||||
|
||||
#include "IrrlichtDevice.h"
|
||||
#include "CIrrDeviceStub.h"
|
||||
#include "IImagePresenter.h"
|
||||
#include "ICursorControl.h"
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
||||
class CIrrDeviceSDL : public CIrrDeviceStub, video::IImagePresenter
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceSDL(const SIrrlichtCreationParameters& param);
|
||||
|
||||
//! destructor
|
||||
virtual ~CIrrDeviceSDL();
|
||||
|
||||
//! runs the device. Returns false if device wants to be deleted
|
||||
virtual bool run();
|
||||
|
||||
//! pause execution temporarily
|
||||
virtual void yield();
|
||||
|
||||
//! pause execution for a specified time
|
||||
virtual void sleep(u32 timeMs, bool pauseTimer);
|
||||
|
||||
//! sets the caption of the window
|
||||
virtual void setWindowCaption(const wchar_t* text);
|
||||
|
||||
//! returns if window is active. if not, nothing need to be drawn
|
||||
virtual bool isWindowActive() const;
|
||||
|
||||
//! returns if window has focus.
|
||||
bool isWindowFocused() const;
|
||||
|
||||
//! returns if window is minimized.
|
||||
bool isWindowMinimized() const;
|
||||
|
||||
//! returns color format of the window.
|
||||
video::ECOLOR_FORMAT getColorFormat() const;
|
||||
|
||||
//! presents a surface in the client area
|
||||
virtual bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0);
|
||||
|
||||
//! notifies the device that it should close itself
|
||||
virtual void closeDevice();
|
||||
|
||||
//! \return Returns a pointer to a list with all video modes supported
|
||||
video::IVideoModeList* getVideoModeList();
|
||||
|
||||
//! Sets if the window should be resizable in windowed mode.
|
||||
virtual void setResizable(bool resize=false);
|
||||
|
||||
//! Minimizes the window.
|
||||
virtual void minimizeWindow();
|
||||
|
||||
//! Activate any joysticks, and generate events for them.
|
||||
virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo);
|
||||
|
||||
//! Implementation of the linux cursor control
|
||||
class CCursorControl : public gui::ICursorControl
|
||||
{
|
||||
public:
|
||||
|
||||
CCursorControl(CIrrDeviceSDL* dev)
|
||||
: Device(dev), IsVisible(true)
|
||||
{
|
||||
}
|
||||
|
||||
//! Changes the visible state of the mouse cursor.
|
||||
virtual void setVisible(bool visible)
|
||||
{
|
||||
IsVisible = visible;
|
||||
if ( visible )
|
||||
SDL_ShowCursor( SDL_ENABLE );
|
||||
else
|
||||
SDL_ShowCursor( SDL_DISABLE );
|
||||
}
|
||||
|
||||
//! Returns if the cursor is currently visible.
|
||||
virtual bool isVisible() const
|
||||
{
|
||||
return IsVisible;
|
||||
}
|
||||
|
||||
//! Sets the new position of the cursor.
|
||||
virtual void setPosition(const core::position2d<f32> &pos)
|
||||
{
|
||||
setPosition(pos.X, pos.Y);
|
||||
}
|
||||
|
||||
//! Sets the new position of the cursor.
|
||||
virtual void setPosition(f32 x, f32 y)
|
||||
{
|
||||
setPosition((s32)(x*Device->Width), (s32)(y*Device->Height));
|
||||
}
|
||||
|
||||
//! Sets the new position of the cursor.
|
||||
virtual void setPosition(const core::position2d<s32> &pos)
|
||||
{
|
||||
setPosition(pos.X, pos.Y);
|
||||
}
|
||||
|
||||
//! Sets the new position of the cursor.
|
||||
virtual void setPosition(s32 x, s32 y)
|
||||
{
|
||||
SDL_WarpMouse( x, y );
|
||||
}
|
||||
|
||||
//! Returns the current position of the mouse cursor.
|
||||
virtual core::position2d<s32> getPosition()
|
||||
{
|
||||
updateCursorPos();
|
||||
return CursorPos;
|
||||
}
|
||||
|
||||
//! Returns the current position of the mouse cursor.
|
||||
virtual core::position2d<f32> getRelativePosition()
|
||||
{
|
||||
updateCursorPos();
|
||||
return core::position2d<f32>(CursorPos.X / (f32)Device->Width,
|
||||
CursorPos.Y / (f32)Device->Height);
|
||||
}
|
||||
|
||||
virtual void setReferenceRect(core::rect<s32>* rect=0)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void updateCursorPos()
|
||||
{
|
||||
CursorPos.X = Device->MouseX;
|
||||
CursorPos.Y = Device->MouseY;
|
||||
|
||||
if (CursorPos.X < 0)
|
||||
CursorPos.X = 0;
|
||||
if (CursorPos.X > (s32)Device->Width)
|
||||
CursorPos.X = Device->Width;
|
||||
if (CursorPos.Y < 0)
|
||||
CursorPos.Y = 0;
|
||||
if (CursorPos.Y > (s32)Device->Height)
|
||||
CursorPos.Y = Device->Height;
|
||||
}
|
||||
|
||||
CIrrDeviceSDL* Device;
|
||||
core::position2d<s32> CursorPos;
|
||||
bool IsVisible;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
//! create the driver
|
||||
void createDriver();
|
||||
|
||||
bool createWindow();
|
||||
|
||||
void createKeyMap();
|
||||
|
||||
SDL_Surface* Screen;
|
||||
int SDL_Flags;
|
||||
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
|
||||
core::array<SDL_Joystick*> Joysticks;
|
||||
#endif
|
||||
|
||||
s32 MouseX, MouseY;
|
||||
u32 MouseButtonStates;
|
||||
|
||||
u32 Width, Height;
|
||||
|
||||
bool Close;
|
||||
bool Resizable;
|
||||
bool WindowHasFocus;
|
||||
bool WindowMinimized;
|
||||
|
||||
struct SKeyMap
|
||||
{
|
||||
SKeyMap() {}
|
||||
SKeyMap(s32 x11, s32 win32)
|
||||
: SDLKey(x11), Win32Key(win32)
|
||||
{
|
||||
}
|
||||
|
||||
s32 SDLKey;
|
||||
s32 Win32Key;
|
||||
|
||||
bool operator<(const SKeyMap& o) const
|
||||
{
|
||||
return SDLKey<o.SDLKey;
|
||||
}
|
||||
};
|
||||
|
||||
core::array<SKeyMap> KeyMap;
|
||||
};
|
||||
|
||||
} // end namespace irr
|
||||
|
||||
#endif // _IRR_USE_SDL_DEVICE_
|
||||
#endif // __C_IRR_DEVICE_SDL_H_INCLUDED__
|
||||
|
||||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
// This device code is based on the original SDL device implementation
|
||||
// contributed by Shane Parker (sirshane).
|
||||
|
||||
#ifndef __C_IRR_DEVICE_SDL_H_INCLUDED__
|
||||
#define __C_IRR_DEVICE_SDL_H_INCLUDED__
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
|
||||
#ifdef _IRR_USE_SDL_DEVICE_
|
||||
|
||||
#include "IrrlichtDevice.h"
|
||||
#include "CIrrDeviceStub.h"
|
||||
#include "IImagePresenter.h"
|
||||
#include "ICursorControl.h"
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
||||
class CIrrDeviceSDL : public CIrrDeviceStub, video::IImagePresenter
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceSDL(const SIrrlichtCreationParameters& param);
|
||||
|
||||
//! destructor
|
||||
virtual ~CIrrDeviceSDL();
|
||||
|
||||
//! runs the device. Returns false if device wants to be deleted
|
||||
virtual bool run();
|
||||
|
||||
//! pause execution temporarily
|
||||
virtual void yield();
|
||||
|
||||
//! pause execution for a specified time
|
||||
virtual void sleep(u32 timeMs, bool pauseTimer);
|
||||
|
||||
//! sets the caption of the window
|
||||
virtual void setWindowCaption(const wchar_t* text);
|
||||
|
||||
//! returns if window is active. if not, nothing need to be drawn
|
||||
virtual bool isWindowActive() const;
|
||||
|
||||
//! returns if window has focus.
|
||||
bool isWindowFocused() const;
|
||||
|
||||
//! returns if window is minimized.
|
||||
bool isWindowMinimized() const;
|
||||
|
||||
//! returns color format of the window.
|
||||
video::ECOLOR_FORMAT getColorFormat() const;
|
||||
|
||||
//! presents a surface in the client area
|
||||
virtual bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0);
|
||||
|
||||
//! notifies the device that it should close itself
|
||||
virtual void closeDevice();
|
||||
|
||||
//! \return Returns a pointer to a list with all video modes supported
|
||||
video::IVideoModeList* getVideoModeList();
|
||||
|
||||
//! Sets if the window should be resizable in windowed mode.
|
||||
virtual void setResizable(bool resize=false);
|
||||
|
||||
//! Minimizes the window.
|
||||
virtual void minimizeWindow();
|
||||
|
||||
//! Activate any joysticks, and generate events for them.
|
||||
virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo);
|
||||
|
||||
//! Implementation of the linux cursor control
|
||||
class CCursorControl : public gui::ICursorControl
|
||||
{
|
||||
public:
|
||||
|
||||
CCursorControl(CIrrDeviceSDL* dev)
|
||||
: Device(dev), IsVisible(true)
|
||||
{
|
||||
}
|
||||
|
||||
//! Changes the visible state of the mouse cursor.
|
||||
virtual void setVisible(bool visible)
|
||||
{
|
||||
IsVisible = visible;
|
||||
if ( visible )
|
||||
SDL_ShowCursor( SDL_ENABLE );
|
||||
else
|
||||
SDL_ShowCursor( SDL_DISABLE );
|
||||
}
|
||||
|
||||
//! Returns if the cursor is currently visible.
|
||||
virtual bool isVisible() const
|
||||
{
|
||||
return IsVisible;
|
||||
}
|
||||
|
||||
//! Sets the new position of the cursor.
|
||||
virtual void setPosition(const core::position2d<f32> &pos)
|
||||
{
|
||||
setPosition(pos.X, pos.Y);
|
||||
}
|
||||
|
||||
//! Sets the new position of the cursor.
|
||||
virtual void setPosition(f32 x, f32 y)
|
||||
{
|
||||
setPosition((s32)(x*Device->Width), (s32)(y*Device->Height));
|
||||
}
|
||||
|
||||
//! Sets the new position of the cursor.
|
||||
virtual void setPosition(const core::position2d<s32> &pos)
|
||||
{
|
||||
setPosition(pos.X, pos.Y);
|
||||
}
|
||||
|
||||
//! Sets the new position of the cursor.
|
||||
virtual void setPosition(s32 x, s32 y)
|
||||
{
|
||||
SDL_WarpMouse( x, y );
|
||||
}
|
||||
|
||||
//! Returns the current position of the mouse cursor.
|
||||
virtual core::position2d<s32> getPosition()
|
||||
{
|
||||
updateCursorPos();
|
||||
return CursorPos;
|
||||
}
|
||||
|
||||
//! Returns the current position of the mouse cursor.
|
||||
virtual core::position2d<f32> getRelativePosition()
|
||||
{
|
||||
updateCursorPos();
|
||||
return core::position2d<f32>(CursorPos.X / (f32)Device->Width,
|
||||
CursorPos.Y / (f32)Device->Height);
|
||||
}
|
||||
|
||||
virtual void setReferenceRect(core::rect<s32>* rect=0)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void updateCursorPos()
|
||||
{
|
||||
CursorPos.X = Device->MouseX;
|
||||
CursorPos.Y = Device->MouseY;
|
||||
|
||||
if (CursorPos.X < 0)
|
||||
CursorPos.X = 0;
|
||||
if (CursorPos.X > (s32)Device->Width)
|
||||
CursorPos.X = Device->Width;
|
||||
if (CursorPos.Y < 0)
|
||||
CursorPos.Y = 0;
|
||||
if (CursorPos.Y > (s32)Device->Height)
|
||||
CursorPos.Y = Device->Height;
|
||||
}
|
||||
|
||||
CIrrDeviceSDL* Device;
|
||||
core::position2d<s32> CursorPos;
|
||||
bool IsVisible;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
//! create the driver
|
||||
void createDriver();
|
||||
|
||||
bool createWindow();
|
||||
|
||||
void createKeyMap();
|
||||
|
||||
SDL_Surface* Screen;
|
||||
int SDL_Flags;
|
||||
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
|
||||
core::array<SDL_Joystick*> Joysticks;
|
||||
#endif
|
||||
|
||||
s32 MouseX, MouseY;
|
||||
u32 MouseButtonStates;
|
||||
|
||||
u32 Width, Height;
|
||||
|
||||
bool Close;
|
||||
bool Resizable;
|
||||
bool WindowHasFocus;
|
||||
bool WindowMinimized;
|
||||
|
||||
struct SKeyMap
|
||||
{
|
||||
SKeyMap() {}
|
||||
SKeyMap(s32 x11, s32 win32)
|
||||
: SDLKey(x11), Win32Key(win32)
|
||||
{
|
||||
}
|
||||
|
||||
s32 SDLKey;
|
||||
s32 Win32Key;
|
||||
|
||||
bool operator<(const SKeyMap& o) const
|
||||
{
|
||||
return SDLKey<o.SDLKey;
|
||||
}
|
||||
};
|
||||
|
||||
core::array<SKeyMap> KeyMap;
|
||||
};
|
||||
|
||||
} // end namespace irr
|
||||
|
||||
#endif // _IRR_USE_SDL_DEVICE_
|
||||
#endif // __C_IRR_DEVICE_SDL_H_INCLUDED__
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,87 +1,87 @@
|
|||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __C_LWO_MESH_FILE_LOADER_H_INCLUDED__
|
||||
#define __C_LWO_MESH_FILE_LOADER_H_INCLUDED__
|
||||
|
||||
#include "IMeshLoader.h"
|
||||
#include "SMeshBuffer.h"
|
||||
#include "irrString.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
class IReadFile;
|
||||
class IFileSystem;
|
||||
} // end namespace io
|
||||
namespace scene
|
||||
{
|
||||
|
||||
struct SMesh;
|
||||
class ISceneManager;
|
||||
|
||||
//! Meshloader capable of loading Lightwave 3D meshes.
|
||||
class CLWOMeshFileLoader : public IMeshLoader
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
CLWOMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs);
|
||||
|
||||
//! destructor
|
||||
virtual ~CLWOMeshFileLoader();
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
//! based on the file extension (e.g. ".bsp")
|
||||
virtual bool isALoadableFileExtension(const core::string<c16>& filename) const;
|
||||
|
||||
//! creates/loads an animated mesh from the file.
|
||||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IUnknown::drop() for more information.
|
||||
virtual IAnimatedMesh* createMesh(io::IReadFile* file);
|
||||
|
||||
private:
|
||||
|
||||
struct tLWOMaterial;
|
||||
|
||||
bool readFileHeader();
|
||||
bool readChunks();
|
||||
void readObj1(u32 size);
|
||||
void readTagMapping(u32 size);
|
||||
void readVertexMapping(u32 size);
|
||||
void readDiscVertexMapping (u32 size);
|
||||
void readObj2(u32 size);
|
||||
void readMat(u32 size);
|
||||
u32 readString(core::stringc& name, u32 size=0);
|
||||
u32 readVec(core::vector3df& vec);
|
||||
u32 readVX(u32& num);
|
||||
u32 readColor(video::SColor& color);
|
||||
video::ITexture* loadTexture(const core::stringc& file);
|
||||
|
||||
scene::ISceneManager* SceneManager;
|
||||
io::IFileSystem* FileSystem;
|
||||
io::IReadFile* File;
|
||||
SMesh* Mesh;
|
||||
|
||||
core::array<core::vector3df> Points;
|
||||
core::array<core::array<u32> > Indices;
|
||||
core::array<core::stringc> UvName;
|
||||
core::array<core::array<u32> > UvIndex;
|
||||
core::array<core::stringc> DUvName;
|
||||
core::array<core::array<u32> > VmPolyPointsIndex;
|
||||
core::array<core::array<core::vector2df> > VmCoordsIndex;
|
||||
|
||||
core::array<u16> MaterialMapping;
|
||||
core::array<core::array<core::vector2df> > TCoords;
|
||||
core::array<tLWOMaterial*> Materials;
|
||||
core::array<core::stringc> Images;
|
||||
u8 FormatVersion;
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __C_LWO_MESH_FILE_LOADER_H_INCLUDED__
|
||||
#define __C_LWO_MESH_FILE_LOADER_H_INCLUDED__
|
||||
|
||||
#include "IMeshLoader.h"
|
||||
#include "SMeshBuffer.h"
|
||||
#include "irrString.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
class IReadFile;
|
||||
class IFileSystem;
|
||||
} // end namespace io
|
||||
namespace scene
|
||||
{
|
||||
|
||||
struct SMesh;
|
||||
class ISceneManager;
|
||||
|
||||
//! Meshloader capable of loading Lightwave 3D meshes.
|
||||
class CLWOMeshFileLoader : public IMeshLoader
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
CLWOMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs);
|
||||
|
||||
//! destructor
|
||||
virtual ~CLWOMeshFileLoader();
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
//! based on the file extension (e.g. ".bsp")
|
||||
virtual bool isALoadableFileExtension(const core::string<c16>& filename) const;
|
||||
|
||||
//! creates/loads an animated mesh from the file.
|
||||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IUnknown::drop() for more information.
|
||||
virtual IAnimatedMesh* createMesh(io::IReadFile* file);
|
||||
|
||||
private:
|
||||
|
||||
struct tLWOMaterial;
|
||||
|
||||
bool readFileHeader();
|
||||
bool readChunks();
|
||||
void readObj1(u32 size);
|
||||
void readTagMapping(u32 size);
|
||||
void readVertexMapping(u32 size);
|
||||
void readDiscVertexMapping (u32 size);
|
||||
void readObj2(u32 size);
|
||||
void readMat(u32 size);
|
||||
u32 readString(core::stringc& name, u32 size=0);
|
||||
u32 readVec(core::vector3df& vec);
|
||||
u32 readVX(u32& num);
|
||||
u32 readColor(video::SColor& color);
|
||||
video::ITexture* loadTexture(const core::stringc& file);
|
||||
|
||||
scene::ISceneManager* SceneManager;
|
||||
io::IFileSystem* FileSystem;
|
||||
io::IReadFile* File;
|
||||
SMesh* Mesh;
|
||||
|
||||
core::array<core::vector3df> Points;
|
||||
core::array<core::array<u32> > Indices;
|
||||
core::array<core::stringc> UvName;
|
||||
core::array<core::array<u32> > UvIndex;
|
||||
core::array<core::stringc> DUvName;
|
||||
core::array<core::array<u32> > VmPolyPointsIndex;
|
||||
core::array<core::array<core::vector2df> > VmCoordsIndex;
|
||||
|
||||
core::array<u16> MaterialMapping;
|
||||
core::array<core::array<core::vector2df> > TCoords;
|
||||
core::array<tLWOMaterial*> Materials;
|
||||
core::array<core::stringc> Images;
|
||||
u8 FormatVersion;
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -24,10 +24,8 @@ namespace scene
|
|||
public:
|
||||
|
||||
//! constructor
|
||||
CQ3LevelMesh( io::IFileSystem* fs,
|
||||
scene::ISceneManager* smgr,
|
||||
const quake3::Q3LevelLoadParameter &loadParam
|
||||
);
|
||||
CQ3LevelMesh(io::IFileSystem* fs, scene::ISceneManager* smgr,
|
||||
const quake3::Q3LevelLoadParameter &loadParam);
|
||||
|
||||
//! destructor
|
||||
virtual ~CQ3LevelMesh();
|
||||
|
|
|
@ -1,340 +1,340 @@
|
|||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "CSceneNodeAnimatorCameraFPS.h"
|
||||
#include "IVideoDriver.h"
|
||||
#include "ISceneManager.h"
|
||||
#include "Keycodes.h"
|
||||
#include "ICursorControl.h"
|
||||
#include "ICameraSceneNode.h"
|
||||
#include "ISceneNodeAnimatorCollisionResponse.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
//! constructor
|
||||
CSceneNodeAnimatorCameraFPS::CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cursorControl,
|
||||
f32 rotateSpeed, f32 moveSpeed, f32 jumpSpeed,
|
||||
SKeyMap* keyMapArray, u32 keyMapSize, bool noVerticalMovement, bool invertY)
|
||||
: CursorControl(cursorControl), MaxVerticalAngle(88.0f),
|
||||
MoveSpeed(moveSpeed), RotateSpeed(rotateSpeed), JumpSpeed(jumpSpeed),
|
||||
MouseYDirection(invertY ? -1.0f : 1.0f),
|
||||
LastAnimationTime(0), firstUpdate(true), NoVerticalMovement(noVerticalMovement)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CCameraSceneNodeAnimatorFPS");
|
||||
#endif
|
||||
|
||||
if (CursorControl)
|
||||
CursorControl->grab();
|
||||
|
||||
allKeysUp();
|
||||
|
||||
// create key map
|
||||
if (!keyMapArray || !keyMapSize)
|
||||
{
|
||||
// create default key map
|
||||
KeyMap.push_back(SCamKeyMap(EKA_MOVE_FORWARD, irr::KEY_UP));
|
||||
KeyMap.push_back(SCamKeyMap(EKA_MOVE_BACKWARD, irr::KEY_DOWN));
|
||||
KeyMap.push_back(SCamKeyMap(EKA_STRAFE_LEFT, irr::KEY_LEFT));
|
||||
KeyMap.push_back(SCamKeyMap(EKA_STRAFE_RIGHT, irr::KEY_RIGHT));
|
||||
KeyMap.push_back(SCamKeyMap(EKA_JUMP_UP, irr::KEY_KEY_J));
|
||||
}
|
||||
else
|
||||
{
|
||||
// create custom key map
|
||||
setKeyMap(keyMapArray, keyMapSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! destructor
|
||||
CSceneNodeAnimatorCameraFPS::~CSceneNodeAnimatorCameraFPS()
|
||||
{
|
||||
if (CursorControl)
|
||||
CursorControl->drop();
|
||||
}
|
||||
|
||||
|
||||
//! It is possible to send mouse and key events to the camera. Most cameras
|
||||
//! may ignore this input, but camera scene nodes which are created for
|
||||
//! example with scene::ISceneManager::addMayaCameraSceneNode or
|
||||
//! scene::ISceneManager::addFPSCameraSceneNode, may want to get this input
|
||||
//! for changing their position, look at target or whatever.
|
||||
bool CSceneNodeAnimatorCameraFPS::OnEvent(const SEvent& evt)
|
||||
{
|
||||
switch(evt.EventType)
|
||||
{
|
||||
case EET_KEY_INPUT_EVENT:
|
||||
for (u32 i=0; i<KeyMap.size(); ++i)
|
||||
{
|
||||
if (KeyMap[i].keycode == evt.KeyInput.Key)
|
||||
{
|
||||
CursorKeys[KeyMap[i].action] = evt.KeyInput.PressedDown;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EET_MOUSE_INPUT_EVENT:
|
||||
if (evt.MouseInput.Event == EMIE_MOUSE_MOVED)
|
||||
{
|
||||
CursorPos = CursorControl->getRelativePosition();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void CSceneNodeAnimatorCameraFPS::animateNode(ISceneNode* node, u32 timeMs)
|
||||
{
|
||||
if (!node || node->getType() != ESNT_CAMERA)
|
||||
return;
|
||||
|
||||
ICameraSceneNode* camera = static_cast<ICameraSceneNode*>(node);
|
||||
|
||||
if (firstUpdate)
|
||||
{
|
||||
camera->updateAbsolutePosition();
|
||||
if (CursorControl && camera)
|
||||
{
|
||||
CursorControl->setPosition(0.5f, 0.5f);
|
||||
CursorPos = CenterCursor = CursorControl->getRelativePosition();
|
||||
}
|
||||
|
||||
LastAnimationTime = timeMs;
|
||||
|
||||
firstUpdate = false;
|
||||
}
|
||||
|
||||
// If the camera isn't the active camera, and receiving input, then don't process it.
|
||||
if(!camera->isInputReceiverEnabled())
|
||||
return;
|
||||
|
||||
scene::ISceneManager * smgr = camera->getSceneManager();
|
||||
if(smgr && smgr->getActiveCamera() != camera)
|
||||
return;
|
||||
|
||||
// get time
|
||||
f32 timeDiff = (f32) ( timeMs - LastAnimationTime );
|
||||
LastAnimationTime = timeMs;
|
||||
|
||||
// update position
|
||||
core::vector3df pos = camera->getPosition();
|
||||
|
||||
// Update rotation
|
||||
core::vector3df target = (camera->getTarget() - camera->getAbsolutePosition());
|
||||
core::vector3df relativeRotation = target.getHorizontalAngle();
|
||||
|
||||
if (CursorControl)
|
||||
{
|
||||
if (CursorPos != CenterCursor)
|
||||
{
|
||||
relativeRotation.Y -= (0.5f - CursorPos.X) * RotateSpeed;
|
||||
relativeRotation.X -= (0.5f - CursorPos.Y) * RotateSpeed * MouseYDirection;
|
||||
|
||||
// X < MaxVerticalAngle or X > 360-MaxVerticalAngle
|
||||
|
||||
if (relativeRotation.X > MaxVerticalAngle*2 &&
|
||||
relativeRotation.X < 360.0f-MaxVerticalAngle)
|
||||
{
|
||||
relativeRotation.X = 360.0f-MaxVerticalAngle;
|
||||
}
|
||||
else
|
||||
if (relativeRotation.X > MaxVerticalAngle &&
|
||||
relativeRotation.X < 360.0f-MaxVerticalAngle)
|
||||
{
|
||||
relativeRotation.X = MaxVerticalAngle;
|
||||
}
|
||||
}
|
||||
|
||||
// reset cursor position to the centre of the window. Do this unconditionally
|
||||
// to cope with the case where the mouse has escaped our window in a single
|
||||
// tick, so we don't get messages for it.
|
||||
CursorControl->setPosition(0.5f, 0.5f);
|
||||
CenterCursor = CursorControl->getRelativePosition();
|
||||
// needed to avoid problems when the event receiver is disabled
|
||||
CursorPos = CenterCursor;
|
||||
}
|
||||
|
||||
// set target
|
||||
|
||||
target.set(0,0, core::max_(1.f, pos.getLength()));
|
||||
core::vector3df movedir = target;
|
||||
|
||||
core::matrix4 mat;
|
||||
mat.setRotationDegrees(core::vector3df(relativeRotation.X, relativeRotation.Y, 0));
|
||||
mat.transformVect(target);
|
||||
|
||||
if (NoVerticalMovement)
|
||||
{
|
||||
mat.setRotationDegrees(core::vector3df(0, relativeRotation.Y, 0));
|
||||
mat.transformVect(movedir);
|
||||
}
|
||||
else
|
||||
{
|
||||
movedir = target;
|
||||
}
|
||||
|
||||
movedir.normalize();
|
||||
|
||||
if (CursorKeys[EKA_MOVE_FORWARD])
|
||||
pos += movedir * timeDiff * MoveSpeed;
|
||||
|
||||
if (CursorKeys[EKA_MOVE_BACKWARD])
|
||||
pos -= movedir * timeDiff * MoveSpeed;
|
||||
|
||||
// strafing
|
||||
|
||||
core::vector3df strafevect = target;
|
||||
strafevect = strafevect.crossProduct(camera->getUpVector());
|
||||
|
||||
if (NoVerticalMovement)
|
||||
strafevect.Y = 0.0f;
|
||||
|
||||
strafevect.normalize();
|
||||
|
||||
if (CursorKeys[EKA_STRAFE_LEFT])
|
||||
pos += strafevect * timeDiff * MoveSpeed;
|
||||
|
||||
if (CursorKeys[EKA_STRAFE_RIGHT])
|
||||
pos -= strafevect * timeDiff * MoveSpeed;
|
||||
|
||||
// For jumping, we find the collision response animator attached to our camera
|
||||
// and if it's not falling, we tell it to jump.
|
||||
if (CursorKeys[EKA_JUMP_UP])
|
||||
{
|
||||
const core::list<ISceneNodeAnimator*> & animators = camera->getAnimators();
|
||||
core::list<ISceneNodeAnimator*>::ConstIterator it = animators.begin();
|
||||
while(it != animators.end())
|
||||
{
|
||||
if(ESNAT_COLLISION_RESPONSE == (*it)->getType())
|
||||
{
|
||||
ISceneNodeAnimatorCollisionResponse * collisionResponse =
|
||||
static_cast<ISceneNodeAnimatorCollisionResponse *>(*it);
|
||||
|
||||
if(!collisionResponse->isFalling())
|
||||
collisionResponse->jump(JumpSpeed);
|
||||
}
|
||||
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
// write translation
|
||||
camera->setPosition(pos);
|
||||
|
||||
// write right target
|
||||
target += pos;
|
||||
camera->setTarget(target);
|
||||
}
|
||||
|
||||
|
||||
void CSceneNodeAnimatorCameraFPS::allKeysUp()
|
||||
{
|
||||
for (u32 i=0; i<6; ++i)
|
||||
CursorKeys[i] = false;
|
||||
}
|
||||
|
||||
|
||||
//! Sets the rotation speed
|
||||
void CSceneNodeAnimatorCameraFPS::setRotateSpeed(f32 speed)
|
||||
{
|
||||
RotateSpeed = speed;
|
||||
}
|
||||
|
||||
|
||||
//! Sets the movement speed
|
||||
void CSceneNodeAnimatorCameraFPS::setMoveSpeed(f32 speed)
|
||||
{
|
||||
MoveSpeed = speed;
|
||||
}
|
||||
|
||||
|
||||
//! Gets the rotation speed
|
||||
f32 CSceneNodeAnimatorCameraFPS::getRotateSpeed() const
|
||||
{
|
||||
return RotateSpeed;
|
||||
}
|
||||
|
||||
|
||||
// Gets the movement speed
|
||||
f32 CSceneNodeAnimatorCameraFPS::getMoveSpeed() const
|
||||
{
|
||||
return MoveSpeed;
|
||||
}
|
||||
|
||||
|
||||
//! Sets the keyboard mapping for this animator
|
||||
void CSceneNodeAnimatorCameraFPS::setKeyMap(SKeyMap *map, u32 count)
|
||||
{
|
||||
// clear the keymap
|
||||
KeyMap.clear();
|
||||
|
||||
// add actions
|
||||
for (u32 i=0; i<count; ++i)
|
||||
{
|
||||
switch(map[i].Action)
|
||||
{
|
||||
case EKA_MOVE_FORWARD: KeyMap.push_back(SCamKeyMap(EKA_MOVE_FORWARD, map[i].KeyCode));
|
||||
break;
|
||||
case EKA_MOVE_BACKWARD: KeyMap.push_back(SCamKeyMap(EKA_MOVE_BACKWARD, map[i].KeyCode));
|
||||
break;
|
||||
case EKA_STRAFE_LEFT: KeyMap.push_back(SCamKeyMap(EKA_STRAFE_LEFT, map[i].KeyCode));
|
||||
break;
|
||||
case EKA_STRAFE_RIGHT: KeyMap.push_back(SCamKeyMap(EKA_STRAFE_RIGHT, map[i].KeyCode));
|
||||
break;
|
||||
case EKA_JUMP_UP: KeyMap.push_back(SCamKeyMap(EKA_JUMP_UP, map[i].KeyCode));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Sets whether vertical movement should be allowed.
|
||||
void CSceneNodeAnimatorCameraFPS::setVerticalMovement(bool allow)
|
||||
{
|
||||
NoVerticalMovement = !allow;
|
||||
}
|
||||
|
||||
|
||||
//! Sets whether the Y axis of the mouse should be inverted.
|
||||
void CSceneNodeAnimatorCameraFPS::setInvertMouse(bool invert)
|
||||
{
|
||||
if (invert)
|
||||
MouseYDirection = -1.0f;
|
||||
else
|
||||
MouseYDirection = 1.0f;
|
||||
}
|
||||
|
||||
|
||||
ISceneNodeAnimator* CSceneNodeAnimatorCameraFPS::createClone(ISceneNode* node, ISceneManager* newManager)
|
||||
{
|
||||
CSceneNodeAnimatorCameraFPS * newAnimator =
|
||||
new CSceneNodeAnimatorCameraFPS(CursorControl, RotateSpeed, MoveSpeed, JumpSpeed,
|
||||
0, 0, NoVerticalMovement);
|
||||
newAnimator->setKeyMap(KeyMap);
|
||||
return newAnimator;
|
||||
}
|
||||
|
||||
|
||||
void CSceneNodeAnimatorCameraFPS::setKeyMap(const core::array<SCamKeyMap>& keymap)
|
||||
{
|
||||
KeyMap=keymap;
|
||||
}
|
||||
|
||||
|
||||
} // namespace scene
|
||||
} // namespace irr
|
||||
|
||||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "CSceneNodeAnimatorCameraFPS.h"
|
||||
#include "IVideoDriver.h"
|
||||
#include "ISceneManager.h"
|
||||
#include "Keycodes.h"
|
||||
#include "ICursorControl.h"
|
||||
#include "ICameraSceneNode.h"
|
||||
#include "ISceneNodeAnimatorCollisionResponse.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
//! constructor
|
||||
CSceneNodeAnimatorCameraFPS::CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cursorControl,
|
||||
f32 rotateSpeed, f32 moveSpeed, f32 jumpSpeed,
|
||||
SKeyMap* keyMapArray, u32 keyMapSize, bool noVerticalMovement, bool invertY)
|
||||
: CursorControl(cursorControl), MaxVerticalAngle(88.0f),
|
||||
MoveSpeed(moveSpeed), RotateSpeed(rotateSpeed), JumpSpeed(jumpSpeed),
|
||||
MouseYDirection(invertY ? -1.0f : 1.0f),
|
||||
LastAnimationTime(0), firstUpdate(true), NoVerticalMovement(noVerticalMovement)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CCameraSceneNodeAnimatorFPS");
|
||||
#endif
|
||||
|
||||
if (CursorControl)
|
||||
CursorControl->grab();
|
||||
|
||||
allKeysUp();
|
||||
|
||||
// create key map
|
||||
if (!keyMapArray || !keyMapSize)
|
||||
{
|
||||
// create default key map
|
||||
KeyMap.push_back(SCamKeyMap(EKA_MOVE_FORWARD, irr::KEY_UP));
|
||||
KeyMap.push_back(SCamKeyMap(EKA_MOVE_BACKWARD, irr::KEY_DOWN));
|
||||
KeyMap.push_back(SCamKeyMap(EKA_STRAFE_LEFT, irr::KEY_LEFT));
|
||||
KeyMap.push_back(SCamKeyMap(EKA_STRAFE_RIGHT, irr::KEY_RIGHT));
|
||||
KeyMap.push_back(SCamKeyMap(EKA_JUMP_UP, irr::KEY_KEY_J));
|
||||
}
|
||||
else
|
||||
{
|
||||
// create custom key map
|
||||
setKeyMap(keyMapArray, keyMapSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! destructor
|
||||
CSceneNodeAnimatorCameraFPS::~CSceneNodeAnimatorCameraFPS()
|
||||
{
|
||||
if (CursorControl)
|
||||
CursorControl->drop();
|
||||
}
|
||||
|
||||
|
||||
//! It is possible to send mouse and key events to the camera. Most cameras
|
||||
//! may ignore this input, but camera scene nodes which are created for
|
||||
//! example with scene::ISceneManager::addMayaCameraSceneNode or
|
||||
//! scene::ISceneManager::addFPSCameraSceneNode, may want to get this input
|
||||
//! for changing their position, look at target or whatever.
|
||||
bool CSceneNodeAnimatorCameraFPS::OnEvent(const SEvent& evt)
|
||||
{
|
||||
switch(evt.EventType)
|
||||
{
|
||||
case EET_KEY_INPUT_EVENT:
|
||||
for (u32 i=0; i<KeyMap.size(); ++i)
|
||||
{
|
||||
if (KeyMap[i].keycode == evt.KeyInput.Key)
|
||||
{
|
||||
CursorKeys[KeyMap[i].action] = evt.KeyInput.PressedDown;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EET_MOUSE_INPUT_EVENT:
|
||||
if (evt.MouseInput.Event == EMIE_MOUSE_MOVED)
|
||||
{
|
||||
CursorPos = CursorControl->getRelativePosition();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void CSceneNodeAnimatorCameraFPS::animateNode(ISceneNode* node, u32 timeMs)
|
||||
{
|
||||
if (!node || node->getType() != ESNT_CAMERA)
|
||||
return;
|
||||
|
||||
ICameraSceneNode* camera = static_cast<ICameraSceneNode*>(node);
|
||||
|
||||
if (firstUpdate)
|
||||
{
|
||||
camera->updateAbsolutePosition();
|
||||
if (CursorControl && camera)
|
||||
{
|
||||
CursorControl->setPosition(0.5f, 0.5f);
|
||||
CursorPos = CenterCursor = CursorControl->getRelativePosition();
|
||||
}
|
||||
|
||||
LastAnimationTime = timeMs;
|
||||
|
||||
firstUpdate = false;
|
||||
}
|
||||
|
||||
// If the camera isn't the active camera, and receiving input, then don't process it.
|
||||
if(!camera->isInputReceiverEnabled())
|
||||
return;
|
||||
|
||||
scene::ISceneManager * smgr = camera->getSceneManager();
|
||||
if(smgr && smgr->getActiveCamera() != camera)
|
||||
return;
|
||||
|
||||
// get time
|
||||
f32 timeDiff = (f32) ( timeMs - LastAnimationTime );
|
||||
LastAnimationTime = timeMs;
|
||||
|
||||
// update position
|
||||
core::vector3df pos = camera->getPosition();
|
||||
|
||||
// Update rotation
|
||||
core::vector3df target = (camera->getTarget() - camera->getAbsolutePosition());
|
||||
core::vector3df relativeRotation = target.getHorizontalAngle();
|
||||
|
||||
if (CursorControl)
|
||||
{
|
||||
if (CursorPos != CenterCursor)
|
||||
{
|
||||
relativeRotation.Y -= (0.5f - CursorPos.X) * RotateSpeed;
|
||||
relativeRotation.X -= (0.5f - CursorPos.Y) * RotateSpeed * MouseYDirection;
|
||||
|
||||
// X < MaxVerticalAngle or X > 360-MaxVerticalAngle
|
||||
|
||||
if (relativeRotation.X > MaxVerticalAngle*2 &&
|
||||
relativeRotation.X < 360.0f-MaxVerticalAngle)
|
||||
{
|
||||
relativeRotation.X = 360.0f-MaxVerticalAngle;
|
||||
}
|
||||
else
|
||||
if (relativeRotation.X > MaxVerticalAngle &&
|
||||
relativeRotation.X < 360.0f-MaxVerticalAngle)
|
||||
{
|
||||
relativeRotation.X = MaxVerticalAngle;
|
||||
}
|
||||
}
|
||||
|
||||
// reset cursor position to the centre of the window. Do this unconditionally
|
||||
// to cope with the case where the mouse has escaped our window in a single
|
||||
// tick, so we don't get messages for it.
|
||||
CursorControl->setPosition(0.5f, 0.5f);
|
||||
CenterCursor = CursorControl->getRelativePosition();
|
||||
// needed to avoid problems when the event receiver is disabled
|
||||
CursorPos = CenterCursor;
|
||||
}
|
||||
|
||||
// set target
|
||||
|
||||
target.set(0,0, core::max_(1.f, pos.getLength()));
|
||||
core::vector3df movedir = target;
|
||||
|
||||
core::matrix4 mat;
|
||||
mat.setRotationDegrees(core::vector3df(relativeRotation.X, relativeRotation.Y, 0));
|
||||
mat.transformVect(target);
|
||||
|
||||
if (NoVerticalMovement)
|
||||
{
|
||||
mat.setRotationDegrees(core::vector3df(0, relativeRotation.Y, 0));
|
||||
mat.transformVect(movedir);
|
||||
}
|
||||
else
|
||||
{
|
||||
movedir = target;
|
||||
}
|
||||
|
||||
movedir.normalize();
|
||||
|
||||
if (CursorKeys[EKA_MOVE_FORWARD])
|
||||
pos += movedir * timeDiff * MoveSpeed;
|
||||
|
||||
if (CursorKeys[EKA_MOVE_BACKWARD])
|
||||
pos -= movedir * timeDiff * MoveSpeed;
|
||||
|
||||
// strafing
|
||||
|
||||
core::vector3df strafevect = target;
|
||||
strafevect = strafevect.crossProduct(camera->getUpVector());
|
||||
|
||||
if (NoVerticalMovement)
|
||||
strafevect.Y = 0.0f;
|
||||
|
||||
strafevect.normalize();
|
||||
|
||||
if (CursorKeys[EKA_STRAFE_LEFT])
|
||||
pos += strafevect * timeDiff * MoveSpeed;
|
||||
|
||||
if (CursorKeys[EKA_STRAFE_RIGHT])
|
||||
pos -= strafevect * timeDiff * MoveSpeed;
|
||||
|
||||
// For jumping, we find the collision response animator attached to our camera
|
||||
// and if it's not falling, we tell it to jump.
|
||||
if (CursorKeys[EKA_JUMP_UP])
|
||||
{
|
||||
const core::list<ISceneNodeAnimator*> & animators = camera->getAnimators();
|
||||
core::list<ISceneNodeAnimator*>::ConstIterator it = animators.begin();
|
||||
while(it != animators.end())
|
||||
{
|
||||
if(ESNAT_COLLISION_RESPONSE == (*it)->getType())
|
||||
{
|
||||
ISceneNodeAnimatorCollisionResponse * collisionResponse =
|
||||
static_cast<ISceneNodeAnimatorCollisionResponse *>(*it);
|
||||
|
||||
if(!collisionResponse->isFalling())
|
||||
collisionResponse->jump(JumpSpeed);
|
||||
}
|
||||
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
// write translation
|
||||
camera->setPosition(pos);
|
||||
|
||||
// write right target
|
||||
target += pos;
|
||||
camera->setTarget(target);
|
||||
}
|
||||
|
||||
|
||||
void CSceneNodeAnimatorCameraFPS::allKeysUp()
|
||||
{
|
||||
for (u32 i=0; i<6; ++i)
|
||||
CursorKeys[i] = false;
|
||||
}
|
||||
|
||||
|
||||
//! Sets the rotation speed
|
||||
void CSceneNodeAnimatorCameraFPS::setRotateSpeed(f32 speed)
|
||||
{
|
||||
RotateSpeed = speed;
|
||||
}
|
||||
|
||||
|
||||
//! Sets the movement speed
|
||||
void CSceneNodeAnimatorCameraFPS::setMoveSpeed(f32 speed)
|
||||
{
|
||||
MoveSpeed = speed;
|
||||
}
|
||||
|
||||
|
||||
//! Gets the rotation speed
|
||||
f32 CSceneNodeAnimatorCameraFPS::getRotateSpeed() const
|
||||
{
|
||||
return RotateSpeed;
|
||||
}
|
||||
|
||||
|
||||
// Gets the movement speed
|
||||
f32 CSceneNodeAnimatorCameraFPS::getMoveSpeed() const
|
||||
{
|
||||
return MoveSpeed;
|
||||
}
|
||||
|
||||
|
||||
//! Sets the keyboard mapping for this animator
|
||||
void CSceneNodeAnimatorCameraFPS::setKeyMap(SKeyMap *map, u32 count)
|
||||
{
|
||||
// clear the keymap
|
||||
KeyMap.clear();
|
||||
|
||||
// add actions
|
||||
for (u32 i=0; i<count; ++i)
|
||||
{
|
||||
switch(map[i].Action)
|
||||
{
|
||||
case EKA_MOVE_FORWARD: KeyMap.push_back(SCamKeyMap(EKA_MOVE_FORWARD, map[i].KeyCode));
|
||||
break;
|
||||
case EKA_MOVE_BACKWARD: KeyMap.push_back(SCamKeyMap(EKA_MOVE_BACKWARD, map[i].KeyCode));
|
||||
break;
|
||||
case EKA_STRAFE_LEFT: KeyMap.push_back(SCamKeyMap(EKA_STRAFE_LEFT, map[i].KeyCode));
|
||||
break;
|
||||
case EKA_STRAFE_RIGHT: KeyMap.push_back(SCamKeyMap(EKA_STRAFE_RIGHT, map[i].KeyCode));
|
||||
break;
|
||||
case EKA_JUMP_UP: KeyMap.push_back(SCamKeyMap(EKA_JUMP_UP, map[i].KeyCode));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Sets whether vertical movement should be allowed.
|
||||
void CSceneNodeAnimatorCameraFPS::setVerticalMovement(bool allow)
|
||||
{
|
||||
NoVerticalMovement = !allow;
|
||||
}
|
||||
|
||||
|
||||
//! Sets whether the Y axis of the mouse should be inverted.
|
||||
void CSceneNodeAnimatorCameraFPS::setInvertMouse(bool invert)
|
||||
{
|
||||
if (invert)
|
||||
MouseYDirection = -1.0f;
|
||||
else
|
||||
MouseYDirection = 1.0f;
|
||||
}
|
||||
|
||||
|
||||
ISceneNodeAnimator* CSceneNodeAnimatorCameraFPS::createClone(ISceneNode* node, ISceneManager* newManager)
|
||||
{
|
||||
CSceneNodeAnimatorCameraFPS * newAnimator =
|
||||
new CSceneNodeAnimatorCameraFPS(CursorControl, RotateSpeed, MoveSpeed, JumpSpeed,
|
||||
0, 0, NoVerticalMovement);
|
||||
newAnimator->setKeyMap(KeyMap);
|
||||
return newAnimator;
|
||||
}
|
||||
|
||||
|
||||
void CSceneNodeAnimatorCameraFPS::setKeyMap(const core::array<SCamKeyMap>& keymap)
|
||||
{
|
||||
KeyMap=keymap;
|
||||
}
|
||||
|
||||
|
||||
} // namespace scene
|
||||
} // namespace irr
|
||||
|
||||
|
|
|
@ -1,128 +1,128 @@
|
|||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __C_SCENE_NODE_ANIMATOR_CAMERA_FPS_H_INCLUDED__
|
||||
#define __C_SCENE_NODE_ANIMATOR_CAMERA_FPS_H_INCLUDED__
|
||||
|
||||
#include "ISceneNodeAnimatorCameraFPS.h"
|
||||
#include "vector2d.h"
|
||||
#include "SKeyMap.h"
|
||||
#include "irrArray.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace gui
|
||||
{
|
||||
class ICursorControl;
|
||||
}
|
||||
|
||||
namespace scene
|
||||
{
|
||||
|
||||
//! Special scene node animator for FPS cameras
|
||||
class CSceneNodeAnimatorCameraFPS : public ISceneNodeAnimatorCameraFPS
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cursorControl,
|
||||
f32 rotateSpeed = 100.0f, f32 moveSpeed = .5f, f32 jumpSpeed=0.f,
|
||||
SKeyMap* keyMapArray=0, u32 keyMapSize=0, bool noVerticalMovement=false,
|
||||
bool invertY=false);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CSceneNodeAnimatorCameraFPS();
|
||||
|
||||
//! Animates the scene node, currently only works on cameras
|
||||
virtual void animateNode(ISceneNode* node, u32 timeMs);
|
||||
|
||||
//! Event receiver
|
||||
virtual bool OnEvent(const SEvent& event);
|
||||
|
||||
//! Returns the speed of movement in units per second
|
||||
virtual f32 getMoveSpeed() const;
|
||||
|
||||
//! Sets the speed of movement in units per second
|
||||
virtual void setMoveSpeed(f32 moveSpeed);
|
||||
|
||||
//! Returns the rotation speed
|
||||
virtual f32 getRotateSpeed() const;
|
||||
|
||||
//! Set the rotation speed
|
||||
virtual void setRotateSpeed(f32 rotateSpeed);
|
||||
|
||||
//! Sets the keyboard mapping for this animator
|
||||
//! \param keymap: an array of keyboard mappings, see SKeyMap
|
||||
//! \param count: the size of the keyboard map array
|
||||
virtual void setKeyMap(SKeyMap *map, u32 count);
|
||||
|
||||
//! Sets whether vertical movement should be allowed.
|
||||
virtual void setVerticalMovement(bool allow);
|
||||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __C_SCENE_NODE_ANIMATOR_CAMERA_FPS_H_INCLUDED__
|
||||
#define __C_SCENE_NODE_ANIMATOR_CAMERA_FPS_H_INCLUDED__
|
||||
|
||||
#include "ISceneNodeAnimatorCameraFPS.h"
|
||||
#include "vector2d.h"
|
||||
#include "SKeyMap.h"
|
||||
#include "irrArray.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace gui
|
||||
{
|
||||
class ICursorControl;
|
||||
}
|
||||
|
||||
namespace scene
|
||||
{
|
||||
|
||||
//! Special scene node animator for FPS cameras
|
||||
class CSceneNodeAnimatorCameraFPS : public ISceneNodeAnimatorCameraFPS
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cursorControl,
|
||||
f32 rotateSpeed = 100.0f, f32 moveSpeed = .5f, f32 jumpSpeed=0.f,
|
||||
SKeyMap* keyMapArray=0, u32 keyMapSize=0, bool noVerticalMovement=false,
|
||||
bool invertY=false);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CSceneNodeAnimatorCameraFPS();
|
||||
|
||||
//! Animates the scene node, currently only works on cameras
|
||||
virtual void animateNode(ISceneNode* node, u32 timeMs);
|
||||
|
||||
//! Event receiver
|
||||
virtual bool OnEvent(const SEvent& event);
|
||||
|
||||
//! Returns the speed of movement in units per second
|
||||
virtual f32 getMoveSpeed() const;
|
||||
|
||||
//! Sets the speed of movement in units per second
|
||||
virtual void setMoveSpeed(f32 moveSpeed);
|
||||
|
||||
//! Returns the rotation speed
|
||||
virtual f32 getRotateSpeed() const;
|
||||
|
||||
//! Set the rotation speed
|
||||
virtual void setRotateSpeed(f32 rotateSpeed);
|
||||
|
||||
//! Sets the keyboard mapping for this animator
|
||||
//! \param keymap: an array of keyboard mappings, see SKeyMap
|
||||
//! \param count: the size of the keyboard map array
|
||||
virtual void setKeyMap(SKeyMap *map, u32 count);
|
||||
|
||||
//! Sets whether vertical movement should be allowed.
|
||||
virtual void setVerticalMovement(bool allow);
|
||||
|
||||
//! Sets whether the Y axis of the mouse should be inverted.
|
||||
/** If enabled then moving the mouse down will cause
|
||||
the camera to look up. It is disabled by default. */
|
||||
virtual void setInvertMouse(bool invert);
|
||||
|
||||
//! This animator will receive events when attached to the active camera
|
||||
virtual bool isEventReceiverEnabled() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Returns the type of this animator
|
||||
virtual ESCENE_NODE_ANIMATOR_TYPE getType() const
|
||||
{
|
||||
return ESNAT_CAMERA_FPS;
|
||||
}
|
||||
|
||||
//! Creates a clone of this animator.
|
||||
/** Please note that you will have to drop
|
||||
(IReferenceCounted::drop()) the returned pointer once you're
|
||||
done with it. */
|
||||
virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0);
|
||||
|
||||
struct SCamKeyMap
|
||||
{
|
||||
SCamKeyMap() {};
|
||||
SCamKeyMap(s32 a, EKEY_CODE k) : action(a), keycode(k) {}
|
||||
|
||||
s32 action;
|
||||
EKEY_CODE keycode;
|
||||
};
|
||||
|
||||
//! Sets the keyboard mapping for this animator
|
||||
/** Helper function for the clone method.
|
||||
\param keymap the new keymap array */
|
||||
void setKeyMap(const core::array<SCamKeyMap>& keymap);
|
||||
|
||||
private:
|
||||
void allKeysUp();
|
||||
|
||||
gui::ICursorControl *CursorControl;
|
||||
|
||||
f32 MaxVerticalAngle;
|
||||
|
||||
f32 MoveSpeed;
|
||||
f32 RotateSpeed;
|
||||
f32 JumpSpeed;
|
||||
// -1.0f for inverted mouse, defaults to 1.0f
|
||||
f32 MouseYDirection;
|
||||
|
||||
s32 LastAnimationTime;
|
||||
|
||||
core::array<SCamKeyMap> KeyMap;
|
||||
core::position2d<f32> CenterCursor, CursorPos;
|
||||
|
||||
bool CursorKeys[6];
|
||||
|
||||
bool firstUpdate;
|
||||
bool NoVerticalMovement;
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif // __C_SCENE_NODE_ANIMATOR_CAMERA_FPS_H_INCLUDED__
|
||||
|
||||
virtual void setInvertMouse(bool invert);
|
||||
|
||||
//! This animator will receive events when attached to the active camera
|
||||
virtual bool isEventReceiverEnabled() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Returns the type of this animator
|
||||
virtual ESCENE_NODE_ANIMATOR_TYPE getType() const
|
||||
{
|
||||
return ESNAT_CAMERA_FPS;
|
||||
}
|
||||
|
||||
//! Creates a clone of this animator.
|
||||
/** Please note that you will have to drop
|
||||
(IReferenceCounted::drop()) the returned pointer once you're
|
||||
done with it. */
|
||||
virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0);
|
||||
|
||||
struct SCamKeyMap
|
||||
{
|
||||
SCamKeyMap() {};
|
||||
SCamKeyMap(s32 a, EKEY_CODE k) : action(a), keycode(k) {}
|
||||
|
||||
s32 action;
|
||||
EKEY_CODE keycode;
|
||||
};
|
||||
|
||||
//! Sets the keyboard mapping for this animator
|
||||
/** Helper function for the clone method.
|
||||
\param keymap the new keymap array */
|
||||
void setKeyMap(const core::array<SCamKeyMap>& keymap);
|
||||
|
||||
private:
|
||||
void allKeysUp();
|
||||
|
||||
gui::ICursorControl *CursorControl;
|
||||
|
||||
f32 MaxVerticalAngle;
|
||||
|
||||
f32 MoveSpeed;
|
||||
f32 RotateSpeed;
|
||||
f32 JumpSpeed;
|
||||
// -1.0f for inverted mouse, defaults to 1.0f
|
||||
f32 MouseYDirection;
|
||||
|
||||
s32 LastAnimationTime;
|
||||
|
||||
core::array<SCamKeyMap> KeyMap;
|
||||
core::position2d<f32> CenterCursor, CursorPos;
|
||||
|
||||
bool CursorKeys[6];
|
||||
|
||||
bool firstUpdate;
|
||||
bool NoVerticalMovement;
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif // __C_SCENE_NODE_ANIMATOR_CAMERA_FPS_H_INCLUDED__
|
||||
|
||||
|
|
|
@ -1,294 +1,294 @@
|
|||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "CSceneNodeAnimatorCameraMaya.h"
|
||||
#include "ICursorControl.h"
|
||||
#include "ICameraSceneNode.h"
|
||||
#include "SViewFrustum.h"
|
||||
#include "ISceneManager.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
//! constructor
|
||||
CSceneNodeAnimatorCameraMaya::CSceneNodeAnimatorCameraMaya(gui::ICursorControl* cursor, f32 rotate, f32 zoom, f32 translate)
|
||||
: CursorControl(cursor), Zooming(false), Rotating(false), Moving(false),
|
||||
Translating(false), ZoomSpeed(zoom), RotateSpeed(rotate), TranslateSpeed(translate),
|
||||
CurrentZoom(70.0f), RotX(0.0f), RotY(0.0f), OldCamera(0), MousePos(0.5f, 0.5f)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CSceneNodeAnimatorCameraMaya");
|
||||
#endif
|
||||
|
||||
if (CursorControl)
|
||||
{
|
||||
CursorControl->grab();
|
||||
MousePos = CursorControl->getRelativePosition();
|
||||
}
|
||||
|
||||
allKeysUp();
|
||||
}
|
||||
|
||||
|
||||
//! destructor
|
||||
CSceneNodeAnimatorCameraMaya::~CSceneNodeAnimatorCameraMaya()
|
||||
{
|
||||
if (CursorControl)
|
||||
CursorControl->drop();
|
||||
}
|
||||
|
||||
|
||||
//! It is possible to send mouse and key events to the camera. Most cameras
|
||||
//! may ignore this input, but camera scene nodes which are created for
|
||||
//! example with scene::ISceneManager::addMayaCameraSceneNode or
|
||||
//! scene::ISceneManager::addMeshViewerCameraSceneNode, may want to get this input
|
||||
//! for changing their position, look at target or whatever.
|
||||
bool CSceneNodeAnimatorCameraMaya::OnEvent(const SEvent& event)
|
||||
{
|
||||
if (event.EventType != EET_MOUSE_INPUT_EVENT)
|
||||
return false;
|
||||
|
||||
switch(event.MouseInput.Event)
|
||||
{
|
||||
case EMIE_LMOUSE_PRESSED_DOWN:
|
||||
MouseKeys[0] = true;
|
||||
break;
|
||||
case EMIE_RMOUSE_PRESSED_DOWN:
|
||||
MouseKeys[2] = true;
|
||||
break;
|
||||
case EMIE_MMOUSE_PRESSED_DOWN:
|
||||
MouseKeys[1] = true;
|
||||
break;
|
||||
case EMIE_LMOUSE_LEFT_UP:
|
||||
MouseKeys[0] = false;
|
||||
break;
|
||||
case EMIE_RMOUSE_LEFT_UP:
|
||||
MouseKeys[2] = false;
|
||||
break;
|
||||
case EMIE_MMOUSE_LEFT_UP:
|
||||
MouseKeys[1] = false;
|
||||
break;
|
||||
case EMIE_MOUSE_MOVED:
|
||||
MousePos = CursorControl->getRelativePosition();
|
||||
break;
|
||||
case EMIE_MOUSE_WHEEL:
|
||||
case EMIE_COUNT:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//! OnAnimate() is called just before rendering the whole scene.
|
||||
//! nodes may calculate or store animations here, and may do other useful things,
|
||||
//! dependent on what they are.
|
||||
void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs)
|
||||
{
|
||||
//Alt + LM = Rotate around camera pivot
|
||||
//Alt + LM + MM = Dolly forth/back in view direction (speed % distance camera pivot - max distance to pivot)
|
||||
//Alt + MM = Move on camera plane (Screen center is about the mouse pointer, depending on move speed)
|
||||
|
||||
if (!node || node->getType() != ESNT_CAMERA)
|
||||
return;
|
||||
|
||||
ICameraSceneNode* camera = static_cast<ICameraSceneNode*>(node);
|
||||
|
||||
// If the camera isn't the active camera, and receiving input, then don't process it.
|
||||
if(!camera->isInputReceiverEnabled())
|
||||
return;
|
||||
|
||||
scene::ISceneManager * smgr = camera->getSceneManager();
|
||||
if(smgr && smgr->getActiveCamera() != camera)
|
||||
return;
|
||||
|
||||
if (OldCamera != camera)
|
||||
{
|
||||
OldTarget = camera->getTarget();
|
||||
OldCamera = camera;
|
||||
}
|
||||
|
||||
core::vector3df target = camera->getTarget();
|
||||
|
||||
f32 nRotX = RotX;
|
||||
f32 nRotY = RotY;
|
||||
f32 nZoom = CurrentZoom;
|
||||
|
||||
if ( (isMouseKeyDown(0) && isMouseKeyDown(2)) || isMouseKeyDown(1) )
|
||||
{
|
||||
if (!Zooming)
|
||||
{
|
||||
ZoomStart = MousePos;
|
||||
Zooming = true;
|
||||
nZoom = CurrentZoom;
|
||||
}
|
||||
else
|
||||
{
|
||||
const f32 targetMinDistance = 0.1f;
|
||||
nZoom += (ZoomStart.X - MousePos.X) * ZoomSpeed;
|
||||
|
||||
if (nZoom < targetMinDistance) // jox: fixed bug: bounce back when zooming to close
|
||||
nZoom = targetMinDistance;
|
||||
}
|
||||
}
|
||||
else if (Zooming)
|
||||
{
|
||||
const f32 old = CurrentZoom;
|
||||
CurrentZoom = CurrentZoom + (ZoomStart.X - MousePos.X ) * ZoomSpeed;
|
||||
nZoom = CurrentZoom;
|
||||
|
||||
if (nZoom < 0)
|
||||
nZoom = CurrentZoom = old;
|
||||
Zooming = false;
|
||||
}
|
||||
|
||||
// Translation ---------------------------------
|
||||
|
||||
core::vector3df translate(OldTarget), upVector(camera->getUpVector());
|
||||
|
||||
core::vector3df tvectX = Pos - target;
|
||||
tvectX = tvectX.crossProduct(upVector);
|
||||
tvectX.normalize();
|
||||
|
||||
const SViewFrustum* const va = camera->getViewFrustum();
|
||||
core::vector3df tvectY = (va->getFarLeftDown() - va->getFarRightDown());
|
||||
tvectY = tvectY.crossProduct(upVector.Y > 0 ? Pos - target : target - Pos);
|
||||
tvectY.normalize();
|
||||
|
||||
if (isMouseKeyDown(2) && !Zooming)
|
||||
{
|
||||
if (!Translating)
|
||||
{
|
||||
TranslateStart = MousePos;
|
||||
Translating = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
translate += tvectX * (TranslateStart.X - MousePos.X)*TranslateSpeed +
|
||||
tvectY * (TranslateStart.Y - MousePos.Y)*TranslateSpeed;
|
||||
}
|
||||
}
|
||||
else if (Translating)
|
||||
{
|
||||
translate += tvectX * (TranslateStart.X - MousePos.X)*TranslateSpeed +
|
||||
tvectY * (TranslateStart.Y - MousePos.Y)*TranslateSpeed;
|
||||
OldTarget = translate;
|
||||
Translating = false;
|
||||
}
|
||||
|
||||
// Rotation ------------------------------------
|
||||
|
||||
if (isMouseKeyDown(0) && !Zooming)
|
||||
{
|
||||
if (!Rotating)
|
||||
{
|
||||
RotateStart = MousePos;
|
||||
Rotating = true;
|
||||
nRotX = RotX;
|
||||
nRotY = RotY;
|
||||
}
|
||||
else
|
||||
{
|
||||
nRotX += (RotateStart.X - MousePos.X) * RotateSpeed;
|
||||
nRotY += (RotateStart.Y - MousePos.Y) * RotateSpeed;
|
||||
}
|
||||
}
|
||||
else if (Rotating)
|
||||
{
|
||||
RotX += (RotateStart.X - MousePos.X) * RotateSpeed;
|
||||
RotY += (RotateStart.Y - MousePos.Y) * RotateSpeed;
|
||||
nRotX = RotX;
|
||||
nRotY = RotY;
|
||||
Rotating = false;
|
||||
}
|
||||
|
||||
// Set Pos ------------------------------------
|
||||
|
||||
target = translate;
|
||||
|
||||
Pos.X = nZoom + target.X;
|
||||
Pos.Y = target.Y;
|
||||
Pos.Z = target.Z;
|
||||
|
||||
Pos.rotateXYBy(nRotY, target);
|
||||
Pos.rotateXZBy(-nRotX, target);
|
||||
|
||||
// Rotation Error ----------------------------
|
||||
|
||||
// jox: fixed bug: jitter when rotating to the top and bottom of y
|
||||
upVector.set(0,1,0);
|
||||
upVector.rotateXYBy(-nRotY);
|
||||
upVector.rotateXZBy(-nRotX+180.f);
|
||||
|
||||
camera->setPosition(Pos);
|
||||
camera->setTarget(target);
|
||||
camera->setUpVector(upVector);
|
||||
}
|
||||
|
||||
|
||||
bool CSceneNodeAnimatorCameraMaya::isMouseKeyDown(s32 key)
|
||||
{
|
||||
return MouseKeys[key];
|
||||
}
|
||||
|
||||
|
||||
void CSceneNodeAnimatorCameraMaya::allKeysUp()
|
||||
{
|
||||
for (s32 i=0; i<3; ++i)
|
||||
MouseKeys[i] = false;
|
||||
}
|
||||
|
||||
|
||||
//! Sets the rotation speed
|
||||
void CSceneNodeAnimatorCameraMaya::setRotateSpeed(f32 speed)
|
||||
{
|
||||
RotateSpeed = speed;
|
||||
}
|
||||
|
||||
|
||||
//! Sets the movement speed
|
||||
void CSceneNodeAnimatorCameraMaya::setMoveSpeed(f32 speed)
|
||||
{
|
||||
TranslateSpeed = speed;
|
||||
}
|
||||
|
||||
|
||||
//! Sets the zoom speed
|
||||
void CSceneNodeAnimatorCameraMaya::setZoomSpeed(f32 speed)
|
||||
{
|
||||
ZoomSpeed = speed;
|
||||
}
|
||||
|
||||
|
||||
//! Gets the rotation speed
|
||||
f32 CSceneNodeAnimatorCameraMaya::getRotateSpeed() const
|
||||
{
|
||||
return RotateSpeed;
|
||||
}
|
||||
|
||||
|
||||
// Gets the movement speed
|
||||
f32 CSceneNodeAnimatorCameraMaya::getMoveSpeed() const
|
||||
{
|
||||
return TranslateSpeed;
|
||||
}
|
||||
|
||||
|
||||
//! Gets the zoom speed
|
||||
f32 CSceneNodeAnimatorCameraMaya::getZoomSpeed() const
|
||||
{
|
||||
return ZoomSpeed;
|
||||
}
|
||||
|
||||
ISceneNodeAnimator* CSceneNodeAnimatorCameraMaya::createClone(ISceneNode* node, ISceneManager* newManager)
|
||||
{
|
||||
CSceneNodeAnimatorCameraMaya * newAnimator =
|
||||
new CSceneNodeAnimatorCameraMaya(CursorControl, RotateSpeed, ZoomSpeed, TranslateSpeed);
|
||||
return newAnimator;
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
} // end namespace
|
||||
|
||||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "CSceneNodeAnimatorCameraMaya.h"
|
||||
#include "ICursorControl.h"
|
||||
#include "ICameraSceneNode.h"
|
||||
#include "SViewFrustum.h"
|
||||
#include "ISceneManager.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
//! constructor
|
||||
CSceneNodeAnimatorCameraMaya::CSceneNodeAnimatorCameraMaya(gui::ICursorControl* cursor, f32 rotate, f32 zoom, f32 translate)
|
||||
: CursorControl(cursor), Zooming(false), Rotating(false), Moving(false),
|
||||
Translating(false), ZoomSpeed(zoom), RotateSpeed(rotate), TranslateSpeed(translate),
|
||||
CurrentZoom(70.0f), RotX(0.0f), RotY(0.0f), OldCamera(0), MousePos(0.5f, 0.5f)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CSceneNodeAnimatorCameraMaya");
|
||||
#endif
|
||||
|
||||
if (CursorControl)
|
||||
{
|
||||
CursorControl->grab();
|
||||
MousePos = CursorControl->getRelativePosition();
|
||||
}
|
||||
|
||||
allKeysUp();
|
||||
}
|
||||
|
||||
|
||||
//! destructor
|
||||
CSceneNodeAnimatorCameraMaya::~CSceneNodeAnimatorCameraMaya()
|
||||
{
|
||||
if (CursorControl)
|
||||
CursorControl->drop();
|
||||
}
|
||||
|
||||
|
||||
//! It is possible to send mouse and key events to the camera. Most cameras
|
||||
//! may ignore this input, but camera scene nodes which are created for
|
||||
//! example with scene::ISceneManager::addMayaCameraSceneNode or
|
||||
//! scene::ISceneManager::addMeshViewerCameraSceneNode, may want to get this input
|
||||
//! for changing their position, look at target or whatever.
|
||||
bool CSceneNodeAnimatorCameraMaya::OnEvent(const SEvent& event)
|
||||
{
|
||||
if (event.EventType != EET_MOUSE_INPUT_EVENT)
|
||||
return false;
|
||||
|
||||
switch(event.MouseInput.Event)
|
||||
{
|
||||
case EMIE_LMOUSE_PRESSED_DOWN:
|
||||
MouseKeys[0] = true;
|
||||
break;
|
||||
case EMIE_RMOUSE_PRESSED_DOWN:
|
||||
MouseKeys[2] = true;
|
||||
break;
|
||||
case EMIE_MMOUSE_PRESSED_DOWN:
|
||||
MouseKeys[1] = true;
|
||||
break;
|
||||
case EMIE_LMOUSE_LEFT_UP:
|
||||
MouseKeys[0] = false;
|
||||
break;
|
||||
case EMIE_RMOUSE_LEFT_UP:
|
||||
MouseKeys[2] = false;
|
||||
break;
|
||||
case EMIE_MMOUSE_LEFT_UP:
|
||||
MouseKeys[1] = false;
|
||||
break;
|
||||
case EMIE_MOUSE_MOVED:
|
||||
MousePos = CursorControl->getRelativePosition();
|
||||
break;
|
||||
case EMIE_MOUSE_WHEEL:
|
||||
case EMIE_COUNT:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//! OnAnimate() is called just before rendering the whole scene.
|
||||
//! nodes may calculate or store animations here, and may do other useful things,
|
||||
//! dependent on what they are.
|
||||
void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs)
|
||||
{
|
||||
//Alt + LM = Rotate around camera pivot
|
||||
//Alt + LM + MM = Dolly forth/back in view direction (speed % distance camera pivot - max distance to pivot)
|
||||
//Alt + MM = Move on camera plane (Screen center is about the mouse pointer, depending on move speed)
|
||||
|
||||
if (!node || node->getType() != ESNT_CAMERA)
|
||||
return;
|
||||
|
||||
ICameraSceneNode* camera = static_cast<ICameraSceneNode*>(node);
|
||||
|
||||
// If the camera isn't the active camera, and receiving input, then don't process it.
|
||||
if(!camera->isInputReceiverEnabled())
|
||||
return;
|
||||
|
||||
scene::ISceneManager * smgr = camera->getSceneManager();
|
||||
if(smgr && smgr->getActiveCamera() != camera)
|
||||
return;
|
||||
|
||||
if (OldCamera != camera)
|
||||
{
|
||||
OldTarget = camera->getTarget();
|
||||
OldCamera = camera;
|
||||
}
|
||||
|
||||
core::vector3df target = camera->getTarget();
|
||||
|
||||
f32 nRotX = RotX;
|
||||
f32 nRotY = RotY;
|
||||
f32 nZoom = CurrentZoom;
|
||||
|
||||
if ( (isMouseKeyDown(0) && isMouseKeyDown(2)) || isMouseKeyDown(1) )
|
||||
{
|
||||
if (!Zooming)
|
||||
{
|
||||
ZoomStart = MousePos;
|
||||
Zooming = true;
|
||||
nZoom = CurrentZoom;
|
||||
}
|
||||
else
|
||||
{
|
||||
const f32 targetMinDistance = 0.1f;
|
||||
nZoom += (ZoomStart.X - MousePos.X) * ZoomSpeed;
|
||||
|
||||
if (nZoom < targetMinDistance) // jox: fixed bug: bounce back when zooming to close
|
||||
nZoom = targetMinDistance;
|
||||
}
|
||||
}
|
||||
else if (Zooming)
|
||||
{
|
||||
const f32 old = CurrentZoom;
|
||||
CurrentZoom = CurrentZoom + (ZoomStart.X - MousePos.X ) * ZoomSpeed;
|
||||
nZoom = CurrentZoom;
|
||||
|
||||
if (nZoom < 0)
|
||||
nZoom = CurrentZoom = old;
|
||||
Zooming = false;
|
||||
}
|
||||
|
||||
// Translation ---------------------------------
|
||||
|
||||
core::vector3df translate(OldTarget), upVector(camera->getUpVector());
|
||||
|
||||
core::vector3df tvectX = Pos - target;
|
||||
tvectX = tvectX.crossProduct(upVector);
|
||||
tvectX.normalize();
|
||||
|
||||
const SViewFrustum* const va = camera->getViewFrustum();
|
||||
core::vector3df tvectY = (va->getFarLeftDown() - va->getFarRightDown());
|
||||
tvectY = tvectY.crossProduct(upVector.Y > 0 ? Pos - target : target - Pos);
|
||||
tvectY.normalize();
|
||||
|
||||
if (isMouseKeyDown(2) && !Zooming)
|
||||
{
|
||||
if (!Translating)
|
||||
{
|
||||
TranslateStart = MousePos;
|
||||
Translating = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
translate += tvectX * (TranslateStart.X - MousePos.X)*TranslateSpeed +
|
||||
tvectY * (TranslateStart.Y - MousePos.Y)*TranslateSpeed;
|
||||
}
|
||||
}
|
||||
else if (Translating)
|
||||
{
|
||||
translate += tvectX * (TranslateStart.X - MousePos.X)*TranslateSpeed +
|
||||
tvectY * (TranslateStart.Y - MousePos.Y)*TranslateSpeed;
|
||||
OldTarget = translate;
|
||||
Translating = false;
|
||||
}
|
||||
|
||||
// Rotation ------------------------------------
|
||||
|
||||
if (isMouseKeyDown(0) && !Zooming)
|
||||
{
|
||||
if (!Rotating)
|
||||
{
|
||||
RotateStart = MousePos;
|
||||
Rotating = true;
|
||||
nRotX = RotX;
|
||||
nRotY = RotY;
|
||||
}
|
||||
else
|
||||
{
|
||||
nRotX += (RotateStart.X - MousePos.X) * RotateSpeed;
|
||||
nRotY += (RotateStart.Y - MousePos.Y) * RotateSpeed;
|
||||
}
|
||||
}
|
||||
else if (Rotating)
|
||||
{
|
||||
RotX += (RotateStart.X - MousePos.X) * RotateSpeed;
|
||||
RotY += (RotateStart.Y - MousePos.Y) * RotateSpeed;
|
||||
nRotX = RotX;
|
||||
nRotY = RotY;
|
||||
Rotating = false;
|
||||
}
|
||||
|
||||
// Set Pos ------------------------------------
|
||||
|
||||
target = translate;
|
||||
|
||||
Pos.X = nZoom + target.X;
|
||||
Pos.Y = target.Y;
|
||||
Pos.Z = target.Z;
|
||||
|
||||
Pos.rotateXYBy(nRotY, target);
|
||||
Pos.rotateXZBy(-nRotX, target);
|
||||
|
||||
// Rotation Error ----------------------------
|
||||
|
||||
// jox: fixed bug: jitter when rotating to the top and bottom of y
|
||||
upVector.set(0,1,0);
|
||||
upVector.rotateXYBy(-nRotY);
|
||||
upVector.rotateXZBy(-nRotX+180.f);
|
||||
|
||||
camera->setPosition(Pos);
|
||||
camera->setTarget(target);
|
||||
camera->setUpVector(upVector);
|
||||
}
|
||||
|
||||
|
||||
bool CSceneNodeAnimatorCameraMaya::isMouseKeyDown(s32 key)
|
||||
{
|
||||
return MouseKeys[key];
|
||||
}
|
||||
|
||||
|
||||
void CSceneNodeAnimatorCameraMaya::allKeysUp()
|
||||
{
|
||||
for (s32 i=0; i<3; ++i)
|
||||
MouseKeys[i] = false;
|
||||
}
|
||||
|
||||
|
||||
//! Sets the rotation speed
|
||||
void CSceneNodeAnimatorCameraMaya::setRotateSpeed(f32 speed)
|
||||
{
|
||||
RotateSpeed = speed;
|
||||
}
|
||||
|
||||
|
||||
//! Sets the movement speed
|
||||
void CSceneNodeAnimatorCameraMaya::setMoveSpeed(f32 speed)
|
||||
{
|
||||
TranslateSpeed = speed;
|
||||
}
|
||||
|
||||
|
||||
//! Sets the zoom speed
|
||||
void CSceneNodeAnimatorCameraMaya::setZoomSpeed(f32 speed)
|
||||
{
|
||||
ZoomSpeed = speed;
|
||||
}
|
||||
|
||||
|
||||
//! Gets the rotation speed
|
||||
f32 CSceneNodeAnimatorCameraMaya::getRotateSpeed() const
|
||||
{
|
||||
return RotateSpeed;
|
||||
}
|
||||
|
||||
|
||||
// Gets the movement speed
|
||||
f32 CSceneNodeAnimatorCameraMaya::getMoveSpeed() const
|
||||
{
|
||||
return TranslateSpeed;
|
||||
}
|
||||
|
||||
|
||||
//! Gets the zoom speed
|
||||
f32 CSceneNodeAnimatorCameraMaya::getZoomSpeed() const
|
||||
{
|
||||
return ZoomSpeed;
|
||||
}
|
||||
|
||||
ISceneNodeAnimator* CSceneNodeAnimatorCameraMaya::createClone(ISceneNode* node, ISceneManager* newManager)
|
||||
{
|
||||
CSceneNodeAnimatorCameraMaya * newAnimator =
|
||||
new CSceneNodeAnimatorCameraMaya(CursorControl, RotateSpeed, ZoomSpeed, TranslateSpeed);
|
||||
return newAnimator;
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
} // end namespace
|
||||
|
||||
|
|
|
@ -1,49 +1,49 @@
|
|||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __C_SCENE_NODE_ANIMATOR_DELETE_H_INCLUDED__
|
||||
#define __C_SCENE_NODE_ANIMATOR_DELETE_H_INCLUDED__
|
||||
|
||||
#include "ISceneNodeAnimatorFinishing.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
class CSceneNodeAnimatorDelete : public ISceneNodeAnimatorFinishing
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
CSceneNodeAnimatorDelete(ISceneManager* manager, u32 when);
|
||||
|
||||
//! destructor
|
||||
virtual ~CSceneNodeAnimatorDelete();
|
||||
|
||||
//! animates a scene node
|
||||
virtual void animateNode(ISceneNode* node, u32 timeMs);
|
||||
|
||||
//! Returns type of the scene node animator
|
||||
virtual ESCENE_NODE_ANIMATOR_TYPE getType() const
|
||||
{
|
||||
return ESNAT_DELETION;
|
||||
}
|
||||
|
||||
//! Creates a clone of this animator.
|
||||
/** Please note that you will have to drop
|
||||
(IReferenceCounted::drop()) the returned pointer after calling
|
||||
this. */
|
||||
virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0);
|
||||
|
||||
private:
|
||||
|
||||
ISceneManager* SceneManager;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __C_SCENE_NODE_ANIMATOR_DELETE_H_INCLUDED__
|
||||
#define __C_SCENE_NODE_ANIMATOR_DELETE_H_INCLUDED__
|
||||
|
||||
#include "ISceneNodeAnimatorFinishing.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
class CSceneNodeAnimatorDelete : public ISceneNodeAnimatorFinishing
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
CSceneNodeAnimatorDelete(ISceneManager* manager, u32 when);
|
||||
|
||||
//! destructor
|
||||
virtual ~CSceneNodeAnimatorDelete();
|
||||
|
||||
//! animates a scene node
|
||||
virtual void animateNode(ISceneNode* node, u32 timeMs);
|
||||
|
||||
//! Returns type of the scene node animator
|
||||
virtual ESCENE_NODE_ANIMATOR_TYPE getType() const
|
||||
{
|
||||
return ESNAT_DELETION;
|
||||
}
|
||||
|
||||
//! Creates a clone of this animator.
|
||||
/** Please note that you will have to drop
|
||||
(IReferenceCounted::drop()) the returned pointer after calling
|
||||
this. */
|
||||
virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0);
|
||||
|
||||
private:
|
||||
|
||||
ISceneManager* SceneManager;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,134 +1,134 @@
|
|||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "CSceneNodeAnimatorFollowSpline.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
//! constructor
|
||||
CSceneNodeAnimatorFollowSpline::CSceneNodeAnimatorFollowSpline(u32 time,
|
||||
const core::array<core::vector3df>& points, f32 speed,
|
||||
f32 tightness)
|
||||
: Points(points), Speed(speed), Tightness(tightness), StartTime(time)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CSceneNodeAnimatorFollowSpline");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
inline s32 CSceneNodeAnimatorFollowSpline::clamp(s32 idx, s32 size)
|
||||
{
|
||||
return ( idx<0 ? size+idx : ( idx>=size ? idx-size : idx ) );
|
||||
}
|
||||
|
||||
|
||||
//! animates a scene node
|
||||
void CSceneNodeAnimatorFollowSpline::animateNode(ISceneNode* node, u32 timeMs)
|
||||
{
|
||||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "CSceneNodeAnimatorFollowSpline.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
//! constructor
|
||||
CSceneNodeAnimatorFollowSpline::CSceneNodeAnimatorFollowSpline(u32 time,
|
||||
const core::array<core::vector3df>& points, f32 speed,
|
||||
f32 tightness)
|
||||
: Points(points), Speed(speed), Tightness(tightness), StartTime(time)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CSceneNodeAnimatorFollowSpline");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
inline s32 CSceneNodeAnimatorFollowSpline::clamp(s32 idx, s32 size)
|
||||
{
|
||||
return ( idx<0 ? size+idx : ( idx>=size ? idx-size : idx ) );
|
||||
}
|
||||
|
||||
|
||||
//! animates a scene node
|
||||
void CSceneNodeAnimatorFollowSpline::animateNode(ISceneNode* node, u32 timeMs)
|
||||
{
|
||||
if(!node)
|
||||
return;
|
||||
|
||||
const u32 pSize = Points.size();
|
||||
if (pSize==0)
|
||||
return;
|
||||
if (pSize==1)
|
||||
{
|
||||
node->setPosition(Points[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
const f32 dt = ( (timeMs-StartTime) * Speed * 0.001f );
|
||||
const f32 u = core::fract ( dt );
|
||||
const s32 idx = core::floor32( dt ) % pSize;
|
||||
//const f32 u = 0.001f * fmodf( dt, 1000.0f );
|
||||
|
||||
const core::vector3df& p0 = Points[ clamp( idx - 1, pSize ) ];
|
||||
const core::vector3df& p1 = Points[ clamp( idx + 0, pSize ) ]; // starting point
|
||||
const core::vector3df& p2 = Points[ clamp( idx + 1, pSize ) ]; // end point
|
||||
const core::vector3df& p3 = Points[ clamp( idx + 2, pSize ) ];
|
||||
|
||||
// hermite polynomials
|
||||
const f32 h1 = 2.0f * u * u * u - 3.0f * u * u + 1.0f;
|
||||
const f32 h2 = -2.0f * u * u * u + 3.0f * u * u;
|
||||
const f32 h3 = u * u * u - 2.0f * u * u + u;
|
||||
const f32 h4 = u * u * u - u * u;
|
||||
|
||||
// tangents
|
||||
const core::vector3df t1 = ( p2 - p0 ) * Tightness;
|
||||
const core::vector3df t2 = ( p3 - p1 ) * Tightness;
|
||||
|
||||
// interpolated point
|
||||
node->setPosition(p1 * h1 + p2 * h2 + t1 * h3 + t2 * h4);
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the scene node animator.
|
||||
void CSceneNodeAnimatorFollowSpline::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
|
||||
{
|
||||
out->addFloat("Speed", Speed);
|
||||
out->addFloat("Tightness", Tightness);
|
||||
|
||||
u32 count = Points.size();
|
||||
|
||||
if ( options && (options->Flags & io::EARWF_FOR_EDITOR))
|
||||
{
|
||||
// add one point in addition when serializing for editors
|
||||
// to make it easier to add points quickly
|
||||
count += 1;
|
||||
}
|
||||
|
||||
for (u32 i=0; i<count; ++i)
|
||||
{
|
||||
core::stringc tname = "Point";
|
||||
tname += (int)(i+1);
|
||||
|
||||
out->addVector3d(tname.c_str(), i<Points.size() ? Points[i] : core::vector3df(0,0,0) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the scene node animator.
|
||||
void CSceneNodeAnimatorFollowSpline::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
|
||||
{
|
||||
Speed = in->getAttributeAsFloat("Speed");
|
||||
Tightness = in->getAttributeAsFloat("Tightness");
|
||||
Points.clear();
|
||||
|
||||
for(u32 i=1; true; ++i)
|
||||
{
|
||||
core::stringc pname = "Point";
|
||||
pname += i;
|
||||
|
||||
if (in->existsAttribute(pname.c_str()))
|
||||
Points.push_back(in->getAttributeAsVector3d(pname.c_str()));
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
// remove last point if double entry from editor
|
||||
if ( options && (options->Flags & io::EARWF_FOR_EDITOR) &&
|
||||
Points.size() > 2 && Points.getLast() == core::vector3df(0,0,0))
|
||||
{
|
||||
Points.erase(Points.size()-1);
|
||||
|
||||
if (Points.size() > 2 && Points.getLast() == core::vector3df(0,0,0))
|
||||
Points.erase(Points.size()-1);
|
||||
}
|
||||
}
|
||||
|
||||
ISceneNodeAnimator* CSceneNodeAnimatorFollowSpline::createClone(ISceneNode* node, ISceneManager* newManager)
|
||||
{
|
||||
CSceneNodeAnimatorFollowSpline * newAnimator =
|
||||
new CSceneNodeAnimatorFollowSpline(StartTime, Points, Speed, Tightness);
|
||||
|
||||
return newAnimator;
|
||||
}
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
|
||||
const u32 pSize = Points.size();
|
||||
if (pSize==0)
|
||||
return;
|
||||
if (pSize==1)
|
||||
{
|
||||
node->setPosition(Points[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
const f32 dt = ( (timeMs-StartTime) * Speed * 0.001f );
|
||||
const f32 u = core::fract ( dt );
|
||||
const s32 idx = core::floor32( dt ) % pSize;
|
||||
//const f32 u = 0.001f * fmodf( dt, 1000.0f );
|
||||
|
||||
const core::vector3df& p0 = Points[ clamp( idx - 1, pSize ) ];
|
||||
const core::vector3df& p1 = Points[ clamp( idx + 0, pSize ) ]; // starting point
|
||||
const core::vector3df& p2 = Points[ clamp( idx + 1, pSize ) ]; // end point
|
||||
const core::vector3df& p3 = Points[ clamp( idx + 2, pSize ) ];
|
||||
|
||||
// hermite polynomials
|
||||
const f32 h1 = 2.0f * u * u * u - 3.0f * u * u + 1.0f;
|
||||
const f32 h2 = -2.0f * u * u * u + 3.0f * u * u;
|
||||
const f32 h3 = u * u * u - 2.0f * u * u + u;
|
||||
const f32 h4 = u * u * u - u * u;
|
||||
|
||||
// tangents
|
||||
const core::vector3df t1 = ( p2 - p0 ) * Tightness;
|
||||
const core::vector3df t2 = ( p3 - p1 ) * Tightness;
|
||||
|
||||
// interpolated point
|
||||
node->setPosition(p1 * h1 + p2 * h2 + t1 * h3 + t2 * h4);
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the scene node animator.
|
||||
void CSceneNodeAnimatorFollowSpline::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
|
||||
{
|
||||
out->addFloat("Speed", Speed);
|
||||
out->addFloat("Tightness", Tightness);
|
||||
|
||||
u32 count = Points.size();
|
||||
|
||||
if ( options && (options->Flags & io::EARWF_FOR_EDITOR))
|
||||
{
|
||||
// add one point in addition when serializing for editors
|
||||
// to make it easier to add points quickly
|
||||
count += 1;
|
||||
}
|
||||
|
||||
for (u32 i=0; i<count; ++i)
|
||||
{
|
||||
core::stringc tname = "Point";
|
||||
tname += (int)(i+1);
|
||||
|
||||
out->addVector3d(tname.c_str(), i<Points.size() ? Points[i] : core::vector3df(0,0,0) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the scene node animator.
|
||||
void CSceneNodeAnimatorFollowSpline::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
|
||||
{
|
||||
Speed = in->getAttributeAsFloat("Speed");
|
||||
Tightness = in->getAttributeAsFloat("Tightness");
|
||||
Points.clear();
|
||||
|
||||
for(u32 i=1; true; ++i)
|
||||
{
|
||||
core::stringc pname = "Point";
|
||||
pname += i;
|
||||
|
||||
if (in->existsAttribute(pname.c_str()))
|
||||
Points.push_back(in->getAttributeAsVector3d(pname.c_str()));
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
// remove last point if double entry from editor
|
||||
if ( options && (options->Flags & io::EARWF_FOR_EDITOR) &&
|
||||
Points.size() > 2 && Points.getLast() == core::vector3df(0,0,0))
|
||||
{
|
||||
Points.erase(Points.size()-1);
|
||||
|
||||
if (Points.size() > 2 && Points.getLast() == core::vector3df(0,0,0))
|
||||
Points.erase(Points.size()-1);
|
||||
}
|
||||
}
|
||||
|
||||
ISceneNodeAnimator* CSceneNodeAnimatorFollowSpline::createClone(ISceneNode* node, ISceneManager* newManager)
|
||||
{
|
||||
CSceneNodeAnimatorFollowSpline * newAnimator =
|
||||
new CSceneNodeAnimatorFollowSpline(StartTime, Points, Speed, Tightness);
|
||||
|
||||
return newAnimator;
|
||||
}
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
|
|
|
@ -1,324 +1,322 @@
|
|||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
//
|
||||
// created by Dean Wadsworth aka Varmint Dec 31 2007
|
||||
|
||||
#include "CVolumeLightSceneNode.h"
|
||||
#include "IVideoDriver.h"
|
||||
#include "ISceneManager.h"
|
||||
#include "S3DVertex.h"
|
||||
#include "os.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
//! constructor
|
||||
CVolumeLightSceneNode::CVolumeLightSceneNode(ISceneNode* parent, ISceneManager* mgr,
|
||||
s32 id, const u32 subdivU, const u32 subdivV,
|
||||
const video::SColor foot,
|
||||
const video::SColor tail,
|
||||
const core::vector3df& position,
|
||||
const core::vector3df& rotation, const core::vector3df& scale)
|
||||
: IVolumeLightSceneNode(parent, mgr, id, position, rotation, scale),
|
||||
LPDistance(8.0f), SubdivideU(subdivU), SubdivideV(subdivV),
|
||||
FootColour(foot), TailColour(tail),
|
||||
LightDimensions(core::vector3df(1.0f, 1.2f, 1.0f))
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CVolumeLightSceneNode");
|
||||
#endif
|
||||
|
||||
Buffer = new SMeshBuffer();
|
||||
if (Buffer)
|
||||
{
|
||||
Buffer->setHardwareMappingHint(EHM_STATIC);
|
||||
constructLight();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CVolumeLightSceneNode::~CVolumeLightSceneNode()
|
||||
{
|
||||
if (Buffer)
|
||||
Buffer->drop();
|
||||
}
|
||||
|
||||
|
||||
void CVolumeLightSceneNode::addToBuffer(const video::S3DVertex& v)
|
||||
{
|
||||
const s32 tnidx = Buffer->Vertices.linear_reverse_search(v);
|
||||
const bool alreadyIn = (tnidx != -1);
|
||||
u16 nidx = (u16)tnidx;
|
||||
if (!alreadyIn) {
|
||||
nidx = (u16)Buffer->Vertices.size();
|
||||
Buffer->Indices.push_back(nidx);
|
||||
Buffer->Vertices.push_back(v);
|
||||
} else
|
||||
Buffer->Indices.push_back(nidx);
|
||||
}
|
||||
|
||||
|
||||
void CVolumeLightSceneNode::constructLight()
|
||||
{
|
||||
const core::vector3df lightPoint(0, -(LPDistance*LightDimensions.Y), 0);
|
||||
const f32 ax = LightDimensions.X * 0.5f; // X Axis
|
||||
const f32 az = LightDimensions.Z * 0.5f; // Z Axis
|
||||
|
||||
Buffer->Vertices.clear();
|
||||
Buffer->Vertices.reallocate(6+12*(SubdivideU+SubdivideV));
|
||||
Buffer->Indices.clear();
|
||||
Buffer->Indices.reallocate(6+12*(SubdivideU+SubdivideV));
|
||||
//draw the bottom foot.. the glowing region
|
||||
addToBuffer(video::S3DVertex(-ax, 0, az, 0,0,0, FootColour, 0, 1));
|
||||
addToBuffer(video::S3DVertex(ax , 0, az, 0,0,0, FootColour, 1, 1));
|
||||
addToBuffer(video::S3DVertex(ax , 0,-az, 0,0,0, FootColour, 1, 0));
|
||||
|
||||
addToBuffer(video::S3DVertex(ax , 0,-az, 0,0,0, FootColour, 1, 0));
|
||||
addToBuffer(video::S3DVertex(-ax, 0,-az, 0,0,0, FootColour, 0, 0));
|
||||
addToBuffer(video::S3DVertex(-ax, 0, az, 0,0,0, FootColour, 0, 1));
|
||||
|
||||
f32 tu = 0.f;
|
||||
const f32 tuStep = 1.f/SubdivideU;
|
||||
f32 bx = -ax;
|
||||
const f32 bxStep = LightDimensions.X * tuStep;
|
||||
// Slices in X/U space
|
||||
for (u32 i = 0; i <= SubdivideU; ++i)
|
||||
{
|
||||
// These are the two endpoints for a slice at the foot
|
||||
core::vector3df end1(bx, 0.0f, -az);
|
||||
core::vector3df end2(bx, 0.0f, az);
|
||||
|
||||
end1 -= lightPoint; // get a vector from point to lightsource
|
||||
end1.normalize(); // normalize vector
|
||||
end1 *= LightDimensions.Y; // multiply it out by shootlength
|
||||
|
||||
end1.X += bx; // Add the original point location to the vector
|
||||
end1.Z -= az;
|
||||
|
||||
// Do it again for the other point.
|
||||
end2 -= lightPoint;
|
||||
end2.normalize();
|
||||
end2 *= LightDimensions.Y;
|
||||
|
||||
end2.X += bx;
|
||||
end2.Z += az;
|
||||
|
||||
addToBuffer(video::S3DVertex(bx , 0, az, 0,0,0, FootColour, tu, 1));
|
||||
addToBuffer(video::S3DVertex(bx , 0, -az, 0,0,0, FootColour, tu, 0));
|
||||
addToBuffer(video::S3DVertex(end2.X , end2.Y, end2.Z, 0,0,0, TailColour, tu, 1));
|
||||
|
||||
addToBuffer(video::S3DVertex(bx , 0, -az, 0,0,0, FootColour, tu, 0));
|
||||
addToBuffer(video::S3DVertex(end1.X , end1.Y, end1.Z, 0,0,0, TailColour, tu, 0));
|
||||
addToBuffer(video::S3DVertex(end2.X , end2.Y, end2.Z, 0,0,0, TailColour, tu, 1));
|
||||
|
||||
//back side
|
||||
addToBuffer(video::S3DVertex(-end2.X , end2.Y, -end2.Z, 0,0,0, TailColour, tu, 1));
|
||||
addToBuffer(video::S3DVertex(-bx , 0, -az, 0,0,0, FootColour, tu, 1));
|
||||
addToBuffer(video::S3DVertex(-bx , 0, az, 0,0,0, FootColour, tu, 0));
|
||||
|
||||
addToBuffer(video::S3DVertex(-bx , 0, az, 0,0,0, FootColour, tu, 0));
|
||||
addToBuffer(video::S3DVertex(-end1.X , end1.Y, -end1.Z, 0,0,0, TailColour, tu, 0));
|
||||
addToBuffer(video::S3DVertex(-end2.X , end2.Y, -end2.Z, 0,0,0, TailColour, tu, 1));
|
||||
tu += tuStep;
|
||||
bx += bxStep;
|
||||
}
|
||||
|
||||
f32 tv = 0.f;
|
||||
const f32 tvStep = 1.f/SubdivideV;
|
||||
f32 bz = -az;
|
||||
const f32 bzStep = LightDimensions.Z * tvStep;
|
||||
// Slices in Z/V space
|
||||
for(u32 i = 0; i <= SubdivideV; ++i)
|
||||
{
|
||||
// These are the two endpoints for a slice at the foot
|
||||
core::vector3df end1(-ax, 0.0f, bz);
|
||||
core::vector3df end2(ax, 0.0f, bz);
|
||||
|
||||
end1 -= lightPoint; // get a vector from point to lightsource
|
||||
end1.normalize(); // normalize vector
|
||||
end1 *= LightDimensions.Y; // multiply it out by shootlength
|
||||
|
||||
end1.X -= ax; // Add the original point location to the vector
|
||||
end1.Z += bz;
|
||||
|
||||
// Do it again for the other point.
|
||||
end2 -= lightPoint;
|
||||
end2.normalize();
|
||||
end2 *= LightDimensions.Y;
|
||||
|
||||
end2.X += ax;
|
||||
end2.Z += bz;
|
||||
|
||||
addToBuffer(video::S3DVertex(-ax , 0, bz, 0,0,0, FootColour, 0, tv));
|
||||
addToBuffer(video::S3DVertex(ax , 0, bz, 0,0,0, FootColour, 1, tv));
|
||||
addToBuffer(video::S3DVertex(end2.X , end2.Y, end2.Z, 0,0,0, TailColour, 1, tv));
|
||||
|
||||
addToBuffer(video::S3DVertex(end2.X , end2.Y, end2.Z, 0,0,0, TailColour, 1, tv));
|
||||
addToBuffer(video::S3DVertex(end1.X , end1.Y, end1.Z, 0,0,0, TailColour, 0, tv));
|
||||
addToBuffer(video::S3DVertex(-ax , 0, bz, 0,0,0, FootColour, 0, tv));
|
||||
|
||||
//back side
|
||||
addToBuffer(video::S3DVertex(ax , 0, -bz, 0,0,0, FootColour, 0, tv));
|
||||
addToBuffer(video::S3DVertex(-ax , 0, -bz, 0,0,0, FootColour, 1, tv));
|
||||
addToBuffer(video::S3DVertex(-end2.X , end2.Y, -end2.Z, 0,0,0, TailColour, 1, tv));
|
||||
|
||||
addToBuffer(video::S3DVertex(-end2.X , end2.Y, -end2.Z, 0,0,0, TailColour, 1, tv));
|
||||
addToBuffer(video::S3DVertex(-end1.X , end1.Y, -end1.Z, 0,0,0, TailColour, 0, tv));
|
||||
addToBuffer(video::S3DVertex(ax , 0, -bz, 0,0,0, FootColour, 0, tv));
|
||||
tv += tvStep;
|
||||
bz += bzStep;
|
||||
}
|
||||
|
||||
Buffer->recalculateBoundingBox();
|
||||
|
||||
Buffer->Material.MaterialType = video::EMT_ONETEXTURE_BLEND;
|
||||
Buffer->Material.MaterialTypeParam = pack_texureBlendFunc( video::EBF_SRC_COLOR, video::EBF_SRC_ALPHA, video::EMFN_MODULATE_1X );
|
||||
|
||||
Buffer->Material.Lighting = false;
|
||||
Buffer->Material.ZWriteEnable = false;
|
||||
|
||||
Buffer->setDirty(EBT_VERTEX_AND_INDEX);
|
||||
}
|
||||
|
||||
|
||||
//! renders the node.
|
||||
void CVolumeLightSceneNode::render()
|
||||
{
|
||||
if (!Buffer)
|
||||
return;
|
||||
|
||||
video::IVideoDriver* driver = SceneManager->getVideoDriver();
|
||||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
||||
|
||||
driver->setMaterial(Buffer->Material);
|
||||
driver->drawMeshBuffer(Buffer);
|
||||
}
|
||||
|
||||
|
||||
//! returns the axis aligned bounding box of this node
|
||||
const core::aabbox3d<f32>& CVolumeLightSceneNode::getBoundingBox() const
|
||||
{
|
||||
return Buffer->BoundingBox;
|
||||
}
|
||||
|
||||
|
||||
void CVolumeLightSceneNode::OnRegisterSceneNode()
|
||||
{
|
||||
if (IsVisible)
|
||||
{
|
||||
SceneManager->registerNodeForRendering(this, ESNRP_TRANSPARENT);
|
||||
}
|
||||
ISceneNode::OnRegisterSceneNode();
|
||||
}
|
||||
|
||||
|
||||
//! returns the material based on the zero based index i. To get the amount
|
||||
//! of materials used by this scene node, use getMaterialCount().
|
||||
//! This function is needed for inserting the node into the scene hirachy on a
|
||||
//! optimal position for minimizing renderstate changes, but can also be used
|
||||
//! to directly modify the material of a scene node.
|
||||
video::SMaterial& CVolumeLightSceneNode::getMaterial(u32 i)
|
||||
{
|
||||
return Buffer->Material;
|
||||
}
|
||||
|
||||
|
||||
//! returns amount of materials used by this scene node.
|
||||
u32 CVolumeLightSceneNode::getMaterialCount() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void CVolumeLightSceneNode::setSubDivideU (const u32 inU)
|
||||
{
|
||||
SubdivideU = inU;
|
||||
constructLight();
|
||||
}
|
||||
|
||||
|
||||
void CVolumeLightSceneNode::setSubDivideV (const u32 inV)
|
||||
{
|
||||
SubdivideV = inV;
|
||||
constructLight();
|
||||
}
|
||||
|
||||
|
||||
void CVolumeLightSceneNode::setFootColour(const video::SColor inColouf)
|
||||
{
|
||||
FootColour = inColouf;
|
||||
constructLight();
|
||||
}
|
||||
|
||||
|
||||
void CVolumeLightSceneNode::setTailColour(const video::SColor inColouf)
|
||||
{
|
||||
TailColour = inColouf;
|
||||
constructLight();
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the scene node.
|
||||
void CVolumeLightSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
|
||||
{
|
||||
ISceneNode::serializeAttributes(out, options);
|
||||
|
||||
out->addFloat("lpDistance", LPDistance);
|
||||
out->addInt("subDivideU", SubdivideU);
|
||||
out->addInt("subDivideV", SubdivideV);
|
||||
|
||||
out->addColor("footColour", FootColour);
|
||||
out->addColor("tailColour", TailColour);
|
||||
|
||||
out->addVector3d("lightDimension", LightDimensions);
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the scene node.
|
||||
void CVolumeLightSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
|
||||
{
|
||||
LPDistance = in->getAttributeAsFloat("lpDistance");
|
||||
LPDistance = core::max_(LPDistance, 8.0f);
|
||||
|
||||
SubdivideU = in->getAttributeAsInt("subDivideU");
|
||||
SubdivideU = core::max_(SubdivideU, 1u);
|
||||
|
||||
SubdivideV = in->getAttributeAsInt("subDivideV");
|
||||
SubdivideV = core::max_(SubdivideV, 1u);
|
||||
|
||||
FootColour = in->getAttributeAsColor("footColour");
|
||||
TailColour = in->getAttributeAsColor("tailColour");
|
||||
|
||||
LightDimensions = in->getAttributeAsVector3d("lightDimension");
|
||||
|
||||
constructLight();
|
||||
|
||||
ISceneNode::deserializeAttributes(in, options);
|
||||
}
|
||||
|
||||
|
||||
//! Creates a clone of this scene node and its children.
|
||||
ISceneNode* CVolumeLightSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager)
|
||||
{
|
||||
if (!newParent)
|
||||
newParent = Parent;
|
||||
if (!newManager)
|
||||
newManager = SceneManager;
|
||||
|
||||
CVolumeLightSceneNode* nb = new CVolumeLightSceneNode(newParent,
|
||||
newManager, ID, SubdivideU, SubdivideV, FootColour, TailColour, RelativeTranslation);
|
||||
|
||||
nb->cloneMembers(this, newManager);
|
||||
nb->Buffer->Material = Buffer->Material;
|
||||
|
||||
nb->drop();
|
||||
return nb;
|
||||
}
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
// Copyright (C) 2007-2009 Dean Wadsworth
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "CVolumeLightSceneNode.h"
|
||||
#include "IVideoDriver.h"
|
||||
#include "ISceneManager.h"
|
||||
#include "S3DVertex.h"
|
||||
#include "os.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
//! constructor
|
||||
CVolumeLightSceneNode::CVolumeLightSceneNode(ISceneNode* parent, ISceneManager* mgr,
|
||||
s32 id, const u32 subdivU, const u32 subdivV,
|
||||
const video::SColor foot,
|
||||
const video::SColor tail,
|
||||
const core::vector3df& position,
|
||||
const core::vector3df& rotation, const core::vector3df& scale)
|
||||
: IVolumeLightSceneNode(parent, mgr, id, position, rotation, scale),
|
||||
LPDistance(8.0f), SubdivideU(subdivU), SubdivideV(subdivV),
|
||||
FootColour(foot), TailColour(tail),
|
||||
LightDimensions(core::vector3df(1.0f, 1.2f, 1.0f))
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CVolumeLightSceneNode");
|
||||
#endif
|
||||
|
||||
Buffer = new SMeshBuffer();
|
||||
if (Buffer)
|
||||
{
|
||||
Buffer->setHardwareMappingHint(EHM_STATIC);
|
||||
constructLight();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CVolumeLightSceneNode::~CVolumeLightSceneNode()
|
||||
{
|
||||
if (Buffer)
|
||||
Buffer->drop();
|
||||
}
|
||||
|
||||
|
||||
void CVolumeLightSceneNode::addToBuffer(const video::S3DVertex& v)
|
||||
{
|
||||
const s32 tnidx = Buffer->Vertices.linear_reverse_search(v);
|
||||
const bool alreadyIn = (tnidx != -1);
|
||||
u16 nidx = (u16)tnidx;
|
||||
if (!alreadyIn) {
|
||||
nidx = (u16)Buffer->Vertices.size();
|
||||
Buffer->Indices.push_back(nidx);
|
||||
Buffer->Vertices.push_back(v);
|
||||
} else
|
||||
Buffer->Indices.push_back(nidx);
|
||||
}
|
||||
|
||||
|
||||
void CVolumeLightSceneNode::constructLight()
|
||||
{
|
||||
const core::vector3df lightPoint(0, -(LPDistance*LightDimensions.Y), 0);
|
||||
const f32 ax = LightDimensions.X * 0.5f; // X Axis
|
||||
const f32 az = LightDimensions.Z * 0.5f; // Z Axis
|
||||
|
||||
Buffer->Vertices.clear();
|
||||
Buffer->Vertices.reallocate(6+12*(SubdivideU+SubdivideV));
|
||||
Buffer->Indices.clear();
|
||||
Buffer->Indices.reallocate(6+12*(SubdivideU+SubdivideV));
|
||||
//draw the bottom foot.. the glowing region
|
||||
addToBuffer(video::S3DVertex(-ax, 0, az, 0,0,0, FootColour, 0, 1));
|
||||
addToBuffer(video::S3DVertex(ax , 0, az, 0,0,0, FootColour, 1, 1));
|
||||
addToBuffer(video::S3DVertex(ax , 0,-az, 0,0,0, FootColour, 1, 0));
|
||||
|
||||
addToBuffer(video::S3DVertex(ax , 0,-az, 0,0,0, FootColour, 1, 0));
|
||||
addToBuffer(video::S3DVertex(-ax, 0,-az, 0,0,0, FootColour, 0, 0));
|
||||
addToBuffer(video::S3DVertex(-ax, 0, az, 0,0,0, FootColour, 0, 1));
|
||||
|
||||
f32 tu = 0.f;
|
||||
const f32 tuStep = 1.f/SubdivideU;
|
||||
f32 bx = -ax;
|
||||
const f32 bxStep = LightDimensions.X * tuStep;
|
||||
// Slices in X/U space
|
||||
for (u32 i = 0; i <= SubdivideU; ++i)
|
||||
{
|
||||
// These are the two endpoints for a slice at the foot
|
||||
core::vector3df end1(bx, 0.0f, -az);
|
||||
core::vector3df end2(bx, 0.0f, az);
|
||||
|
||||
end1 -= lightPoint; // get a vector from point to lightsource
|
||||
end1.normalize(); // normalize vector
|
||||
end1 *= LightDimensions.Y; // multiply it out by shootlength
|
||||
|
||||
end1.X += bx; // Add the original point location to the vector
|
||||
end1.Z -= az;
|
||||
|
||||
// Do it again for the other point.
|
||||
end2 -= lightPoint;
|
||||
end2.normalize();
|
||||
end2 *= LightDimensions.Y;
|
||||
|
||||
end2.X += bx;
|
||||
end2.Z += az;
|
||||
|
||||
addToBuffer(video::S3DVertex(bx , 0, az, 0,0,0, FootColour, tu, 1));
|
||||
addToBuffer(video::S3DVertex(bx , 0, -az, 0,0,0, FootColour, tu, 0));
|
||||
addToBuffer(video::S3DVertex(end2.X , end2.Y, end2.Z, 0,0,0, TailColour, tu, 1));
|
||||
|
||||
addToBuffer(video::S3DVertex(bx , 0, -az, 0,0,0, FootColour, tu, 0));
|
||||
addToBuffer(video::S3DVertex(end1.X , end1.Y, end1.Z, 0,0,0, TailColour, tu, 0));
|
||||
addToBuffer(video::S3DVertex(end2.X , end2.Y, end2.Z, 0,0,0, TailColour, tu, 1));
|
||||
|
||||
//back side
|
||||
addToBuffer(video::S3DVertex(-end2.X , end2.Y, -end2.Z, 0,0,0, TailColour, tu, 1));
|
||||
addToBuffer(video::S3DVertex(-bx , 0, -az, 0,0,0, FootColour, tu, 1));
|
||||
addToBuffer(video::S3DVertex(-bx , 0, az, 0,0,0, FootColour, tu, 0));
|
||||
|
||||
addToBuffer(video::S3DVertex(-bx , 0, az, 0,0,0, FootColour, tu, 0));
|
||||
addToBuffer(video::S3DVertex(-end1.X , end1.Y, -end1.Z, 0,0,0, TailColour, tu, 0));
|
||||
addToBuffer(video::S3DVertex(-end2.X , end2.Y, -end2.Z, 0,0,0, TailColour, tu, 1));
|
||||
tu += tuStep;
|
||||
bx += bxStep;
|
||||
}
|
||||
|
||||
f32 tv = 0.f;
|
||||
const f32 tvStep = 1.f/SubdivideV;
|
||||
f32 bz = -az;
|
||||
const f32 bzStep = LightDimensions.Z * tvStep;
|
||||
// Slices in Z/V space
|
||||
for(u32 i = 0; i <= SubdivideV; ++i)
|
||||
{
|
||||
// These are the two endpoints for a slice at the foot
|
||||
core::vector3df end1(-ax, 0.0f, bz);
|
||||
core::vector3df end2(ax, 0.0f, bz);
|
||||
|
||||
end1 -= lightPoint; // get a vector from point to lightsource
|
||||
end1.normalize(); // normalize vector
|
||||
end1 *= LightDimensions.Y; // multiply it out by shootlength
|
||||
|
||||
end1.X -= ax; // Add the original point location to the vector
|
||||
end1.Z += bz;
|
||||
|
||||
// Do it again for the other point.
|
||||
end2 -= lightPoint;
|
||||
end2.normalize();
|
||||
end2 *= LightDimensions.Y;
|
||||
|
||||
end2.X += ax;
|
||||
end2.Z += bz;
|
||||
|
||||
addToBuffer(video::S3DVertex(-ax , 0, bz, 0,0,0, FootColour, 0, tv));
|
||||
addToBuffer(video::S3DVertex(ax , 0, bz, 0,0,0, FootColour, 1, tv));
|
||||
addToBuffer(video::S3DVertex(end2.X , end2.Y, end2.Z, 0,0,0, TailColour, 1, tv));
|
||||
|
||||
addToBuffer(video::S3DVertex(end2.X , end2.Y, end2.Z, 0,0,0, TailColour, 1, tv));
|
||||
addToBuffer(video::S3DVertex(end1.X , end1.Y, end1.Z, 0,0,0, TailColour, 0, tv));
|
||||
addToBuffer(video::S3DVertex(-ax , 0, bz, 0,0,0, FootColour, 0, tv));
|
||||
|
||||
//back side
|
||||
addToBuffer(video::S3DVertex(ax , 0, -bz, 0,0,0, FootColour, 0, tv));
|
||||
addToBuffer(video::S3DVertex(-ax , 0, -bz, 0,0,0, FootColour, 1, tv));
|
||||
addToBuffer(video::S3DVertex(-end2.X , end2.Y, -end2.Z, 0,0,0, TailColour, 1, tv));
|
||||
|
||||
addToBuffer(video::S3DVertex(-end2.X , end2.Y, -end2.Z, 0,0,0, TailColour, 1, tv));
|
||||
addToBuffer(video::S3DVertex(-end1.X , end1.Y, -end1.Z, 0,0,0, TailColour, 0, tv));
|
||||
addToBuffer(video::S3DVertex(ax , 0, -bz, 0,0,0, FootColour, 0, tv));
|
||||
tv += tvStep;
|
||||
bz += bzStep;
|
||||
}
|
||||
|
||||
Buffer->recalculateBoundingBox();
|
||||
|
||||
Buffer->Material.MaterialType = video::EMT_ONETEXTURE_BLEND;
|
||||
Buffer->Material.MaterialTypeParam = pack_texureBlendFunc( video::EBF_SRC_COLOR, video::EBF_SRC_ALPHA, video::EMFN_MODULATE_1X );
|
||||
|
||||
Buffer->Material.Lighting = false;
|
||||
Buffer->Material.ZWriteEnable = false;
|
||||
|
||||
Buffer->setDirty(EBT_VERTEX_AND_INDEX);
|
||||
}
|
||||
|
||||
|
||||
//! renders the node.
|
||||
void CVolumeLightSceneNode::render()
|
||||
{
|
||||
if (!Buffer)
|
||||
return;
|
||||
|
||||
video::IVideoDriver* driver = SceneManager->getVideoDriver();
|
||||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
||||
|
||||
driver->setMaterial(Buffer->Material);
|
||||
driver->drawMeshBuffer(Buffer);
|
||||
}
|
||||
|
||||
|
||||
//! returns the axis aligned bounding box of this node
|
||||
const core::aabbox3d<f32>& CVolumeLightSceneNode::getBoundingBox() const
|
||||
{
|
||||
return Buffer->BoundingBox;
|
||||
}
|
||||
|
||||
|
||||
void CVolumeLightSceneNode::OnRegisterSceneNode()
|
||||
{
|
||||
if (IsVisible)
|
||||
{
|
||||
SceneManager->registerNodeForRendering(this, ESNRP_TRANSPARENT);
|
||||
}
|
||||
ISceneNode::OnRegisterSceneNode();
|
||||
}
|
||||
|
||||
|
||||
//! returns the material based on the zero based index i. To get the amount
|
||||
//! of materials used by this scene node, use getMaterialCount().
|
||||
//! This function is needed for inserting the node into the scene hirachy on a
|
||||
//! optimal position for minimizing renderstate changes, but can also be used
|
||||
//! to directly modify the material of a scene node.
|
||||
video::SMaterial& CVolumeLightSceneNode::getMaterial(u32 i)
|
||||
{
|
||||
return Buffer->Material;
|
||||
}
|
||||
|
||||
|
||||
//! returns amount of materials used by this scene node.
|
||||
u32 CVolumeLightSceneNode::getMaterialCount() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void CVolumeLightSceneNode::setSubDivideU (const u32 inU)
|
||||
{
|
||||
SubdivideU = inU;
|
||||
constructLight();
|
||||
}
|
||||
|
||||
|
||||
void CVolumeLightSceneNode::setSubDivideV (const u32 inV)
|
||||
{
|
||||
SubdivideV = inV;
|
||||
constructLight();
|
||||
}
|
||||
|
||||
|
||||
void CVolumeLightSceneNode::setFootColour(const video::SColor inColouf)
|
||||
{
|
||||
FootColour = inColouf;
|
||||
constructLight();
|
||||
}
|
||||
|
||||
|
||||
void CVolumeLightSceneNode::setTailColour(const video::SColor inColouf)
|
||||
{
|
||||
TailColour = inColouf;
|
||||
constructLight();
|
||||
}
|
||||
|
||||
|
||||
//! Writes attributes of the scene node.
|
||||
void CVolumeLightSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
|
||||
{
|
||||
ISceneNode::serializeAttributes(out, options);
|
||||
|
||||
out->addFloat("lpDistance", LPDistance);
|
||||
out->addInt("subDivideU", SubdivideU);
|
||||
out->addInt("subDivideV", SubdivideV);
|
||||
|
||||
out->addColor("footColour", FootColour);
|
||||
out->addColor("tailColour", TailColour);
|
||||
|
||||
out->addVector3d("lightDimension", LightDimensions);
|
||||
}
|
||||
|
||||
|
||||
//! Reads attributes of the scene node.
|
||||
void CVolumeLightSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
|
||||
{
|
||||
LPDistance = in->getAttributeAsFloat("lpDistance");
|
||||
LPDistance = core::max_(LPDistance, 8.0f);
|
||||
|
||||
SubdivideU = in->getAttributeAsInt("subDivideU");
|
||||
SubdivideU = core::max_(SubdivideU, 1u);
|
||||
|
||||
SubdivideV = in->getAttributeAsInt("subDivideV");
|
||||
SubdivideV = core::max_(SubdivideV, 1u);
|
||||
|
||||
FootColour = in->getAttributeAsColor("footColour");
|
||||
TailColour = in->getAttributeAsColor("tailColour");
|
||||
|
||||
LightDimensions = in->getAttributeAsVector3d("lightDimension");
|
||||
|
||||
constructLight();
|
||||
|
||||
ISceneNode::deserializeAttributes(in, options);
|
||||
}
|
||||
|
||||
|
||||
//! Creates a clone of this scene node and its children.
|
||||
ISceneNode* CVolumeLightSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager)
|
||||
{
|
||||
if (!newParent)
|
||||
newParent = Parent;
|
||||
if (!newManager)
|
||||
newManager = SceneManager;
|
||||
|
||||
CVolumeLightSceneNode* nb = new CVolumeLightSceneNode(newParent,
|
||||
newManager, ID, SubdivideU, SubdivideV, FootColour, TailColour, RelativeTranslation);
|
||||
|
||||
nb->cloneMembers(this, newManager);
|
||||
nb->Buffer->Material = Buffer->Material;
|
||||
|
||||
nb->drop();
|
||||
return nb;
|
||||
}
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
|
|
|
@ -1,100 +1,100 @@
|
|||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
//
|
||||
// created by Dean Wadsworth aka Varmint Dec 31 2007
|
||||
|
||||
#ifndef __VOLUME_LIGHT_SCENE_NODE_H_INCLUDED__
|
||||
#define __VOLUME_LIGHT_SCENE_NODE_H_INCLUDED__
|
||||
|
||||
#include "IVolumeLightSceneNode.h"
|
||||
#include "SMeshBuffer.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
class CVolumeLightSceneNode : public IVolumeLightSceneNode
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
CVolumeLightSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
|
||||
const u32 subdivU = 32, const u32 subdivV = 32,
|
||||
const video::SColor foot = video::SColor(51, 0, 230, 180),
|
||||
const video::SColor tail = video::SColor(0, 0, 0, 0),
|
||||
const core::vector3df& position = core::vector3df(0,0,0),
|
||||
const core::vector3df& rotation = core::vector3df(0,0,0),
|
||||
const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f));
|
||||
|
||||
virtual ~CVolumeLightSceneNode();
|
||||
|
||||
virtual void OnRegisterSceneNode();
|
||||
|
||||
//! renders the node.
|
||||
virtual void render();
|
||||
|
||||
//! returns the axis aligned bounding box of this node
|
||||
virtual const core::aabbox3d<f32>& getBoundingBox() const;
|
||||
|
||||
//! returns the material based on the zero based index i. To get the amount
|
||||
//! of materials used by this scene node, use getMaterialCount().
|
||||
//! This function is needed for inserting the node into the scene hirachy on a
|
||||
//! optimal position for minimizing renderstate changes, but can also be used
|
||||
//! to directly modify the material of a scene node.
|
||||
virtual video::SMaterial& getMaterial(u32 i);
|
||||
|
||||
//! returns amount of materials used by this scene node.
|
||||
virtual u32 getMaterialCount() const;
|
||||
|
||||
//! Returns type of the scene node
|
||||
virtual ESCENE_NODE_TYPE getType() const { return ESNT_CUBE; }
|
||||
|
||||
//! Writes attributes of the scene node.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const;
|
||||
|
||||
//! Reads attributes of the scene node.
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0);
|
||||
|
||||
//! Creates a clone of this scene node and its children.
|
||||
virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0);
|
||||
|
||||
virtual void setSubDivideU (const u32 inU);
|
||||
virtual void setSubDivideV (const u32 inV);
|
||||
|
||||
virtual u32 getSubDivideU () const { return SubdivideU; }
|
||||
virtual u32 getSubDivideV () const { return SubdivideV; }
|
||||
|
||||
virtual void setFootColour(const video::SColor inColouf);
|
||||
virtual void setTailColour(const video::SColor inColouf);
|
||||
|
||||
virtual video::SColor getFootColour () const { return FootColour; }
|
||||
virtual video::SColor getTailColour () const { return TailColour; }
|
||||
|
||||
virtual IMeshBuffer * getMeshBuffer(void) const { return Buffer; }
|
||||
|
||||
private:
|
||||
void addToBuffer(const video::S3DVertex& v);
|
||||
void constructLight();
|
||||
|
||||
SMeshBuffer* Buffer;
|
||||
|
||||
f32 LPDistance; // Distance to hypothetical lightsource point -- affects fov angle
|
||||
|
||||
u32 SubdivideU; // Number of subdivisions in U and V space.
|
||||
u32 SubdivideV; // Controls the number of "slices" in the volume.
|
||||
// NOTE : Total number of polygons = 2 + ((SubdivideU + 1) + (SubdivideV + 1)) * 2
|
||||
// Each slice being a quad plus the rectangular plane at the bottom.
|
||||
|
||||
video::SColor FootColour; // Color at the source
|
||||
video::SColor TailColour; // Color at the end.
|
||||
|
||||
core::vector3df LightDimensions; // LightDimensions.Y Distance of shooting -- Length of beams
|
||||
// LightDimensions.X and LightDimensions.Z determine the size/dimension of the plane
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
//
|
||||
// created by Dean Wadsworth aka Varmint Dec 31 2007
|
||||
|
||||
#ifndef __VOLUME_LIGHT_SCENE_NODE_H_INCLUDED__
|
||||
#define __VOLUME_LIGHT_SCENE_NODE_H_INCLUDED__
|
||||
|
||||
#include "IVolumeLightSceneNode.h"
|
||||
#include "SMeshBuffer.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
class CVolumeLightSceneNode : public IVolumeLightSceneNode
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
CVolumeLightSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
|
||||
const u32 subdivU = 32, const u32 subdivV = 32,
|
||||
const video::SColor foot = video::SColor(51, 0, 230, 180),
|
||||
const video::SColor tail = video::SColor(0, 0, 0, 0),
|
||||
const core::vector3df& position = core::vector3df(0,0,0),
|
||||
const core::vector3df& rotation = core::vector3df(0,0,0),
|
||||
const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f));
|
||||
|
||||
virtual ~CVolumeLightSceneNode();
|
||||
|
||||
virtual void OnRegisterSceneNode();
|
||||
|
||||
//! renders the node.
|
||||
virtual void render();
|
||||
|
||||
//! returns the axis aligned bounding box of this node
|
||||
virtual const core::aabbox3d<f32>& getBoundingBox() const;
|
||||
|
||||
//! returns the material based on the zero based index i. To get the amount
|
||||
//! of materials used by this scene node, use getMaterialCount().
|
||||
//! This function is needed for inserting the node into the scene hirachy on a
|
||||
//! optimal position for minimizing renderstate changes, but can also be used
|
||||
//! to directly modify the material of a scene node.
|
||||
virtual video::SMaterial& getMaterial(u32 i);
|
||||
|
||||
//! returns amount of materials used by this scene node.
|
||||
virtual u32 getMaterialCount() const;
|
||||
|
||||
//! Returns type of the scene node
|
||||
virtual ESCENE_NODE_TYPE getType() const { return ESNT_CUBE; }
|
||||
|
||||
//! Writes attributes of the scene node.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const;
|
||||
|
||||
//! Reads attributes of the scene node.
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0);
|
||||
|
||||
//! Creates a clone of this scene node and its children.
|
||||
virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0);
|
||||
|
||||
virtual void setSubDivideU (const u32 inU);
|
||||
virtual void setSubDivideV (const u32 inV);
|
||||
|
||||
virtual u32 getSubDivideU () const { return SubdivideU; }
|
||||
virtual u32 getSubDivideV () const { return SubdivideV; }
|
||||
|
||||
virtual void setFootColour(const video::SColor inColouf);
|
||||
virtual void setTailColour(const video::SColor inColouf);
|
||||
|
||||
virtual video::SColor getFootColour () const { return FootColour; }
|
||||
virtual video::SColor getTailColour () const { return TailColour; }
|
||||
|
||||
virtual IMeshBuffer * getMeshBuffer(void) const { return Buffer; }
|
||||
|
||||
private:
|
||||
void addToBuffer(const video::S3DVertex& v);
|
||||
void constructLight();
|
||||
|
||||
SMeshBuffer* Buffer;
|
||||
|
||||
f32 LPDistance; // Distance to hypothetical lightsource point -- affects fov angle
|
||||
|
||||
u32 SubdivideU; // Number of subdivisions in U and V space.
|
||||
u32 SubdivideV; // Controls the number of "slices" in the volume.
|
||||
// NOTE : Total number of polygons = 2 + ((SubdivideU + 1) + (SubdivideV + 1)) * 2
|
||||
// Each slice being a quad plus the rectangular plane at the bottom.
|
||||
|
||||
video::SColor FootColour; // Color at the source
|
||||
video::SColor TailColour; // Color at the end.
|
||||
|
||||
core::vector3df LightDimensions; // LightDimensions.Y Distance of shooting -- Length of beams
|
||||
// LightDimensions.X and LightDimensions.Z determine the size/dimension of the plane
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
// Copyright (C) 2002-2008 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __I_SCENE_NODE_ANIMATOR_FINISHING_H_INCLUDED__
|
||||
#define __I_SCENE_NODE_ANIMATOR_FINISHING_H_INCLUDED__
|
||||
|
||||
#include "ISceneNode.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
//! This is an abstract base class for animators that have a discrete end time.
|
||||
class ISceneNodeAnimatorFinishing : public ISceneNodeAnimator
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
ISceneNodeAnimatorFinishing(u32 finishTime)
|
||||
: FinishTime(finishTime), HasFinished(false) { }
|
||||
|
||||
//! destructor
|
||||
virtual ~ISceneNodeAnimatorFinishing() { }
|
||||
|
||||
//! This is a pure virtual class, so it can't be cloned directly.
|
||||
virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0) = 0;
|
||||
|
||||
virtual bool hasFinished(void) const { return HasFinished; }
|
||||
|
||||
protected:
|
||||
|
||||
u32 FinishTime;
|
||||
bool HasFinished;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
// Copyright (C) 2002-2008 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __I_SCENE_NODE_ANIMATOR_FINISHING_H_INCLUDED__
|
||||
#define __I_SCENE_NODE_ANIMATOR_FINISHING_H_INCLUDED__
|
||||
|
||||
#include "ISceneNode.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
//! This is an abstract base class for animators that have a discrete end time.
|
||||
class ISceneNodeAnimatorFinishing : public ISceneNodeAnimator
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
ISceneNodeAnimatorFinishing(u32 finishTime)
|
||||
: FinishTime(finishTime), HasFinished(false) { }
|
||||
|
||||
//! destructor
|
||||
virtual ~ISceneNodeAnimatorFinishing() { }
|
||||
|
||||
//! This is a pure virtual class, so it can't be cloned directly.
|
||||
virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0) = 0;
|
||||
|
||||
virtual bool hasFinished(void) const { return HasFinished; }
|
||||
|
||||
protected:
|
||||
|
||||
u32 FinishTime;
|
||||
bool HasFinished;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
|
|
16918
source/Irrlicht/glext.h
16918
source/Irrlicht/glext.h
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue