Tutorial 2 With cel shading. Need help.

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
nice_sallad
Posts: 7
Joined: Thu Aug 27, 2009 10:02 pm

Tutorial 2 With cel shading. Need help.

Post by nice_sallad »

Hi, so we have this big project in school.
Me and my friend are making a first person shooter and decided to use the Irrlicht Engine. We are planning on making all of the maps in .bsp format and we're also going to use cel shading so i'm messing around with tutorial 2 but i just can't get it to work!

It says: cannot convert from 'irr::scene::ISceneNode *' to 'irr::scene::IAnimatedMeshSceneNode *'

this is were it won't work.

BTW! I'm using the "ToonShader" By sio2
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=18400

Code: Select all


IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");
	IAnimatedMeshSceneNode* node =(IAnimatedMeshSceneNode*)smgr->addAnimatedMeshSceneNode(mesh); 
    //addAnimatedMeshSceneNode
	
	
	if (mesh)
			node = (IAnimatedMeshSceneNode*)smgr->addOctTreeSceneNode(mesh->getMesh(0), 0, -1, 1024);
	

	if (node)
		node->setPosition(vector3df(-1300,-144,-1249));
	    node->setMaterialFlag(EMF_LIGHTING, false);
		node->setMD2Animation (EMAT_STAND );
		node->setMaterialType((E_MATERIAL_TYPE)mtlToonShader); 
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

first of all:

IAnimatedMeshSceneNode* node =(IAnimatedMeshSceneNode*)smgr->addAnimatedMeshSceneNode(mesh);

so, you convert the IAnimtedMeshSceneNode to IAnimatedMeshSceneNode?

if (mesh)
node = (IAnimatedMeshSceneNode*)smgr->addOctTreeSceneNode(mesh->getMesh(0), 0, -1, 1024);

so, you added a node previously, now you add a new node, overwriting the pointer of the previous one

if (node)
node->setPosition(vector3df(-1300,-144,-1249));
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation (EMAT_STAND );
node->setMaterialType((E_MATERIAL_TYPE)mtlToonShader);

so, if it succeded to load the node, you set the position, but even it didn't you set its material flag, animation (for map? orz), and material type.
(remember to use { } )

oh, and yes, learn some c++

now, for the problem, i dunno which line did it fail to you, maybe the octtreescenenode line?

BUT
dont use AnimatedMeshSceneNode for map xD
use ISceneNode
Image
Image
nice_sallad
Posts: 7
Joined: Thu Aug 27, 2009 10:02 pm

Post by nice_sallad »

ok, now i've changed the code and it runs now... though the whole map is black... any ideas?? i could upload the entire code if u want to.


Code: Select all


IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");
  ISceneNode* node = 0;
   
   
   

	if (mesh)
			node = smgr->addOctTreeSceneNode(mesh->getMesh(0), 0, -1, 1024);	
			node->setMaterialType((E_MATERIAL_TYPE)mtlToonShader);
			node->setMaterialFlag(EMF_LIGHTING, false);
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Either the shader is broken/unsupported or the textures don't work as expected. Or other reasons, it's really hard to guess without seeing more core, screenshots, console output etc. Try to make a simpler version which does not use Octree and bsp, but a .x mesh or .obj.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

nice_sallad wrote:

Code: Select all

	if (mesh)
			node = smgr->addOctTreeSceneNode(mesh->getMesh(0), 0, -1, 1024);	
			node->setMaterialType((E_MATERIAL_TYPE)mtlToonShader);
			node->setMaterialFlag(EMF_LIGHTING, false);
This is still wrong dude, as b@z pointed out before... It will crash if the mesh is NULL... Seriously learn C++ properly otherwise your code will probably never work properly as it'll be riddled with these oversights.
Image Image Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, actually the test for mesh is there, it just needs another test for node after the call. But as it's pretty unlikely that this will fail here, the actual problem is a very different one...
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Aye technically, certainly the node should be checked for!
Image Image Image
nice_sallad
Posts: 7
Joined: Thu Aug 27, 2009 10:02 pm

Post by nice_sallad »

Personally i think the problem is that i'm using a .bsp map. It's just a solid object. The cel shader is made for models.
What mapeditor should i use if i want all object to load as one so i can apply the cel shader individualy?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You can also apply the cel shader to mesh buffers in the bsp node. YOu just have to access the materials in the meshbuffers instead of calling the change method on the whole node.
nice_sallad
Posts: 7
Joined: Thu Aug 27, 2009 10:02 pm

Post by nice_sallad »

hybrid wrote:You can also apply the cel shader to mesh buffers in the bsp node. YOu just have to access the materials in the meshbuffers instead of calling the change method on the whole node.
Sounds great but how do i do it?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Check the scene node api. There's a way to enumerate materials and meshbuffers (the latter only in mesh scene nodes of course, where you have to cast your base ISceneNode pointer first).
nice_sallad
Posts: 7
Joined: Thu Aug 27, 2009 10:02 pm

Post by nice_sallad »

Lets jus say that you were doing this. How would you add the cel shading effect to an entire map? In this case the maps in the game will probably be made with LightWave 3D but lets say that we're trying to cel shade an entire quake 3 map, a .bsp file. How would you do it?
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

applying a cel shader material to each material in the scene node.
nice_sallad
Posts: 7
Joined: Thu Aug 27, 2009 10:02 pm

Post by nice_sallad »

I was thinking of loading each item individually but wouldn't that be messy and lag?

If that's what you said. But i don't think that's possible with a .bsp map so should i just finish my map in LightWave3D and then load each object on the map as a seperate model?
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

Check the scene node api. There's a way to enumerate materials and meshbuffers (the latter only in mesh scene nodes of course, where you have to cast your base ISceneNode pointer first)
You dont seem to be looking for help you seem to be looking for someone to do the work for you? theres been more than enough help here so far, just try some of the proposed solutions
Post Reply