Material questions

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
troopa
Posts: 28
Joined: Thu Mar 23, 2006 11:00 am
Location: Toulouse (France)
Contact:

Material questions

Post by troopa »

I would like to have some information about material because I have many problem with it and I didn't found many documentation on this subject (correct me if I 'm wrong)

1) First, I have a custom scene node and I would like to make it transparent belong the vertex alpha value, so I choose the "EMT_TRANSPARENT_VERTEX_ALPHA" material type and it works BUT my problem is that writing into the Zbuffer is disable and there is "problem of deep" between my nodes. I'll try to set "true" the "Material.Zbuffer" and "Material.ZWriteEnable" but it doesn't work ....

2) I have a mesh that I made on blender and that I export into ".obj". It is loaded correctly and I would like to make it transparent and give him a color. How can I made that.

3) Finally, One side of the skybox (I picked it from the example) is blank (white). I have checked the path. I don't understand because the skybox has already works. Maybe, it's a side effect.

Thanks in advance...
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

1) are you registering your custom node as transparent in it's OnPreRender?
Have a look at CMeshSceneNode.cpp for an example.

2) do you mean vertex colours? try IMeshManipulator::setVertexColors()

3) no idea. does irrlicht say it has loaded the texture in the console window?
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
troopa
Posts: 28
Joined: Thu Mar 23, 2006 11:00 am
Location: Toulouse (France)
Contact:

Post by troopa »

thanks for your reply and sorry to answer so late but I have no time this last days.

1) I register the node as transparent but I have the same problem...

Code: Select all

void TrajectoireSceneNode::OnPreRender()
{
	if (IsVisible)
		SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT);
	//	SceneManager->registerNodeForRendering(this);

	ISceneNode::OnPreRender();
}
2) It works fine !! but I got a problem when I quit the program. Something like a segmentation fault. It comes from here because It's not happen when I cut the following code source :

Code: Select all

scene::IMesh* arrow = device->getSceneManager()->getMesh("./ressources/arrow.obj")->getMesh(1); 
	if (!arrow) 
	{
		printf("incorrect filename\n"); 
		return 1; 
	}
	smgr->getMeshManipulator()->setVertexColors(arrow,video::SColor(127,0,255,0)); 
	node = device->getSceneManager()->addMeshSceneNode(arrow);
	//arrow->drop();
	node->setName((const wchar_t*)"arrow" );

	
	// set default material properties
	node->setPosition(core::vector3df(2900,1400,3200));
	node->setRotation(core::vector3df(-90,0,0)); 
	node->setScale(core::vector3df(100,100,100));
	//node->setMaterialType(video::EMT_SOLID);
	node->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA); 
	node->setMaterialFlag(video::EMF_LIGHTING, false);
I have no error when I use a IAnimatedMesh but my mesh isn't animate so I would like to use a IMesh. I think it comes from a dropped node or something but in this case. Do I have to drop the IMesh arrow ?

3) Irrlicht says it has loaded all oh the needed texture. I seems to be a bug, isn't it ?
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

To fix #2, do this -

Code: Select all

scene::IAnimatedMesh* mainArrowMesh = device->getSceneManager()->getMesh("./ressources/arrow.obj");
scene::IMesh* subArrowMesh = mainArrowMesh->getMesh(1);
mainArrowMesh->grab();
Then when you are done with both meshes, call drop on the mainArrowMesh.

Or, you can use the createMeshCopy function of CMeshManipulator to create a copy of the getMesh(1).
Image
troopa
Posts: 28
Joined: Thu Mar 23, 2006 11:00 am
Location: Toulouse (France)
Contact:

Post by troopa »

Thanks !! it works but I don't understand why. Why sould have to grab the IAnimatedMesh object because I never drop it by myself. I did not understand well the mechanism of the drop and grab methods and the methods description into the API is not enough for me. I would like to know exactly when and where I have to drop and grab my object.

Is there a tutorial or wiki stuff to a newbie like me who don't want have memory leaks...
Post Reply