Changed some internals of the Volume light and gave it an interface.
git-svn-id: http://svn.code.sf.net/p/irrlicht/code/trunk@1171 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
bc628786b5
commit
ff4388e85d
47
include/IVolumeLightSceneNode.h
Normal file
47
include/IVolumeLightSceneNode.h
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright (C) 2002-2007 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 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;
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
@ -113,6 +113,7 @@
|
||||
#include "IReferenceCounted.h"
|
||||
#include "IVideoDriver.h"
|
||||
#include "IVideoModeList.h"
|
||||
#include "IVolumeLightSceneNode.h"
|
||||
#include "IWriteFile.h"
|
||||
#include "IXMLReader.h"
|
||||
#include "IXMLWriter.h"
|
||||
|
@ -151,7 +151,6 @@ void CCameraFPSSceneNode::animate( u32 timeMs )
|
||||
LastAnimationTime = timeMs;
|
||||
}
|
||||
|
||||
|
||||
// update position
|
||||
core::vector3df pos = getPosition();
|
||||
|
||||
@ -172,10 +171,10 @@ void CCameraFPSSceneNode::animate( u32 timeMs )
|
||||
RelativeRotation.Y *= -1.0f;
|
||||
|
||||
RelativeRotation.Y += (0.5f - cursorpos.X) * RotateSpeed;
|
||||
RelativeRotation.X = core::clamp ( RelativeRotation.X + (0.5f - cursorpos.Y) * RotateSpeed,
|
||||
-MAX_VERTICAL_ANGLE,
|
||||
+MAX_VERTICAL_ANGLE
|
||||
);
|
||||
RelativeRotation.X = core::clamp(
|
||||
RelativeRotation.X + (0.5f - cursorpos.Y) * RotateSpeed,
|
||||
-MAX_VERTICAL_ANGLE,
|
||||
+MAX_VERTICAL_ANGLE);
|
||||
|
||||
RelativeRotation.X *= -1.0f;
|
||||
RelativeRotation.Y *= -1.0f;
|
||||
@ -230,7 +229,6 @@ void CCameraFPSSceneNode::animate( u32 timeMs )
|
||||
}
|
||||
|
||||
// write translation
|
||||
|
||||
setPosition(pos);
|
||||
}
|
||||
|
||||
@ -238,9 +236,9 @@ void CCameraFPSSceneNode::animate( u32 timeMs )
|
||||
|
||||
TargetVector = Target;
|
||||
Target += pos;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CCameraFPSSceneNode::allKeysUp()
|
||||
{
|
||||
for (s32 i=0; i<6; ++i)
|
||||
|
@ -135,7 +135,7 @@ public:
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
if ( getTexelAlpha ( srcFact ) + getTexelAlpha ( dstFact ) )
|
||||
if ( getTexelAlpha(srcFact) || getTexelAlpha(dstFact) )
|
||||
{
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE);
|
||||
|
@ -22,7 +22,7 @@ CVolumeLightSceneNode::CVolumeLightSceneNode(ISceneNode* parent, ISceneManager*
|
||||
const video::SColor tail,
|
||||
const core::vector3df& position,
|
||||
const core::vector3df& rotation, const core::vector3df& scale)
|
||||
: ISceneNode(parent, mgr, id, position, rotation, scale), Buffer(0),
|
||||
: 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))
|
||||
@ -35,26 +35,17 @@ CVolumeLightSceneNode::CVolumeLightSceneNode(ISceneNode* parent, ISceneManager*
|
||||
}
|
||||
|
||||
|
||||
//! destructor
|
||||
CVolumeLightSceneNode::~CVolumeLightSceneNode()
|
||||
{
|
||||
if (Buffer)
|
||||
Buffer->drop();
|
||||
}
|
||||
|
||||
|
||||
void CVolumeLightSceneNode::addToBuffer(video::S3DVertex v)
|
||||
{
|
||||
const s32 tnidx = Buffer->Vertices.linear_reverse_search(v);
|
||||
const s32 tnidx = Buffer.Vertices.linear_reverse_search(v);
|
||||
const bool alreadyIn = (tnidx != -1);
|
||||
u16 nidx = (u16)tnidx;
|
||||
if (!alreadyIn) {
|
||||
nidx = Buffer->Vertices.size();
|
||||
Buffer->Indices.push_back(nidx);
|
||||
Buffer->Vertices.push_back(v);
|
||||
nidx = Buffer.Vertices.size();
|
||||
Buffer.Indices.push_back(nidx);
|
||||
Buffer.Vertices.push_back(v);
|
||||
} else
|
||||
Buffer->Indices.push_back(nidx);
|
||||
|
||||
Buffer.Indices.push_back(nidx);
|
||||
}
|
||||
|
||||
|
||||
@ -64,10 +55,10 @@ void CVolumeLightSceneNode::constructLight()
|
||||
const f32 ax = LightDimensions.X * 0.5f; // X Axis
|
||||
const f32 az = LightDimensions.Z * 0.5f; // Z Axis
|
||||
|
||||
if (Buffer)
|
||||
Buffer->drop();
|
||||
Buffer = new SMeshBuffer();
|
||||
|
||||
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));
|
||||
@ -169,13 +160,13 @@ void CVolumeLightSceneNode::constructLight()
|
||||
bz += bzStep;
|
||||
}
|
||||
|
||||
Buffer->recalculateBoundingBox();
|
||||
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.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.Material.Lighting = false;
|
||||
Buffer.Material.ZWriteEnable = false;
|
||||
}
|
||||
|
||||
|
||||
@ -185,18 +176,18 @@ void CVolumeLightSceneNode::render()
|
||||
video::IVideoDriver* driver = SceneManager->getVideoDriver();
|
||||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
||||
|
||||
driver->setMaterial(Buffer->Material);
|
||||
driver->setMaterial(Buffer.Material);
|
||||
driver->drawVertexPrimitiveList(
|
||||
Buffer->getVertices(), Buffer->getVertexCount(),
|
||||
Buffer->getIndices(), Buffer->getIndexCount() / 3 ,
|
||||
Buffer->getVertexType(), EPT_TRIANGLES);
|
||||
Buffer.getVertices(), Buffer.getVertexCount(),
|
||||
Buffer.getIndices(), Buffer.getIndexCount() / 3 ,
|
||||
Buffer.getVertexType(), EPT_TRIANGLES);
|
||||
}
|
||||
|
||||
|
||||
//! returns the axis aligned bounding box of this node
|
||||
const core::aabbox3d<f32>& CVolumeLightSceneNode::getBoundingBox() const
|
||||
{
|
||||
return Buffer->BoundingBox;
|
||||
return Buffer.BoundingBox;
|
||||
}
|
||||
|
||||
|
||||
@ -205,13 +196,13 @@ void CVolumeLightSceneNode::OnRegisterSceneNode()
|
||||
if (IsVisible)
|
||||
{
|
||||
//lie to sceneManager
|
||||
Buffer->Material.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
|
||||
Buffer->Material.MaterialTypeParam = 0.01f;
|
||||
Buffer.Material.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
|
||||
Buffer.Material.MaterialTypeParam = 0.01f;
|
||||
SceneManager->registerNodeForRendering(this, ESNRP_AUTOMATIC);
|
||||
|
||||
//restore state
|
||||
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.MaterialType = video::EMT_ONETEXTURE_BLEND;
|
||||
Buffer.Material.MaterialTypeParam = pack_texureBlendFunc( video::EBF_SRC_COLOR, video::EBF_SRC_ALPHA, video::EMFN_MODULATE_1X );
|
||||
}
|
||||
ISceneNode::OnRegisterSceneNode();
|
||||
}
|
||||
@ -224,7 +215,7 @@ void CVolumeLightSceneNode::OnRegisterSceneNode()
|
||||
//! to directly modify the material of a scene node.
|
||||
video::SMaterial& CVolumeLightSceneNode::getMaterial(u32 i)
|
||||
{
|
||||
return Buffer->Material;
|
||||
return Buffer.Material;
|
||||
}
|
||||
|
||||
|
||||
@ -286,7 +277,7 @@ ISceneNode* CVolumeLightSceneNode::clone(ISceneNode* newParent, ISceneManager* n
|
||||
newManager, ID, SubdivideU, SubdivideV, FootColour, TailColour, RelativeTranslation);
|
||||
|
||||
nb->cloneMembers(this, newManager);
|
||||
nb->Buffer->Material = Buffer->Material;
|
||||
nb->Buffer.Material = Buffer.Material;
|
||||
|
||||
nb->drop();
|
||||
return nb;
|
||||
|
@ -7,14 +7,14 @@
|
||||
#ifndef __VOLUME_LIGHT_SCENE_NODE_H_INCLUDED__
|
||||
#define __VOLUME_LIGHT_SCENE_NODE_H_INCLUDED__
|
||||
|
||||
#include "ISceneNode.h"
|
||||
#include "IVolumeLightSceneNode.h"
|
||||
#include "SMeshBuffer.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
class CVolumeLightSceneNode : public ISceneNode
|
||||
class CVolumeLightSceneNode : public IVolumeLightSceneNode
|
||||
{
|
||||
public:
|
||||
|
||||
@ -27,9 +27,6 @@ namespace scene
|
||||
const core::vector3df& rotation = core::vector3df(0,0,0),
|
||||
const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f));
|
||||
|
||||
//! destructor
|
||||
virtual ~CVolumeLightSceneNode();
|
||||
|
||||
virtual void OnRegisterSceneNode();
|
||||
|
||||
//! renders the node.
|
||||
@ -59,25 +56,25 @@ namespace scene
|
||||
|
||||
//! Creates a clone of this scene node and its children.
|
||||
virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0);
|
||||
|
||||
void setSubDivideU (const u32 inU) { SubdivideU = inU; }
|
||||
void setSubDivideV (const u32 inV) { SubdivideV = inV; }
|
||||
|
||||
u32 getSubDivideU () const { return SubdivideU; }
|
||||
u32 getSubDivideV () const { return SubdivideV; }
|
||||
|
||||
void setFootColour(const video::SColor inColouf) { FootColour = inColouf; }
|
||||
void setTailColour(const video::SColor inColouf) { TailColour = inColouf; }
|
||||
|
||||
video::SColor getFootColour () const { return FootColour; }
|
||||
video::SColor getTailColour () const { return TailColour; }
|
||||
|
||||
virtual void setSubDivideU (const u32 inU) { SubdivideU = inU; }
|
||||
virtual void setSubDivideV (const u32 inV) { SubdivideV = inV; }
|
||||
|
||||
virtual u32 getSubDivideU () const { return SubdivideU; }
|
||||
virtual u32 getSubDivideV () const { return SubdivideV; }
|
||||
|
||||
virtual void setFootColour(const video::SColor inColouf) { FootColour = inColouf; }
|
||||
virtual void setTailColour(const video::SColor inColouf) { TailColour = inColouf; }
|
||||
|
||||
virtual video::SColor getFootColour () const { return FootColour; }
|
||||
virtual video::SColor getTailColour () const { return TailColour; }
|
||||
|
||||
private:
|
||||
void addToBuffer(video::S3DVertex v);
|
||||
void constructLight();
|
||||
|
||||
SMeshBuffer * Buffer;
|
||||
|
||||
SMeshBuffer Buffer;
|
||||
|
||||
f32 LPDistance; // Distance to hypothetical lightsource point -- affects fov angle
|
||||
|
||||
u32 SubdivideU; // Number of subdivisions in U and V space.
|
||||
@ -87,7 +84,7 @@ namespace scene
|
||||
|
||||
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
|
||||
};
|
||||
@ -96,3 +93,4 @@ namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user