The discrepancy between the upload and create node.

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.
Post Reply
svedach
Posts: 20
Joined: Fri Oct 14, 2016 12:22 pm

The discrepancy between the upload and create node.

Post by svedach »

I made in Blender cube of material retained in .dae format. Uploaded in Irrlich, I received the following image:
Image


Then I created a cube in Irrlicht addCubeSceneNode(1), awarded him the material from the temporary node generated from .dae file and get a completely different picture:
Image

Why does the color and reflection of the cube so different? The material used is the same.

The CODE:

Code: Select all

scene::IAnimatedMesh*       Mesh = g_GraphicalWorld->SceneManager()->getMesh("Resources/IndividCubePart.dae");
    scene::ISceneNode*          TempNode    = g_GraphicalWorld->SceneManager()->addMeshSceneNode(Mesh);
    video::SMaterial            Material    = TempNode->getMaterial(0);
    _Node = g_GraphicalWorld->SceneManager()->addCubeSceneNode(1);//g_GraphicalWorld->SceneManager()->addMeshSceneNode(Mesh);
 
    _Node->setMaterialFlag(video::EMF_FOG_ENABLE, true);
    _Node->setMaterialFlag(video::EMF_LIGHTING, true);
CuteAlien
Admin
Posts: 9634
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: The discrepancy between the upload and create node.

Post by CuteAlien »

My guess would be that the mesh vertices have different colors.
Try to add:

Code: Select all

 
g_GraphicalWorld->SceneManager()-> getMeshManipulator()->setVertexColors (_Node->getMesh(), static_cast<irr::video::S3DVertex*>(Mesh->getMeshBuffer(0)->getVertices())[0].Color );
 
(Note: I didn't compile, so maybe I got something wrong. The idea is - get the first vertex of the first meshbuffer in the Mesh and copy it's color).
Assumes mesh has vertex-type EVT_STANDARD.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
svedach
Posts: 20
Joined: Fri Oct 14, 2016 12:22 pm

Re: The discrepancy between the upload and create node.

Post by svedach »

Thanks for the answer. Poprobovol your proposed solution, here's what happened:
Image
CuteAlien
Admin
Posts: 9634
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: The discrepancy between the upload and create node.

Post by CuteAlien »

Hm, lighting very different. Not quite certain - but only thing I can think of right now is that one cube has maybe less vertices shared. So in the Irrlicht cube case it tries to interpolate lighting more over the corner or so. Could be Blender even has one material per side (Irrlicht uses one for the whole cube I think). In short - there's different ways to make a cube...
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
svedach
Posts: 20
Joined: Fri Oct 14, 2016 12:22 pm

Re: The discrepancy between the upload and create node.

Post by svedach »

Thanks for the reply. Is it possible to cube created in Irrlicht display as created in Blender?
CuteAlien
Admin
Posts: 9634
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: The discrepancy between the upload and create node.

Post by CuteAlien »

Can you upload that cube-file you have so I can take a look at it? I mean - you can obviously have the same look as it is just a description of geometry and that can be created by code as well. Thought maybe not with cubescenenode. Could be to have exact same result you have to create your own cube. Or just use that file - why create it by hand anyway?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
svedach
Posts: 20
Joined: Fri Oct 14, 2016 12:22 pm

Re: The discrepancy between the upload and create node.

Post by svedach »

Thank you for your help. I do not want to get the exact geometry of the cube, I want the same display. I use a combination of Irrlicht and Bullet Physics to simulate of neural networks learning environment (do not count them for advertising:https://www.youtube.com/channel/UCM773C ... MFpvrVTO2A). I wanted to make a beautiful display of objects in the world, and to do so in Irrlihte difficult.
That model cubes that I use:
http://my-files.ru/ltvq2h
Can you tell me how to simulate the capsule in Irrlihte?
CuteAlien
Admin
Posts: 9634
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: The discrepancy between the upload and create node.

Post by CuteAlien »

The cube you send me isn't just a cube. It's a cube with round corners:
Image
If you want to use that - then just export it (as .dae or as .obj file) and use that one in Irrlicht.
You can't make a real cube have same lighting results as an object which isn't a real cube. Lighting is depending on vertices and those are not the same.

Thought it might look more similar if you disable GouraudShading in the SMaterial.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
svedach
Posts: 20
Joined: Fri Oct 14, 2016 12:22 pm

Re: The discrepancy between the upload and create node.

Post by svedach »

Thank you so much. Taking into account the differences in the geometry of the cube, I got the same display effect. You really helped me.
Post Reply