PhysicsEditor Loader Extension

A place to post your custom classes and engine extensions to share with the community.

PhysicsEditor Loader Extension

Postby StuartTresadern » Mon Dec 09, 2013 8:51 pm

Anyone who has the Physics Editor may find this of some use. I have provided a customer exporter for the Physics Editor http://www.codeandweb.com/physicseditor and a new extension class for the isogenic engine.

Custom Exporter:

Two files are attached for the custom export, simply create a new folder in the exporter directory and copy the files in, restart the editor if you have it open and the new exporter will be available for selection next time you start it up.

The exporter will process all the parameters set in the editor to the isogenic engine, poly points, Density Restitution, Friction, Is Sensor, Linear and Angular Damping, Sleep, Bullet, Garvitic and Fixed Rotation. It also passes the Group and Category bits but I still have to check them.

exporter001.png
exporter001.png (207.63 KiB) Viewed 10442 times


PhysicsEditorLoader Extension:

Copy the PhysicsEditorLoader.js to your game classes directory and reference it in your clientConfig.

I normally implement the loader in my main client class but you can implement it in any class you want:

Code: Select all
self.implement(PhysicsEditorLoader);


The exported physics definition file has already been assigned a default variable name of : physicsdef if you only have a single file then you can leave it as is or rename as required.

Next you need to call the loader:

First parameter is the variable assigned to the physics definition file by default this is set to physicsdef.
Second parameter is the path to the physics definition file.
And the third parameter is the callback which passes an array of box2d entities.

Code: Select all
self.loadPhysicsData('warshipsphy','./assets/images/warshipphy.js', function(bodies){

                        for (var i = 0; i < bodies.length;i++){

                            bodies[i].texture(ige.client.gameTexture[0])
                            bodies[i].cell(i+1)
                            bodies[i].translateTo((i*100)-500,(i*100)-500,0);
                            bodies[i].depth(i)
                            bodies[i].mount(ige.$('scene1'));
                            bodies[i].dimensionsFromCell();
                        }

                    });


In the callback do whatever you need to the returned array of IgeEntityBox2d() entities.
Attachments
PhysicsEditorLoader.zip
Physics Loader Extension
(1.32 KiB) Downloaded 685 times
exporter.zip
Exporter files for PhysicsEditor
(1.67 KiB) Downloaded 657 times
Last edited by StuartTresadern on Mon Dec 09, 2013 9:10 pm, edited 1 time in total.
User avatar
StuartTresadern
 
Posts: 59
Joined: Sun Dec 01, 2013 5:23 pm
Location: Germany

PhysicsEditor Loader Extension (2)

Postby StuartTresadern » Mon Dec 09, 2013 8:53 pm

Sample image showing the poly data in the engine.

exporter002.png
exporter002.png (243.69 KiB) Viewed 10441 times
User avatar
StuartTresadern
 
Posts: 59
Joined: Sun Dec 01, 2013 5:23 pm
Location: Germany

Re: PhysicsEditor Loader Extension

Postby rob » Wed Dec 18, 2013 7:23 pm

Wow that is amazing, thanks for sharing!
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 Custom Code

Who is online

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