LensFlareSceneNode

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
gammaray
Posts: 23
Joined: Wed Jun 28, 2006 9:38 pm

LensFlareSceneNode

Post by gammaray »

I've modified the CLensFlareSceneNode (found somewhere on this forum a while back, also available with Acki's IrrExtensions) to work with irrlicht 1.3.1 - just thought someone might find it useful:)

You can grab the code here: http://satfilm.net.pl/~gammaray/CLensFlareSceneNode.zip
G3LO
Posts: 16
Joined: Mon Aug 20, 2007 10:37 am
Location: Poland

Post by G3LO »

Thanks,
be sure i`ll use it :D
is a problem integrating Acki`s extensions into irr 1.3.1?, because i`m thinking about using his custom bones nodes (or something like that) in irr 1.3.1
h4ck d4 5y5t3m
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

G3LO wrote:Thanks,
be sure i`ll use it :D
is a problem integrating Acki`s extensions into irr 1.3.1?, because i`m thinking about using his custom bones nodes (or something like that) in irr 1.3.1
I recommend to use the new skinnedmesh method from the SVN for bones.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
G3LO
Posts: 16
Joined: Mon Aug 20, 2007 10:37 am
Location: Poland

Post by G3LO »

I recommend to use the new skinnedmesh
I read a bit about it, could you tell me if this branch is complete or at least is support for .X files avalivable?
Also, is there any possibility to get some examples of basic usage of bones (source files)?
h4ck d4 5y5t3m
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The branch is basically feature complete. All mesh loaders are supported and should work as expected. It just needs more testing. So the more people try it and report back problems as well as success stories, the sooner it will be merged back into the core library.
Using the custom bones extension does not make sense anymore. There is no support for the latest Irrlicht releases (although it might be simple to update) and the new animation system provides even more features.
koller202
Posts: 143
Joined: Tue May 08, 2007 4:53 am
Location: Thailand

Post by koller202 »

can u give me example how to use it ?
________
Pot news
Last edited by koller202 on Thu Feb 17, 2011 1:15 am, edited 1 time in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Compile it and link your app against the new dll. The API documentation can be created from the sources. Or do you mean the lensFlare?
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

koller202 wrote:can u give me example how to use it ?
For skinned mesh its very easy just
ISceneNode bone = myNode->getBoneSceneNode("BoneName");
bone->setRotation,Position, etc, etc...
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
G3LO
Posts: 16
Joined: Mon Aug 20, 2007 10:37 am
Location: Poland

Post by G3LO »

Litte example

Code: Select all

int main()
{
	IrrlichtDevice *device =
		createDevice(EDT_OPENGL, dimension2d<s32>(640, 480), 16,
			false, false, false, 0);
			
	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();

	IAnimatedMesh* mesh = smgr->getMesh("test.x");
	IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode ( mesh );

    IBoneSceneNode* hand;
    
	if (node)
	{
	    node->setJointMode (3); // 2 works too
        hand = node->getJointNode ("Bone09");

		node->setMaterialFlag(EMF_LIGHTING, false);
		node->setFrameLoop(24, 47);
	}

	smgr->addCameraSceneNodeFPS();

	while(device->run())
	{
        driver->beginScene(true, true, SColor(0,200,200,200));

        node->animateJoints();
        hand->setRotation ( vector3df (0,90,0) );

		smgr->drawAll();

		driver->endScene();
	}

	device->drop();

	return 0;
}
Maybe it`s little puzzed, but i hope you`ll get general idea.
I came to this experimantig so it may be not optimal.
h4ck d4 5y5t3m
koller202
Posts: 143
Joined: Tue May 08, 2007 4:53 am
Location: Thailand

Post by koller202 »

thank you G3LO

i want example about how to use CLensFlareSceneNode
i tried to use it but error

thx
________
NOVITEC ROSSO
Last edited by koller202 on Thu Feb 17, 2011 1:15 am, edited 1 time in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You should just create a new lens flare scene node. By passing it the scene manager it becomes added to it. Then it should render correctly.
koller202
Posts: 143
Joined: Tue May 08, 2007 4:53 am
Location: Thailand

Post by koller202 »

thx hybird
i didn t know why

Code: Select all

#include "CLensFlareSceneNode.h"

Code: Select all

CLensFlareSceneNode *ab = new CLensFlareSceneNode(smgr->getRootSceneNode(),smgr,666,core::vector3df(100,100,100));
it error 102

Code: Select all

/*
This tutorial will briefly show how to use the terrain renderer of Irrlicht. It will also
show the terrain renderer triangle selector to be able to do collision detection with
terrain.

Note that the Terrain Renderer in Irrlicht is based on Spintz' GeoMipMapSceneNode, lots 
of thanks go to him.
DeusXL provided a new elegant simple solution for building larger area on small heightmaps
-> terrain smoothing.
In the beginning there is nothing special. We include the needed header files and create
an event listener to listen if the user presses the 'W' key so we can switch to wireframe
mode and if he presses 'D' we toggle to material between solid and detail mapped.
*/
#include <irrlicht.h>
#include <iostream>
#include "CLensFlareSceneNode.h"

using namespace irr;
using namespace core;
using namespace video;
using namespace gui;



#pragma comment(lib, "Irrlicht.lib")

class MyEventReceiver : public IEventReceiver
{
public:

	MyEventReceiver(scene::ISceneNode* terrain)
	{
		// store pointer to terrain so we can change its drawing mode
		Terrain = terrain;
	}

	bool OnEvent(SEvent event)
	{
		// check if user presses the key 'W' or 'D'
		if (event.EventType == irr::EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown)
		{
			switch (event.KeyInput.Key)
			{
			case irr::KEY_KEY_W: // switch wire frame mode
				Terrain->setMaterialFlag(video::EMF_WIREFRAME, !Terrain->getMaterial(0).Wireframe);
				Terrain->setMaterialFlag(video::EMF_POINTCLOUD, false);
				return true;
			case irr::KEY_KEY_P: // switch wire frame mode
				Terrain->setMaterialFlag(video::EMF_POINTCLOUD, !Terrain->getMaterial(0).PointCloud);
				Terrain->setMaterialFlag(video::EMF_WIREFRAME, false);
				return true;
			case irr::KEY_KEY_D: // toggle detail map
				Terrain->setMaterialType(
					Terrain->getMaterial(0).MaterialType == video::EMT_SOLID ? 
					video::EMT_DETAIL_MAP : video::EMT_SOLID);
				return true;
			}
		}

		return false;
	}

private:
	scene::ISceneNode* Terrain;
};


/*
The start of the main function starts like in most other example. We ask the user
for the desired renderer and start it up.
*/
int main()
{
	// let user select driver type

	video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D9;

	printf("Please select the driver you want for this example:\n"\
		" (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\
		" (d) Software Renderer\n (e) Burning's Software Renderer\n"\
		" (f) NullDevice\n (otherKey) exit\n\n");

	char i;
	std::cin >> i;

	switch(i)
	{
		case 'a': driverType = video::EDT_DIRECT3D9;break;
		case 'b': driverType = video::EDT_DIRECT3D8;break;
		case 'c': driverType = video::EDT_OPENGL;   break;
		case 'd': driverType = video::EDT_SOFTWARE; break;
		case 'e': driverType = video::EDT_BURNINGSVIDEO;break;
		case 'f': driverType = video::EDT_NULL;     break;
		default: return 1;
	}	

	// create device

	IrrlichtDevice* device = createDevice(driverType, core::dimension2d<s32>(640, 480));

	if (device == 0)
		return 1; // could not create selected driver.

	
	/*
	First, we add standard stuff to the scene: A nice irrlicht engine
	logo, a small help text, a user controlled camera, and we disable
	the mouse cursor.
	*/   

	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();
	gui::IGUIEnvironment* env = device->getGUIEnvironment();

	driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);

	// add irrlicht logo
	env->addImage(driver->getTexture("../../media/irrlichtlogo2.png"),
		core::position2d<s32>(10,10));

	//set other font
	env->getSkin()->setFont(env->getFont("../../media/fontlucida.png"));

	// add some help text
	gui::IGUIStaticText* text = env->addStaticText(
		L"Press 'W' to change wireframe mode\nPress 'D' to toggle detail map",
		core::rect<s32>(10,440,250,475), true, true, 0, -1, true);

	// add camera
	scene::ICameraSceneNode* camera = 
		smgr->addCameraSceneNodeFPS(0,100.0f,1200.f);

	camera->setPosition(core::vector3df(1900*2,255*2,3700*2));
	camera->setTarget(core::vector3df(2397*2,343*2,2700*2));
	camera->setFarValue(12000.0f);

	// disable mouse cursor
	device->getCursorControl()->setVisible(false);

	/*
	Here comes the terrain renderer scene node: We add it just like any 
	other scene node to the scene using ISceneManager::addTerrainSceneNode(). 
	The only parameter we use is a file name to the heightmap we use. A heightmap
	is simply a gray scale texture. The terrain renderer loads it and creates 
	the 3D terrain from it.
	To make the terrain look more big, we change the scale factor of it to (40, 4.4, 40).
	Because we don't have any dynamic lights in the scene, we switch off the lighting,
	and we set the file terrain-texture.jpg as texture for the terrain and 
	detailmap3.jpg as second texture, called detail map. At last, we set
	the scale values for the texture: The first texture will be repeated only one time over 
	the whole terrain, and the second one (detail map) 20 times. 
	*/

	// add terrain scene node
	scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode( 
		"../../media/terrain-heightmap.bmp",
		0,										// parent node
		-1,										// node id
		core::vector3df(0.f, 0.f, 0.f),			// position
		core::vector3df(0.f, 0.f, 0.f),			// rotation
		core::vector3df(40.f, 4.4f, 40.f),		// scale
		video::SColor ( 255, 255, 255, 255 ),	// vertexColor,
		5,										// maxLOD
		scene::ETPS_17,							// patchSize
		4										// smoothFactor
		);

	terrain->setMaterialFlag(video::EMF_LIGHTING, false);

	terrain->setMaterialTexture(0, driver->getTexture("../../media/terrain-texture.jpg"));
	terrain->setMaterialTexture(1, driver->getTexture("../../media/detailmap3.jpg"));
	
	terrain->setMaterialType(video::EMT_DETAIL_MAP);

	terrain->scaleTexture(1.0f, 20.0f);
	//terrain->setDebugDataVisible ( true );

	/*
	To be able to do collision with the terrain, we create a triangle selector.
	If you want to know what triangle selectors do, just take a look into the 
	collision tutorial. The terrain triangle selector works together with the
	terrain. To demonstrate this, we create a collision response animator 
	and attach it to the camera, so that the camera will not be able to fly 
	through the terrain.
	*/

	// create triangle selector for the terrain	
	scene::ITriangleSelector* selector
		= smgr->createTerrainTriangleSelector(terrain, 0);
	terrain->setTriangleSelector(selector);
	selector->drop();

	// create collision response animator and attach it to the camera
	scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
		selector, camera, core::vector3df(60,100,60),
		core::vector3df(0,0,0), 
		core::vector3df(0,50,0));
	camera->addAnimator(anim);
	anim->drop();

	/*
	To make the user be able to switch between normal and wireframe mode, we create
	an instance of the event reciever from above and let Irrlicht know about it. In 
	addition, we add the skybox which we already used in lots of Irrlicht examples.
	*/

	// create event receiver
	MyEventReceiver receiver(terrain);
	device->setEventReceiver(&receiver);

   	// create skybox
	driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);

	smgr->addSkyBoxSceneNode(
		driver->getTexture("../../media/irrlicht2_up.jpg"),
		driver->getTexture("../../media/irrlicht2_dn.jpg"),
		driver->getTexture("../../media/irrlicht2_lf.jpg"),
		driver->getTexture("../../media/irrlicht2_rt.jpg"),
		driver->getTexture("../../media/irrlicht2_ft.jpg"),
		driver->getTexture("../../media/irrlicht2_bk.jpg"));

	driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);


	/*
	That's it, draw everything. Now you know how to use terrain in Irrlicht.
	*/

	int lastFPS = -1;
	
	
//	terrain->setVisible(false);
	//CLensFlareSceneNode *test;
	CLensFlareSceneNode *ab = new CLensFlareSceneNode(smgr->getRootSceneNode(),smgr,666,core::vector3df(100,100,100));
	while(device->run())
	if (device->isWindowActive())
	{
		driver->beginScene(true, true, 0 );

		smgr->drawAll();
		env->drawAll();

		driver->endScene();

		// display frames per second in window title
		int fps = driver->getFPS();
		if (lastFPS != fps)
		{
			core::stringw str = L"Terrain Renderer - Irrlicht Engine [";
			str += driver->getName();
			str += "] FPS:";
			str += fps;
			// Also print terrain height of current camera position
			// We can use camera position because terrain is located at coordinate origin
			str += " Height: ";
			str += terrain->getHeight(camera->getAbsolutePosition().X, camera->getAbsolutePosition().Z);

			device->setWindowCaption(str.c_str());
			lastFPS = fps;
		}
	}

	device->drop();
	
	return 0;
}
________
Alaska medical marijuana dispensary
Last edited by koller202 on Thu Feb 17, 2011 1:15 am, edited 1 time in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I don't know what 102 means. You have to post the Message, not the number
koller202
Posts: 143
Joined: Tue May 08, 2007 4:53 am
Location: Thailand

Post by koller202 »

i can compile already:D

Code: Select all

CLensFlareSceneNode *ab = new CLensFlareSceneNode(smgr->getRootSceneNode(),smgr,666,core::vector3df(100,1000,100));
but where lensflare in my screen i cannot see lenflare

Code: Select all

vector3df(100,1000,100))

i set camere target to this pos but i can t see

thank you
________
New Jersey Marijuana Dispensary
Last edited by koller202 on Thu Feb 17, 2011 1:15 am, edited 1 time in total.
gammaray
Posts: 23
Joined: Wed Jun 28, 2006 9:38 pm

Re:

Post by gammaray »

In order to see the the lens flare you need to set a texture for the node. I think there's a texture in the zip I provided.

Code: Select all

ILensFlareSceneNode* flare = new CLensFlareSceneNode(0, smgr, -1, vector3df(0,0,0));

flare->setMaterialTexture(0, driver->getTexture("../path/to/texture"));

// or, an alternative solution (on my system setTexture used on the flare node sometimes casues a crash)
// flare->getMaterial(0).Textures[0] = driver->getTexture("../path/to/texture")
Post Reply