Mesh material

Problems building or running the engine, queries about how to use features etc.
Post Reply
Dipy
Gnoblar
Posts: 7
Joined: Thu Oct 05, 2006 4:44 pm
Contact:

Mesh material

Post by Dipy »

Hi,

I'm building sort of an editor and have several textured meshs. I implemented a per triangle mouse picking selection (thanks to one of this forums' post).
But now, I would like to have a visual feedback of what object is selected: as of now, I just toggle the showBoundingBox of the selected sceneNode. However, it should look better if I would be able to dynamically change the objects material:
I'm thinking of adding a 'semi alpha red material' on top of all my mesh's materials. But question is: how do I do such effect, and be able to revert it (when the mesh is no longer selected).

I'm quite new to Ogre, and any help or piece of code will be welcomed.

Thanks
Dipy
Gnoblar
Posts: 7
Joined: Thu Oct 05, 2006 4:44 pm
Contact:

Post by Dipy »

No one can help me, or give me some clues about where to look ?
So far, I've tried some things but it all ends with some errors like this:
Error #: 7
Function: Node::getMaterial
Description: Could not find material Core/NodeMaterial.

Thanks for any advice that could help
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

I kept an eye on this topic, and meant to create a small example of how to do this. :)

However, since you seem to be in a hurry / I seem to be slow, here is some code for you:

http://svn.berlios.de/wsvn/dsa-hl/rl/tr ... rev=0&sc=0

Look for MeshObject::setHighlighted!

Please notice that the code is from Team Pantheon's Rastullahs Lockenpracht, so give them credits. :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Dipy
Gnoblar
Posts: 7
Joined: Thu Oct 05, 2006 4:44 pm
Contact:

Post by Dipy »

However, since you seem to be in a hurry / I seem to be slow, here is some code for you:

http://svn.berlios.de/wsvn/dsa-hl/rl/tr ... rev=0&sc=0

Look for MeshObject::setHighlighted!
You were right, I'm in a hurry :).
Thanks a lot, this was what I was looking for, and it works great (except that it has some problems if calling this function to not highlight a mesh that was already not highlighted, or to highlight a mesh already highlighted). It seems to be in relation with the commented lines.

I'm curious, what does following lines do:

Code: Select all

if (ent->isHardwareAnimationEnabled())
            {
                subent->setCustomParameter(0,
                    highlight ? Vector4(1, 1, 1, 1) : Vector4(0, 0, 0, 0));
            }
Please notice that the code is from Team Pantheon's Rastullahs Lockenpracht, so give them credits. :wink:
Sure I will.
Post Reply