Away3D with OimoPhysics

I’ve created simple example on how to use latest OimoPhysics with Away3D


That looks great and is very fast too! I get between 55-60 FPS in Chrome, and while part of that is probably due to Away3D being so light, it’s nice to see that the physics doesn’t slow the scene down at all.

If I understand correctly Oimo is a lightweight, pure Haxe physics engine, and thus it should be easier to modify and adapt than something used via an extension (such as Bullet)? I’m wondering how general the Oimo library is, could it be also used with e.g. Armory or Heaps? I remember reading somewhere that there is some ongoing work towards making Heaps usable with OpenFL, which might provide a more advanced 3D rendering alternative to Away3D.

Really cool GameStudioHx :slight_smile: :grinning:

kris just looked inside the engine and inside heaps.
hxd.prim.Cylinders, hxd.prim.Spheres, hxd.prim.Cubes inherit from hxd.prim.Quad, they provide a getBounds, hxd.cols.Bounds provides methods that could feed oimo.

tmpVec3_0 = oimoBody.getTransform().getRotation().toEulerXyz();			
			awayBody.moveTo(oimoBody.getPosition().x, oimoBody.getPosition().y, oimoBody.getPosition().z);			
			awayBody.transform.appendRotation(tmpVec3_0.x * radToDeg, awayBody.rightVector, awayBody.position);	
			awayBody.transform.appendRotation(tmpVec3_0.y * radToDeg, awayBody.upVector, awayBody.position);					
			awayBody.transform.appendRotation(tmpVec3_0.z * radToDeg, awayBody.forwardVector, awayBody.position);

You can see that omio is decoupled from the render engine, instead of inputting away3d body you could input a Quad

var geom:AwayCylinderGeom = cast mesh.geometry;
				var radius = geom.topRadius;
				var halfHeight = geom.height / 2;
				rBody = OimoUtils.addCylinder(OimoUtils.oimoWorld, tmpVec3_1, radius, halfHeight, type);

If you look in heaps you will see it has some physics engine built in, I believe a very early 2d version of this was physaxe, so you might not need oimo depending on your needs if you were using heaps.

Away3D is quite an extensive 3d engine so you might find it easier for lighting than other solutions, it would be a lot of work to get away3d to render with a different toolkit as it evolved on top of flash it was quite decoupled but totally decoupling might hard, after all the TS version of Away3D emulated quite a bit of flash api mirroring the kind of work that went into openfl.

Kha does not have stuff like Cylinders likely you would need to look at Armory3D, I know that directly working with Iron ( it’s inside ) is not so easy but likely you could hook omio to armory, by looking at the way they have hooked it up to bullet, the Armory bullet implementation is pure js and pure c++ so maybe faster than oimo for native atleast?

Depending on your needs I think Away3D could be really nice, obviously Kha often finds ways to do stuff faster but Away will be quicker to implement short term, so it really depends on you time budget, I mean for 3D armory is integrated with blender so it can make a lot of sense, but I think hacking away3d is likely going to be easier as it’s mostly abstracted well from the actual render detail stuff so you can change lots without needing to go too near shader stuff.

From what I can see there is a setup and update physics timer and the loop through away and oimo primatives and modify accordingly. It probably would not be too hard to adapt this demo to heaps since it’s mostly the one class that couples them, but I have not worked with heaps 3d only away back in the flash days. I like away3d a lot I have fond memories of it and pv3d ( as3 & as2 ).

@nanjizal indeed… Here’s a quick and dirty demo of how it might work with Heaps
Demo doesn’t work correctly as rotations are incorrect. Heaps has different coordinate system so some more work is needed to fix those rotations…

1 Like