Some questions/suggestions: Would it be better to use MaterialPtrs instead of Material*s? Also I think it would be best to allow direct access to the temporary material, too, so the classes can be used for more than transparency. Then the setTransparency() et al functions would just be utility functions.
Dynamic Adjusting of transparency for geometry [solved]
-
DWORD
- OGRE Retired Moderator

- Posts: 1365
- Joined: Tue Sep 07, 2004 12:43 pm
- Location: Aalborg, Denmark
Nice. 
Some questions/suggestions: Would it be better to use MaterialPtrs instead of Material*s? Also I think it would be best to allow direct access to the temporary material, too, so the classes can be used for more than transparency. Then the setTransparency() et al functions would just be utility functions.
Some questions/suggestions: Would it be better to use MaterialPtrs instead of Material*s? Also I think it would be best to allow direct access to the temporary material, too, so the classes can be used for more than transparency. Then the setTransparency() et al functions would just be utility functions.
-
Kencho
- OGRE Retired Moderator

- Posts: 4011
- Joined: Fri Sep 19, 2003 6:28 pm
- Location: Burgos, Spain
- x 2
Yeah, I thought about leaving them open for additional functionality too, though I haven't found a way this could be useful (unless you want to do different skins, like the team colour of a football player).
About MaterialPtr, I'm not good with Ptrs, but I'll try.
think that I've done this in about two hours, just after lunching, so it's still "young"
About MaterialPtr, I'm not good with Ptrs, but I'll try.
think that I've done this in about two hours, just after lunching, so it's still "young"
-
DWORD
- OGRE Retired Moderator

- Posts: 1365
- Joined: Tue Sep 07, 2004 12:43 pm
- Location: Aalborg, Denmark
I could think of some. The materials are there, so if not for anything else, then just to follow the nice spirit of Ogre where everything is adjustable.Kencho wrote:Yeah, I thought about leaving them open for additional functionality too, though I haven't found a way this could be useful (unless you want to do different skins, like the team colour of a football player).
I don't know if it's necessary. But it's not that different, just be sure to pass around const MaterialPtr& to avoid the refcount overhead.Kencho wrote:About MaterialPtr, I'm not good with Ptrs, but I'll try.
Fair enough.Kencho wrote:think that I've done this in about two hours, just after lunching, so it's still "young"
-
BEM
- Gnoblar
- Posts: 18
- Joined: Thu Dec 08, 2005 11:40 am
Handy! (some possible bugs to report also)
Hi! Im still new to Ogre, tell me if anything I am doing sounds untidy
I have just used these classes to temporarily make an object transparent during a mouse drag:
BEGINNING DRAG:
currEntity = (Entity*)itr->movable;
currMaterial = new EntityMaterialInstance(currEntity);
//currMaterial->setMaterialName("Examples/RustySteel");
//currMaterial->setSceneBlending (SBT_TRANSPARENT_ALPHA);
currMaterial->setTransparency (0.5f);
ENDING DRAG:
delete currMaterial;
--------------------
This works well on the default ninja mesh, but for some reason does not work on the robot mesh. It has something to do with material, because if I replace the robot material with RustySteel, it works fine.
--------------------
Compile problem on VisualStudio05:
I had to comment out line in subEntryMaterialInstance constructor
//MaterialInstance::MaterialInstance ();
(it complained you could not call constructor of an abstract class)
possible bug (perhaps from my edit?):
After setting a new material, this was not reversed upon deleting the temporary material
I have just used these classes to temporarily make an object transparent during a mouse drag:
BEGINNING DRAG:
currEntity = (Entity*)itr->movable;
currMaterial = new EntityMaterialInstance(currEntity);
//currMaterial->setMaterialName("Examples/RustySteel");
//currMaterial->setSceneBlending (SBT_TRANSPARENT_ALPHA);
currMaterial->setTransparency (0.5f);
ENDING DRAG:
delete currMaterial;
--------------------
This works well on the default ninja mesh, but for some reason does not work on the robot mesh. It has something to do with material, because if I replace the robot material with RustySteel, it works fine.
--------------------
Compile problem on VisualStudio05:
I had to comment out line in subEntryMaterialInstance constructor
//MaterialInstance::MaterialInstance ();
(it complained you could not call constructor of an abstract class)
possible bug (perhaps from my edit?):
After setting a new material, this was not reversed upon deleting the temporary material
-
alanic
- Gnoblar
- Posts: 14
- Joined: Wed Dec 05, 2007 9:40 pm
*digs up the old post*
Neat stuff. I fixed a little error in the wiki page about how base class constructor is called.
Beside setTransparency, I added setAmbient, setSpecular and setDiffuse in my local copy so that objects can also be tinted easily at the same time. I just called the same methods of the material copy. I don't know if there is a better way to do it through the passes but tinting would definitely be useful to others so maybe we should add it.
Neat stuff. I fixed a little error in the wiki page about how base class constructor is called.
Beside setTransparency, I added setAmbient, setSpecular and setDiffuse in my local copy so that objects can also be tinted easily at the same time. I just called the same methods of the material copy. I don't know if there is a better way to do it through the passes but tinting would definitely be useful to others so maybe we should add it.
-
mickeyren
- Greenskin
- Posts: 142
- Joined: Thu Dec 18, 2008 11:32 am
Re: Dynamic Adjusting of transparency for geometry [solved]
I was wondering if the classes works well for everyone.
So far, it doesn't work well with the robot and the ogrehead.
It does fade the ogrehead out but not correctly - eg, there are artifacts.
The robot - it doesn't fade the robot at all, though once you set its transparency, its hands/body would have incorrect depth.
Would appreciate if someone can tell me if i can change something or try something to make it work.
THanks.
So far, it doesn't work well with the robot and the ogrehead.
It does fade the ogrehead out but not correctly - eg, there are artifacts.
The robot - it doesn't fade the robot at all, though once you set its transparency, its hands/body would have incorrect depth.
Would appreciate if someone can tell me if i can change something or try something to make it work.
THanks.
-
jacmoe
- OGRE Retired Moderator

- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
Re: Dynamic Adjusting of transparency for geometry [solved]
Just keep in mind that the Ogre head consists of four submeshes because it has four materials, which gives 4 subentities.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
-
mickeyren
- Greenskin
- Posts: 142
- Joined: Thu Dec 18, 2008 11:32 am
Re: Dynamic Adjusting of transparency for geometry [solved]
Yes, but I was under the impression that the classes also takes care of all sub entities.
Anyone has an idea why if the classes was applied to the robots it does not work?
Anyone has an idea why if the classes was applied to the robots it does not work?
-
McSwan
- Greenskin
- Posts: 122
- Joined: Tue May 11, 2004 5:40 am
- x 1
Re: Dynamic Adjusting of transparency for geometry [solved]
setOpacity / color etc. ought to be made part of the core engine and handled in there. I think most users would want this.
