We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › Geomerative - Some questions
Page Index Toggle Pages: 1
Geomerative - Some questions (Read 1693 times)
Geomerative - Some questions
Jul 7th, 2009, 4:05pm
 
Hi Ricard, thanks for suggesting Geomerative for my current project. I've tested it against my needs and it's pretty much perfect. You just saved me a lot of work!

Some questions:

- How do I test if a point is inside a group, a path etc.? RGroup.contains() does not seem to do what I expected it to do. Sorry, I was being retarded. It does do what it says it does.

- What is the difference between RContour and RPath?

I'm sure I'll run into more, I'll let you know...
Re: Geomerative - Some questions
Reply #1 - Jul 8th, 2009, 1:59am
 
RPath is a sequence of commands lineTo, quadTo or bezierTo.  moveTo is not part of the commands since this command just creates a new path.

RContour is just a sequence of polygons vertices (as in a polygon without holes).  In the long run I would like to drop all this differentiation between contours and paths, and contours would just become RPath with only lineTo.

However I think you would rarely need RGroup, RPolygon RContour, etc.

Normally RShape and RPath should be sufficient, the other classes are mostly there for backwards compatibility and for performance (e.g. if you know you are often going to draw the same shape to the screen and you know the backend is OPENGL then the best is to transform to RPolygon only once and then just draw the RPolygon as many times needed, but this is just due to limitations of the OPENGL backend and not good for other backends such as PDF where you want to draw the shape using the commands beziers, quads, etc.).

RGroup existed before in order to represent a hierarchy of shapes, but I have modified the library so that it is more similar to PShape, this would allow to easily switch from one to the other.  So now only RShape is needed and has a field called children which is an array of children shapes.  It also has all the methods that RGroup used to have (e.g. contains).

And finally RG which is a static class containing a procedural API very similar to Processing's is preferred to the classes for loading RSVG and RFont or the RShape and RPath constructors.

These are the major differences from the old Geomerative and the new one.  However I tried to keep the new one as backwards compatible as possible in order not to break existing sketches.

ricard

Re: Geomerative - Some questions
Reply #2 - Jul 9th, 2009, 11:53pm
 
Ah, that explains a lot. RShape and RPath work very well for my purposes, just used it to make some sketches with extruded 3D type. RMesh takes care of the front face, RShape.getPoints() gives me the vertices for the side faces.

Some comments:

- It would have been nice to specify a detail level for getPoints(). The default level is good, but I like to have an option of having a lores version for faster previews. Right now getPoints() seems to use the size of the RShape to determine number of points, which is fine for default use but not very flexible.

- Being able to get the intersection point(s) between a RShape and a line would have been nice.

- Ditto the minimum distance between a given point and a RShape. The source for java.awt.Line2D has code for this.

- Maybe have a way of getting a flipped RMesh from a RShape in order to get a mesh usable as a back face for 3D letters? It's easily done with transforms, I know.

In any case, props for a very useful lib, you saved me some real work this week! I'll try to repay you by writing some useful example sketches.
Re: Geomerative - Some questions
Reply #3 - Jul 10th, 2009, 3:42am
 
Quote:
- It would have been nice to specify a detail level for getPoints(). The default level is good, but I like to have an option of having a lores version for faster previews. Right now getPoints() seems to use the size of the RShape to determine number of points, which is fine for default use but not very flexible.


This is already possible using the RG.setPolygonizerXXX() methods.  Check the Tutorial 07 that is in the tutorials directory in the library folder.
In any case for faster preview and if you don't need equally spaced vertices I would use:
Code:
RG.setPolygonizer(RG.ADAPTATIVE);
RG.setPolygonizerAngle(angle);

where setPolygonizerAngle() is used to set the angle tolerance of consecutive segments when evaluating the vertices.

I know this is not the best name for the methods, but setSegmenterXXX() which was used before was not better.  Recommendations for better names are very welcome.

Quote:
- Being able to get the intersection point(s) between a RShape and a line would have been nice.

- Ditto the minimum distance between a given point and a RShape. The source for java.awt.Line2D has code for this.


These would definitely be nice to have.  I have also needed this in the past and ended up doing it manually, I'll see if I can add these to Geomerative in the coming days.

Quote:
- Maybe have a way of getting a flipped RMesh from a RShape in order to get a mesh usable as a back face for 3D letters It's easily done with transforms, I know.


Hm... I actually haven't used the library for a lot for 3D stuff.  Only in Cascade On Wheels of Steph Thirion and in Casas Tristes.  In both cases I did 3D extrusion of shapes but I didn't need to flip the back faces, I guess because in both cases there was no needed to see the back side.

I will do a little test and see what method could be helpful for this task.
Page Index Toggle Pages: 1