SFML community forums

Help => Graphics => Topic started by: mkalex777 on October 01, 2015, 11:06:36 am

Title: jelly physics deformations with sfml, is it possible
Post by: mkalex777 on October 01, 2015, 11:06:36 am
I want to achieve effect, something like this: http://www.youtube.com/watch?v=E-fr5lBmbbQ

Is it possible?
How to implement it? Probably there is need to use shaders for transformations?
Title: Re: jelly physics deformations with sfml, is it possible
Post by: eXpl0it3r on October 01, 2015, 11:34:56 am
Why don't you first do a bit of research on the topic yourself?
Title: Re: jelly physics deformations with sfml, is it possible
Post by: mkalex777 on October 01, 2015, 02:15:11 pm
Why don't you first do a bit of research on the topic yourself?

Yes, I'm research, so it's the reason why I'm writing here.
I'm interested if it possible with SFML architecture, because there is need to transform the geometry, but SFML hide it inside library...
Title: Re: jelly physics deformations with sfml, is it possible
Post by: Laurent on October 01, 2015, 02:27:22 pm
You should first find out (and tell us) how it is supposed to be done, and then we can help you implement the technique with SFML.
Title: Re: jelly physics deformations with sfml, is it possible
Post by: mkalex777 on October 01, 2015, 04:26:25 pm
I'm just trying to find the way on how I can fill multi point polygon with SFML, so I can use it to render soft body objects for further investigations...
Title: Re: jelly physics deformations with sfml, is it possible
Post by: G. on October 01, 2015, 04:29:15 pm
Look for metaballs.

If you want to "transform the geometry", you can use a vector of sf::Vertex (or an sf::VertexArray).
Title: Re: jelly physics deformations with sfml, is it possible
Post by: AlexAUT on October 01, 2015, 07:42:03 pm
I'm just trying to find the way on how I can fill multi point polygon with SFML

Have a look at VertexArray  (http://www.sfml-dev.org/documentation/2.0/classsf_1_1VertexArray.php), there is also a section in the tutorials about custom shapes (http://www.sfml-dev.org/tutorials/2.3/graphics-vertex-array.php). They allow you to set each point by your own (Use sf::Triangle/TriangleStrip/TriangleFan, depending on your needs, to draw a filled polygon).



AlexAUT
Title: Re: jelly physics deformations with sfml, is it possible
Post by: mkalex777 on October 01, 2015, 09:25:09 pm
I'm just trying to find the way on how I can fill multi point polygon with SFML

Have a look at VertexArray  (http://www.sfml-dev.org/documentation/2.0/classsf_1_1VertexArray.php), there is also a section in the tutorials about custom shapes (http://www.sfml-dev.org/tutorials/2.3/graphics-vertex-array.php). They allow you to set each point by your own (Use sf::Triangle/TriangleStrip/TriangleFan, depending on your needs, to draw a filled polygon).



AlexAUT

Yes, I read it. I'm using vertex array to fill a gradient rectangle (quad) and to render realtime fps graph (lines). I read about concaveshape, but it uses vertex array with specific flow direction. I tried it to fill multipoint polygon, but it gives strange shapes.
Is there any guide or example on how to generate vertex array in correct order for multipoint polygon?
Title: Re: jelly physics deformations with sfml, is it possible
Post by: AlexAUT on October 01, 2015, 09:48:48 pm
Quote
multipoint polygon

I've never heard that word, but I think you meant just a concave polygon? To draw a concave polygon correctly you have multiple options, at my university we learned about cutting a concave polygon to multiple convex polygons (which would save your problem I guess?)

You just google "break concave polygon into convex" or "Polygon triangulation" and you should find a way to implement it.


AlexAUT
Title: Re: jelly physics deformations with sfml, is it possible
Post by: mkalex777 on October 01, 2015, 10:27:44 pm
Quote
multipoint polygon

I've never heard that word, but I think you meant just a concave polygon? To draw a concave polygon correctly you have multiple options, at my university we learned about cutting a concave polygon to multiple convex polygons (which would save your problem I guess?)

You just google "break concave polygon into convex" or "Polygon triangulation" and you should find a way to implement it.


AlexAUT

Yes, exactly. Sorry for terminology. I know about it, but I think that its probaly should be already implemented as a ready to use class or something like that. Does SFML provides some tools to work with it without implementation of complicated algorithms?
What I'm looking for is a way on how I can generate vertex array for a circle, make some transformations and pass it to the window.draw.
I think that it can be done in such way. But I never worked with such tasks, so please correct me if I'm wrong. May be there is a better way to implement it? What is your thoughts?

I'm using some physics in the game, but it works just with object models to calculate coordinates, speed, collisions and there is no graphics effects for collisions. So, I want to add some graphics effects, to make objects more alive and responsive :)
Title: Re: jelly physics deformations with sfml, is it possible
Post by: AlexAUT on October 02, 2015, 12:01:43 am
SFML 2.x does not offer such a feature, but you could use Thor ConcaveShape  (http://www.bromeon.ch/libraries/thor/v2.0/doc/group___shapes.html)(SFML extension written by a member of the SFML Team, Nexus).

What I'm looking for is a way on how I can generate vertex array for a circle, make some transformations and pass it to the window.draw.

If you need just a Circle you could use sf::CircleShape (http://www.sfml-dev.org/documentation/2.0/classsf_1_1CircleShape.php)?
If you want to make it with VertexArray you have to generate the geometry data yourself and apply the transformation yourself, in case of a circle it isn't that hard (a bit sin and cos  :P).



AlexAUT
Title: Re: jelly physics deformations with sfml, is it possible
Post by: mkalex777 on October 02, 2015, 01:45:04 pm
If you need just a Circle you could use sf::CircleShape (http://www.sfml-dev.org/documentation/2.0/classsf_1_1CircleShape.php)?

If you want to make it with VertexArray you have to generate the geometry data yourself and apply the transformation yourself, in case of a circle it isn't that hard (a bit sin and cos  :P).

Yes, I'm already using CircleShape, I just want to make it more alive by adding some deformations.
Thanks, I know how to draw a circle, I just interested if SFML provides any kind of helper to render polygon from array of points... It seems that it is not...
Title: Re: jelly physics deformations with sfml, is it possible
Post by: Nexus on October 02, 2015, 03:34:23 pm
I just interested if SFML provides any kind of helper to render polygon from array of points...
What's the problem with sf::VertexArray? ???

You really have to be more specific. If you need a concave polygon composition, look at the Delaunay Triangulation (http://www.bromeon.ch/libraries/thor/v2.0/doc/_triangulation_8hpp.html) I implemented in Thor, or use thor::ConcaveShape directly.