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.
Read raw data from ManualObject - demo code in wiki now
- Beauty
- 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
Help to add information to the wiki. Also tiny edits will let it grow ... 
Add your country to your profile ... it's interesting to know from where of the world you are.

Add your country to your profile ... it's interesting to know from where of the world you are.
- Beauty
- 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
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)
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 ... 
Add your country to your profile ... it's interesting to know from where of the world you are.

Add your country to your profile ... it's interesting to know from where of the world you are.
-
- 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
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?
- 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
This also seems useful for projects like Procedural Geometry. Or was this what it was intended for in the first place? 

Developer @ MakeHuman.org
- Beauty
- 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
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.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?
http://www.ogre3d.org/forums/viewtopic. ... 51#p448551
Well, I don't know the internals of Procedural Geometry, but I suppose it's based ManualObject.duststorm wrote:This also seems useful for projects like Procedural Geometry. Or was this what it was intended for in the first place?
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 ... 
Add your country to your profile ... it's interesting to know from where of the world you are.

Add your country to your profile ... it's interesting to know from where of the world you are.
- 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
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!
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)
"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)
- Beauty
- 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
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.
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 ... 
Add your country to your profile ... it's interesting to know from where of the world you are.

Add your country to your profile ... it's interesting to know from where of the world you are.
- 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
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!
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)
"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)
- Beauty
- 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
Thanks edoardo for your report.
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.

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 ... 
Add your country to your profile ... it's interesting to know from where of the world you are.

Add your country to your profile ... it's interesting to know from where of the world you are.