Read raw data from ManualObject - demo code in wiki now

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
x 39
Contact:

Read raw data from ManualObject - demo code in wiki now

Post by Beauty »

It was not easy to find out how to read out the vertex buffer and index buffer of a ManualObject.
I need it to modify the code of Raycasting to the polygon level for usage with ManualObject.

Now I published a demo code which shows how to read out the data.
Look to wiki page Read raw data from ManualObject - MOGRE

Maybe it's useful for anybody.
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
x 39
Contact:

Re: Read raw data from ManualObject - demo code in wiki now

Post by Beauty »

Nice to see that my code was useful at least for user PickleNinja.
By use of this he created a modified C++ version to read out vertex information from ManualObjects for usage with the RaycastingToPolygonLevel code.
Well, his code doesn't make a differentiation for the rendering types (dangerous), but this is a common issue of the current raycasting code.
PickleNinjas code you finde here: Raycasting to the polygon level - section ManualObject GetMeshInformation()


If somebody needs a more advanced code for polygon raycasting:
The "preview version" of my completely re-written polygon raycasting code I published in this forum post. (download attached file)
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
drwbns
Orc Shaman
Posts: 786
Joined: Mon Jan 18, 2010 6:06 pm
Location: Costa Mesa, California
x 24

Re: Read raw data from ManualObject - demo code in wiki now

Post by drwbns »

Glad to see work done in this area Beauty, congrats! One question - with your preview code, is the only difference that it's written in c#, or are there other differences? I did a quick peek and saw you had different functions but is the plan to rewrite the c++ code for raycasting?
User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
x 80
Contact:

Re: Read raw data from ManualObject - demo code in wiki now

Post by duststorm »

This also seems useful for projects like Procedural Geometry. Or was this what it was intended for in the first place? ;)
Developer @ MakeHuman.org
User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
x 39
Contact:

Re: Read raw data from ManualObject - demo code in wiki now

Post by Beauty »

drwbns wrote: [...] is the only difference that it's written in c#, or are there other differences?
[...] is the plan to rewrite the c++ code for raycasting?
I wrote a long answer for that. Then I decided to publish it in my "official" forum topic. So other "followers" have better chances to see it.
http://www.ogre3d.org/forums/viewtopic. ... 51#p448551
duststorm wrote:This also seems useful for projects like Procedural Geometry. Or was this what it was intended for in the first place? ;)
Well, I don't know the internals of Procedural Geometry, but I suppose it's based ManualObject.
So you should be right. By usage of my code it would be possible to do ray detection with it on polygon level.
Thanks for the idea of usage.

Personal reason for my re-wrote of the polygon raycasting code:
In my application I create dynamic objects by code. (underwater pipeline simulation)
Now I need to create a sensor simulation (similar to sonar sensors) which can detect the pipeline. (A part of my diploma thesis on university.)
For this I need ray detection for ManualObjects.
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
User avatar
edoardo
Kobold
Posts: 36
Joined: Thu Apr 28, 2011 8:44 am
Location: Torino, Italy

Re: Read raw data from ManualObject - demo code in wiki now

Post by edoardo »

Hi Beauty,

I just wanted to suggest you to Dispose() the VertexBuffer and IndexBuffer, because that could lead to memory errors (that part is unsafe - unmanaged - for C#, hence the potential problem if you don't Dispose the data structures).

See my last modification to this wiki page for the details...

Hoping to help!
--
"Fatti non foste a viver come bruti, | ma per seguir virtute e canoscenza."
"You were not made to live your lives as brutes, | but to be followers of virtue and knowledge."
(Divina Commedia, Inferno, Canto XXVI, 119 – 120)
User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
x 39
Contact:

Re: Read raw data from ManualObject - demo code in wiki now

Post by Beauty »

Thanks for your note and editing the wiki page.

The code of your refered page was ported (not by me) from the C++ snippet (here), which was published a few years ago.
Even there are no dispose calls.
It seems so that nobody found this issue (or nobody corrected the wiki page).
Or there should be no dispose call.

My C++ and pointer knowledge is bad and I'm not shure.
Will the pointer be disposed or the target?
If the target will be disposed, it could cause problems if other processes (e.g. the Ogre render internals) wants to access the data.

What's the opinion of other users?

Did you try the code with the added dispose calls?
Does it cause problems/crashes?


By the way:
If you want to use polygon raycasting, you should use my improved code (completely re-written).
I published the files in this forum post.
The differences/improvements I described here.
It's not the best way to publish it (for long-term usage). I want to clean up the helper methods a little bit and then publish an a repository. Details and links I want to added to a seperate wiki page.
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
User avatar
edoardo
Kobold
Posts: 36
Joined: Thu Apr 28, 2011 8:44 am
Location: Torino, Italy

Re: Read raw data from ManualObject - demo code in wiki now

Post by edoardo »

I'm currently using with my team the corrected version, and NOW we aren't experiencing any crash, but before, after a lot of picking actions we got a memory error (AccessViolationException).

We are using the correction from months now, and all proceeds well, so I'm pretty sure about that.

I'm not very sure how to explain the behavior though, I think the Dispose() instructs the GarbageCollector to free/reuse the memory used by the copy of vertex and index buffers that is created in the method.

If anyone else have more aware answer... thank you in advance!
--
"Fatti non foste a viver come bruti, | ma per seguir virtute e canoscenza."
"You were not made to live your lives as brutes, | but to be followers of virtue and knowledge."
(Divina Commedia, Inferno, Canto XXVI, 119 – 120)
User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
x 39
Contact:

Re: Read raw data from ManualObject - demo code in wiki now

Post by Beauty »

Thanks edoardo for your report. :D
It's very good to know the results your intensive tests.
So I will look for similar code on different places (my re-written code + wiki pages) and add the dispose call.

Interesting to know that you are (seems to be) a Mogre user for months. In the Mogre forum you just created 3 posts until now.
If you like, you can create a post in the topic Full stack for a game built in C#
In this thread Mogre users write which add-ons and libraries they use for their projects (e.g. Input, GUI, network). It would be nice to know, which ones you use.

Did you posted some information about your project?
For what do you use Ogre/Mogre?
You could post it in the showcase forum topic.

Do you know the tool MogreBuilder?
By use of this it's very easy to build Ogre/Mogre from the scratch. Also compiling modified Ogre versions should be possible. Details you find here.
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
Post Reply