Polygon primitive

  ... discussions about development with the GLES2 branch of AndEngine.

Polygon primitive

Postby red » Fri Dec 30, 2011 1:34 am

Hi,

could someone provide example of polygon class implementation, I don't know how to draw a line in one color and the filling in another one (and alpha channel)

Thanks
red
 
Posts: 9
Joined: Fri Feb 25, 2011 11:52 pm

Re: Polygon primitive

Postby IFL » Thu Jan 19, 2012 4:12 pm

I'm currently working on this :!: I might not finish today, but it'll be soon. Are you wanting the polygon to be able to change shape once it has been created?
User avatar
IFL
 
Posts: 177
Joined: Fri Mar 04, 2011 6:28 am

Re: Polygon primitive

Postby red » Sat Jan 28, 2012 3:19 pm

IFL wrote:I'm currently working on this :!: I might not finish today, but it'll be soon. Are you wanting the polygon to be able to change shape once it has been created?


That would be great, will you share your polygon implementation?
red
 
Posts: 9
Joined: Fri Feb 25, 2011 11:52 pm

Re: Polygon primitive

Postby recastrodiaz » Sun Jan 29, 2012 3:50 pm

I have a working GLES2 implementation and an example using it in my github forks :
https://github.com/recastrodiaz/AndEngine
https://github.com/recastrodiaz/AndEngi ... ample.java
It is not fully tested and it lacks some features, but does render convex and non convex polygons.
Let me know what you think and what features you might need. Any help is welcome.
recastrodiaz
 
Posts: 26
Joined: Mon Aug 22, 2011 11:32 pm
Location: Lyon, France

Re: Polygon primitive

Postby IFL » Sun Jan 29, 2012 10:48 pm

Thanks, recastrodiaz!
User avatar
IFL
 
Posts: 177
Joined: Fri Mar 04, 2011 6:28 am

Re: Polygon primitive

Postby nazgee » Mon Jan 30, 2012 12:00 pm

Work perfectly for me. Well... Almost :)

I use it for physics debug draw, and accidentaly I tried to use it to draw a line (two vertices) - it crashed badly :) But this probably should not be considered as a bug- two vertices polygon is a "non-standard" one :)
Dirt Rider Mayhem is PUBLISHED now!
Image
User avatar
nazgee
 
Posts: 524
Joined: Fri Oct 21, 2011 10:31 pm
Location: Poland, Wrocław

Re: Polygon primitive

Postby recastrodiaz » Mon Jan 30, 2012 9:11 pm

In fact when you create a polygon with less that 3 vertices or a non simple polygon it will certainly crash. I changed the code this afternoon so an update of the vertices won't force the renderer to crash if the new vertices can't be properly triangulated.
I also think I should use/implement a better triangulation algorithm.
recastrodiaz
 
Posts: 26
Joined: Mon Aug 22, 2011 11:32 pm
Location: Lyon, France

Re: Polygon primitive

Postby jgibbs » Sat Feb 04, 2012 1:20 pm

Very useful class. Is there any way to put a texture overlay onto this shape? I'd like to use this to draw the ground base of my game but it would look a lot better if I could apply a simple repeating texture to it rather than just using a static color.
Check out my adventures into Android programming:

4x4 Adventures - Featured in the Top Free Play Store listings
Slippery Sid
jgibbs
 
Posts: 105
Joined: Fri Nov 25, 2011 9:32 am
Location: New Zealand

Re: Polygon primitive

Postby recastrodiaz » Mon Feb 06, 2012 10:47 pm

Not yet, but I think it could be done by doing some UV mapping magic, though you would need to provide a triangular mesh (and avoid using the current triangulation algorithm), texture coordinates and of course a texture. Maybe, what you are trying to do could be done otherwise ?
recastrodiaz
 
Posts: 26
Joined: Mon Aug 22, 2011 11:32 pm
Location: Lyon, France

Re: Polygon primitive

Postby jgibbs » Tue Feb 07, 2012 6:11 am

I've played quite a bit with texture mapping objects in 3D, in particular using 3D programs to generate the meshes and to push out the files and textures coords to read into a viewer, but I've never needed to not triangulate the textures. It's always been a 1-1 mapping of the textures to triangles.

I'm wondering if what I'm trying to do might be quite simple, I've just never done it so I'm looking to others for their knowledge before I crack open the low level stuff. If you don't give UV coordinates, or just give UV coords of, say, a simple face, would that achieve what I'm attempting here. All I'm after is the ability to have a tile repeated across the face. The anchor points are not important to me, only the scale.

I haven't looked into what the polygon class creates as far as the final GL mesh so this may not work if it's going to need to be painted onto separate triangle instances, but if it's a one-shot draw of a vertex buffer I'm hoping that it might be achievable. It would be a great way to 'wallpaper' any arbitrary shaped object.

Just to illustrate what I'm trying to achieve here...

This would be a terrain, read from a description file and generated as a single polygon object:
base1.jpg
base1.jpg (15.8 KiB) Viewed 2798 times


This might be the triangulation internally of the polygon, obviously out of my control:
base2.jpg
base2.jpg (19.6 KiB) Viewed 2798 times


This would be a texture tile that is designed to repeat:
base3.jpg
base3.jpg (13.12 KiB) Viewed 2798 times


The texture repeated across the terrain to be clipped:
base4.jpg
base4.jpg (24.25 KiB) Viewed 2798 times


And the final desired goal:
base5.jpg
base5.jpg (21.42 KiB) Viewed 2798 times
Check out my adventures into Android programming:

4x4 Adventures - Featured in the Top Free Play Store listings
Slippery Sid
jgibbs
 
Posts: 105
Joined: Fri Nov 25, 2011 9:32 am
Location: New Zealand

Next

Return to GLES2

Who is online

Users browsing this forum: Robyrq and 21 guests