Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Polygon Paths
Started by horacebury Aug 07 2013 12:54 PM

5 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

horacebury

[GLOBAL: userInfoPane.html]
horacebury
  • Corona Geek

  • 3,069 posts
  • Corona SDK

Is it possible to access and modify polygon paths? This would be very useful but it does not appear to be documented yet and I can't figure out how to access the polygon path points.



[TOPIC: post.html]
#2

walter

[GLOBAL: userInfoPane.html]
walter
  • Moderator

  • 726 posts
  • Alumni

Not yet.

 

Can you give an example of how you might want to access points

 

This is be an overly simplistic example (and a rough API sketch)...

 

local poly = display.newPolygon( ... )
 
poly.path:setPoint( 3, newX, newY )

 

...but seeing how you envision getting and setting points would be really helpful.



[TOPIC: post.html]
#3

horacebury

[GLOBAL: userInfoPane.html]
horacebury
  • Corona Geek

  • 3,069 posts
  • Corona SDK

Considering that the shape sample tweens the properties of the paths by setting table values rather than calling a function, I think accessing a table of point x,y values would continue that style. It would also allow transitions to be used, whereas a function would not (as easily.)

 

Because quadrilateral distortion (http://docs.coronalabs.com/tachyon/guide/graphics/3D.html#quadrilateral-distortion) is performed using x,y points, I was trying to animate the points on the star in the polygon sample similarly, with something like this:

 

local o = display.newPolygon( x, y, vertices )
local vertices = { 0,-110, 27,-35, 105,-35, 43,16, 65,90, 0,45, -65,90, -43,15, -105,-35, -27,-35, }

transition.to( o.path[2], { time=3000, x=o.path[2].x+100, y.=o.path[2].y+100 } )

 

With multiple transitions used to animate multiple points. This makes me think that perhaps it would be better to define the vertices as:

 

local vertices = { {0,-110} , {27,-35} , {105,-35} , {43,16} , {65,90} , {0,45} , {-65,90} , {-43,15} , {-105,-35} , {-27,-35}, }

 

But I know that is not in keeping with the established point table style. The problem above is that calling newPolygon causes the vertices table to be converted from { ,,, } to { {,} , {,} , {,} } for the returned path table and this may not be acceptable.



[TOPIC: post.html]
#4

walter

[GLOBAL: userInfoPane.html]
walter
  • Moderator

  • 726 posts
  • Alumni

Overall, I see where you're going. There is a language limitation to doing the syntax you're proposing, but I see what you're trying to do.

 

The question that comes to mind is whether vertex shaders could play a role here.



[TOPIC: post.html]
#5

horacebury

[GLOBAL: userInfoPane.html]
horacebury
  • Corona Geek

  • 3,069 posts
  • Corona SDK

Are you saying that there is a language limitation when the number of points on the path (or other list of points) is unknown?

 

I'm not sure I follow how shaders could help with changing the shape of a path.



[TOPIC: post.html]
#6

admin

[GLOBAL: userInfoPane.html]
admin
  • Administrator

  • 68 posts
  • Administrators

Ah, I misread your example. The main issue I see is a Lua bridging overhead. That's going to take some time for us to figure out how to do well with minimal performance overhead.

 

Vertex shaders can modify the incoming point geometry and it's all done by the GPU. This is how the filter.wobble works, for example.




[topic_controls]
[/topic_controls]