Adam's Lair Forum
https://forum.adamslair.net:80/

[WIP][Plugin] ComplexBody
https://forum.adamslair.net:80/viewtopic.php?f=18&t=1064
Page 1 of 2

Author:  YMR [ 2017/02/17, 07:17 ]
Post subject:  [WIP][Plugin] ComplexBody

A complex body plugin (arbitrary-sized, non-convex and editable RigidBody).
Warning: This is WIP. Really.
Gfycat Video - Click to Play. [Source]
It works, but...
1. If you change the position, the scale or the rotation of the ComplexBody object, weird things happen when editing the body. The XYZ transformation is not right.
2. The texture management is as far from good as it can be. I'm thinking of rotating each triangle texture based on the rotation of the previous triangle, but first I wanted to finish the editor plugin, and I'm loosing my mind :lol:
3. The vertex sort order could be modified to something better.
4. The code should be cleaner.

How it works:
To edit a ComplexBody it must be selected (green lines) AFTER entering the ComplexBody Editor.
Left click to move or add a vertice.
Right click to remove a vertice.
Ctrl to show the snap lines.
When a vertex is added, it is ordered based on the proximity of the other vertices.

Here is the code: https://github.com/YMRYMR/YMR.ComplexBody

You are welcome to try it and help (or change everything) ;)

PS: The ear cutting triangulation code is the work of fgshen, and the correction code is the work of gomezmateu.oscar. They did the real magic.

Author:  hsnabn [ 2017/02/17, 18:44 ]
Post subject:  Re: [WIP][Plugin] ComplexBody

Editing looks really smooth, even in the current WIP state. This might help a lot in level prototyping situations. Nice work!

Author:  Adam [ 2017/02/17, 18:55 ]
Post subject:  Re: [WIP][Plugin] ComplexBody

Heh, so you already took the editor development deep dive! Nice work :) :1+:

Have you considered letting the complex shape editor do the shape drawing, rather than the object itself? (I'm guessing it's the object, because you can initially see the vertex numbers in Game View mode)

Author:  YMR [ 2017/02/17, 19:08 ]
Post subject:  Re: [WIP][Plugin] ComplexBody

Thanks!

Adam wrote:
Have you considered letting the complex shape editor do the shape drawing, rather than the object itself?
I thought about it, but not sure how to avoid duplicating the drawing code. I've modified the code to be able to work in the editor, but it is 100% game code with little bits for the CamViewState.

Author:  YMR [ 2017/02/23, 06:16 ]
Post subject:  Re: [WIP][Plugin] ComplexBody

Thanks to @Adam's help, the texture rendering is working now xD
Gfycat Video - Click to Play. [Source]
Code commited to GitHub.

The only issue I can think of right now is that the algorithm isn't perfect: When you have a descompensated shape (say W = 1.000,00 and H = 1,00), it could result in an incorrect triangulation.
Anyway, or my current purposes it works, so [for now] I'll end the development of this plugin. But of course, feedback is always welcome.

Author:  Cross [ 2017/02/23, 09:07 ]
Post subject:  Re: [WIP][Plugin] ComplexBody

@YMR:

Looks great! :) I'll test your plugin when I'm back home ^^

Author:  YMR [ 2017/03/01, 09:31 ]
Post subject:  Re: [WIP][Plugin] ComplexBody

Thanks @Cross . Let me know if you find any issue ;)

Author:  YMR [ 2017/03/26, 10:10 ]
Post subject:  Re: [WIP][Plugin] ComplexBody

I've been working on this tool, mainly to allow it to handle border textures/materials, so here is a demo of it's current state:
Gfycat Video - Click to Play. [Source]
Some issues remain unsolved:
1. Weird issues with materials. If you set a Material like SolidBlack, it breaks and the editor freezes. Not sure why. Also, with the Checkerboard material some colors like RGB(0,0,255) make it dissapear.
2. The border polygons don't maintain the parametrized width. That's because the border polygon points are calculated to avoid intersection between border polygons and the length of the lines between outer points and inner points is the border width. That's wrong. The border width should be applied perpendicular to the triangle's outer line. This is a basic geometry issue, I know, but somehow I don't see the solution yet.
3. The border texture is not rotated nor scaled as it should.
4. The code is a mess. It is ugly and dirty and chaotic. Once it works it'll need a heavy refactoring.
5. I made the editor to accommodate the original design (made for editing the ComplexBodies ingame). It should be completely redone when refactoring to allow a better editing experience.
6. Given that this component draws a lot, for performance reasons it should be changed to work directly with the device, instead of the canvas as is does right now.

Points 2 and 3 are the main issues here.
Point 1 is a bug in how I'm drawing things, I guess, so it'll need to be addressed.
Points 4, 5, and 6 should be done at the same time, but if anyone wants to help I could address point 4 before anything else to keep crazyness away. Invited you are ;)

I've updated the repository: https://github.com/YMRYMR/YMR.ComplexBody

Author:  YMR [ 2017/03/26, 21:13 ]
Post subject:  Re: [WIP][Plugin] ComplexBody

The border width is now ok. One less thing to think about :)
But: this code is far from optimized. The border polygons calculus should be done only when modifying the ComplexBody and not at render time.
Gfycat Video - Click to Play. [Source]

Author:  Adam [ 2017/03/27, 17:06 ]
Post subject:  Re: [WIP][Plugin] ComplexBody

This looks really useful, especially for platformers and topdown character movement games.

Nice work :+1: :)

Page 1 of 2 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/