Adam's Lair Forum

game development and casual madness
It is currently 2017/03/26, 11:21

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: 2017/02/12, 11:58 
Junior Member
Junior Member
User avatar

Joined: 2017/02/09, 19:26
Posts: 39
Role: Hobbyist
Hi,

I'm making an Ear Cutting plugin that allows making polygons of N vertices, creating authomatically triangular shapes for its rigid body and changing dynamically in game time and in the editor.
Gfycat Video - Click to Play. [Source]
So far it is almost working, but I have two issues I'm not sure how to solve:
1. It works fine with the launcher but I can't find a way to detect the mouse (position or buttons) in the editor, so right now it is useless for level making.
2. You can see the seams between triangles. I guess I'll have to learn something about shaders, but I'm not sure yet if that is needed.

I've been looking around in the forum, and in the src, but I'm lost again.
Any tip on how to solve this issues?

Thanks!


Top
 Profile  
 
PostPosted: 2017/02/12, 12:18 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 1933
Location: Germany
Role: Professional
Looks great, nice work! :) :1+:

It sounds like you implemented this functionality in game code, which is where it gets a bit problematic: There is no way to provide editor functionality in a CorePlugin, the two are strictly separated and the RigidBody Editor where you'd do most of the editing does not forward input events to the core at all. Only the Game View does, which is by design. So to get this working in the editor, you'd actually have to write an editor plugin.

There is no getting started guide on writing editor plugins right now, but it's been done on the community-side, so there are some questions around on the forum which may have answers that could help, and also you can take a look at the source of some of the existing editor plugins. Also note that Duality auto-generates an editor plugin project just as it does with the core plugin for you - it's just not part of the solution file by default, so you'll have to add it manually in Visual Studio.

In this specific case, you'd probably want to provide a custom tool for the RigidBody editor that does the cutting. The way this works is that you define a public class that derives from the tool base class and the editor will automatically add it to the appropriate toolbar and call your methods. I think the current API might not work that well for what you intend to do here, but could be worth a try.

Other than that, you may be interested in these issues on GitHub that I plan to address sooner or later. Feel free to join the discussion or contribute code samples or sketches on how this could be done!

Allow Non-Convex, Arbitrary-Sized Polygon Shapes in RigidBodies
Introduce an "Edit Shape" Tool to the RigidBody Editor

As far as the texturing issue goes, that might have something to do with how the RigidBodyRenderer works, if you're using that one, e.g. with how it fills polygons: Each one independently of the others, so there is no overarching continuity of texture coordinates. Since you're generating multiple polygons, there are seams between them. Another thing to be addressed on the core side, could be suitable for a PR as well.

Hope this helps a little, even though it might not be the answer that you anticipated.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2017/02/12, 18:54 
Junior Member
Junior Member
User avatar

Joined: 2017/02/09, 19:26
Posts: 39
Role: Hobbyist
Wow! Thanks Adam. Lots of info :D

Yes, I did it in game code. Now I understand why it wasn't working ^^ so I'll look into the RigidBodyEditor code right away.
Quote:
Allow Non-Convex, Arbitrary-Sized Polygon Shapes in RigidBodies
Introduce an "Edit Shape" Tool to the RigidBody Editor
This is exactly the functionality I was missing for level creation ^^ I'll try to get it done as an editor plugin and upload the code.
For the ear cutting approach this code by fgshen, adding the correction by gomezmateu.oscar, solves the triangulation challenge ;) They did the real magic.

About the texture, you're also right. I inherited from RigidBodyRenderer, only drawing the selection circles and calling the ear cutting functions. I'll see if I can override the drawing part.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group