SetCustomParameter for static geometry


26-04-2011 09:10:47

I have been trying to find a solution for a while, however it seems like the problem is in Mogre.
I need to set custom parameter for static geometry to pass a value to a pixel shader. The only way (please correct me if I am wrong) I have found (in Ogre forums) is to do this:
-> region.GetLodIterator()
---> lodBucket.GetMaterialIterator()
-----> material.GetGeometryIterator()
and for every geometrybucket in geometryiterator call setcustomparameter.
unfortunately GetGeometryIterator is not implemented in Mogre material class.
Is there a way to get an actual geometryiterator from the underlying ogre class and from this geometryiterator call setcustomparameter for each geometrybucket?

Something like :
Ogre.StaticGeometry.MaterialBucket mb = material.GetUnderlyingObject(); //this will give me the real OGRE class (not MOGRE)
Ogre.VectorIterator gi = mb.getGeometryIterator();
while (hasMoreElements (gi))
Ogre.StaticGeometry.GeometryBucket gb = gi.current();
gb.SetCustomParameter(1, customParameter);

Is it possible to do this somehow? Plese help


27-04-2011 18:20:17

Unfortunately I can't help you with this problem.

unfortunately GetGeometryIterator is not implemented in Mogre material class.
If the Mogre wrapper needs an extention (lack of wrapped API functions), I would add this to our bug/whish tracker.
Could you please tell us some more details?
(E.g. a link to the related page of the Ogre class reference.)


27-04-2011 18:31:13

it is

so how would you solve such a situation? Is there a way to get native Ogre material bucket object from mogre material bucket?
If it is not, what is the best solution?
Add this custom parameter as another texture coord? (Fortunately I dont need to change this once built)


28-04-2011 10:11:39

I suppose we "just" need to wrap the missing API functions and recompile Mogre.
User amirabiri develops a tool for easy Mogre building. For details look to this topic:
Mogre.Builder - a tool for easy, automatic build of Mogre


28-04-2011 12:50:42

Thank you Beauty, I'll have a look.


28-04-2011 13:32:52

I also added the suggestion to wrap the missing API function in the Mogre 1.7.x forum thread, because mstoyke considers to create a bugfixed/updated release.


07-01-2013 22:20:58

I got this private message, but think it's better for all to discuss it in the public forum.

Hi Beauty,
I would like to ask you for a favour. We were talking almost two years ago about this viewtopic.php?f=8&t=14317 issue. I know this still hasn't been implemented. I found that someone else have similar problem ... =8&t=29737
I would like to kindly ask you if you can implement this wrapped method.

I absolutely appreciate that you might be really busy. If so, I can spare some money, because this customparameter is the only way to move things forward. I know I might try to build MOGRE from source and honestly I would not have any problems to craete new code, but the actual problem is to set up the whole building environment.
Could you please do this?

Pavel, thanks for your interest.
I'm not experienced in wrapper stuff, but had a look to it.

implement this wrapped method
In general all API methods should be wrapped automatically by the Mogre autowrapper tool.
To wrap by hand is not appropriated. Perhaps it's possible to add hand wrapped code by a trick.
There are some classes, which are added by hand written code files (e.g. Math.Vector3).
The aim was to improve the speed by porting a few classes to pure C# code instead of wrapping it.
Theoretically you could do it similar for hand written code.
On the other hand I think it's no good way.

To influence the behaviour of the Mogre autowrapper you can modify the content of the file Attributes.xml.
You find the file in the Mogre repository in the directory Codegen \ AutoWrap.

There are some interesting entries (settings) in the XML file, which are used to disable the wrapping of API members.
This should be the reason why you don't find your needed method.

<class name="InstancedGeometry">
<class name="GeometryBucket" Ignore=""/>
<class name="LODBucket" Ignore=""/>
<class name="MaterialBucket" Ignore=""/>
<class name="OptimisedSubMeshGeometry" Ignore=""/>
<class name="QueuedGeometry" Ignore=""/>
<class name="QueuedSubMesh" Ignore=""/>
<class name="SubMeshLodGeometryLink" Ignore=""/>
<class name="InstancedObject" WrapType="CLRHandle"/>
<class name="BatchInstance">
<variable name="mLodValues" Ignore=""/>
<!-- Removed in 1.6
<function name="getObjectsAsArray" Ignore=""/>-->

The retired Mogre maintainer mstoyke upgraded Mogre from 1.6 to 1.7. Because of some autowrapper problems he "disabled" some API members.
My suggestion: Comment out the line(s) of your needed method and try to build Mogre. If there are problems, try to figure out the reason.
The XML entry <class name="MaterialBucket" Ignore=""/> prevents the wrapping of the whole MaterialBucket class.
Maybe there is only one class member of MaterialBucket, which causes problems. So maybe you just need to figure out, which member(s) causes the problem. If you found it, just disable this member, not the whole MaterialBucket class.
Maybe it's easy to solve your problem, maybe you get in coders hell.
I propose to have a try. :wink:

I know I might try to build MOGRE from source [...], but the actual problem is to set up the whole building environment.

Don't worry. It's not painful as in the past. By our tool MogreBuilder it's very easy.
Most of all steps are done automatically. It's about 5 minutes of preparation (installation of tools). Then you compile and run the MogreBuilder. About 3 hours later your own MogreBuild should be created.
When it works well on your computer, you'll find the (automatically downloaded) file Attributes.xml and can start your experiments.

I can spare some money
Thanks for your offer, but I don't want to have money.
I like to motivate you to try it yourself. Some useful information I wrote down in this post.