Ogre Procedural [v0.2 officially out]

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
Post Reply
User avatar
Mikachu
Gnoll
Posts: 603
Joined: Thu Jul 28, 2005 4:11 pm
Location: Nice, France
x 35

Re: Ogre Procedural v0.1 released!

Post by Mikachu »

@afshin :
Great, that's a cheap port :D

@NoodlesOnMyBack :
In fact, when you call realizeMesh(), an Ogre Mesh is produced (not only a manual object).

So you've got to call

Code: Select all

Ogre::MeshManager::getSingletonPtr()->remove(mName);
for Ogre to release your mesh.

The fact that when you want to produce a new mesh with the same name, and that there's no exception thrown nor message logged nor updating of that mesh belongs to how Ogre manages resources.
But OgreProcedural is not very flexible on this point anyway, I might try and enhance it for 0.2...
OgreProcedural - Procedural Geometry for Ogre3D
User avatar
NoodlesOnMyBack
Goblin
Posts: 200
Joined: Tue Feb 05, 2008 4:14 am
Location: Buenos Aires, Argentina
Contact:

Re: Ogre Procedural v0.1 released!

Post by NoodlesOnMyBack »

Thank you, now works fine.
Image
afshin
Kobold
Posts: 34
Joined: Wed Nov 10, 2010 11:12 pm
Location: Canada

Re: Ogre Procedural v0.1 released!

Post by afshin »

Any restrictions on path points that gets passed to:

Code: Select all

Procedural::Extruder().setExtrusionPath(&p).setShapeToExtrude(&s).realizeMesh(entityName); 
When I tested this by explicitly giving it points it works fine:

Code: Select all


		scene = self.graphics.sceneManager;
		Procedural::Root::getInstance()->sceneManager = scene;
		
		Procedural::Path p = Procedural::BezierPath().setNumSeg(10).addPoint(0,5,0).addPoint(0,4,10).addPoint(10,5,10).realizePath();
		
		Procedural::Shape s = Procedural::CircleShape().setRadius(0.5).realizeShape();
		Procedural::Extruder().setExtrusionPath(&p).setShapeToExtrude(&s).realizeMesh("extrudedMesh");
But when I pass it these points it keeps crashing:
  • X val : -2.910990 Y Val: -4.508870 Z Val: 0.019630
    X val : -2.319500 Y Val: -4.533808 Z Val: -0.365461
    X val : -1.546001 Y Val: -4.527168 Z Val: -0.424392
    X val : -0.503734 Y Val: -4.301475 Z Val: 0.075474
    X val : 0.791556 Y Val: -3.951742 Z Val: 0.121817
    X val : 1.915843 Y Val: -3.756075 Z Val: 0.068665
    X val : 2.981975 Y Val: -3.670143 Z Val: 0.531683
    X val : 3.963867 Y Val: -3.583679 Z Val: 1.248001
    X val : 4.601315 Y Val: -3.625022 Z Val: 1.519513
    X val : 5.607715 Y Val: -3.107523 Z Val: 1.994461
The crash happens in ProceduralExtruder.h when it sets the extrusion path:

Code: Select all

	
/** Sets the extrusion path */
	inline Extruder & setExtrusionPath(Path* extrusionPath)
	{
		mExtrusionPath = extrusionPath;
		return *this;
	}
It happens when the return is called. Using the debugger, extrusionPath variable has all the points, mExtrusionPath gets them fine, but when "return *this" gets executed, I get EXC_BAD_ACCESS. Not sure what is going on ... if some thing is missing or what :(

Any helps is greatly appreciate it,
Afshin
User avatar
Mikachu
Gnoll
Posts: 603
Joined: Thu Jul 28, 2005 4:11 pm
Location: Nice, France
x 35

Re: Ogre Procedural v0.1 released!

Post by Mikachu »

I tested the points you provided with this code

Code: Select all

Path p = BezierPath().setNumSeg(2)
			.addPoint(-2.910990, -4.508870, 0.019630)
			.addPoint(-2.319500, -4.533808, -0.365461)
			.addPoint(-1.546001, -4.527168, -0.424392)
			.addPoint(-0.503734, -4.301475, 0.075474)
			.addPoint(0.791556, -3.951742, 0.121817)
			.addPoint(1.915843, -3.756075, 0.068665)
			.addPoint(2.981975, -3.670143, 0.531683)
			.addPoint(3.963867, -3.583679, 1.248001)
			.addPoint(4.601315, -3.625022, 1.519513)
			.addPoint(5.607715, -3.107523, 1.994461).realizePath();			

			Procedural::Shape s = Procedural::CircleShape().setRadius(0.5).realizeShape();
			Procedural::Extruder().setExtrusionPath(&p).setShapeToExtrude(&s).realizeMesh("extrudedMesh");
			putMesh("extrudedMesh");
and it works..
Can you show the code that causes the crash?

It seems that you are using an invalid pointer or something..
OgreProcedural - Procedural Geometry for Ogre3D
User avatar
zarfius
Gnome
Posts: 367
Joined: Wed Jan 03, 2007 12:44 pm
Location: Brisbane, Australia
x 13
Contact:

Re: Ogre Procedural v0.1 released!

Post by zarfius »

afshin wrote:The crash happens in ProceduralExtruder.h when it sets the extrusion path:

Code: Select all

    /** Sets the extrusion path */
       inline Extruder & setExtrusionPath(Path* extrusionPath)
       {
          mExtrusionPath = extrusionPath;
          return *this;
       }
It happens when the return is called.
My guess is that the parameter passed into setExtrusionPath is invalid (or becomes invalid). i.e. the pointer to a "Path". The problem is that mExtrusionPath is pointing to some memory that may or may not be declared since it's the responsibility of the user to make sure the Path remains in scope.

Just a guess.
Craftwork Games - hand crafted entertainment.
http://www.craftworkgames.com/
afshin
Kobold
Posts: 34
Joined: Wed Nov 10, 2010 11:12 pm
Location: Canada

Re: Ogre Procedural v0.1 released!

Post by afshin »

Mikachu wrote:I tested the points you provided with this code

Code: Select all

Path p = BezierPath().setNumSeg(2)
			.addPoint(-2.910990, -4.508870, 0.019630)
			.addPoint(-2.319500, -4.533808, -0.365461)
			.addPoint(-1.546001, -4.527168, -0.424392)
			.addPoint(-0.503734, -4.301475, 0.075474)
			.addPoint(0.791556, -3.951742, 0.121817)
			.addPoint(1.915843, -3.756075, 0.068665)
			.addPoint(2.981975, -3.670143, 0.531683)
			.addPoint(3.963867, -3.583679, 1.248001)
			.addPoint(4.601315, -3.625022, 1.519513)
			.addPoint(5.607715, -3.107523, 1.994461).realizePath();			

			Procedural::Shape s = Procedural::CircleShape().setRadius(0.5).realizeShape();
			Procedural::Extruder().setExtrusionPath(&p).setShapeToExtrude(&s).realizeMesh("extrudedMesh");
			putMesh("extrudedMesh");
and it works..
Can you show the code that causes the crash?

It seems that you are using an invalid pointer or something..
Yap you are right the problem wasn't in the points ...
zarfius wrote:
afshin wrote:The crash happens in ProceduralExtruder.h when it sets the extrusion path:

Code: Select all

    /** Sets the extrusion path */
       inline Extruder & setExtrusionPath(Path* extrusionPath)
       {
          mExtrusionPath = extrusionPath;
          return *this;
       }
It happens when the return is called.
My guess is that the parameter passed into setExtrusionPath is invalid (or becomes invalid). i.e. the pointer to a "Path". The problem is that mExtrusionPath is pointing to some memory that may or may not be declared since it's the responsibility of the user to make sure the Path remains in scope.

Just a guess.
Good point ... The problem was with memory. I was using Objective-C blocks and doing the drawing in a different thread .... The multi-threading was the issue ... Thanks Mikachu & zarfius for your input :D

In the next step I need to procedurally generate a strand of DNA - something like this:

Image

or the yellow coiled up strand in the picture below:

Image

Any ideas? I did something similar in Maya, but it would be great if I could do it with Ogre Procedural :?: :idea:
User avatar
zarfius
Gnome
Posts: 367
Joined: Wed Jan 03, 2007 12:44 pm
Location: Brisbane, Australia
x 13
Contact:

Re: Ogre Procedural v0.1 released!

Post by zarfius »

afshin wrote:The multi-threading was the issue ...
You have to be particularly careful when implementing Multi-threading. Especially in a language like C++ (you have more than enough freedom to create bugs). The general idea is to keep the threads separate as much as possible. In other words, they should not read / write to the same blocks of memory if possible. When you do have too share some memory (and you probably will) you need to "lock" it from the other threads. This usually means pausing one or more of the threads while it waits for the for the other thread to be finished with the memory. Even when you manage to lock the memory, if it's not implemented correctly you'll find that it can be slower than not use threading in the first place.

http://en.wikipedia.org/wiki/Mutual_exclusion
Craftwork Games - hand crafted entertainment.
http://www.craftworkgames.com/
afshin
Kobold
Posts: 34
Joined: Wed Nov 10, 2010 11:12 pm
Location: Canada

Re: Ogre Procedural v0.1 released!

Post by afshin »

Any idea how to save a procedurally generated mesh to a .mesh file?


I guess I don't need to save it in a file as long as I figure out how to give it colour, transparency and texture in my code. I am planning to go over Ogre and see what I can find ... any help is greatly appreciate it.


Thanks again,
Afshin
User avatar
Mikachu
Gnoll
Posts: 603
Joined: Thu Jul 28, 2005 4:11 pm
Location: Nice, France
x 35

Re: Ogre Procedural v0.1 released!

Post by Mikachu »

A procedurally generated mesh is a standard Ogre mesh, so just use the Ogre API to save it as a mesh : http://www.ogre3d.org/docs/api/html/cla ... 88c2b169db

As for the DNA strand you're trying to build... I guess it should be possible, if you provide the extruder with appropriate input.
It also depends on what you're really trying to achieve, if it must look exactly like the picture, or if a simpler shape, like this one (http://www.dnareplication.info/images/d ... helix2.jpg) does the job.
OgreProcedural - Procedural Geometry for Ogre3D
afshin
Kobold
Posts: 34
Joined: Wed Nov 10, 2010 11:12 pm
Location: Canada

Re: Ogre Procedural v0.1 released!

Post by afshin »

Mikachu wrote:A procedurally generated mesh is a standard Ogre mesh, so just use the Ogre API to save it as a mesh : http://www.ogre3d.org/docs/api/html/cla ... 88c2b169db

As for the DNA strand you're trying to build... I guess it should be possible, if you provide the extruder with appropriate input.
It also depends on what you're really trying to achieve, if it must look exactly like the picture, or if a simpler shape, like this one (http://www.dnareplication.info/images/d ... helix2.jpg) does the job.
Thanks Mikachu for the great link ... Really helpful :)

I used the serialize and wrote the mesh to a file. How do I assign a material to the mesh? I would like to load a .material file but I need to somehow link it to the mesh file so it knows which material file to go and look for. Will this (below) do it?

Code: Select all

 ogreEntity->setMaterialName(...) 
For the DNA, even the one built from simpler shape works. The whole Idea of me using Ogre Procedural was to be able to procedurally generate the DNA (using an agent doing a random walk inside my cell) and then saving it to a mesh file, and using material files to give it texture, color, transparencies and etc.

It seems kinda difficult to create the double strand DNA procedurally (?).
bresgames
Gnoblar
Posts: 14
Joined: Mon Apr 18, 2011 6:19 pm
Location: Sweden
Contact:

Re: Ogre Procedural v0.1 released!

Post by bresgames »

Seems neat, think I'll have much use of this for my project. :)

But I have a problem
Trying to build from source. Getting "OGRE_DIR-NOTFOUND" and "OIS_DIR-NOTFOUND" errors inside CMAKE...

I tried setting the path to my Ogre folder manually inside CMAKE, but that doesn't help...
User avatar
Mikachu
Gnoll
Posts: 603
Joined: Thu Jul 28, 2005 4:11 pm
Location: Nice, France
x 35

Re: Ogre Procedural v0.1 released!

Post by Mikachu »

bresgames wrote:Trying to build from source. Getting "OGRE_DIR-NOTFOUND" and "OIS_DIR-NOTFOUND" errors inside CMAKE...

I tried setting the path to my Ogre folder manually inside CMAKE, but that doesn't help...
Ogre Procedural is using standard "FindOgre.cmake", so a "OGRE_HOME" variable must be set (inside CMake or in your system env vars), pointing to the path where you installed Ogre (if you got Ogre from source that's your "install" target path).

Did you do that?
OgreProcedural - Procedural Geometry for Ogre3D
bresgames
Gnoblar
Posts: 14
Joined: Mon Apr 18, 2011 6:19 pm
Location: Sweden
Contact:

Re: Ogre Procedural v0.1 released!

Post by bresgames »

Mikachu wrote:
bresgames wrote:Trying to build from source. Getting "OGRE_DIR-NOTFOUND" and "OIS_DIR-NOTFOUND" errors inside CMAKE...

I tried setting the path to my Ogre folder manually inside CMAKE, but that doesn't help...
Ogre Procedural is using standard "FindOgre.cmake", so a "OGRE_HOME" variable must be set (inside CMake or in your system env vars), pointing to the path where you installed Ogre (if you got Ogre from source that's your "install" target path).

Did you do that?
Yeah, I did that, used the source package installer for Ogre, and set my system env OGRE_HOME, will try again from the beginning this evening. Guess that something went wrong when building the "INSTALL" project for OGRE? You must do that, right? :)
Edit: hm, maybe I'm confused. As I said, will try again from the beginning when I get back home from work.
Will report my findings here, if I need more help there must be some crusial step that I've missed.
And if I figure it out myself, perhaps I can help someone else with a clarification. :P
bresgames
Gnoblar
Posts: 14
Joined: Mon Apr 18, 2011 6:19 pm
Location: Sweden
Contact:

Re: Ogre Procedural v0.1 released!

Post by bresgames »

Yeah. I got CMAKE to work. Had to build the install project and set OGRE_HOME to the "sdk" folder.

However, I encountered a new problem. :(
It seems like ogre procedural can't find boost when building inside visual studio, seems like the CMAKE generation doesn't support the use of boost in ogre...

Of course, I fixed this by adding the appropriate paths to the ogre procedural project.
Maybe something to fix for further updates, including boost in CMAKE i mean ?

Wellwell, shouldn't complain anymore, it's only version 0.1 and I got it to work. ;)
User avatar
Mikachu
Gnoll
Posts: 603
Joined: Thu Jul 28, 2005 4:11 pm
Location: Nice, France
x 35

Re: Ogre Procedural v0.1 released!

Post by Mikachu »

Hum.. I never had tried to build Ogre Procedural with boost before... but I cannot possibly scan every possible Ogre dependency to add its header files, there are quite a few optional dependencies now... :?
Or it should be at least abstracted by "FindOgre.Cmake".
It seems that "standard" dependencies do not have this problem, since header files are only included in Ogre cpps, but maybe that it wasn't possible with boost?

Open question to Ogre experts : is there a recommended way to handle this case :?: Or should any project using Ogre compiled with optional dependencies take them into account? (even it they make no direct use of them?)
OgreProcedural - Procedural Geometry for Ogre3D
bresgames
Gnoblar
Posts: 14
Joined: Mon Apr 18, 2011 6:19 pm
Location: Sweden
Contact:

Re: Ogre Procedural v0.1 released!

Post by bresgames »

Yeah. The include file with the obscure name of "OgreThreadHeadersBoost.h" includes several boost headers. Who could have known. :shock:

Of course it is too much of ask of you to support every thinkable configuration of Ogre, but boost seems common enough to be considered.
You might wanna run some heavy procedural stuff in a background thread. ;)
Btw, the ogre appwizard also has this problem, I belive, shall doublecheck later on... :roll:

On the other hand, one might argue that "OgreThreadHeadersBoost.h" should be removed and replaced with the appropriate includes in affected source files.
This will make it easier for you, and I think that developing this kind of addons should be encouraged! :)

Anyway, now the samples work as a charm and the code you write to generate stuff is really neat. :D
bruZard
Gnoblar
Posts: 7
Joined: Mon Apr 19, 2010 7:55 am

Re: Ogre Procedural v0.1 released!

Post by bruZard »

it doesn't work for me. i use the precompiled libraries and i get an exception from the resourcemanager:

Code: Select all

OGRE EXCEPTION(5:ItemIdentityException): Cannot find a group named ral            in ResourceGroupManager::isResourceGroupInitialised at ..\..\..\..\OgreMain\src\OgreResourceGroupManager.cpp (line 1889)
i have initialized an own resourcegroup. any idea whats wrong with that?


excuse my bad english...
bresgames
Gnoblar
Posts: 14
Joined: Mon Apr 18, 2011 6:19 pm
Location: Sweden
Contact:

Re: Ogre Procedural v0.1 released!

Post by bresgames »

bruZard wrote:it doesn't work for me. i use the precompiled libraries and i get an exception from the resourcemanager:

Code: Select all

OGRE EXCEPTION(5:ItemIdentityException): Cannot find a group named ral            in ResourceGroupManager::isResourceGroupInitialised at ..\..\..\..\OgreMain\src\OgreResourceGroupManager.cpp (line 1889)
i have initialized an own resourcegroup. any idea whats wrong with that?


excuse my bad english...
How does your code for initialising the resourcegroup look like?
bruZard
Gnoblar
Posts: 7
Joined: Mon Apr 19, 2010 7:55 am

Re: Ogre Procedural v0.1 released!

Post by bruZard »

simple:

Code: Select all

Ogre::ResourceGroupManager &res = Ogre::ResourceGroupManager::getSingleton();
res.createResourceGroup("bogre");
bresgames
Gnoblar
Posts: 14
Joined: Mon Apr 18, 2011 6:19 pm
Location: Sweden
Contact:

Re: Ogre Procedural v0.1 released!

Post by bresgames »

But... The error message says that you're trying to use a resource group named ral? "Cannot find a group named ral"
bresgames
Gnoblar
Posts: 14
Joined: Mon Apr 18, 2011 6:19 pm
Location: Sweden
Contact:

Re: Ogre Procedural v0.1 released!

Post by bresgames »

I just felt like sharing this litte picture. :D

Image

:D
pdv373
Gnoblar
Posts: 6
Joined: Sat Jul 30, 2011 12:03 am
x 7

Re: Ogre Procedural v0.1 released!

Post by pdv373 »

Thanks Mikachu, your library is great, and I'm sure Ogre Community appreciates all your hard work. I do as well. Keep it up.
Image
Image
User avatar
Mikachu
Gnoll
Posts: 603
Joined: Thu Jul 28, 2005 4:11 pm
Location: Nice, France
x 35

Re: Ogre Procedural v0.1 released!

Post by Mikachu »

Hey, that looks great :D

Is there a game project behind it, or is it just some experimentation?
OgreProcedural - Procedural Geometry for Ogre3D
pdv373
Gnoblar
Posts: 6
Joined: Sat Jul 30, 2011 12:03 am
x 7

Re: Ogre Procedural v0.1 released!

Post by pdv373 »

Thank you for the kind words. This is mostly experimentation. We had few ideas related to creation of virtual environments but there are certainly no concrete plans to develop anything. I just had a free evening to play around with your api :D .

I think OgreProcedural is an incredibly useful tool and I'm looking forward to seeing how this library develops. I'm also somewhat suprised that more people are not showing off their OgreProcedural creations.
User avatar
tdev
Silver Sponsor
Silver Sponsor
Posts: 244
Joined: Thu Apr 12, 2007 9:21 pm
Location: Germany
x 14

Re: Ogre Procedural v0.1 released!

Post by tdev »

nice screens :)

we have quite some ideas for this, this is the beginning only, stay tuned :)
Post Reply