{"id":768,"date":"2012-11-05T19:05:30","date_gmt":"2012-11-05T18:05:30","guid":{"rendered":"http:\/\/www.aymericlamboley.fr\/blog\/?p=768"},"modified":"2016-07-05T08:24:28","modified_gmt":"2016-07-05T06:24:28","slug":"playing-with-cadet-editor-and-awayphysics","status":"publish","type":"post","link":"http:\/\/www.aymericlamboley.fr\/blog\/playing-with-cadet-editor-and-awayphysics\/","title":{"rendered":"Playing with Cadet Editor 3D and AwayPhysics"},"content":{"rendered":"<p>The 3D part is a bit in stand-by this last weeks on the <a href=\"http:\/\/citrusengine.com\/\" target=\"_blank\">Citrus Engine<\/a>, because I&#8217;m polishing the engine for the V3 which should be out this week!<\/p>\n<p>I&#8217;ve never clearly introduced AwayPhysics in the Citrus Engine, so it&#8217;s the day! The idea is to have a similar pre-built platformer objects that we already have with Box2D and Nape but with AwayPhysics this time for 3D stuff! This work and Away3D support will evolve during the V3.<\/p>\n<p>Now that 3D views and physics are supported, it&#8217;s time to give a look on which tool we can use as a 3D game Level Editor. At first, I thought to <a href=\"http:\/\/www.closier.nl\/prefab\/\" target=\"_blank\">Prefab<\/a>. This is the best tool to create a scene with Away3D, importing assets, add lights&#8230; But too complex for a simple level design, I mean : hey the Citrus Engine is not a concurrent to <a href=\"http:\/\/unity3d.com\/\" target=\"_blank\">Unity3D<\/a> (which I started to learn thanks to this <a href=\"http:\/\/active.tutsplus.com\/tutorials\/unity\/getting-started-with-unity\/\" target=\"_blank\">awesome tutorial<\/a>) \ud83d\ude00 Its 3D physics part is just here to create basic 3D game \/ puzzle. Also the level editor has to support object creation (physics object), this isn&#8217;t obvious with Prefab.<br \/>\nThen I gave a look to <a href=http:\/\/cadeteditor.github.io\/\" target=\"_blank\">Cadet Editor<\/a>, the 3D editor is very easy to handle. You can create quickly sphere, cube and plane objects, add lights&#8230; That&#8217;s the right tool to see what can be done!<\/p>\n<p><!--more--><\/p>\n<p>I really enjoy the design of Cadet Editor, however it should manage right click with camera rotation instead of displaying a simple menu with a link to Away3D.<br \/>\nIn Cadet3D project are saved into a format close to MXML. See our examples and its code :<br \/>\n<a href=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2012\/11\/cadet3d.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2012\/11\/cadet3d-300x159.png\" alt=\"\" title=\"cadet3d\" width=\"300\" height=\"159\" class=\"alignleft size-medium wp-image-799\" srcset=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2012\/11\/cadet3d-300x159.png 300w, http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2012\/11\/cadet3d-1024x544.png 1024w, http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2012\/11\/cadet3d.png 1365w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<pre lang=\"xml\" line=\"1\"><cadet:CadetScene x:id=\"0\" framerate=\"30\" name=\"Component\" timeScale=\"1\" xmlns:cadet=\"www.unwrong.com\/cadet\/1.0.0\" xmlns:x=\"org.bonesframework.core.serialization.Serializer\" xmlns:bones=\"www.bonesframwork.org\/bones\/1.0.0\" xmlns:cadetAway3D4=\"www.unwrong.com\/cadetAway3D4\/1.0.0\" xmlns:ns0=\"cadetAway3D4.components.cameras\" xmlns:ns1=\"cadetAway3D4.components.materials\" xmlns:ns2=\"cadetAway3D4.components.geom\" xmlns:ns3=\"cadetAway3D4.components.lights\">\r\n  <bones:ArrayCollection x:name=\"children\" x:id=\"1\">\r\n    <cadetAway3D4:RendererAway3D x:name=\"0\" x:id=\"2\" name=\"Away3D 4 Renderer\">\r\n      <ns0:CameraComponent x:name=\"cameraComponent\" x:id=\"3\" transform=\"0.9833181500434875,-8.754431490842762e-8,-0.18189382553100586,0,0.12057413905858994,0.7487242221832275,0.6518235206604004,0,0.13618825376033783,-0.66288161277771,0.7362341284751892,0,-191.17271423339844,590.8668212890625,-854.3065185546875,1\" name=\"Camera\">\r\n        <bones:ArrayCollection x:name=\"children\" x:id=\"4\"\/>\r\n      <\/ns0:CameraComponent>\r\n    <\/cadetAway3D4:RendererAway3D>\r\n    <cadetAway3D4:MeshComponent x:name=\"1\" x:id=\"5\" transform=\"1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1\" name=\"Plane\">\r\n      <ns1:ColorMaterialComponent x:name=\"materialComponent\" x:id=\"6\" gloss=\"50\" specularStrength=\"1\" color=\"333722\" name=\"Blue Material\" depthCompareMode=\"less\"\/>\r\n      <bones:ArrayCollection x:name=\"children\" x:id=\"7\">\r\n        <ns2:PlaneGeometryComponent x:name=\"0\" x:id=\"8\" height=\"1000\" segmentsH=\"1\" segmentsW=\"1\" name=\"a platform\" width=\"1000\"\/>\r\n      <\/bones:ArrayCollection>\r\n      <x:Ref x:name=\"geometryComponent\" x:id=\"8\"\/>\r\n    <\/cadetAway3D4:MeshComponent>\r\n    <ns3:DirectionalLightComponent x:name=\"2\" x:id=\"9\" color=\"16777215\" specular=\"1\" ambient=\"0.1\" transform=\"0.9063077569007874,0,-0.4226183295249939,0,0.3830223083496094,0.42261824011802673,0.8213937878608704,0,0.17860621213912964,-0.9063078165054321,0.3830221891403198,0,0,0,0,1\" ambientColor=\"16777215\" diffuse=\"1\" name=\"Directional Light\">\r\n      <bones:ArrayCollection x:name=\"children\" x:id=\"10\"\/>\r\n    <\/ns3:DirectionalLightComponent>\r\n    <x:Ref x:name=\"3\" x:id=\"3\"\/>\r\n    <cadetAway3D4:MeshComponent x:name=\"4\" x:id=\"11\" transform=\"1,0,0,0,0,1,0,0,0,0,1,0,-58.91594696044922,146.62379455566406,-32.241188049316406,1\" name=\"Cube\">\r\n      <ns1:ColorMaterialComponent x:name=\"materialComponent\" x:id=\"12\" gloss=\"50\" specularStrength=\"1\" color=\"489736\" name=\"Green Material\" depthCompareMode=\"less\"\/>\r\n      <bones:ArrayCollection x:name=\"children\" x:id=\"13\">\r\n        <ns2:CubeGeometryComponent x:name=\"0\" x:id=\"14\" height=\"180.85\" segmentsH=\"1\" tile6=\"1\" depth=\"180.85\" segmentsW=\"1\" segmentsD=\"1\" name=\"a cube\" width=\"180.85\"\/>\r\n      <\/bones:ArrayCollection>\r\n      <x:Ref x:name=\"geometryComponent\" x:id=\"14\"\/>\r\n    <\/cadetAway3D4:MeshComponent>\r\n    <cadetAway3D4:MeshComponent x:name=\"5\" x:id=\"15\" transform=\"1,0,0,0,0,1,0,0,0,0,1,0,-140.8660888671875,340.4476318359375,-54.04615783691406,1\" name=\"Sphere\">\r\n      <ns1:ColorMaterialComponent x:name=\"materialComponent\" x:id=\"16\" gloss=\"50\" specularStrength=\"1\" color=\"12320768\" name=\"Red Material\" depthCompareMode=\"less\"\/>\r\n      <bones:ArrayCollection x:name=\"children\" x:id=\"17\">\r\n        <ns2:SphereGeometryComponent x:name=\"0\" x:id=\"18\" segmentsH=\"12\" segmentsW=\"16\" radius=\"84.13898408877864\" name=\"a sphere\"\/>\r\n      <\/bones:ArrayCollection>\r\n      <x:Ref x:name=\"geometryComponent\" x:id=\"18\"\/>\r\n    <\/cadetAway3D4:MeshComponent>\r\n    <cadetAway3D4:MeshComponent x:name=\"6\" x:id=\"19\" transform=\"1,0,0,0,0,1,0,0,0,0,1,0,151.02638244628906,146.50900268554688,127.5979995727539,1\" name=\"Sphere\">\r\n      <x:Ref x:name=\"materialComponent\" x:id=\"16\"\/>\r\n      <bones:ArrayCollection x:name=\"children\" x:id=\"20\">\r\n        <ns2:SphereGeometryComponent x:name=\"0\" x:id=\"21\" segmentsH=\"12\" segmentsW=\"16\" radius=\"52.35\" name=\"Sphere Geometry\"\/>\r\n      <\/bones:ArrayCollection>\r\n      <x:Ref x:name=\"geometryComponent\" x:id=\"21\"\/>\r\n    <\/cadetAway3D4:MeshComponent>\r\n    <cadetAway3D4:MeshComponent x:name=\"7\" x:id=\"22\" transform=\"1,0,0,0,0,1,0,0,0,0,1,0,164.13088989257813,348.98486328125,102.31562805175781,1\" name=\"Cube\">\r\n      <x:Ref x:name=\"materialComponent\" x:id=\"12\"\/>\r\n      <bones:ArrayCollection x:name=\"children\" x:id=\"23\">\r\n        <ns2:CubeGeometryComponent x:name=\"0\" x:id=\"24\" height=\"76.87\" segmentsH=\"1\" tile6=\"1\" depth=\"76.87\" segmentsW=\"1\" segmentsD=\"1\" name=\"Cube Geometry\" width=\"76.87064711138314\"\/>\r\n      <\/bones:ArrayCollection>\r\n      <x:Ref x:name=\"geometryComponent\" x:id=\"24\"\/>\r\n    <\/cadetAway3D4:MeshComponent>\r\n    <cadetAway3D4:MeshComponent x:name=\"8\" x:id=\"25\" transform=\"1,0,0,0,0,1,0,0,0,0,1,0,-161.5980987548828,37.646751403808594,291.46575927734375,1\" name=\"Cube\">\r\n      <x:Ref x:name=\"materialComponent\" x:id=\"12\"\/>\r\n      <bones:ArrayCollection x:name=\"children\" x:id=\"26\">\r\n        <ns2:CubeGeometryComponent x:name=\"0\" x:id=\"27\" height=\"75.29\" segmentsH=\"1\" tile6=\"1\" depth=\"75.29\" segmentsW=\"1\" segmentsD=\"1\" name=\"Cube Geometry\" width=\"75.29350445797198\"\/>\r\n      <\/bones:ArrayCollection>\r\n      <x:Ref x:name=\"geometryComponent\" x:id=\"27\"\/>\r\n    <\/cadetAway3D4:MeshComponent>\r\n    <cadetAway3D4:MeshComponent x:name=\"9\" x:id=\"28\" transform=\"1,0,0,0,0,1,0,0,0,0,1,0,-10.505144119262695,181.75933837890625,69.79844665527344,1\" name=\"Cube\">\r\n      <x:Ref x:name=\"materialComponent\" x:id=\"12\"\/>\r\n      <bones:ArrayCollection x:name=\"children\" x:id=\"29\">\r\n        <ns2:CubeGeometryComponent x:name=\"0\" x:id=\"30\" height=\"66.29\" segmentsH=\"1\" tile6=\"1\" depth=\"66.29\" segmentsW=\"1\" segmentsD=\"1\" name=\"Cube Geometry\" width=\"66.29740645095558\"\/>\r\n      <\/bones:ArrayCollection>\r\n      <x:Ref x:name=\"geometryComponent\" x:id=\"30\"\/>\r\n    <\/cadetAway3D4:MeshComponent>\r\n    <cadetAway3D4:MeshComponent x:name=\"10\" x:id=\"31\" transform=\"1,0,0,0,0,1,0,0,0,0,1,0,-393.7727966308594,113.91818237304688,-41.75886917114258,1\" name=\"Cube\">\r\n      <x:Ref x:name=\"materialComponent\" x:id=\"12\"\/>\r\n      <bones:ArrayCollection x:name=\"children\" x:id=\"32\">\r\n        <ns2:CubeGeometryComponent x:name=\"0\" x:id=\"33\" height=\"84.85\" segmentsH=\"1\" tile6=\"1\" depth=\"84.85\" segmentsW=\"1\" segmentsD=\"1\" name=\"Cube Geometry\" width=\"84.85060333420417\"\/>\r\n      <\/bones:ArrayCollection>\r\n      <x:Ref x:name=\"geometryComponent\" x:id=\"33\"\/>\r\n    <\/cadetAway3D4:MeshComponent>\r\n    <cadetAway3D4:MeshComponent x:name=\"11\" x:id=\"34\" transform=\"1,0,0,0,0,1,0,0,0,0,1,0,110.92161560058594,25.127405166625977,230.1426239013672,1\" name=\"Cube\">\r\n      <x:Ref x:name=\"materialComponent\" x:id=\"12\"\/>\r\n      <bones:ArrayCollection x:name=\"children\" x:id=\"35\">\r\n        <ns2:CubeGeometryComponent x:name=\"0\" x:id=\"36\" height=\"50.25\" segmentsH=\"1\" tile6=\"1\" depth=\"50.25\" segmentsW=\"1\" segmentsD=\"1\" name=\"Cube Geometry\" width=\"50.25481013821924\"\/>\r\n      <\/bones:ArrayCollection>\r\n      <x:Ref x:name=\"geometryComponent\" x:id=\"36\"\/>\r\n    <\/cadetAway3D4:MeshComponent>\r\n    <cadetAway3D4:MeshComponent x:name=\"12\" x:id=\"37\" transform=\"1,0,0,0,0,1,0,0,0,0,1,0,156.6885223388672,99.52238464355469,51.9654655456543,1\" name=\"Cube\">\r\n      <x:Ref x:name=\"materialComponent\" x:id=\"12\"\/>\r\n      <bones:ArrayCollection x:name=\"children\" x:id=\"38\">\r\n        <ns2:CubeGeometryComponent x:name=\"0\" x:id=\"39\" height=\"49.76\" segmentsH=\"1\" tile6=\"1\" depth=\"49.76\" segmentsW=\"1\" segmentsD=\"1\" name=\"Cube Geometry\" width=\"49.76054139091827\"\/>\r\n      <\/bones:ArrayCollection>\r\n      <x:Ref x:name=\"geometryComponent\" x:id=\"39\"\/>\r\n    <\/cadetAway3D4:MeshComponent>\r\n    <cadetAway3D4:MeshComponent x:name=\"13\" x:id=\"40\" transform=\"1,0,0,0,0,1,0,0,0,0,1,0,-241.41665649414063,106.39049530029297,-15.305731773376465,1\" name=\"Sphere\">\r\n      <x:Ref x:name=\"materialComponent\" x:id=\"16\"\/>\r\n      <bones:ArrayCollection x:name=\"children\" x:id=\"41\">\r\n        <ns2:SphereGeometryComponent x:name=\"0\" x:id=\"42\" segmentsH=\"12\" segmentsW=\"16\" radius=\"81.08778158664182\" name=\"Sphere Geometry\"\/>\r\n      <\/bones:ArrayCollection>\r\n      <x:Ref x:name=\"geometryComponent\" x:id=\"42\"\/>\r\n    <\/cadetAway3D4:MeshComponent>\r\n    <cadetAway3D4:MeshComponent x:name=\"14\" x:id=\"43\" transform=\"1,0,0,0,0,1,0,0,0,0,1,0,240.3887176513672,66.32697296142578,28.3767147064209,1\" name=\"Sphere\">\r\n      <x:Ref x:name=\"materialComponent\" x:id=\"16\"\/>\r\n      <bones:ArrayCollection x:name=\"children\" x:id=\"44\">\r\n        <ns2:SphereGeometryComponent x:name=\"0\" x:id=\"45\" segmentsH=\"12\" segmentsW=\"16\" radius=\"42.73389288130251\" name=\"Sphere Geometry\"\/>\r\n      <\/bones:ArrayCollection>\r\n      <x:Ref x:name=\"geometryComponent\" x:id=\"45\"\/>\r\n    <\/cadetAway3D4:MeshComponent>\r\n    <cadetAway3D4:MeshComponent x:name=\"15\" x:id=\"46\" transform=\"1,0,0,0,0,1,0,0,0,0,1,0,77.10282897949219,82.25804901123047,-173.88815307617188,1\" name=\"Sphere\">\r\n      <x:Ref x:name=\"materialComponent\" x:id=\"16\"\/>\r\n      <bones:ArrayCollection x:name=\"children\" x:id=\"47\">\r\n        <ns2:SphereGeometryComponent x:name=\"0\" x:id=\"48\" segmentsH=\"12\" segmentsW=\"16\" radius=\"44.53863475379832\" name=\"Sphere Geometry\"\/>\r\n      <\/bones:ArrayCollection>\r\n      <x:Ref x:name=\"geometryComponent\" x:id=\"48\"\/>\r\n    <\/cadetAway3D4:MeshComponent>\r\n    <cadetAway3D4:MeshComponent x:name=\"16\" x:id=\"49\" transform=\"1,0,0,0,0,1,0,0,0,0,1,0,-8.887575149536133,77.42305755615234,325.1551513671875,1\" name=\"Sphere\">\r\n      <x:Ref x:name=\"materialComponent\" x:id=\"16\"\/>\r\n      <bones:ArrayCollection x:name=\"children\" x:id=\"50\">\r\n        <ns2:SphereGeometryComponent x:name=\"0\" x:id=\"51\" segmentsH=\"12\" segmentsW=\"16\" radius=\"26.87288819730761\" name=\"Sphere Geometry\"\/>\r\n      <\/bones:ArrayCollection>\r\n      <x:Ref x:name=\"geometryComponent\" x:id=\"51\"\/>\r\n    <\/cadetAway3D4:MeshComponent>\r\n    <cadetAway3D4:MeshComponent x:name=\"17\" x:id=\"52\" transform=\"1,0,0,0,0,1,0,0,0,0,1,0,-111.85294342041016,150.3166961669922,314.55419921875,1\" name=\"Sphere\">\r\n      <x:Ref x:name=\"materialComponent\" x:id=\"16\"\/>\r\n      <bones:ArrayCollection x:name=\"children\" x:id=\"53\">\r\n        <ns2:SphereGeometryComponent x:name=\"0\" x:id=\"54\" segmentsH=\"12\" segmentsW=\"16\" radius=\"36.59617847826625\" name=\"Sphere Geometry\"\/>\r\n      <\/bones:ArrayCollection>\r\n      <x:Ref x:name=\"geometryComponent\" x:id=\"54\"\/>\r\n    <\/cadetAway3D4:MeshComponent>\r\n    <cadetAway3D4:MeshComponent x:name=\"18\" x:id=\"55\" transform=\"1,0,0,0,0,1,0,0,0,0,1,0,194.72483825683594,66.20823669433594,249.91229248046875,1\" name=\"Sphere\">\r\n      <x:Ref x:name=\"materialComponent\" x:id=\"16\"\/>\r\n      <bones:ArrayCollection x:name=\"children\" x:id=\"56\">\r\n        <ns2:SphereGeometryComponent x:name=\"0\" x:id=\"57\" segmentsH=\"12\" segmentsW=\"16\" radius=\"34.06102262376309\" name=\"Sphere Geometry\"\/>\r\n      <\/bones:ArrayCollection>\r\n      <x:Ref x:name=\"geometryComponent\" x:id=\"57\"\/>\r\n    <\/cadetAway3D4:MeshComponent>\r\n    <cadetAway3D4:MeshComponent x:name=\"19\" x:id=\"58\" transform=\"1,0,0,0,0,1,0,0,0,0,1,0,153.58782958984375,59.29662322998047,139.8775634765625,1\" name=\"Sphere\">\r\n      <x:Ref x:name=\"materialComponent\" x:id=\"16\"\/>\r\n      <bones:ArrayCollection x:name=\"children\" x:id=\"59\">\r\n        <ns2:SphereGeometryComponent x:name=\"0\" x:id=\"60\" segmentsH=\"12\" segmentsW=\"16\" radius=\"27.704758141615848\" name=\"Sphere Geometry\"\/>\r\n      <\/bones:ArrayCollection>\r\n      <x:Ref x:name=\"geometryComponent\" x:id=\"60\"\/>\r\n    <\/cadetAway3D4:MeshComponent>\r\n    <x:Ref x:name=\"20\" x:id=\"16\"\/>\r\n    <x:Ref x:name=\"21\" x:id=\"6\"\/>\r\n    <x:Ref x:name=\"22\" x:id=\"12\"\/>\r\n  <\/bones:ArrayCollection>\r\n  <Object x:name=\"userData\" x:id=\"61\"\/>\r\n  <bones:DependencyManager x:name=\"dependencyManager\" x:id=\"62\">\r\n    <bones:ArrayCollection x:name=\"dependencyNodes\" x:id=\"63\"\/>\r\n  <\/bones:DependencyManager>\r\n<\/cadet:CadetScene><\/pre>\n<p>This format isn&#8217;t easy to handle! Cadet should really export to XML or JSON format.<br \/>\nAnyway this what I&#8217;ve done : <a href=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2012\/11\/cadet.html\" target=\"_blank\">demo<\/a>. You can remove the AwayPhysics debug view via the console :<\/p>\n<pre>set awayPhysics visible false<\/pre>\n<p>As usual all the source code is available on the <a href=\"https:\/\/github.com\/alamboley\/Citrus-Engine-Examples\" target=\"_blank\">GitHub<\/a>.<br \/>\nThis is the GameState :<\/p>\n<pre lang=\"actionscript3\" line=\"1\">package awayphysics.cadet3d {\r\n\r\n\timport away3d.controllers.HoverController;\r\n\timport away3d.debug.AwayStats;\r\n\r\n\timport com.citrusengine.core.State;\r\n\timport com.citrusengine.physics.awayphysics.AwayPhysics;\r\n\timport com.citrusengine.utils.ObjectMaker3D;\r\n\timport com.citrusengine.view.CitrusView;\r\n\timport com.citrusengine.view.away3dview.Away3DView;\r\n\r\n\timport flash.events.Event;\r\n\timport flash.events.MouseEvent;\r\n\timport flash.geom.Vector3D;\r\n\r\n\t\/**\r\n\t * @author Aymeric\r\n\t *\/\r\n\tpublic class Cadet3DGameState extends State {\r\n\t\t\r\n\t\t[Embed(source=\"\/..\/embed\/3D\/simpletest.away3d4\", mimeType=\"application\/octet-stream\")]\r\n\t\tprivate const _CADET_LEVEL:Class;\r\n\t\t\r\n\t\t\/\/ navigation variables\r\n\t\tprivate var _cameraController:HoverController;\r\n\r\n\t\tprivate var _move:Boolean = false;\r\n\t\tprivate var _lastPanAngle:Number;\r\n\t\tprivate var _lastTiltAngle:Number;\r\n\t\tprivate var _lastMouseX:Number;\r\n\t\tprivate var _lastMouseY:Number;\r\n\t\tprivate var _lookAtPosition:Vector3D = new Vector3D();\r\n\r\n\t\tpublic function Cadet3DGameState() {\r\n\t\t\t\r\n\t\t\tsuper();\r\n\t\t}\r\n\r\n\t\toverride public function initialize():void {\r\n\t\t\t\r\n\t\t\tsuper.initialize();\r\n\t\t\t\r\n\t\t\taddChild(new AwayStats((view as Away3DView).viewRoot));\r\n\t\t\t\r\n\t\t\tvar awayPhysics:AwayPhysics = new AwayPhysics(\"awayPhysics\");\r\n\t\t\tawayPhysics.visible = true;\r\n\t\t\tadd(awayPhysics);\r\n\t\t\t\r\n\t\t\tObjectMaker3D.FromCadetEditor3D(XML(new _CADET_LEVEL()));\r\n\t\t\t\r\n\t\t\t_cameraController = new HoverController((view as Away3DView).viewRoot.camera, null, 175, 20, 1000);\r\n\t\t\t\r\n\t\t\tstage.addEventListener(MouseEvent.MOUSE_DOWN, _onMouseDown);\r\n\t\t\tstage.addEventListener(MouseEvent.MOUSE_UP, _onMouseUp);\r\n\t\t\tstage.addEventListener(Event.MOUSE_LEAVE, _onMouseUp);\r\n\t\t\tstage.addEventListener(MouseEvent.MOUSE_WHEEL, _onMouseWheel);\r\n\t\t}\r\n\t\t\r\n\t\t\/\/ Make sure and call this override to specify Away3D view.\r\n\t\toverride protected function createView():CitrusView {\r\n\r\n\t\t\treturn new Away3DView(this);\r\n\t\t}\r\n\t\t\r\n\t\toverride public function destroy():void {\r\n\r\n\t\t\tstage.removeEventListener(MouseEvent.MOUSE_DOWN, _onMouseDown);\r\n\t\t\tstage.removeEventListener(MouseEvent.MOUSE_UP, _onMouseUp);\r\n\t\t\tstage.removeEventListener(Event.MOUSE_LEAVE, _onMouseUp);\r\n\t\t\tstage.removeEventListener(MouseEvent.MOUSE_WHEEL, _onMouseWheel);\r\n\r\n\t\t\tsuper.destroy();\r\n\t\t}\r\n\t\t\r\n\t\toverride public function update(timeDelta:Number):void {\r\n\r\n\t\t\tsuper.update(timeDelta);\r\n\r\n\t\t\tif (_move) {\r\n\t\t\t\t_cameraController.panAngle = 0.3 * (stage.mouseX - _lastMouseX) + _lastPanAngle;\r\n\t\t\t\t_cameraController.tiltAngle = 0.3 * (stage.mouseY - _lastMouseY) + _lastTiltAngle;\r\n\t\t\t}\r\n\r\n\t\t\t_cameraController.lookAtPosition = _lookAtPosition;\r\n\t\t}\r\n\t\t\r\n\t\tprivate function _onMouseDown(mEvt:MouseEvent):void {\r\n\t\t\t_lastPanAngle = _cameraController.panAngle;\r\n\t\t\t_lastTiltAngle = _cameraController.tiltAngle;\r\n\t\t\t_lastMouseX = stage.mouseX;\r\n\t\t\t_lastMouseY = stage.mouseY;\r\n\t\t\t_move = true;\r\n\t\t}\r\n\r\n\t\tprivate function _onMouseUp(evt:Event):void {\r\n\t\t\t_move = false;\r\n\t\t}\r\n\r\n\t\tprivate function _onMouseWheel(mEvt:MouseEvent):void {\r\n\r\n\t\t\t_cameraController.distance -= mEvt.delta * 5;\r\n\r\n\t\t\tif (_cameraController.distance < 100)\r\n\t\t\t\t_cameraController.distance = 100;\r\n\t\t\telse if (_cameraController.distance > 2000)\r\n\t\t\t\t_cameraController.distance = 2000;\r\n\t\t}\r\n\r\n\t}\r\n}<\/pre>\n<p>Like Flash as Level Editor or Tiled Map Editor, we use the ObjectMaker class. This is the template for Cadet Editor 3D :<\/p>\n<pre lang=\"actionscript3\" line=\"1\">public static function FromCadetEditor3D(levelData:XML, addToCurrentState:Boolean = true):Array {\r\n\r\n\tvar ce:CitrusEngine = CitrusEngine.getInstance();\r\n\r\n\tvar params:Object;\r\n\r\n\tvar objects:Array = [];\r\n\r\n\tvar type:String;\r\n\tvar radius:Number;\r\n\r\n\tvar object:AwayPhysicsObject;\r\n\r\n\tfor each (var root:XML in levelData.children()) {\r\n\t\tfor each (var parent:XML in root.children()) {\r\n\r\n\t\t\ttype = parent.@name;\r\n\r\n\t\t\tif (type == \"Cube\" || type == \"Plane\" || type == \"Sphere\") {\r\n\r\n\t\t\t\tvar transform:Array = parent.@transform.split(\",\");\r\n\r\n\t\t\t\tparams = {};\r\n\t\t\t\tparams.x = transform[12];\r\n\t\t\t\tparams.y = transform[13];\r\n\t\t\t\tparams.z = transform[14];\r\n\r\n\t\t\t\tfor each (var child:XML in parent.children()) {\r\n\r\n\t\t\t\t\tfor each (var finalElement:XML in child.children()) {\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tparams.width = finalElement.@width;\r\n\t\t\t\t\t\tparams.height = finalElement.@height;\r\n\t\t\t\t\t\tparams.depth = finalElement.@depth;\r\n\t\t\t\t\t\tradius = finalElement.@radius;\r\n\r\n\t\t\t\t\t\tif (radius)\r\n\t\t\t\t\t\t\tparams.radius = finalElement.@radius;\r\n\r\n\t\t\t\t\t\tif (type == \"Plane\") {\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\/\/ the plane seems to use the height as the depth\r\n\t\t\t\t\t\t\tparams.depth = params.height;\r\n\t\t\t\t\t\t\tparams.height = 0;\r\n\t\t\t\t\t\t\tparams.view = new Mesh(new CubeGeometry(params.width, params.height, params.depth), new ColorMaterial(0xFF0000));\r\n\t\t\t\t\t\t\tobject = new Platform(\"plane\", params);\r\n\r\n\t\t\t\t\t\t} else {\r\n\r\n\t\t\t\t\t\t\tif (params.radius) {\r\n\r\n\t\t\t\t\t\t\t\tparams.view = new Mesh(new SphereGeometry(params.radius), new ColorMaterial(0x00FF00));\r\n\t\t\t\t\t\t\t\tobject = new AwayPhysicsObject(\"sphere\", params);\r\n\r\n\t\t\t\t\t\t\t} else {\r\n\r\n\t\t\t\t\t\t\t\tparams.view = new Mesh(new CubeGeometry(params.width, params.height, params.depth), new ColorMaterial(0x0000FF));\r\n\t\t\t\t\t\t\t\tobject = new AwayPhysicsObject(\"cube\", params);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tobjects.push(object);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (addToCurrentState)\r\n\t\tfor each (object in objects) ce.state.add(object);\r\n\r\n\treturn objects;\r\n}<\/pre>\n<p>As you can notice, the object maker uses CE prebuilt objects for AwayPhysics but not in a dynamic way.<\/p>\n<p>This is some points that Cadet Editor should allow to be an excellent level editor :<br \/>\n&#8211; quickly most of the points are in Tiled Map Editor, checkout Citrus Engine support <a href=\"http:\/\/www.aymericlamboley.fr\/blog\/tiled-map-editor-supported-in-the-citrus-engine\/\" target=\"_blank\">there<\/a>.<br \/>\n&#8211; an easy to parse exporter format (xml or json).<br \/>\n&#8211; adding personal properties so we can precize type, gravity, view for example directly in the level editor. A must have!<\/p>\n<p>I will continue my experiments and improve Cadet 3D support. I really hope that some of my requests will be added to Cadet Editor and then it will be an awesome 3D level editor for the CE!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The 3D part is a bit in stand-by this last weeks on the Citrus Engine, because I&#8217;m polishing the engine for the V3 which should be out this week! I&#8217;ve never clearly introduced AwayPhysics in the Citrus Engine, so it&#8217;s the day! The idea is to have a similar pre-built platformer objects that we already &hellip; <a href=\"http:\/\/www.aymericlamboley.fr\/blog\/playing-with-cadet-editor-and-awayphysics\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Playing with Cadet Editor 3D and AwayPhysics<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[4,92,157,51,33,114],"tags":[15,93,159,158,50,34],"_links":{"self":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts\/768"}],"collection":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/comments?post=768"}],"version-history":[{"count":11,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts\/768\/revisions"}],"predecessor-version":[{"id":1595,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts\/768\/revisions\/1595"}],"wp:attachment":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/media?parent=768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/categories?post=768"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/tags?post=768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}