Easier Isometric Entities - Feedback Requested!

Get the latest news on new features, bug fixes and version updates right here!

Easier Isometric Entities - Feedback Requested!

Postby rob » Wed Dec 18, 2013 12:39 am

Hey all,

I am thinking of ways to make creating isometric entities easier. The main reason for this change is the complexity level required to create an isometrically placed entity. The other is that I want to simplify it for the new editor so that drag/drop is possible without a lot of fiddling or code writing.

One of the complexities with iso entities is around how they render their assigned textures as well as how they set their 3d bounds.

At the moment the two are coupled so we require two entities, one mounted to the other. 3d bounds alters the _geometry property which is also used to calculate the texture size. If de-coupled, we could have an isometric bounding cuboid that had no relation to the texture's width and height, thereby allowing a single entity to hold both isometric bounds AND an image texture, reducing memory usage and speeding up frame execution / processing / rendering.

The question then becomes, how to represent this change in terms of method calls. I am thinking something like:

size3d(x, y, z) - stays the same, still sets the _geometry property (perhaps this should now be renamed to bounds3d() ?)
width(val) - sets the texture's width
height(val) - sets the texture's height

You would then combine the calls to define a single entity that had both iso bounds for depth sorting (and hit testing if you want) and also separate width and height for the texture.

Some questions then arise from this change...

1) How do you calculate the AABB of the entity? Should it be the AABB of the texture or the 3d bounds or both combined or what?
2) When doing hit testing (mouse and touch) how do you determine a hit?
3) What is the effect of settings like originTo(x, y, z) and anchor(x, y)?

With this change I think that it makes sense to no longer think of the AABB as the hit test area at all, but rather auto-set a default hit test area as the texture bounds and then allow the programmer to re-defined that if they choose. Currently you can select between the AABB or the iso bounds polygon but perhaps that is no longer required. Instead we can do something like this:

Code: Select all
// Define a custom hit-test trigger polygon and use it
var polygon = new IgePoly2d()
    .id('myPoly1');

entity.triggerPolygon(polygon);


Or if you want to just use the AABB of the entity texture you can do:

Code: Select all
entity.triggerPolygon(entity.aabb());


Or if you want to use the 3d bounds polygon:

Code: Select all
entity.triggerPolygon(entity.isoBoundsPoly());


In this scenario, the AABB will then be the texture bounds, 3d bounds will be the isometric cuboid bounds and if neither of these suits, you can define your own.

I am currently working on an experimental branch to apply these changes and see what the upsides/downsides are to both existing code and performance. Obviously I'm adverse to breaking changes whenever possible but when there are obvious benefits I'm hard pressed to argue.

Can you all weigh in and let me know your thoughts? Thanks!
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
User avatar
rob
Site Admin
 
Posts: 316
Joined: Tue Oct 22, 2013 5:08 pm

Re: Easier Isometric Entities - Feedback Requested!

Postby rob » Wed Dec 18, 2013 12:58 am

After some testing, passing the aabb or the isoBoundsPoly in and storing it wont work because they return polys that are based on absolute co-ordinates. Instead I think the poly should be based on normals so that if the entity is moved, rotated or scaled then the poly can still apply. In this case I'm thinking that altering the call to triggerPolygon to use normalised polys is best, something along the lines of:

entity.triggerPolygon(entity.aabbNormal())

entity.triggerPolygon(entity.bounds3dNormal())

and obviously a custom poly made up of normals as well.
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
User avatar
rob
Site Admin
 
Posts: 316
Joined: Tue Oct 22, 2013 5:08 pm

Re: Easier Isometric Entities - Feedback Requested!

Postby rob » Wed Dec 18, 2013 1:01 am

This will also mean that calls to dimensionsFromTexture and dimensionsFromCell will apply directly to width and height rather than affecting size3d.
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
User avatar
rob
Site Admin
 
Posts: 316
Joined: Tue Oct 22, 2013 5:08 pm

Re: Easier Isometric Entities - Feedback Requested!

Postby rob » Wed Dec 18, 2013 2:28 am

rob wrote:After some testing, passing the aabb or the isoBoundsPoly in and storing it wont work because they return polys that are based on absolute co-ordinates. Instead I think the poly should be based on normals so that if the entity is moved, rotated or scaled then the poly can still apply. In this case I'm thinking that altering the call to triggerPolygon to use normalised polys is best, something along the lines of:

entity.triggerPolygon(entity.aabbNormal())

entity.triggerPolygon(entity.bounds3dNormal())

and obviously a custom poly made up of normals as well.

OK this won't work either for two reasons:

1) We cannot use chaining because we would need the entity reference before the chain had finished
2) What would the normal relate to? Iso or 2d bounds?

Instead I will stick with the convention I used in mouseEventTrigger except that I will modify it to accept a method name:

Code: Select all
// Trigger on 2d texture bounds (bounds2dPolygon is a new method in IgeEntity)
entity.triggerPolygon('bounds2dPolygon');

// Trigger on 3d iso polygon bounds (bounds3dPolygon is also a new method in IgeEntity)
entity.triggerPolygon('bounds3dPolygon');

// Trigger on your own custom polygon returned by your own custom method
entity.triggerPolygon('myCustomPolygonReturningMethod');
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
User avatar
rob
Site Admin
 
Posts: 316
Joined: Tue Oct 22, 2013 5:08 pm

Re: Easier Isometric Entities - Feedback Requested!

Postby rob » Wed Dec 18, 2013 4:53 am

This has now been implemented in the dev branch.

A number of breaking changes have been applied to the latest version in dev and you can find out more about them here: viewtopic.php?f=8&t=98

The changes made to the entities should not break existing isometric entities in your games but you can now convert them to reduce memory and increase performance.

The 9.2 example's character has been updated to use a single entity but contains both a 3d cuboid and texture. All other examples are being converted presently.

If you would like to discuss this change please do so in this thread or open a new topic in the help section.
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
User avatar
rob
Site Admin
 
Posts: 316
Joined: Tue Oct 22, 2013 5:08 pm

Re: Easier Isometric Entities - Feedback Requested!

Postby foolmoron » Thu Dec 19, 2013 6:11 pm

Seems like a good change, as it was definitely confusing having to make an isometric entity by mounting two objects together and such.

However even after converting my iso entities, some of my entities are still broken (non-iso ones, strangely enough). I'm gonna have to spend some more time checking things out later.
foolmoron
 
Posts: 57
Joined: Thu Oct 24, 2013 7:20 pm

Re: Easier Isometric Entities - Feedback Requested!

Postby rob » Thu Dec 19, 2013 6:14 pm

foolmoron wrote:Seems like a good change, as it was definitely confusing having to make an isometric entity by mounting two objects together and such.

However even after converting my iso entities, some of my entities are still broken (non-iso ones, strangely enough). I'm gonna have to spend some more time checking things out later.

Thanks for the feedback.

Keep in mind that if you used to set your 2d entities via size3d() calls then you need to change that to bounds2d(x, y) or width(x) height(y) calls, or use the built-in dimensionsFromTexture() and dimensionsFromCell() methods to size your textures correctly.

Let me know if that helps or it's something else :)
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
User avatar
rob
Site Admin
 
Posts: 316
Joined: Tue Oct 22, 2013 5:08 pm


Return to New Features, Latest Versions & General Updates

Who is online

Users browsing this forum: No registered users and 1 guest
cron