It's far from 100% and could still use some work, but it's far enough along for our purposes, so I figured to post it for others.
Feel free to use it / modify it and improve it. It's been tested in Mac and Windows and against the latest SVN head.
I started with CCubeSceneNode frame and went from there.
1) in ISceneManager.h add the following just before addCubeSceneNode
Code: Select all
//! adds Volume Lighting Scene Node.
//! the returned pointer must not be dropped.
virtual ISceneNode* addVolumeLightSceneNode(ISceneNode* parent=0, s32 id=-1,
const s32 subdivU = 32, const s32 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)) = 0;
Code: Select all
//! adds Volume Lighting Scene Node.
//! the returned pointer must not be dropped.
virtual ISceneNode* addVolumeLightSceneNode(ISceneNode* parent=0, s32 id=-1,
const s32 subdivU = 32, const s32 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));
Code: Select all
#include "CVolumeLightSceneNode.h"
Code: Select all
//! adds Volume Lighting Scene Node.
//! the returned pointer must not be dropped.
ISceneNode* CSceneManager::addVolumeLightSceneNode(ISceneNode* parent, s32 id,
const s32 subdivU, const s32 subdivV,
const video::SColor foot,
const video::SColor tail,
const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale)
{
if (!parent)
parent = this;
ISceneNode* node = new CVolumeLightSceneNode(parent, this, id, subdivU, subdivV, foot, tail, position, rotation, scale);
node->drop();
return node;
}
To use I used the meshViewer to test it. Add the following code, I added it just before the main loop to draw everything.
Code: Select all
//test for volume lighting
scene::ISceneNode * n = smgr->addVolumeLightSceneNode(NULL, -1,
32, //Sub Divid U
32, //Sub Divid V
video::SColor(30, 255, 255, 255), //foot colour
video::SColor(0, 255, 0, 0) //tail colour
);
if (n) {
n->setScale(core::vector3df(66.0f, 75.0f, 66.0f));
video::SMaterial& mat = n->getMaterial(0);
mat.setTexture(0, smgr->getVideoDriver()->getTexture("lightFalloff.png"));
}
Code Links
http://shadow.krabbit.com/varmint/volLi ... neNode.cpp
http://shadow.krabbit.com/varmint/volLi ... ceneNode.h
test image
http://shadow.krabbit.com/varmint/volLi ... alloff.png
enjoy