Code: Select all
// create the sun node as a sphere scene node.
scene::IMeshSceneNode* sunMeshNode = smgr->addSphereSceneNode(1, 16, smgr->getRootSceneNode());
sunMeshNode->setMaterialTexture(0, driver->getTexture("media/sun/mesh.png"));
sunMeshNode->setMaterialType(video::EMT_SOLID);
sunMeshNode->setMaterialFlag(video::EMF_LIGHTING, false);
sunMeshNode->setScale(core::vector3d<f32>(600, 600, 600));
sunMeshNode->setPosition(core::vector3df(8000, 4000, 750));
// add a billboard to the sun node
//scene::IBillboardSceneNode* sunBillboardNode = smgr->addBillboardSceneNode(sunMeshNode);
//sunBillboardNode->setMaterialTexture(0, driver->getTexture("media/sun/sun.png"));
//sunBillboardNode->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
//sunBillboardNode->setMaterialFlag(video::EMF_LIGHTING, false);
//sunBillboardNode->setSize(core::dimension2d<f32>(4000, 4000));
// add the lensflare to the sun
scene::CLensFlareSceneNode* lensFlareNode = new scene::CLensFlareSceneNode(sunMeshNode, smgr);
lensFlareNode->setMaterialTexture(0, driver->getTexture("media/lensflare/flare.png"));
// create a follow camara animator for the sun
//scene::CSceneNodeAnimatorFollowCamera* sunAnim = new scene::CSceneNodeAnimatorFollowCamera(core::vector3df(-8000, 4000, 750));
//sunMeshNode->addAnimator(sunAnim);
//sunAnim->drop();
// some lenses, halos and circles
lensFlareNode->getFlareData().clear();
lensFlareNode->getFlareData().push_back(scene::SFlareData(scene::EFT_LENS, -0.15f, 0.15f, video::SColor(255, 60, 60, 90)));
lensFlareNode->getFlareData().push_back(scene::SFlareData(scene::EFT_HALO, -0.3f, 0.3f, video::SColor(120, 60, 255, 180)));
lensFlareNode->getFlareData().push_back(scene::SFlareData(scene::EFT_HALO, -0.4f, 0.2f, video::SColor(220, 80, 80, 98)));
lensFlareNode->getFlareData().push_back(scene::SFlareData(scene::EFT_CIRCLE, -0.45f, 0.1f, video::SColor(220, 80, 80, 85)));
lensFlareNode->getFlareData().push_back(scene::SFlareData(scene::EFT_RING, -0.42f, 0.3f, video::SColor(180, 60, 255, 110)));
then if you add a build in animator
Code: Select all
scene::ISceneNodeAnimator * sunAnim = smgr->createFlyCircleAnimator(
core::vector3df(8000, 4000, 750), 5000);
new scene::CSceneNodeAnimatorFollowCamera(core::vector3df(-8000, 4000, 750));
sunMeshNode->addAnimator(sunAnim);
sunAnim->drop();
I hope that you get the same behaviour.
a point that is important are the two lines
Code: Select all
// update strength of the lensflare
if(occlusionQueryResult!= 0xffffffff)
lensFlareNode->setStrength(f32(occlusionQueryResult)/8000.f);
8000 means that nearly 8000 pixels of the sphere are visible, if it is not occluded. If you don't have a constant distance to the lensflare (or the helper mesh) you have to adapt this value. The more distance you have got between the camera and the helper mesh (sphere) the less pixels are visible in case of no occlusion.
I hope this will help you...