Flat shape meshes.

Klaim

06-08-2013 14:12:07

I see no simple way to generate a flat mesh using a given Shape.
I'm guessing I should use the extruder, but I'm not sure it's the intended use as it's designed for a more complex use.

Is a flat shape mesh generated missing?
I first thought that I could apply a shape to a plan but I was wrong.

mikachu

06-08-2013 14:18:32

http://docs.ogreprocedural.org/classPro ... ml#details

Is it what you're looking for?

Klaim

06-08-2013 14:22:38

It looks like it yes. Thanks! I read it already without understanding what it was really about at first.
I thought it was to manage triangles manually and I didn't see the shape function.

Klaim

22-08-2013 23:37:03

I think I might have found a related bug.

I have this code:

static const float CURSOR_SCALE = 1.00f;
static const float CURSOR_ORIGIN_X = 0.0f;
static const float CURSOR_ORIGIN_Y = 0.0f;
static const float CURSOR_WIDTH = 0.7f;
static const float CURSOR_HEIGHT = 1.0f;
static const float CURSOR_BACK_X = CURSOR_ORIGIN_X + (CURSOR_WIDTH / 2.f);
static const float CURSOR_BACK_Y = CURSOR_ORIGIN_Y -CURSOR_HEIGHT + (CURSOR_HEIGHT / 4.f);


Procedural::Shape cursor_shape;
cursor_shape
.addPoint( CURSOR_ORIGIN_X, CURSOR_ORIGIN_Y )
.addPoint( CURSOR_ORIGIN_X, -CURSOR_HEIGHT )
.addPoint( CURSOR_BACK_X, CURSOR_BACK_Y )
.addPoint( CURSOR_WIDTH, CURSOR_BACK_Y )
.close()
.setOutSide( Procedural::Side::SIDE_LEFT )
.scale( CURSOR_SCALE, CURSOR_SCALE )
;


Now if I do:

auto cursor_mesh = cursor_shape.realizeMesh("mouse_cursor_mesh");

I got this, which is correct but I would like to fill it:

[attachment=1]netrush-cursor-wireframe.jpg[/attachment]

But if I do (to fill it):

auto cursor_mesh = Procedural::Triangulator()
.setShapeToTriangulate( &cursor_shape )
.realizeMesh( "mouse_cursor_mesh" );



I got:

[attachment=0]netrush-cursor-fail.jpg[/attachment]

It seem taht the triangulator is missing a point. (no pun intended :mrgreen: )

Am I doing something wrong?

mikachu

23-08-2013 08:04:48

It seems to me that the out side you defined in your shape should be SIDE_RIGHT instead of SIDE_LEFT (but sometimes the triangulator has its bugs too :wink: )

(by definition : if you imagine yourself wandering on the shape in its natural order, it's the side that should be outside of the flat mesh)

Klaim

23-08-2013 13:12:36

Ok I just tried RIGHT.
It seem that logically it should be RIGH indeed, however I get no visual at all if I use it with the triangulator.
Without the triangulator I see the shape as the first picture.

So there is certainly a problem with the triangulator.

I'll have to check if my version differ from the most recent one.

Klaim

23-08-2013 14:19:22

Playing with the scale also do totally weird things when using Triangulator: 0.01 does apparently nothing (but with eye only it's hard to check), 0.0001 will make it's width very thin while having the right height, so the mesh is totally deformed.

No problem without the Triangulator.

Checking versions now.
EDIT> Checked: I'm at 906dd8087f12e92cad0baa28714a7a0c43cd3c18 and there have been no change in Triangulator other than formatting.

mikachu

23-08-2013 18:07:05

Just tried by dropping this code in Unit_Tests, and it works :
static const float CURSOR_SCALE = 1.00f;
static const float CURSOR_ORIGIN_X = 0.0f;
static const float CURSOR_ORIGIN_Y = 0.0f;
static const float CURSOR_WIDTH = 0.7f;
static const float CURSOR_HEIGHT = 1.0f;
static const float CURSOR_BACK_X = CURSOR_ORIGIN_X + (CURSOR_WIDTH / 2.f);
static const float CURSOR_BACK_Y = CURSOR_ORIGIN_Y -CURSOR_HEIGHT + (CURSOR_HEIGHT / 4.f);


Procedural::Shape cursor_shape;
cursor_shape
.addPoint( CURSOR_ORIGIN_X, CURSOR_ORIGIN_Y )
.addPoint( CURSOR_ORIGIN_X, -CURSOR_HEIGHT )
.addPoint( CURSOR_BACK_X, CURSOR_BACK_Y )
.addPoint( CURSOR_WIDTH, CURSOR_BACK_Y )
.close()
.setOutSide( Procedural::Side::SIDE_RIGHT )
.scale( CURSOR_SCALE, CURSOR_SCALE )
;

putMesh(Triangulator().setShapeToTriangulate(&cursor_shape).realizeMesh());


The triangulator outputs a mesh oriented towards NEGATIVE_UNIT_Z, are you seeing it from that side?

mikachu

23-08-2013 18:51:34

Playing with the scale also do totally weird things when using Triangulator: 0.01 does apparently nothing (but with eye only it's hard to check), 0.0001 will make it's width very thin while having the right height, so the mesh is totally deformed.
I reproduced this..

I think I know where it's coming from : in an attempt to make the triangulator more robust, I had to play with epsilons, but the fact that they're not relative to the shape size is a problem..

Klaim

23-08-2013 19:02:25


The triangulator outputs a mesh oriented towards NEGATIVE_UNIT_Z, are you seeing it from that side?


The entity is attached to the scene root node but moved just in front of the camera.
So I suppose that I'm in the negative Z side of the entity... (argh relativity always confuses me XD)

No wait, this mean that I'm looking at the negative Z of the camera, but I'm seeing the positive Z face of the entity.
Indeed it explains why I'm not seeing it.

I could rotate it, but I expected the shape to be filed so that the positive Z is visible. Could you add a way to specify which side I want?

mikachu

23-08-2013 20:33:10

You can rotate it in the generated mesh by calling buildTriangleBuffer() instead of realizeMesh(), then TriangleBuffer::rotate(), and TriangleBuffer::transformToMesh()

Klaim

23-08-2013 20:45:52

You can rotate it in the generated mesh by calling buildTriangleBuffer() instead of realizeMesh(), then TriangleBuffer::rotate(), and TriangleBuffer::transformToMesh()

Okay.

May I suggest to add a simple tool/builder that allows only 2d points and realize a flat mesh facing either Z or -Z ?
That would be very helpful for building 2D custom shapes. (aren't you already doing this in the SVG code? maybe it would allow simplifying SVG generator?)
I would have proposed some code but I think I will not have time in the coming weeks (but maybe later).

Klaim

23-08-2013 21:16:05

Just tried it:

- it works if if scale is 1.0f;
- the mesh have the expected shape, no missing edge;
- the mesh is reversed if I just rotate the mesh;

It's not exactly that kind of rotation I want it seems.

mikachu

23-08-2013 21:47:53

- the mesh is reversed if I just rotate the mesh;
In fact, TriangleBuffer::invertNormals() might be more suitable to your case than rotate().

Klaim

23-08-2013 22:04:03

- the mesh is reversed if I just rotate the mesh;
In fact, TriangleBuffer::invertNormals() might be more suitable to your case than rotate().


It works, thanks!

So the only bug preventing me to use this code is the scaling thing, I'll use the wireframe until you manage to fix it, I'm not pressed.

Klaim

02-11-2013 11:11:19

Mikachu, did you manage to already fix the bug in Triangulator we were talking about or not yet?

mikachu

12-11-2013 10:26:00

Sorry, I didn't get the time to work on that.
Actually, recent weeks have been pretty hectic for me (and it's not going to get better soon), so my time available for opensource dev'ing has dropped...
I still want to fix this, but it'll just have to wait for me (or someone else) to spend some time on it.

Klaim

12-11-2013 11:37:20

Ok, no pressure, I'm not pressed at all with this, I just wanted to know because it was not clear for me from the logs.

Oh by the way, there is no official issue tracker?

mikachu

12-11-2013 13:23:04

Oh by the way, there is no official issue tracker?
Yes, there is the google code's issue tracker : http://code.google.com/p/ogre-procedural/issues/list

Though some feature requests have been there for ages and it could use some cleaning up.