├── examples
├── cadet2D
│ ├── 03_lava
│ │ ├── bin-debug
│ │ │ ├── files
│ │ │ │ ├── _contents.xml
│ │ │ │ └── assets
│ │ │ │ │ ├── _contents.xml
│ │ │ │ │ └── lavaDemo
│ │ │ │ │ ├── FinalRock.png
│ │ │ │ │ ├── GlowTiled.png
│ │ │ │ │ ├── LavaTiled.png
│ │ │ │ │ ├── BanksTiled.png
│ │ │ │ │ ├── FinalBackground.png
│ │ │ │ │ └── _contents.xml
│ │ │ └── extensions
│ │ │ │ └── manifests
│ │ │ │ ├── Core.xml
│ │ │ │ └── Cadet.xml
│ │ ├── src
│ │ │ └── model
│ │ │ │ ├── ISceneModel.as
│ │ │ │ └── SceneModel_XML.as
│ │ └── .project
│ ├── 00_boilerplate
│ │ ├── bin-debug
│ │ │ ├── files
│ │ │ │ └── _contents.xml
│ │ │ └── extensions
│ │ │ │ └── manifests
│ │ │ │ ├── Core.xml
│ │ │ │ ├── Cadet.xml
│ │ │ │ └── Cadet2DBox2D.xml
│ │ ├── src
│ │ │ ├── model
│ │ │ │ ├── ISceneModel.as
│ │ │ │ └── SceneModel_XML.as
│ │ │ └── Boilerplate.as
│ │ └── .project
│ ├── 02_bunny_mark
│ │ ├── src
│ │ │ ├── assets
│ │ │ │ └── wabbit_alpha.png
│ │ │ ├── components
│ │ │ │ ├── behaviours
│ │ │ │ │ └── BounceBehaviour.as
│ │ │ │ └── processes
│ │ │ │ │ └── BunnySpawner.as
│ │ │ ├── BunnyMarkSpawner.as
│ │ │ └── BunnyMark.as
│ │ └── .project
│ └── 01_behaviours_skins
│ │ ├── .project
│ │ └── src
│ │ └── components
│ │ ├── behaviours
│ │ ├── AnimateRotationBehaviour.as
│ │ └── UpdateAlphaBehaviour.as
│ │ └── skins
│ │ └── ShadedCircleSkin.as
├── cadet3D
│ ├── 04_robot
│ │ ├── bin-debug
│ │ │ ├── files
│ │ │ │ ├── _contents.xml
│ │ │ │ └── assets
│ │ │ │ │ ├── Robot.3DS
│ │ │ │ │ ├── RobotDiffuse.png
│ │ │ │ │ └── _contents.xml
│ │ │ └── extensions
│ │ │ │ └── manifests
│ │ │ │ ├── Core.xml
│ │ │ │ ├── Cadet.xml
│ │ │ │ └── Cadet3D.xml
│ │ ├── .project
│ │ └── src
│ │ │ └── Robot.as
│ ├── 03_planets
│ │ ├── bin-debug
│ │ │ ├── files
│ │ │ │ ├── _contents.xml
│ │ │ │ └── assets
│ │ │ │ │ ├── Primitives.3DS
│ │ │ │ │ ├── space
│ │ │ │ │ ├── Mars.jpg
│ │ │ │ │ ├── Moon.jpg
│ │ │ │ │ ├── Earth.jpg
│ │ │ │ │ ├── Jupiter.jpg
│ │ │ │ │ ├── Saturn.jpg
│ │ │ │ │ └── _contents.xml
│ │ │ │ │ ├── _contents.xml
│ │ │ │ │ └── skybox
│ │ │ │ │ ├── space_negX.jpg
│ │ │ │ │ ├── space_negY.jpg
│ │ │ │ │ ├── space_negZ.jpg
│ │ │ │ │ ├── space_posX.jpg
│ │ │ │ │ ├── space_posY.jpg
│ │ │ │ │ ├── space_posZ.jpg
│ │ │ │ │ └── _contents.xml
│ │ │ └── extensions
│ │ │ │ └── manifests
│ │ │ │ ├── Core.xml
│ │ │ │ ├── Cadet.xml
│ │ │ │ └── Cadet3D.xml
│ │ ├── .project
│ │ └── src
│ │ │ └── Planets.as
│ ├── 02_bunny_mark
│ │ ├── src
│ │ │ ├── assets
│ │ │ │ ├── wabbit_alpha.png
│ │ │ │ └── wabbit_alpha_64x64.png
│ │ │ └── components
│ │ │ │ └── behaviours
│ │ │ │ └── BounceBehaviour.as
│ │ └── .project
│ └── 01_behaviours
│ │ ├── .project
│ │ └── src
│ │ └── components
│ │ └── behaviours
│ │ └── AnimateRotationBehaviour.as
├── away3D
│ └── 02_bunny_mark
│ │ ├── src
│ │ ├── assets
│ │ │ └── wabbit_alpha_64x64.png
│ │ └── components
│ │ │ └── behaviours
│ │ │ └── BounceBehaviour.as
│ │ └── .project
├── cadet2DBox2D
│ └── 01_boxes
│ │ ├── .project
│ │ └── src
│ │ ├── components
│ │ └── behaviours
│ │ │ └── ApplyTorqueBehaviour.as
│ │ └── Box.as
└── cadet3DPhysics
│ └── 01_boxes
│ ├── .project
│ └── src
│ └── components
│ └── behaviours
│ └── ApplyTorqueBehaviour.as
├── cadet
├── lib
│ └── CoreApp.swc
├── src
│ └── cadet
│ │ ├── assets
│ │ ├── Skin.png
│ │ ├── Sound.png
│ │ ├── Geometry.png
│ │ ├── Process.png
│ │ ├── Renderer.png
│ │ ├── Texture.png
│ │ ├── Behaviour.png
│ │ ├── Component.png
│ │ ├── Transform.png
│ │ └── CadetEngineIcons.as
│ │ ├── util
│ │ ├── NullBitmap.png
│ │ ├── deg2rad.as
│ │ ├── rad2deg.as
│ │ ├── NullBitmap.as
│ │ ├── TextureUtils.as
│ │ ├── BitmapDataUtil.as
│ │ └── Reference.as
│ │ ├── components
│ │ ├── sounds
│ │ │ ├── ISound.as
│ │ │ └── SoundComponent.as
│ │ ├── processes
│ │ │ ├── IInputMapping.as
│ │ │ ├── TouchInputMapping.as
│ │ │ └── KeyboardInputMapping.as
│ │ ├── geom
│ │ │ └── IGeometry.as
│ │ └── behaviours
│ │ │ ├── IEntityUserControlledBehaviour.as
│ │ │ └── EntityUserControlBehaviour.as
│ │ ├── core
│ │ ├── ISteppableComponent.as
│ │ ├── IComponentContainer.as
│ │ ├── IInitialisableComponent.as
│ │ ├── IRenderer.as
│ │ ├── ICadetScene.as
│ │ └── IComponent.as
│ │ ├── validators
│ │ ├── IComponentValidator.as
│ │ ├── ComponentParentValidator.as
│ │ └── ComponentSiblingValidator.as
│ │ ├── events
│ │ ├── RendererEvent.as
│ │ ├── InputProcessEvent.as
│ │ ├── ValidationEvent.as
│ │ ├── ComponentContainerEvent.as
│ │ └── ComponentEvent.as
│ │ └── operations
│ │ ├── GetTemplatesAndMergeOperation.as
│ │ ├── ValidateAsyncOperation.as
│ │ └── GetTemplatesAndMergeXMLOperation.as
├── .project
├── .flexLibProperties
└── Cadet.iml
├── cadet2D
├── lib
│ ├── CoreApp.swc
│ ├── starling.swc
│ ├── Starling-Extension-Graphics.swc
│ └── Starling-Extension-Particle-System.swc
├── src
│ └── cadet2D
│ │ ├── components
│ │ ├── particles
│ │ │ └── NullParticle.png
│ │ ├── shaders
│ │ │ ├── IShaderComponent.as
│ │ │ ├── fragment
│ │ │ │ └── TextureFragmentShaderComponent.as
│ │ │ └── vertex
│ │ │ │ └── AnimateUVVertexShaderComponent.as
│ │ ├── renderers
│ │ │ ├── RendererInvalidationTypes.as
│ │ │ └── IRenderer2D.as
│ │ ├── processes
│ │ │ ├── IDebugDrawProcess.as
│ │ │ └── InputProcess2D.as
│ │ ├── materials
│ │ │ └── IMaterialComponent.as
│ │ ├── skins
│ │ │ ├── IAnimatable.as
│ │ │ └── IRenderable.as
│ │ ├── geom
│ │ │ ├── ICollisionShape.as
│ │ │ ├── BoundingSphere.as
│ │ │ ├── BezierCurve.as
│ │ │ ├── CollisionShape.as
│ │ │ ├── CompoundGeometry.as
│ │ │ ├── CircleGeometry.as
│ │ │ └── AbstractGeometry.as
│ │ ├── behaviours
│ │ │ └── IFootprint.as
│ │ ├── transforms
│ │ │ └── ITransform2D.as
│ │ └── textures
│ │ │ ├── TextureAtlasComponent.as
│ │ │ └── TextureComponent.as
│ │ ├── events
│ │ ├── SkinEvent.as
│ │ ├── FootprintManagerEvent.as
│ │ └── CollisionEvent.as
│ │ ├── util
│ │ ├── NullBitmapTexture.as
│ │ ├── RenderablesUtil.as
│ │ ├── DisplayUtil.as
│ │ └── LinearPathUtil.as
│ │ ├── geom
│ │ ├── VertexList.as
│ │ ├── Vertex.as
│ │ └── QuadraticBezier.as
│ │ ├── operations
│ │ ├── Cadet2DStartUpOperation.as
│ │ ├── CollapseTransformsOperation.as
│ │ ├── CenterOriginsOperation.as
│ │ └── ConvertToPolygonOperation.as
│ │ ├── overlays
│ │ └── Overlay.as
│ │ └── resources
│ │ └── ExternalXMLResourceParser.as
├── .project
├── .flexLibProperties
└── Cadet2D.iml
├── cadet3D
├── lib
│ └── Away3D.swc
├── src
│ └── cadet3D
│ │ ├── assets
│ │ ├── Cube.png
│ │ ├── Mesh.png
│ │ ├── Camera.png
│ │ ├── Plane.png
│ │ ├── Sphere.png
│ │ ├── Texture.png
│ │ ├── Geometry.png
│ │ ├── Material.png
│ │ ├── Renderer.png
│ │ ├── PointLight.png
│ │ ├── DirectionalLight.png
│ │ └── CadetEngine3DIcons.as
│ │ ├── components
│ │ ├── lights
│ │ │ ├── PointLightComponent.as
│ │ │ ├── DirectionalLightComponent.as
│ │ │ └── LightProbeComponent.as
│ │ ├── renderers
│ │ │ └── IRenderer3D.as
│ │ ├── textures
│ │ │ ├── AbstractTexture2DComponent.as
│ │ │ └── AbstractCubeTextureComponent.as
│ │ ├── geom
│ │ │ ├── AbstractGeometryComponent.as
│ │ │ ├── GeometryComponent.as
│ │ │ └── SphereGeometryComponent.as
│ │ ├── primitives
│ │ │ └── SkyBoxComponent.as
│ │ ├── materials
│ │ │ ├── ColorMaterialComponent.as
│ │ │ └── SkyBoxMaterialComponent.as
│ │ ├── core
│ │ │ └── Sprite3DComponent.as
│ │ └── cameras
│ │ │ └── CameraComponent.as
│ │ ├── serialize
│ │ ├── ISerializer.as
│ │ └── NameValuePair.as
│ │ ├── events
│ │ └── Renderer3DEvent.as
│ │ ├── util
│ │ ├── NullBitmapTexture.as
│ │ └── NullBitmapCubeTexture.as
│ │ ├── primitives
│ │ └── SkyBoxNode.as
│ │ ├── resources
│ │ ├── Away3DMeshResource.as
│ │ ├── Away3DGeometryResource.as
│ │ ├── Away3DMaterialResource.as
│ │ └── Away3DContainer3DResource.as
│ │ └── operations
│ │ └── Cadet3DStartUpOperation.as
├── .flexLibProperties
└── .project
├── .gitignore
├── cadet2DBox2D
├── lib
│ └── Box2D.swc
├── src
│ └── cadet2DBox2D
│ │ ├── components
│ │ ├── behaviours
│ │ │ └── IJoint.as
│ │ └── processes
│ │ │ ├── PhysicsProcessDestructionListener.as
│ │ │ └── PhysicsProcessContactListener.as
│ │ └── events
│ │ ├── RigidBodyBehaviourEvent.as
│ │ └── PhysicsCollisionEvent.as
├── .flexLibProperties
├── .project
└── Cadet2DBox2D.iml
├── cadet3DPhysics
├── lib
│ └── AwayPhysics.swc
├── .flexLibProperties
├── .project
└── src
│ └── cadet3DPhysics
│ └── components
│ └── processes
│ └── PhysicsProcess.as
├── tests
└── transform2D
│ ├── .project
│ └── src
│ ├── util
│ └── TransformUtil.as
│ └── components
│ └── behaviours
│ └── AnimateRotationBehaviour.as
└── LICENSE.md
/examples/cadet2D/03_lava/bin-debug/files/_contents.xml:
--------------------------------------------------------------------------------
1 |
2 | assets
3 |
--------------------------------------------------------------------------------
/examples/cadet3D/04_robot/bin-debug/files/_contents.xml:
--------------------------------------------------------------------------------
1 |
2 | assets
3 |
--------------------------------------------------------------------------------
/cadet/lib/CoreApp.swc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet/lib/CoreApp.swc
--------------------------------------------------------------------------------
/cadet2D/lib/CoreApp.swc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet2D/lib/CoreApp.swc
--------------------------------------------------------------------------------
/cadet3D/lib/Away3D.swc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet3D/lib/Away3D.swc
--------------------------------------------------------------------------------
/examples/cadet2D/00_boilerplate/bin-debug/files/_contents.xml:
--------------------------------------------------------------------------------
1 |
2 | assets
3 |
--------------------------------------------------------------------------------
/examples/cadet2D/03_lava/bin-debug/files/assets/_contents.xml:
--------------------------------------------------------------------------------
1 |
2 | lavaDemo
3 |
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/bin-debug/files/_contents.xml:
--------------------------------------------------------------------------------
1 |
2 | assets
3 |
--------------------------------------------------------------------------------
/cadet2D/lib/starling.swc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet2D/lib/starling.swc
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .settings
2 | Thumbs.db
3 | *.swf
4 | bin/
5 | cadet/out/*
6 | cadet2D/out/*
7 | cadet2DBox2D/out/*
8 |
--------------------------------------------------------------------------------
/cadet2DBox2D/lib/Box2D.swc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet2DBox2D/lib/Box2D.swc
--------------------------------------------------------------------------------
/cadet/src/cadet/assets/Skin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet/src/cadet/assets/Skin.png
--------------------------------------------------------------------------------
/cadet/src/cadet/assets/Sound.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet/src/cadet/assets/Sound.png
--------------------------------------------------------------------------------
/cadet/src/cadet/assets/Geometry.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet/src/cadet/assets/Geometry.png
--------------------------------------------------------------------------------
/cadet/src/cadet/assets/Process.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet/src/cadet/assets/Process.png
--------------------------------------------------------------------------------
/cadet/src/cadet/assets/Renderer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet/src/cadet/assets/Renderer.png
--------------------------------------------------------------------------------
/cadet/src/cadet/assets/Texture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet/src/cadet/assets/Texture.png
--------------------------------------------------------------------------------
/cadet/src/cadet/util/NullBitmap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet/src/cadet/util/NullBitmap.png
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/assets/Cube.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet3D/src/cadet3D/assets/Cube.png
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/assets/Mesh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet3D/src/cadet3D/assets/Mesh.png
--------------------------------------------------------------------------------
/cadet3DPhysics/lib/AwayPhysics.swc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet3DPhysics/lib/AwayPhysics.swc
--------------------------------------------------------------------------------
/cadet/src/cadet/assets/Behaviour.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet/src/cadet/assets/Behaviour.png
--------------------------------------------------------------------------------
/cadet/src/cadet/assets/Component.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet/src/cadet/assets/Component.png
--------------------------------------------------------------------------------
/cadet/src/cadet/assets/Transform.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet/src/cadet/assets/Transform.png
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/assets/Camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet3D/src/cadet3D/assets/Camera.png
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/assets/Plane.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet3D/src/cadet3D/assets/Plane.png
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/assets/Sphere.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet3D/src/cadet3D/assets/Sphere.png
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/assets/Texture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet3D/src/cadet3D/assets/Texture.png
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/assets/Geometry.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet3D/src/cadet3D/assets/Geometry.png
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/assets/Material.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet3D/src/cadet3D/assets/Material.png
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/assets/Renderer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet3D/src/cadet3D/assets/Renderer.png
--------------------------------------------------------------------------------
/cadet2D/lib/Starling-Extension-Graphics.swc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet2D/lib/Starling-Extension-Graphics.swc
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/assets/PointLight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet3D/src/cadet3D/assets/PointLight.png
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/assets/DirectionalLight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet3D/src/cadet3D/assets/DirectionalLight.png
--------------------------------------------------------------------------------
/cadet2D/lib/Starling-Extension-Particle-System.swc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet2D/lib/Starling-Extension-Particle-System.swc
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/particles/NullParticle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/cadet2D/src/cadet2D/components/particles/NullParticle.png
--------------------------------------------------------------------------------
/examples/cadet2D/02_bunny_mark/src/assets/wabbit_alpha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet2D/02_bunny_mark/src/assets/wabbit_alpha.png
--------------------------------------------------------------------------------
/examples/cadet3D/02_bunny_mark/src/assets/wabbit_alpha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet3D/02_bunny_mark/src/assets/wabbit_alpha.png
--------------------------------------------------------------------------------
/examples/cadet3D/04_robot/bin-debug/files/assets/Robot.3DS:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet3D/04_robot/bin-debug/files/assets/Robot.3DS
--------------------------------------------------------------------------------
/cadet/src/cadet/components/sounds/ISound.as:
--------------------------------------------------------------------------------
1 | package cadet.components.sounds
2 | {
3 | public interface ISound
4 | {
5 | function play():Boolean;
6 | function stop():void;
7 | }
8 | }
--------------------------------------------------------------------------------
/examples/away3D/02_bunny_mark/src/assets/wabbit_alpha_64x64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/away3D/02_bunny_mark/src/assets/wabbit_alpha_64x64.png
--------------------------------------------------------------------------------
/examples/cadet3D/02_bunny_mark/src/assets/wabbit_alpha_64x64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet3D/02_bunny_mark/src/assets/wabbit_alpha_64x64.png
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/bin-debug/files/assets/Primitives.3DS:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet3D/03_planets/bin-debug/files/assets/Primitives.3DS
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/bin-debug/files/assets/space/Mars.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet3D/03_planets/bin-debug/files/assets/space/Mars.jpg
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/bin-debug/files/assets/space/Moon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet3D/03_planets/bin-debug/files/assets/space/Moon.jpg
--------------------------------------------------------------------------------
/examples/cadet3D/04_robot/bin-debug/files/assets/RobotDiffuse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet3D/04_robot/bin-debug/files/assets/RobotDiffuse.png
--------------------------------------------------------------------------------
/examples/cadet3D/04_robot/bin-debug/files/assets/_contents.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | RobotDiffuse.png
4 |
5 | Robot.3DS
6 |
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/bin-debug/files/assets/_contents.xml:
--------------------------------------------------------------------------------
1 |
2 | skybox
3 | space
4 |
5 | Primitives.3DS
6 |
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/bin-debug/files/assets/space/Earth.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet3D/03_planets/bin-debug/files/assets/space/Earth.jpg
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/bin-debug/files/assets/space/Jupiter.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet3D/03_planets/bin-debug/files/assets/space/Jupiter.jpg
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/bin-debug/files/assets/space/Saturn.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet3D/03_planets/bin-debug/files/assets/space/Saturn.jpg
--------------------------------------------------------------------------------
/examples/cadet2D/03_lava/bin-debug/files/assets/lavaDemo/FinalRock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet2D/03_lava/bin-debug/files/assets/lavaDemo/FinalRock.png
--------------------------------------------------------------------------------
/examples/cadet2D/03_lava/bin-debug/files/assets/lavaDemo/GlowTiled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet2D/03_lava/bin-debug/files/assets/lavaDemo/GlowTiled.png
--------------------------------------------------------------------------------
/examples/cadet2D/03_lava/bin-debug/files/assets/lavaDemo/LavaTiled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet2D/03_lava/bin-debug/files/assets/lavaDemo/LavaTiled.png
--------------------------------------------------------------------------------
/examples/cadet2D/03_lava/bin-debug/files/assets/lavaDemo/BanksTiled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet2D/03_lava/bin-debug/files/assets/lavaDemo/BanksTiled.png
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/bin-debug/files/assets/skybox/space_negX.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet3D/03_planets/bin-debug/files/assets/skybox/space_negX.jpg
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/bin-debug/files/assets/skybox/space_negY.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet3D/03_planets/bin-debug/files/assets/skybox/space_negY.jpg
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/bin-debug/files/assets/skybox/space_negZ.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet3D/03_planets/bin-debug/files/assets/skybox/space_negZ.jpg
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/bin-debug/files/assets/skybox/space_posX.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet3D/03_planets/bin-debug/files/assets/skybox/space_posX.jpg
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/bin-debug/files/assets/skybox/space_posY.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet3D/03_planets/bin-debug/files/assets/skybox/space_posY.jpg
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/bin-debug/files/assets/skybox/space_posZ.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet3D/03_planets/bin-debug/files/assets/skybox/space_posZ.jpg
--------------------------------------------------------------------------------
/examples/cadet2D/03_lava/bin-debug/files/assets/lavaDemo/FinalBackground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CadetEditor/CadetEngine-as/HEAD/examples/cadet2D/03_lava/bin-debug/files/assets/lavaDemo/FinalBackground.png
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/shaders/IShaderComponent.as:
--------------------------------------------------------------------------------
1 | package cadet2D.components.shaders
2 | {
3 | import starling.display.shaders.IShader;
4 |
5 | public interface IShaderComponent
6 | {
7 | function get shader():IShader;
8 | }
9 | }
--------------------------------------------------------------------------------
/examples/cadet2D/03_lava/bin-debug/files/assets/lavaDemo/_contents.xml:
--------------------------------------------------------------------------------
1 |
2 | BanksTiled.png
3 | FinalBackground.png
4 | FinalRock.png
5 | GlowTiled.png
6 | LavaTiled.png
7 |
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/bin-debug/files/assets/space/_contents.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Earth.jpg
4 | Jupiter.jpg
5 | Mars.jpg
6 | Moon.jpg
7 | Saturn.jpg
8 | Sun.jpg
9 |
--------------------------------------------------------------------------------
/cadet3DPhysics/.flexLibProperties:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/bin-debug/files/assets/skybox/_contents.xml:
--------------------------------------------------------------------------------
1 |
2 | space_negX.jpg
3 | space_negY.jpg
4 | space_negZ.jpg
5 | space_posX.jpg
6 | space_posY.jpg
7 | space_posZ.jpg
8 |
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/renderers/RendererInvalidationTypes.as:
--------------------------------------------------------------------------------
1 | package cadet2D.components.renderers
2 | {
3 | public class RendererInvalidationTypes
4 | {
5 | public static const VIEWPORT :String = "viewport";
6 | public static const OVERLAYS :String = "overlays";
7 | }
8 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/components/processes/IInputMapping.as:
--------------------------------------------------------------------------------
1 | package cadet.components.processes
2 | {
3 | import cadet.core.IComponent;
4 |
5 | public interface IInputMapping extends IComponent
6 | {
7 | function set input( value:String ):void;
8 | function get input():String;
9 | }
10 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/processes/IDebugDrawProcess.as:
--------------------------------------------------------------------------------
1 | package cadet2D.components.processes
2 | {
3 | public interface IDebugDrawProcess
4 | {
5 | function get trackCamera():Boolean;
6 | function set trackCamera(value:Boolean):void;
7 |
8 | function get sprite():*;
9 | }
10 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/materials/IMaterialComponent.as:
--------------------------------------------------------------------------------
1 | package cadet2D.components.materials
2 | {
3 | import flash.events.IEventDispatcher;
4 |
5 | import starling.display.materials.IMaterial;
6 |
7 | public interface IMaterialComponent extends IEventDispatcher
8 | {
9 | function get material():IMaterial;
10 | }
11 | }
--------------------------------------------------------------------------------
/examples/cadet2D/03_lava/src/model/ISceneModel.as:
--------------------------------------------------------------------------------
1 | package model
2 | {
3 | import flash.display.DisplayObject;
4 |
5 | import cadet.core.CadetScene;
6 |
7 | public interface ISceneModel
8 | {
9 | function init( parent:DisplayObject ):void
10 |
11 | function get cadetScene():CadetScene;
12 | function set cadetScene( value:CadetScene ):void;
13 | }
14 | }
--------------------------------------------------------------------------------
/examples/cadet2D/00_boilerplate/src/model/ISceneModel.as:
--------------------------------------------------------------------------------
1 | package model
2 | {
3 | import flash.display.DisplayObject;
4 |
5 | import cadet.core.CadetScene;
6 |
7 | public interface ISceneModel
8 | {
9 | function init( parent:DisplayObject ):void
10 |
11 | function get cadetScene():CadetScene;
12 | function set cadetScene( value:CadetScene ):void;
13 | }
14 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/components/lights/PointLightComponent.as:
--------------------------------------------------------------------------------
1 | package cadet3D.components.lights
2 | {
3 | import away3d.lights.PointLight;
4 |
5 | public class PointLightComponent extends AbstractLightComponent
6 | {
7 | public function PointLightComponent()
8 | {
9 | _object3D = _light = new PointLight();
10 |
11 | castsShadows = true;
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/events/SkinEvent.as:
--------------------------------------------------------------------------------
1 | package cadet2D.events
2 | {
3 | import flash.events.Event;
4 |
5 | public class SkinEvent extends Event
6 | {
7 | public static const TEXTURE_VALIDATED :String = "textureValidated";
8 |
9 | public function SkinEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
10 | {
11 | super(type, bubbles, cancelable);
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/cadet2DBox2D/src/cadet2DBox2D/components/behaviours/IJoint.as:
--------------------------------------------------------------------------------
1 | package cadet2DBox2D.components.behaviours
2 | {
3 | import cadet.core.IComponent;
4 |
5 | import cadet2DBox2D.components.processes.PhysicsProcess;
6 |
7 | public interface IJoint extends IComponent
8 | {
9 | function set physicsProcess( value:PhysicsProcess ):void;
10 | function get physicsProcess():PhysicsProcess;
11 | }
12 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/components/renderers/IRenderer3D.as:
--------------------------------------------------------------------------------
1 | package cadet3D.components.renderers
2 | {
3 | import flash.display.DisplayObjectContainer;
4 |
5 | import cadet.core.IRenderer;
6 |
7 | public interface IRenderer3D extends IRenderer
8 | {
9 | function enable(parent:DisplayObjectContainer, depth:int = -1):void;
10 | function disable(parent:DisplayObjectContainer):void;
11 | }
12 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/skins/IAnimatable.as:
--------------------------------------------------------------------------------
1 | package cadet2D.components.skins
2 | {
3 | public interface IAnimatable extends IRenderable
4 | {
5 | function addToJuggler():Boolean
6 | function removeFromJuggler():Boolean
7 |
8 | function get isAnimating():Boolean
9 |
10 | function set previewAnimation( value:Boolean ):void;
11 | function get previewAnimation():Boolean;
12 | }
13 | }
--------------------------------------------------------------------------------
/cadet3D/.flexLibProperties:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/examples/cadet2D/03_lava/bin-debug/extensions/manifests/Core.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/examples/cadet2D/00_boilerplate/bin-debug/extensions/manifests/Core.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/examples/cadet3D/04_robot/bin-debug/extensions/manifests/Core.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/bin-debug/extensions/manifests/Core.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/cadet2DBox2D/.flexLibProperties:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/examples/cadet2D/03_lava/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | C2D_03_Lava
4 |
5 |
6 |
7 |
8 |
9 | com.adobe.flexbuilder.project.flexbuilder
10 |
11 |
12 |
13 |
14 |
15 | com.adobe.flexbuilder.project.actionscriptnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/tests/transform2D/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | C2D_Tests_Transform
4 |
5 |
6 |
7 |
8 |
9 | com.adobe.flexbuilder.project.flexbuilder
10 |
11 |
12 |
13 |
14 |
15 | com.adobe.flexbuilder.project.actionscriptnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/away3D/02_bunny_mark/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | A3D_02_BunnyMark
4 |
5 |
6 |
7 |
8 |
9 | com.adobe.flexbuilder.project.flexbuilder
10 |
11 |
12 |
13 |
14 |
15 | com.adobe.flexbuilder.project.actionscriptnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/cadet2D/02_bunny_mark/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | C2D_02_BunnyMark
4 |
5 |
6 |
7 |
8 |
9 | com.adobe.flexbuilder.project.flexbuilder
10 |
11 |
12 |
13 |
14 |
15 | com.adobe.flexbuilder.project.actionscriptnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/cadet2DBox2D/01_boxes/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | C2D_Box2D_01_Boxes
4 |
5 |
6 |
7 |
8 |
9 | com.adobe.flexbuilder.project.flexbuilder
10 |
11 |
12 |
13 |
14 |
15 | com.adobe.flexbuilder.project.actionscriptnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/cadet3D/01_behaviours/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | C3D_01_Behaviours
4 |
5 |
6 |
7 |
8 |
9 | com.adobe.flexbuilder.project.flexbuilder
10 |
11 |
12 |
13 |
14 |
15 | com.adobe.flexbuilder.project.actionscriptnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/cadet3D/02_bunny_mark/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | C3D_02_BunnyMark
4 |
5 |
6 |
7 |
8 |
9 | com.adobe.flexbuilder.project.flexbuilder
10 |
11 |
12 |
13 |
14 |
15 | com.adobe.flexbuilder.project.actionscriptnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/cadet2D/00_boilerplate/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | C2D_00_Boilerplate
4 |
5 |
6 |
7 |
8 |
9 | com.adobe.flexbuilder.project.flexbuilder
10 |
11 |
12 |
13 |
14 |
15 | com.adobe.flexbuilder.project.actionscriptnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/cadet3DPhysics/01_boxes/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | C3D_Physics_01_Boxes
4 |
5 |
6 |
7 |
8 |
9 | com.adobe.flexbuilder.project.flexbuilder
10 |
11 |
12 |
13 |
14 |
15 | com.adobe.flexbuilder.project.actionscriptnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | C3D_03_Planets
4 |
5 |
6 |
7 |
8 |
9 | com.adobe.flexbuilder.project.flexbuilder
10 |
11 |
12 |
13 |
14 |
15 | com.adobe.flexbuilder.project.actionscriptnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/cadet3D/04_robot/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | C3D_04_Robot
4 |
5 |
6 |
7 |
8 |
9 | com.adobe.flexbuilder.project.flexbuilder
10 |
11 |
12 |
13 |
14 |
15 | com.adobe.flexbuilder.project.actionscriptnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/cadet2D/01_behaviours_skins/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | C2D_01_BehavioursAndSkins
4 |
5 |
6 |
7 |
8 |
9 | com.adobe.flexbuilder.project.flexbuilder
10 |
11 |
12 |
13 |
14 |
15 | com.adobe.flexbuilder.project.actionscriptnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/cadet2D/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | CadetEngine_Ext_2D
4 |
5 |
6 |
7 |
8 |
9 | com.adobe.flexbuilder.project.flexbuilder
10 |
11 |
12 |
13 |
14 |
15 | com.adobe.flexbuilder.project.aslibnature
16 | com.adobe.flexbuilder.project.actionscriptnature
17 |
18 |
19 |
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/util/NullBitmapTexture.as:
--------------------------------------------------------------------------------
1 | package cadet2D.util
2 | {
3 | import flash.display.Bitmap;
4 |
5 | import cadet.util.NullBitmap;
6 |
7 | import starling.textures.Texture;
8 |
9 | public class NullBitmapTexture
10 | {
11 | private static var _instance :Texture;
12 |
13 | public static function get instance():Texture
14 | {
15 | if ( _instance == null )
16 | {
17 | _instance = Texture.fromBitmap( new Bitmap(NullBitmap.instance), false );
18 | }
19 | return _instance;
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/cadet3D/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | CadetEngine_Ext_3D
4 |
5 |
6 |
7 |
8 |
9 | com.adobe.flexbuilder.project.flexbuilder
10 |
11 |
12 |
13 |
14 |
15 | com.adobe.flexbuilder.project.aslibnature
16 | com.adobe.flexbuilder.project.actionscriptnature
17 |
18 |
19 |
--------------------------------------------------------------------------------
/cadet/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | CadetEngine
4 |
5 |
6 |
7 |
8 |
9 | com.adobe.flexbuilder.project.flexbuilder
10 |
11 |
12 |
13 |
14 |
15 | com.adobe.flexbuilder.project.aslibnature
16 | com.adobe.flexbuilder.project.actionscriptnature
17 |
18 |
19 |
--------------------------------------------------------------------------------
/cadet2DBox2D/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | CadetEngine_Ext_2DBox2D
4 |
5 |
6 |
7 |
8 |
9 | com.adobe.flexbuilder.project.flexbuilder
10 |
11 |
12 |
13 |
14 |
15 | com.adobe.flexbuilder.project.aslibnature
16 | com.adobe.flexbuilder.project.actionscriptnature
17 |
18 |
19 |
--------------------------------------------------------------------------------
/cadet3DPhysics/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | CadetEngine_Ext_3DPhysics
4 |
5 |
6 |
7 |
8 |
9 | com.adobe.flexbuilder.project.flexbuilder
10 |
11 |
12 |
13 |
14 |
15 | com.adobe.flexbuilder.project.aslibnature
16 | com.adobe.flexbuilder.project.actionscriptnature
17 |
18 |
19 |
--------------------------------------------------------------------------------
/examples/cadet2D/03_lava/bin-debug/extensions/manifests/Cadet.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/examples/cadet2D/00_boilerplate/bin-debug/extensions/manifests/Cadet.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/cadet/src/cadet/core/ISteppableComponent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.core
12 | {
13 | public interface ISteppableComponent extends IComponent
14 | {
15 | function step( dt:Number ):void;
16 | }
17 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/components/geom/IGeometry.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.components.geom
12 | {
13 | import cadet.core.IComponent;
14 |
15 | public interface IGeometry extends IComponent
16 | {
17 |
18 | }
19 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/serialize/ISerializer.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3D.serialize
12 | {
13 | import away3d.core.base.Object3D;
14 |
15 | public interface ISerializer
16 | {
17 | function export(object:Object3D):String;
18 | }
19 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/util/deg2rad.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.util
12 | {
13 | /** Converts an angle from degrees into radians. */
14 | public function deg2rad(deg:Number):Number
15 | {
16 | return deg / 180.0 * Math.PI;
17 | }
18 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/util/rad2deg.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.util
12 | {
13 | /** Converts an angle from radions into degrees. */
14 | public function rad2deg(rad:Number):Number
15 | {
16 | return rad / Math.PI * 180.0;
17 | }
18 | }
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/bin-debug/extensions/manifests/Cadet.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/examples/cadet3D/04_robot/bin-debug/extensions/manifests/Cadet.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/cadet/src/cadet/validators/IComponentValidator.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.validators
12 | {
13 | import cadet.core.IComponentContainer;
14 |
15 | public interface IComponentValidator
16 | {
17 | function validate( componentType:Class, parent:IComponentContainer ):Boolean;
18 | }
19 | }
--------------------------------------------------------------------------------
/tests/transform2D/src/util/TransformUtil.as:
--------------------------------------------------------------------------------
1 | package util
2 | {
3 | import flash.geom.Matrix;
4 | import flash.geom.Point;
5 |
6 | import starling.utils.MatrixUtil;
7 |
8 | public class TransformUtil
9 | {
10 | public static function convertCoordSpace( parentMatrix:Matrix, childMatrix:Matrix ):Point
11 | {
12 | trace("parent globalMatrix "+parentMatrix);
13 | parentMatrix.invert(); // invert and get global-to-local
14 |
15 | trace("child globalMatrix "+childMatrix);
16 | // this is from Starling, but you can copy this method code as well - it's just 2 lines
17 | var pt:Point = MatrixUtil.transformCoords(parentMatrix, childMatrix.tx, childMatrix.ty);
18 | trace("globalToLocal point x "+pt.x+" y "+pt.y);
19 |
20 | return pt;
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/geom/ICollisionShape.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.components.geom
12 | {
13 | import cadet.core.IComponent;
14 |
15 | import cadet2D.components.transforms.Transform2D;
16 |
17 | public interface ICollisionShape extends IComponent
18 | {
19 | function get transform():Transform2D;
20 | }
21 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/components/behaviours/IEntityUserControlledBehaviour.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.components.behaviours
12 | {
13 | public interface IEntityUserControlledBehaviour
14 | {
15 | function up():void;
16 | function down():void;
17 | function left():void;
18 | function right():void;
19 | function space():void;
20 | }
21 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/shaders/fragment/TextureFragmentShaderComponent.as:
--------------------------------------------------------------------------------
1 | package cadet2D.components.shaders.fragment
2 | {
3 | import cadet.core.Component;
4 |
5 | import cadet2D.components.shaders.IShaderComponent;
6 |
7 | import starling.display.shaders.IShader;
8 | import starling.display.shaders.fragment.TextureFragmentShader;
9 |
10 | public class TextureFragmentShaderComponent extends Component implements IShaderComponent
11 | {
12 | private var _shader :IShader;
13 |
14 | public function TextureFragmentShaderComponent(name:String="TextureFragmentShaderComponent")
15 | {
16 | super(name);
17 |
18 | _shader = new TextureFragmentShader();
19 | }
20 |
21 | public function get shader():IShader
22 | {
23 | return _shader;
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/serialize/NameValuePair.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3D.serialize
12 | {
13 | public class NameValuePair
14 | {
15 | public var name :String;
16 | public var value :Object;
17 |
18 | public function NameValuePair( name:String, value:Object )
19 | {
20 | this.name = name;
21 | this.value = value;
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/behaviours/IFootprint.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.components.behaviours
12 | {
13 | import cadet.core.IComponent;
14 |
15 | public interface IFootprint extends IComponent
16 | {
17 | function get x():int;
18 | function get y():int;
19 | function get sizeX():int;
20 | function get sizeY():int;
21 | function get values():Array;
22 | }
23 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/skins/IRenderable.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.components.skins
12 | {
13 | import cadet.core.IComponent;
14 |
15 | import starling.display.DisplayObject;
16 |
17 | public interface IRenderable extends IComponent
18 | {
19 | function get indexStr():String
20 | function get displayObject():DisplayObject; // Ties this implementation to Starling
21 | }
22 | }
--------------------------------------------------------------------------------
/tests/transform2D/src/components/behaviours/AnimateRotationBehaviour.as:
--------------------------------------------------------------------------------
1 | package components.behaviours
2 | {
3 | import cadet.core.Component;
4 | import cadet.core.ISteppableComponent;
5 | import cadet2D.components.transforms.Transform2D;
6 |
7 | public class AnimateRotationBehaviour extends Component implements ISteppableComponent
8 | {
9 | public var transform2D :Transform2D;
10 |
11 | public var rotationSpeed :Number = 15;
12 |
13 | public function AnimateRotationBehaviour(name:String=null)
14 | {
15 | super();
16 | }
17 |
18 | override protected function addedToParent():void
19 | {
20 | addSiblingReference(Transform2D, "transform2D");
21 | }
22 |
23 | public function step( dt:Number ):void
24 | {
25 | if ( !transform2D ) return;
26 |
27 | transform2D.rotation += rotationSpeed * dt;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/cadet2DBox2D/src/cadet2DBox2D/events/RigidBodyBehaviourEvent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2DBox2D.events
12 | {
13 | import flash.events.Event;
14 |
15 | public class RigidBodyBehaviourEvent extends Event
16 | {
17 | public static const DESTROY_RIGID_BODY :String = "destroyRigidBody";
18 |
19 | public function RigidBodyBehaviourEvent(type:String)
20 | {
21 | super(type);
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/events/RendererEvent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.events
12 | {
13 | import flash.events.Event;
14 |
15 | public class RendererEvent extends Event
16 | {
17 | public static const INITIALISED:String = "initialised";
18 |
19 | public function RendererEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
20 | {
21 | super(type, bubbles, cancelable);
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/core/IComponentContainer.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.core
12 | {
13 | import core.data.ArrayCollection;
14 |
15 | [Event( type="cadet.events.ComponentContainerEvent", name="childAdded" )]
16 | [Event( type="cadet.events.ComponentContainerEvent", name="childRemoved" )]
17 |
18 | public interface IComponentContainer extends IComponent
19 | {
20 | function get children():ArrayCollection;
21 | }
22 | }
--------------------------------------------------------------------------------
/examples/cadet2D/01_behaviours_skins/src/components/behaviours/AnimateRotationBehaviour.as:
--------------------------------------------------------------------------------
1 | package components.behaviours
2 | {
3 | import cadet.core.Component;
4 | import cadet.core.ISteppableComponent;
5 | import cadet2D.components.transforms.Transform2D;
6 |
7 | public class AnimateRotationBehaviour extends Component implements ISteppableComponent
8 | {
9 | public var transform2D :Transform2D;
10 |
11 | public var rotationSpeed :Number = 15;
12 |
13 | public function AnimateRotationBehaviour(name:String=null)
14 | {
15 | super();
16 | }
17 |
18 | override protected function addedToParent():void
19 | {
20 | addSiblingReference(Transform2D, "transform2D");
21 | }
22 |
23 | public function step( dt:Number ):void
24 | {
25 | if ( !transform2D ) return;
26 |
27 | transform2D.rotation += rotationSpeed * dt;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/util/RenderablesUtil.as:
--------------------------------------------------------------------------------
1 | package cadet2D.util
2 | {
3 | import cadet2D.components.skins.IRenderable;
4 |
5 | public class RenderablesUtil
6 | {
7 | public static function sortSkinsById( renderableA:IRenderable, renderableB:IRenderable):int
8 | {
9 | var skinA_Ids:Array = renderableA.indexStr.split("_");
10 | var skinB_Ids:Array = renderableB.indexStr.split("_");
11 |
12 | var longest:uint = Math.max(skinA_Ids.length, skinB_Ids.length);
13 | var index:uint = 0;
14 |
15 | while ( index < longest ) {
16 | var idA:Number = index < skinA_Ids.length ? skinA_Ids[index] : -1;
17 | var idB:Number = index < skinB_Ids.length ? skinB_Ids[index] : -1;
18 |
19 | if ( idA < idB ) {
20 | return -1;
21 | } else if ( idA > idB ) {
22 | return 1;
23 | }
24 | index ++;
25 | }
26 |
27 | return 0;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/components/lights/DirectionalLightComponent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3D.components.lights
12 | {
13 | import away3d.lights.DirectionalLight;
14 |
15 | public class DirectionalLightComponent extends AbstractLightComponent
16 | {
17 | public function DirectionalLightComponent()
18 | {
19 | _object3D = _light = new DirectionalLight();
20 |
21 | castsShadows = true;
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/transforms/ITransform2D.as:
--------------------------------------------------------------------------------
1 | package cadet2D.components.transforms
2 | {
3 | import flash.geom.Matrix;
4 |
5 | import cadet.core.IComponent;
6 |
7 | public interface ITransform2D extends IComponent
8 | {
9 | function set x( value:Number ):void;
10 | function get x():Number;
11 | function set y( value:Number ):void;
12 | function get y():Number;
13 | function set scaleX( value:Number ):void;
14 | function get scaleX():Number;
15 | function set scaleY( value:Number ):void;
16 | function get scaleY():Number;
17 | function set rotation( value:Number ):void;
18 | function get rotation():Number;
19 | function set matrix( value:Matrix ):void;
20 | function get matrix():Matrix;
21 | function get globalMatrix():Matrix;
22 | function get parentTransform():ITransform2D;
23 | function set parentTransform( value:ITransform2D ):void;
24 | }
25 | }
--------------------------------------------------------------------------------
/examples/cadet3D/01_behaviours/src/components/behaviours/AnimateRotationBehaviour.as:
--------------------------------------------------------------------------------
1 | package components.behaviours
2 | {
3 | import cadet.core.Component;
4 | import cadet.core.ISteppableComponent;
5 |
6 | import cadet3D.components.core.MeshComponent;
7 |
8 | public class AnimateRotationBehaviour extends Component implements ISteppableComponent
9 | {
10 | public var mesh :MeshComponent;
11 |
12 | public var rotationSpeed :Number = 30;
13 |
14 | public function AnimateRotationBehaviour(name:String=null)
15 | {
16 | super();
17 | }
18 |
19 | override protected function addedToParent():void
20 | {
21 | if ( parentComponent is MeshComponent ) {
22 | mesh = MeshComponent(parentComponent);
23 | }
24 | }
25 |
26 | public function step( dt:Number ):void
27 | {
28 | if ( !mesh ) return;
29 |
30 | mesh.rotationX += rotationSpeed * dt;
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/geom/BoundingSphere.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.components.geom
12 | {
13 | import cadet2D.components.processes.CollisionDetectionProcess;
14 | import cadet.core.Component;
15 |
16 | public class BoundingSphere extends CollisionShape implements ICollisionShape
17 | {
18 | [Serializable][Inspectable]
19 | public var radius :Number = 40;
20 |
21 | public function BoundingSphere()
22 | {
23 | name = "Bounding Sphere";
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/util/DisplayUtil.as:
--------------------------------------------------------------------------------
1 | package cadet2D.util
2 | {
3 | import starling.display.DisplayObject;
4 |
5 | public class DisplayUtil
6 | {
7 | static public function haveCommonParent(currentObject:DisplayObject, targetSpace:DisplayObject):Boolean
8 | {
9 | // 1. find a common parent of this and the target space
10 | var commonParent:DisplayObject = null;
11 | var sAncestors:Vector. = new Vector.();
12 |
13 | while (currentObject)
14 | {
15 | sAncestors.push(currentObject);
16 | currentObject = currentObject.parent;
17 | }
18 |
19 | currentObject = targetSpace;
20 | while (currentObject && sAncestors.indexOf(currentObject) == -1)
21 | currentObject = currentObject.parent;
22 |
23 | sAncestors.length = 0;
24 |
25 | if (currentObject) {
26 | commonParent = currentObject;
27 | return true;
28 | }
29 |
30 | return false;
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/cadet/.flexLibProperties:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/events/Renderer3DEvent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3D.events
12 | {
13 | import flash.events.Event;
14 |
15 | public class Renderer3DEvent extends Event
16 | {
17 | public static const PRE_RENDER :String = "preRender";
18 | public static const POST_RENDER :String = "postRender";
19 |
20 | public function Renderer3DEvent(type:String)
21 | {
22 | super(type);
23 | }
24 |
25 | override public function clone():Event
26 | {
27 | return new Renderer3DEvent( type );
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/util/NullBitmapTexture.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3D.util
12 | {
13 | import away3d.textures.BitmapTexture;
14 | import cadet.util.NullBitmap;
15 |
16 | public class NullBitmapTexture
17 | {
18 | private static var _instance :BitmapTexture;
19 |
20 | public static function get instance():BitmapTexture
21 | {
22 | if ( _instance == null )
23 | {
24 | _instance = new BitmapTexture( NullBitmap.instance );
25 | }
26 | return _instance;
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/examples/cadet2D/01_behaviours_skins/src/components/behaviours/UpdateAlphaBehaviour.as:
--------------------------------------------------------------------------------
1 | package components.behaviours
2 | {
3 | import cadet.core.Component;
4 | import cadet.core.ISteppableComponent;
5 |
6 | import cadet2D.components.renderers.Renderer2D;
7 | import cadet2D.components.skins.GeometrySkin;
8 |
9 | public class UpdateAlphaBehaviour extends Component implements ISteppableComponent
10 | {
11 | public var skin :GeometrySkin;
12 | public var renderer :Renderer2D;
13 |
14 | public function UpdateAlphaBehaviour()
15 | {
16 | super();
17 | }
18 |
19 | override protected function addedToScene():void
20 | {
21 | addSiblingReference(GeometrySkin, "skin");
22 | addSceneReference(Renderer2D, "renderer");
23 | }
24 |
25 | public function step( dt:Number ):void
26 | {
27 | if ( !skin ) return;
28 |
29 | skin.fillAlpha = renderer.mouseX/renderer.viewport.stage.stageWidth;
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/util/NullBitmap.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.util
12 | {
13 | import flash.display.BitmapData;
14 |
15 | public class NullBitmap
16 | {
17 | [Embed(source="NullBitmap.png")]
18 | private static var NullBitmap :Class;
19 | private static var _instance :BitmapData;
20 |
21 | public static function get instance():BitmapData
22 | {
23 | if ( _instance == null )
24 | {
25 | _instance = new NullBitmap().bitmapData;
26 | }
27 | return _instance;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/geom/VertexList.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.geom
12 | {
13 | public class VertexList extends Vertex
14 | {
15 | public var next :VertexList;
16 |
17 | public function VertexList(x:Number = 0, y:Number = 0)
18 | {
19 | super(x,y)
20 | next = this;
21 | }
22 |
23 | public function toArray():Array
24 | {
25 | var array:Array = [];
26 | var v:VertexList = this;
27 | do
28 | {
29 | array.push(v.clone());
30 | v = v.next;
31 | }
32 | while( v != this )
33 |
34 | return array;
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/events/InputProcessEvent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.events
12 | {
13 | import flash.events.Event;
14 |
15 | public class InputProcessEvent extends Event
16 | {
17 | public static const INPUT_DOWN :String = "inputDown";
18 | public static const INPUT_UP :String = "inputUp";
19 |
20 | public static const UPDATE :String = "update";
21 |
22 | public var name :String;
23 |
24 | public function InputProcessEvent(type:String, name:String)
25 | {
26 | super(type);
27 | this.name = name;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/util/TextureUtils.as:
--------------------------------------------------------------------------------
1 | // From the original away3d.tools.utils.TextureUtils
2 | package cadet.util
3 | {
4 | import flash.display.BitmapData;
5 |
6 | public class TextureUtils
7 | {
8 | private static const MAX_SIZE : uint = 2048;
9 |
10 | public static function isBitmapDataValid(bitmapData : BitmapData) : Boolean
11 | {
12 | if (bitmapData == null) return true;
13 |
14 | return isDimensionValid(bitmapData.width) && isDimensionValid(bitmapData.height);
15 | }
16 |
17 | public static function isDimensionValid(d : uint) : Boolean
18 | {
19 | return d >= 1 && d <= MAX_SIZE && isPowerOfTwo(d);
20 | }
21 |
22 | public static function isPowerOfTwo(value : int) : Boolean
23 | {
24 | return value ? ((value & -value) == value) : false;
25 | }
26 |
27 | public static function getBestPowerOf2(value : uint) : Number
28 | {
29 | var p : uint = 1;
30 |
31 | while (p < value)
32 | p <<= 1;
33 |
34 | if (p > MAX_SIZE) p = MAX_SIZE;
35 |
36 | return p;
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/core/IInitialisableComponent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | // Some Processes and Behaviours need to function differently in design time and run time.
12 | // For instance, a Process may reference a list of Skins at design time which are then spawned intermittently at run time.
13 | // These Components need to be initialised to perform these operations when the scene is running, by implementing this interface,
14 | // the Components register to have their init() function called when the scene first steps.
15 |
16 | package cadet.core
17 | {
18 | public interface IInitialisableComponent extends IComponent
19 | {
20 | function init():void;
21 | }
22 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/events/ValidationEvent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.events
12 | {
13 | import flash.events.Event;
14 |
15 | public class ValidationEvent extends Event
16 | {
17 | public static const INVALIDATE :String = "invalidate";
18 | public static const VALIDATED :String = "validated";
19 |
20 | public var validationType :String;
21 |
22 | public function ValidationEvent(type:String, validationType:String = null)
23 | {
24 | super(type);
25 | this.validationType = validationType;
26 | }
27 |
28 | override public function clone():Event
29 | {
30 | return new ValidationEvent( type, validationType );
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/cadet2DBox2D/src/cadet2DBox2D/components/processes/PhysicsProcessDestructionListener.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2DBox2D.components.processes
12 | {
13 | import Box2D.Dynamics.Joints.b2Joint;
14 | import Box2D.Dynamics.b2DestructionListener;
15 |
16 | public class PhysicsProcessDestructionListener extends b2DestructionListener
17 | {
18 | private var process :PhysicsProcess;
19 |
20 | public function PhysicsProcessDestructionListener( process:PhysicsProcess )
21 | {
22 | this.process = process;
23 | }
24 |
25 | override public function SayGoodbyeJoint(joint:b2Joint):void
26 | {
27 | process.jointDestroyed(joint);
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/components/textures/AbstractTexture2DComponent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3D.components.textures
12 | {
13 | import away3d.textures.Texture2DBase;
14 |
15 | import cadet.core.Component;
16 |
17 | public class AbstractTexture2DComponent extends Component
18 | {
19 | protected var _texture2D :Texture2DBase;
20 |
21 | public function AbstractTexture2DComponent()
22 | {
23 |
24 | }
25 |
26 | override public function dispose():void
27 | {
28 | _texture2D.dispose();
29 | super.dispose();
30 | }
31 |
32 | public function get texture2D():Texture2DBase
33 | {
34 | return _texture2D;
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/operations/Cadet2DStartUpOperation.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | // For use when loading CadetScenes outside of the CadetEditor, e.g. in a Flash Builder project.
12 | package cadet2D.operations
13 | {
14 | import cadet.operations.CadetStartUpOperationBase;
15 |
16 | public class Cadet2DStartUpOperation extends CadetStartUpOperationBase
17 | {
18 | public function Cadet2DStartUpOperation( cadetFileURL:String = null, fileSystemType:String = "url" )
19 | {
20 | super(cadetFileURL, fileSystemType);
21 |
22 | addManifest( baseManifestURL + "Cadet2D.xml");
23 | }
24 | }
25 | }
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/events/FootprintManagerEvent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.events
12 | {
13 | import flash.events.Event;
14 |
15 | public class FootprintManagerEvent extends Event
16 | {
17 | public static const CHANGE :String = "change";
18 |
19 | private var _indices :Array;
20 |
21 | public function FootprintManagerEvent(type:String, indices:Array)
22 | {
23 | super(type);
24 | _indices = indices;
25 | }
26 |
27 | override public function clone():Event
28 | {
29 | return new FootprintManagerEvent( type, _indices );
30 | }
31 |
32 | public function get indices():Array { return _indices.slice(); }
33 |
34 | }
35 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/validators/ComponentParentValidator.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.validators
12 | {
13 | import cadet.core.IComponentContainer;
14 |
15 | public class ComponentParentValidator implements IComponentValidator
16 | {
17 | private var compatibleParentType :Class;
18 |
19 | public function ComponentParentValidator( compatibleParentType:Class )
20 | {
21 | this.compatibleParentType = compatibleParentType;
22 | }
23 |
24 | public function validate(componentType:Class, parent:IComponentContainer):Boolean
25 | {
26 | if ( parent is compatibleParentType == false ) return false;
27 | return true;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/components/geom/AbstractGeometryComponent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3D.components.geom
12 | {
13 | import away3d.core.base.Geometry;
14 |
15 | import cadet.components.geom.IGeometry;
16 | import cadet.core.Component;
17 |
18 | public class AbstractGeometryComponent extends Component implements IGeometry
19 | {
20 | // Invalidation types;
21 | protected const GEOMETRY :String = "geometry";
22 |
23 | protected var _geometry :Geometry;
24 |
25 | public function AbstractGeometryComponent()
26 | {
27 | _geometry = new Geometry();
28 | }
29 |
30 | public function get geometry():Geometry
31 | {
32 | return _geometry;
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/components/geom/GeometryComponent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3D.components.geom
12 | {
13 | import away3d.core.base.Geometry;
14 |
15 | import cadet.core.Component;
16 |
17 | import flash.events.Event;
18 |
19 | public class GeometryComponent extends AbstractGeometryComponent
20 | {
21 | public function GeometryComponent()
22 | {
23 |
24 | }
25 |
26 | [Serializable( type="resource" )][Inspectable( editor="ResourceItemEditor" )]
27 | public function set geometry( value:Geometry ):void
28 | {
29 | if ( value == _geometry ) return;
30 | _geometry = value || new Geometry();
31 | dispatchEvent( new Event( Event.CHANGE ) );
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/events/ComponentContainerEvent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.events
12 | {
13 | import flash.events.Event;
14 |
15 | import cadet.core.IComponent;
16 |
17 | public class ComponentContainerEvent extends Event
18 | {
19 | public static const CHILD_ADDED :String = "childAdded";
20 | public static const CHILD_REMOVED :String = "childRemoved";
21 |
22 | public var child:IComponent;
23 |
24 | public function ComponentContainerEvent(type:String, child:IComponent)
25 | {
26 | super(type);
27 | this.child = child;
28 | }
29 |
30 |
31 | override public function clone():Event
32 | {
33 | return new ComponentContainerEvent( type, child );
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/renderers/IRenderer2D.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.components.renderers
12 | {
13 | import flash.display.DisplayObject;
14 | import flash.geom.Matrix;
15 | import flash.geom.Point;
16 |
17 | import cadet.core.IRenderer;
18 |
19 | public interface IRenderer2D extends IRenderer
20 | {
21 | //need to return Object rather than Sprite because of Starling implementation
22 | //function get worldContainer():Sprite;
23 | function worldToViewport( pt:Point ):Point;
24 | function viewportToWorld( pt:Point ):Point;
25 |
26 | function enable(parent:DisplayObject):void;
27 | function disable():void;
28 |
29 | function setWorldContainerTransform( m:Matrix ):void;
30 | }
31 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/components/textures/AbstractCubeTextureComponent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3D.components.textures
12 | {
13 | import away3d.textures.CubeTextureBase;
14 | import away3d.textures.Texture2DBase;
15 |
16 | import cadet.core.Component;
17 |
18 | public class AbstractCubeTextureComponent extends Component
19 | {
20 | protected var _cubeTexture :CubeTextureBase;
21 |
22 | public function AbstractCubeTextureComponent()
23 | {
24 |
25 | }
26 |
27 | override public function dispose():void
28 | {
29 | _cubeTexture.dispose();
30 | super.dispose();
31 | }
32 |
33 | public function get cubeTexture():CubeTextureBase
34 | {
35 | return _cubeTexture;
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/primitives/SkyBoxNode.as:
--------------------------------------------------------------------------------
1 | package cadet3D.primitives
2 | {
3 | import away3d.core.math.Plane3D;
4 | import away3d.core.partition.EntityNode;
5 | import away3d.core.traverse.PartitionTraverser;
6 |
7 | /**
8 | * SkyBoxNode is a space partitioning leaf node that contains a SkyBox object.
9 | */
10 | public class SkyBoxNode extends EntityNode
11 | {
12 | private var _skyBox:SkyBox;
13 |
14 | /**
15 | * Creates a new SkyBoxNode object.
16 | * @param skyBox The SkyBox to be contained in the node.
17 | */
18 | public function SkyBoxNode(skyBox:SkyBox)
19 | {
20 | super(skyBox);
21 | _skyBox = skyBox;
22 | }
23 |
24 | /**
25 | * @inheritDoc
26 | */
27 | override public function acceptTraverser(traverser:PartitionTraverser):void
28 | {
29 | if (traverser.enterNode(this)) {
30 | super.acceptTraverser(traverser);
31 | traverser.applySkyBox(_skyBox);
32 | }
33 | }
34 |
35 | override public function isInFrustum(planes:Vector., numPlanes:int):Boolean
36 | {
37 | planes = planes;
38 | numPlanes = numPlanes;
39 | return true;
40 | }
41 | }
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/cadet/src/cadet/core/IRenderer.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.core
12 | {
13 | import flash.display.Stage;
14 |
15 | public interface IRenderer extends IComponent
16 | {
17 | //function get viewport():Sprite;
18 |
19 | function set viewportWidth( value:Number ):void;
20 | function get viewportWidth():Number;
21 | function set viewportHeight( value:Number ):void;
22 | function get viewportHeight():Number;
23 |
24 | function get mouseX():Number
25 | function get mouseY():Number;
26 |
27 | // function enable(parent:DisplayObjectContainer, depth:int = -1):void
28 | // function disable(parent:DisplayObjectContainer):void
29 |
30 | function getNativeStage():Stage
31 |
32 | function get initialised():Boolean;
33 | }
34 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/geom/BezierCurve.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.components.geom
12 | {
13 | import cadet2D.geom.QuadraticBezier;
14 |
15 | public class BezierCurve extends AbstractGeometry
16 | {
17 | protected var _segments :Array;//Vector.;
18 |
19 | public function BezierCurve()
20 | {
21 | name = "BezierCurve";
22 | _segments = new Array();//Vector.();
23 | }
24 |
25 | [Serializable]
26 | public function set segments( value:Array ):void//Vector. ):void
27 | {
28 | _segments = value;
29 | invalidate("geometry");
30 | }
31 | public function get segments():Array//Vector.
32 | {
33 | return _segments;
34 | }
35 |
36 | }
37 | }
--------------------------------------------------------------------------------
/examples/cadet2D/03_lava/src/model/SceneModel_XML.as:
--------------------------------------------------------------------------------
1 | package model
2 | {
3 | import flash.display.DisplayObject;
4 | import flash.events.Event;
5 |
6 | import cadet.core.CadetScene;
7 | import cadet.util.ComponentUtil;
8 |
9 | import cadet2D.components.renderers.Renderer2D;
10 |
11 | public class SceneModel_XML implements ISceneModel
12 | {
13 | private var _parent :DisplayObject;
14 | private var _cadetScene :CadetScene;
15 |
16 | public function SceneModel_XML()
17 | {
18 | }
19 |
20 | public function init(parent:DisplayObject):void
21 | {
22 | _parent = parent;
23 |
24 | // Grab a reference to the Renderer2D and enable it
25 | var renderer:Renderer2D = ComponentUtil.getChildOfType(_cadetScene, Renderer2D);
26 | renderer.enable(parent);
27 |
28 | _parent.addEventListener( Event.ENTER_FRAME, enterFrameHandler );
29 | }
30 |
31 | public function get cadetScene():CadetScene
32 | {
33 | return _cadetScene;
34 | }
35 |
36 | public function set cadetScene(value:CadetScene):void
37 | {
38 | _cadetScene = value;
39 | }
40 |
41 | private function enterFrameHandler( event:Event ):void
42 | {
43 | _cadetScene.step();
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/util/NullBitmapCubeTexture.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3D.util
12 | {
13 | import away3d.textures.BitmapCubeTexture;
14 | import cadet.util.NullBitmap;
15 |
16 | public class NullBitmapCubeTexture
17 | {
18 | private static var _instance :BitmapCubeTexture;
19 |
20 | public static function get instance():BitmapCubeTexture
21 | {
22 | if ( _instance == null )
23 | {
24 | _instance = getCopy();
25 | }
26 | return _instance;
27 | }
28 |
29 | public static function getCopy():BitmapCubeTexture
30 | {
31 | return new BitmapCubeTexture( NullBitmap.instance, NullBitmap.instance, NullBitmap.instance, NullBitmap.instance, NullBitmap.instance, NullBitmap.instance );
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/examples/cadet2D/00_boilerplate/src/model/SceneModel_XML.as:
--------------------------------------------------------------------------------
1 | package model
2 | {
3 | import flash.display.DisplayObject;
4 | import flash.events.Event;
5 |
6 | import cadet.core.CadetScene;
7 | import cadet.util.ComponentUtil;
8 |
9 | import cadet2D.components.renderers.Renderer2D;
10 |
11 | public class SceneModel_XML implements ISceneModel
12 | {
13 | private var _parent :DisplayObject;
14 | private var _cadetScene :CadetScene;
15 |
16 | public function SceneModel_XML()
17 | {
18 | }
19 |
20 | public function init(parent:DisplayObject):void
21 | {
22 | _parent = parent;
23 |
24 | // Grab a reference to the Renderer2D and enable it
25 | var renderer:Renderer2D = ComponentUtil.getChildOfType(_cadetScene, Renderer2D);
26 | renderer.enable(parent);
27 |
28 | _parent.addEventListener( Event.ENTER_FRAME, enterFrameHandler );
29 | }
30 |
31 | public function get cadetScene():CadetScene
32 | {
33 | return _cadetScene;
34 | }
35 |
36 | public function set cadetScene(value:CadetScene):void
37 | {
38 | _cadetScene = value;
39 | }
40 |
41 | private function enterFrameHandler( event:Event ):void
42 | {
43 | _cadetScene.step();
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/core/ICadetScene.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.core
12 | {
13 | import core.app.managers.DependencyManager;
14 |
15 | /**
16 | * An ICadetScene acts as a top-level component in much the same way the Stage class acts as a top-level DisplayObject
17 | * in Flash's display list. All components have a reference to the scene they are currently a child of, again much like
18 | * DisplayObject's.
19 | * @author Jonathan
20 | *
21 | */
22 | public interface ICadetScene extends IComponentContainer
23 | {
24 | function step():void
25 | function get dependencyManager():DependencyManager;
26 | function set userData( value:Object ):void;
27 | function get userData():Object;
28 | function get runMode():Boolean;
29 | function set runMode( value:Boolean ):void;
30 | }
31 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/assets/CadetEngineIcons.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.assets
12 | {
13 | public class CadetEngineIcons
14 | {
15 | [Embed( source = 'Behaviour.png' )] static public var Behaviour:Class;
16 | [Embed( source = 'Component.png' )] static public var Component:Class;
17 | [Embed( source = 'Geometry.png' )] static public var Geometry:Class;
18 | [Embed( source = 'Process.png' )] static public var Process:Class;
19 | [Embed( source = 'Renderer.png' )] static public var Renderer:Class;
20 | [Embed( source = 'Skin.png' )] static public var Skin:Class;
21 | [Embed( source = 'Sound.png' )] static public var Sound:Class;
22 | [Embed( source = 'Texture.png' )] static public var Texture:Class;
23 | [Embed( source = 'Transform.png' )] static public var Transform:Class;
24 | }
25 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/resources/Away3DMeshResource.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3D.resources
12 | {
13 | import away3d.entities.Mesh;
14 |
15 | import core.app.resources.IFactoryResource;
16 |
17 | public class Away3DMeshResource implements IFactoryResource
18 | {
19 | private var id :String;
20 | private var mesh :Mesh;
21 |
22 | public function Away3DMeshResource(id:String, mesh:Mesh)
23 | {
24 | this.id = id;
25 | this.mesh = mesh;
26 | }
27 |
28 | public function getLabel():String
29 | {
30 | return "Away3D Mesh Resource";
31 | }
32 |
33 | public function getInstance():Object
34 | {
35 | return mesh.clone();
36 | }
37 |
38 | public function getInstanceType():Class
39 | {
40 | return Mesh;
41 | }
42 |
43 | public function getID():String
44 | {
45 | return id;
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/events/CollisionEvent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.events
12 | {
13 | import flash.events.Event;
14 |
15 | import cadet2D.components.geom.ICollisionShape;
16 |
17 | public class CollisionEvent extends Event
18 | {
19 | public static const COLLISION :String = "collision";
20 |
21 | private var _objectA :ICollisionShape;
22 | private var _objectB :ICollisionShape;
23 |
24 | public function CollisionEvent(type:String, objectA:ICollisionShape, objectB:ICollisionShape)
25 | {
26 | super(type, false, false);
27 | _objectA = objectA;
28 | _objectB = objectB;
29 | }
30 |
31 | override public function clone():Event
32 | {
33 | return new CollisionEvent( type, _objectA, _objectB );
34 | }
35 |
36 | public function get objectA():ICollisionShape { return _objectA; }
37 | public function get objectB():ICollisionShape { return _objectB; }
38 | }
39 | }
--------------------------------------------------------------------------------
/examples/cadet2D/00_boilerplate/src/Boilerplate.as:
--------------------------------------------------------------------------------
1 | package
2 | {
3 | import flash.display.Sprite;
4 | import flash.events.Event;
5 |
6 | import cadet.core.CadetScene;
7 |
8 | import cadet2D.operations.Cadet2DStartUpOperation;
9 |
10 | import model.ISceneModel;
11 | import model.SceneModel_XML;
12 |
13 | [SWF( width="800", height="600", backgroundColor="0x002135", frameRate="60" )]
14 | public class Boilerplate extends Sprite
15 | {
16 | private var _sceneModel :ISceneModel;
17 | private var _cadetFileURL :String = "/scene.cdt2d";
18 |
19 | public function Boilerplate()
20 | {
21 | // Required when loading data and assets.
22 | var startUpOperation:Cadet2DStartUpOperation = new Cadet2DStartUpOperation(_cadetFileURL);
23 | startUpOperation.addManifest( startUpOperation.baseManifestURL + "Cadet2DBox2D.xml");
24 | startUpOperation.addEventListener(flash.events.Event.COMPLETE, startUpCompleteHandler);
25 | startUpOperation.execute();
26 | }
27 |
28 | private function startUpCompleteHandler( event:Event ):void
29 | {
30 | var operation:Cadet2DStartUpOperation = Cadet2DStartUpOperation( event.target );
31 |
32 | if ( _cadetFileURL ) {
33 | _sceneModel = new SceneModel_XML();
34 | _sceneModel.cadetScene = CadetScene(operation.getResult());
35 | }
36 |
37 | _sceneModel.init(this);
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/events/ComponentEvent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.events
12 | {
13 | import flash.events.Event;
14 |
15 | import cadet.core.IComponent;
16 |
17 | public class ComponentEvent extends Event
18 | {
19 | public static const ADDED_TO_PARENT :String = "addedToParent";
20 | public static const REMOVED_FROM_PARENT :String = "removedFromParent";
21 |
22 | public static const ADDED_TO_SCENE :String = "addedToScene";
23 | public static const REMOVED_FROM_SCENE :String = "removedFromScene";
24 |
25 | private var _component:IComponent;
26 |
27 | public function ComponentEvent(type:String, component:IComponent)
28 | {
29 | super(type);
30 | _component = component;
31 | }
32 |
33 | public function get component():IComponent { return _component; }
34 |
35 | override public function clone():Event
36 | {
37 | return new ComponentEvent( type, _component );
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/geom/CollisionShape.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.components.geom
12 | {
13 | import cadet.core.CadetScene;
14 | import cadet.core.Component;
15 | import cadet.core.IComponentContainer;
16 | import cadet.util.ComponentReferenceUtil;
17 | import cadet.util.ComponentUtil;
18 |
19 | import cadet2D.components.transforms.Transform2D;
20 |
21 | import flash.events.Event;
22 |
23 | [Event( type="cadet.events.CollisionEvent", name="collision" )]
24 |
25 | public class CollisionShape extends Component implements ICollisionShape
26 | {
27 | public var _transform :Transform2D;
28 |
29 | public function CollisionShape()
30 | {
31 | }
32 |
33 | override protected function addedToScene():void
34 | {
35 | addSiblingReference(Transform2D, "_transform");
36 | }
37 |
38 | public function get transform():Transform2D
39 | {
40 | return _transform;
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/geom/Vertex.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.geom
12 | {
13 | import flash.geom.Point;
14 |
15 | import core.app.dataStructures.ObjectPool;
16 |
17 |
18 | public class Vertex
19 | {
20 | [Serializable]
21 | public var x :Number
22 | [Serializable]
23 | public var y :Number
24 |
25 | public function Vertex(x:Number = 0, y:Number = 0)
26 | {
27 | this.x = x
28 | this.y = y
29 | }
30 |
31 | public function setValues( x:Number, y:Number ):void
32 | {
33 | this.x = x;
34 | this.y = y;
35 | }
36 |
37 | public function toPoint():Point
38 | {
39 | return new Point( x, y );
40 | }
41 |
42 | public function clone():Vertex
43 | {
44 | var v:Vertex = ObjectPool.getInstance(Vertex);
45 | v.setValues(x,y);
46 | return v;
47 | }
48 |
49 | public function toString():String
50 | {
51 | return "{x: "+x+", y: "+y+"}";
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/geom/QuadraticBezier.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.geom
12 | {
13 | public class QuadraticBezier
14 | {
15 | [Serializable] public var startX :Number;
16 | [Serializable] public var startY :Number;
17 | [Serializable] public var controlX :Number;
18 | [Serializable] public var controlY :Number;
19 | [Serializable] public var endX :Number;
20 | [Serializable] public var endY :Number;
21 |
22 | public function QuadraticBezier( startX:Number = 0, startY:Number = 0, controlX:Number = 0, controlY:Number = 0, endX:Number = 0, endY:Number = 0)
23 | {
24 | this.startX = startX;
25 | this.startY = startY;
26 | this.controlX = controlX;
27 | this.controlY = controlY;
28 | this.endX = endX;
29 | this.endY = endY;
30 | }
31 |
32 | public function clone():QuadraticBezier
33 | {
34 | return new QuadraticBezier( startX, startY, controlX, controlY, endX, endY );
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/components/primitives/SkyBoxComponent.as:
--------------------------------------------------------------------------------
1 | package cadet3D.components.primitives
2 | {
3 | import away3d.materials.SkyBoxMaterial;
4 |
5 | import cadet3D.components.core.ObjectContainer3DComponent;
6 | import cadet3D.components.materials.SkyBoxMaterialComponent;
7 | import cadet3D.primitives.SkyBox;
8 | import cadet3D.util.NullBitmapCubeTexture;
9 |
10 | public class SkyBoxComponent extends ObjectContainer3DComponent
11 | {
12 | private var _skyBox :SkyBox;
13 | private var _materialComponent :SkyBoxMaterialComponent;
14 | //private var defaultBitmapData :BitmapData = new BitmapData(256, 256, false, 0xFF0000);
15 |
16 | public function SkyBoxComponent()
17 | {
18 | _object3D = _skyBox = new SkyBox(NullBitmapCubeTexture.getCopy());
19 | }
20 |
21 | [Serializable][Inspectable( priority="150", editor="ComponentList", scope="scene" )]
22 | public function get materialComponent():SkyBoxMaterialComponent
23 | {
24 | return _materialComponent;
25 | }
26 |
27 | public function set materialComponent(value : SkyBoxMaterialComponent) : void
28 | {
29 | _materialComponent = value;
30 | if ( _materialComponent ) {
31 | _skyBox.material = _materialComponent.material;
32 | }
33 | else {
34 | _skyBox.material = new SkyBoxMaterial(NullBitmapCubeTexture.getCopy());
35 | }
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/resources/Away3DGeometryResource.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3D.resources
12 | {
13 | import away3d.core.base.Geometry;
14 |
15 | import core.app.resources.FactoryResource;
16 | import core.app.resources.IFactoryResource;
17 |
18 | public class Away3DGeometryResource implements IFactoryResource
19 | {
20 | private var id :String;
21 | private var geometry :Geometry;
22 |
23 | public function Away3DGeometryResource(id:String, geometry:Geometry)
24 | {
25 | this.id = id;
26 | this.geometry = geometry;
27 | }
28 |
29 | public function getLabel():String
30 | {
31 | return "Away3D Geometry Resource";
32 | }
33 |
34 | public function getInstance():Object
35 | {
36 | return geometry.clone();
37 | }
38 |
39 | public function getInstanceType():Class
40 | {
41 | return Geometry;
42 | }
43 |
44 | public function getID():String
45 | {
46 | return id;
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/resources/Away3DMaterialResource.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3D.resources
12 | {
13 | import away3d.materials.MaterialBase;
14 |
15 | import core.app.resources.FactoryResource;
16 | import core.app.resources.IFactoryResource;
17 |
18 | public class Away3DMaterialResource implements IFactoryResource
19 | {
20 | private var id :String;
21 | private var material :MaterialBase;
22 |
23 | public function Away3DMaterialResource(id:String, material:MaterialBase)
24 | {
25 | this.id = id;
26 | this.material = material;
27 | }
28 |
29 | public function getLabel():String
30 | {
31 | return "Away3D Material Resource";
32 | }
33 |
34 | public function getInstance():Object
35 | {
36 | return material;
37 | }
38 |
39 | public function getInstanceType():Class
40 | {
41 | return MaterialBase;
42 | }
43 |
44 | public function getID():String
45 | {
46 | return id;
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/bin-debug/extensions/manifests/Cadet3D.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/examples/cadet3D/04_robot/bin-debug/extensions/manifests/Cadet3D.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/overlays/Overlay.as:
--------------------------------------------------------------------------------
1 | package cadet2D.overlays
2 | {
3 | import starling.display.Shape;
4 |
5 | public class Overlay extends Shape
6 | {
7 | protected var _invalidationTable :Object;
8 | //private var invalidationEvent :InvalidationEvent;
9 |
10 | public function Overlay()
11 | {
12 | _invalidationTable = {};
13 | //invalidationEvent = new InvalidationEvent( InvalidationEvent.INVALIDATE );
14 | invalidate("*");
15 | }
16 |
17 | // Invalidation methods
18 | public function invalidate( invalidationType:String ):void
19 | {
20 | _invalidationTable[invalidationType] = true;
21 | //invalidationEvent.invalidationType = invalidationType;
22 | //dispatchEvent( invalidationEvent );
23 | }
24 |
25 | public function validateNow():void
26 | {
27 | validate();
28 | _invalidationTable = {};
29 | }
30 |
31 | protected function validate():void
32 | {
33 |
34 | }
35 |
36 | public function isInvalid(type:String):Boolean
37 | {
38 | if ( _invalidationTable["*"] ) return true;
39 | if ( type == "*" )
40 | {
41 | for each ( var val:String in _invalidationTable )
42 | {
43 | return true;
44 | }
45 | }
46 | return _invalidationTable[type] == true;
47 | }
48 |
49 | public function get invalidationTable():Object { return _invalidationTable; }
50 | }
51 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/resources/Away3DContainer3DResource.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3D.resources
12 | {
13 | import away3d.containers.ObjectContainer3D;
14 |
15 | import core.app.resources.IFactoryResource;
16 |
17 | public class Away3DContainer3DResource implements IFactoryResource
18 | {
19 | private var id :String;
20 | private var container3D :ObjectContainer3D;
21 |
22 | public function Away3DContainer3DResource(id:String, container3D:ObjectContainer3D)
23 | {
24 | this.id = id;
25 | this.container3D = container3D;
26 | }
27 |
28 | public function getLabel():String
29 | {
30 | return "Away3D Container3D Resource";
31 | }
32 |
33 | public function getInstance():Object
34 | {
35 | return container3D.clone();
36 | }
37 |
38 | public function getInstanceType():Class
39 | {
40 | return ObjectContainer3D;
41 | }
42 |
43 | public function getID():String
44 | {
45 | return id;
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/examples/cadet2D/02_bunny_mark/src/components/behaviours/BounceBehaviour.as:
--------------------------------------------------------------------------------
1 | package components.behaviours
2 | {
3 | import flash.geom.Point;
4 | import flash.geom.Rectangle;
5 |
6 | import cadet.core.Component;
7 | import cadet.core.ISteppableComponent;
8 |
9 | import cadet2D.components.transforms.ITransform2D;
10 |
11 | public class BounceBehaviour extends Component implements ISteppableComponent
12 | {
13 | public var velocity :Point;
14 | public var transform :ITransform2D;
15 |
16 | public var gravity :int = 3;
17 |
18 | public var boundsRect :Rectangle;
19 |
20 | public function BounceBehaviour()
21 | {
22 |
23 | }
24 |
25 | public function step( dt:Number ):void
26 | {
27 | transform.x += velocity.x;
28 | transform.y += velocity.y;
29 | velocity.y += gravity;
30 |
31 | if (transform.x > boundsRect.right) {
32 | velocity.x *= -1;
33 | transform.x = boundsRect.right;
34 | }
35 | else if (transform.x < boundsRect.left) {
36 | velocity.x *= -1;
37 | transform.x = boundsRect.left;
38 | }
39 |
40 | if (transform.y > boundsRect.bottom) {
41 | velocity.y *= -0.8;
42 | transform.y = boundsRect.bottom;
43 |
44 | if (Math.random() > 0.5) {
45 | velocity.y -= Math.random() * 12;
46 | }
47 | }
48 | else if (transform.y < boundsRect.top) {
49 | velocity.y = 0;
50 | transform.y = boundsRect.top;
51 | }
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/operations/Cadet3DStartUpOperation.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | // For use when loading CadetScenes outside of the CadetEditor, e.g. in a Flash Builder project.
12 | package cadet3D.operations
13 | {
14 | import cadet.operations.CadetStartUpOperationBase;
15 |
16 | import cadet3D.resources.ExternalAway3DResourceParser;
17 |
18 | import core.app.CoreApp;
19 | import core.app.resources.ExternalResourceParserFactory;
20 |
21 | public class Cadet3DStartUpOperation extends CadetStartUpOperationBase
22 | {
23 | public function Cadet3DStartUpOperation( cadetFileURL:String)
24 | {
25 | super(cadetFileURL);
26 |
27 | // Add ExternalAway3DResourceParser to handle .3ds & .obj files.
28 | CoreApp.resourceManager.addResource( new ExternalResourceParserFactory( ExternalAway3DResourceParser, "External Away3D Resource Parser", ["obj", "3ds"] ) );
29 |
30 | addManifest( baseManifestURL + "Cadet3D.xml");
31 | }
32 | }
33 | }
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/examples/cadet2DBox2D/01_boxes/src/components/behaviours/ApplyTorqueBehaviour.as:
--------------------------------------------------------------------------------
1 | package components.behaviours
2 | {
3 | import Box2D.Dynamics.b2Body;
4 |
5 | import cadet.core.Component;
6 | import cadet.core.ISteppableComponent;
7 | import cadet2DBox2D.components.behaviours.RigidBodyBehaviour;
8 |
9 | public class ApplyTorqueBehaviour extends Component implements ISteppableComponent
10 | {
11 | public var rigidBodyBehaviour :RigidBodyBehaviour;
12 | public var torque :Number;
13 | public var targetVelocity :Number;
14 |
15 | public function ApplyTorqueBehaviour( torque:Number = 50, targetVelocity:Number = 2 )
16 | {
17 | this.torque = torque;
18 | this.targetVelocity = targetVelocity;
19 | }
20 |
21 | override protected function addedToScene():void
22 | {
23 | addSiblingReference( RigidBodyBehaviour, "rigidBodyBehaviour" );
24 | }
25 |
26 | public function step(dt:Number):void
27 | {
28 | // If we're not attached to an Entity with a RigidBodyBehaviour, then skip.
29 | if ( !rigidBodyBehaviour ) return;
30 |
31 | // Calculate a ratio where 0.5 means we're spinning at half the target speed, and 1 means full speed.
32 | var ratio:Number = rigidBodyBehaviour.getAngularVelocity() / targetVelocity;
33 |
34 | // Scale the torque value by the opposite of the ratio, so as we near the target
35 | // velocity, we reduce the amount of torque applied.
36 | rigidBodyBehaviour.applyTorque((1-ratio)*torque);
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/examples/cadet3D/04_robot/src/Robot.as:
--------------------------------------------------------------------------------
1 | package
2 | {
3 | import flash.display.Sprite;
4 | import flash.events.Event;
5 |
6 | import cadet.core.CadetScene;
7 | import cadet.util.ComponentUtil;
8 |
9 | import cadet3D.components.renderers.Renderer3D;
10 | import cadet3D.operations.Cadet3DStartUpOperation;
11 |
12 | [SWF( width="700", height="400", backgroundColor="0x002135", frameRate="60" )]
13 | public class Robot extends Sprite
14 | {
15 | private var cadetScene:CadetScene;
16 |
17 | private var cadetFileURL:String = "/robot.cdt3d";
18 |
19 | public function Robot()
20 | {
21 | // Required when loading data and assets.
22 | var startUpOperation:Cadet3DStartUpOperation = new Cadet3DStartUpOperation(cadetFileURL);
23 | startUpOperation.addEventListener(Event.COMPLETE, startUpCompleteHandler);
24 | startUpOperation.execute();
25 | }
26 |
27 | private function startUpCompleteHandler( event:Event ):void
28 | {
29 | var operation:Cadet3DStartUpOperation = Cadet3DStartUpOperation( event.target );
30 |
31 | initScene( CadetScene(operation.getResult()) );
32 | }
33 |
34 | private function initScene( scene:CadetScene ):void
35 | {
36 | cadetScene = scene;
37 |
38 | var renderer:Renderer3D = ComponentUtil.getChildOfType(cadetScene, Renderer3D);
39 | renderer.enable(this);
40 |
41 | addEventListener( Event.ENTER_FRAME, enterFrameHandler );
42 | }
43 |
44 | private function enterFrameHandler( event:Event ):void
45 | {
46 | cadetScene.step();
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/examples/cadet3D/03_planets/src/Planets.as:
--------------------------------------------------------------------------------
1 | package
2 | {
3 | import flash.display.Sprite;
4 | import flash.events.Event;
5 |
6 | import cadet.core.CadetScene;
7 | import cadet.util.ComponentUtil;
8 |
9 | import cadet3D.components.renderers.Renderer3D;
10 | import cadet3D.operations.Cadet3DStartUpOperation;
11 |
12 | [SWF( width="700", height="400", backgroundColor="0x002135", frameRate="60" )]
13 | public class Planets extends Sprite
14 | {
15 | private var cadetScene:CadetScene;
16 |
17 | private var cadetFileURL:String = "/planets.cdt3d";
18 |
19 | public function Planets()
20 | {
21 | // Required when loading data and assets.
22 | var startUpOperation:Cadet3DStartUpOperation = new Cadet3DStartUpOperation(cadetFileURL);
23 | startUpOperation.addEventListener(Event.COMPLETE, startUpCompleteHandler);
24 | startUpOperation.execute();
25 | }
26 |
27 | private function startUpCompleteHandler( event:Event ):void
28 | {
29 | var operation:Cadet3DStartUpOperation = Cadet3DStartUpOperation( event.target );
30 |
31 | initScene( CadetScene(operation.getResult()) );
32 | }
33 |
34 | private function initScene( scene:CadetScene ):void
35 | {
36 | cadetScene = scene;
37 |
38 | var renderer:Renderer3D = ComponentUtil.getChildOfType(cadetScene, Renderer3D);
39 | renderer.enable(this);
40 |
41 | addEventListener( Event.ENTER_FRAME, enterFrameHandler );
42 | }
43 |
44 | private function enterFrameHandler( event:Event ):void
45 | {
46 | cadetScene.step();
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/components/materials/ColorMaterialComponent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3D.components.materials
12 | {
13 | import away3d.materials.ColorMaterial;
14 | import away3d.materials.methods.FilteredShadowMapMethod;
15 |
16 | import flash.display.BlendMode;
17 |
18 | public class ColorMaterialComponent extends AbstractMaterialComponent
19 | {
20 | private var _colorMaterial :ColorMaterial;
21 |
22 | public function ColorMaterialComponent( material:ColorMaterial = null )
23 | {
24 | if ( material != null )
25 | {
26 | _material = _colorMaterial = material;
27 | }
28 | else
29 | {
30 | _material = _colorMaterial = new ColorMaterial(0xCCCCCC);
31 | }
32 | }
33 |
34 | /**
35 | * The diffuse color of the surface.
36 | */
37 | [Serializable][Inspectable( priority="100", editor="ColorPicker" )]
38 | public function get color() : uint
39 | {
40 | return _colorMaterial.color;
41 | }
42 |
43 | public function set color(value : uint) : void
44 | {
45 | _colorMaterial.color = value;
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/cadet/Cadet.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Simplified BSD License
2 | ======================
3 |
4 | Copyright 2012 Unwrong Ltd. All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without modification,
7 | are permitted provided that the following conditions are met:
8 |
9 | 1. Redistributions of source code must retain the above copyright notice, this list of
10 | conditions and the following disclaimer.
11 |
12 | 2. Redistributions in binary form must reproduce the above copyright notice, this list
13 | of conditions and the following disclaimer in the documentation and/or other materials
14 | provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY UNWRONG "AS IS" AND ANY EXPRESS OR IMPLIED
17 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNWRONG OR
19 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | The views and conclusions contained in the software and documentation are those of the
27 | authors and should not be interpreted as representing official policies, either expressed
28 | or implied, of Unwrong.
29 |
--------------------------------------------------------------------------------
/cadet2DBox2D/src/cadet2DBox2D/events/PhysicsCollisionEvent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2DBox2D.events
12 | {
13 | import flash.events.Event;
14 | import flash.geom.Point;
15 |
16 | import cadet2DBox2D.components.behaviours.RigidBodyBehaviour;
17 |
18 | public class PhysicsCollisionEvent extends Event
19 | {
20 | public static const COLLISION :String = "collision";
21 |
22 | public var behaviourA :RigidBodyBehaviour;
23 | public var behaviourB :RigidBodyBehaviour;
24 |
25 | public var position :Point; // In world space
26 | public var normal :Point; // Points from A->B;
27 | public var normalImpulse :Number; // In newtons
28 | public var tangentImpulse :Number; // In newtons
29 |
30 | public function PhysicsCollisionEvent(type:String, behaviourA:RigidBodyBehaviour, behaviourB:RigidBodyBehaviour, position:Point, normal:Point, normalImpulse:Number, tangentImpulse:Number)
31 | {
32 | super(type);
33 |
34 | this.behaviourA = behaviourA;
35 | this.behaviourB = behaviourB;
36 | this.position = position;
37 | this.normal = normal;
38 | this.normalImpulse = normalImpulse;
39 | this.tangentImpulse = tangentImpulse;
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/examples/cadet2D/02_bunny_mark/src/components/processes/BunnySpawner.as:
--------------------------------------------------------------------------------
1 | package components.processes
2 | {
3 | import cadet.core.Component;
4 | import cadet.core.ISteppableComponent;
5 |
6 | import cadet2D.components.skins.ImageSkin;
7 | import cadet2D.components.textures.TextureComponent;
8 |
9 | import components.behaviours.BounceBehaviour;
10 |
11 | import flash.geom.Point;
12 | import flash.geom.Rectangle;
13 |
14 | public class BunnySpawner extends Component implements ISteppableComponent
15 | {
16 | public var numEntities :int = 100;
17 | private var entityIndex :uint;
18 |
19 | public var textureComponent :TextureComponent;
20 | public var boundsRect :Rectangle;
21 |
22 | public function BunnySpawner()
23 | {
24 |
25 | }
26 |
27 | private function createBunny():void
28 | {
29 | // Add the BounceBehaviour to the scene
30 | var randomVelocity:Point = new Point(Math.random() * 10, (Math.random() * 10) - 5);
31 | var bounceBehaviour:BounceBehaviour = new BounceBehaviour();
32 | bounceBehaviour.velocity = randomVelocity;
33 | bounceBehaviour.boundsRect = boundsRect;
34 | scene.children.addItem(bounceBehaviour);
35 |
36 | // Add a Skin to the scene
37 | var skin:ImageSkin = new ImageSkin();
38 | skin.texture = textureComponent;
39 | scene.children.addItem(skin);
40 |
41 | // Pass reference to skin to bounceBehaviour
42 | bounceBehaviour.transform = skin;
43 | }
44 |
45 | public function step( dt:Number ):void
46 | {
47 | if (entityIndex < numEntities) {
48 | entityIndex ++;
49 | createBunny();
50 | }
51 | }
52 | }
53 | }
54 |
55 |
56 |
--------------------------------------------------------------------------------
/cadet/src/cadet/core/IComponent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.core
12 | {
13 | import flash.events.IEventDispatcher;
14 |
15 | [Event( type="cadet.events.ComponentEvent", name="addedToParent" )]
16 | [Event( type="cadet.events.ComponentEvent", name="removedFromParent" )]
17 | [Event( type="cadet.events.ComponentEvent", name="addedToScene" )]
18 | [Event( type="cadet.events.ComponentEvent", name="removedFromScene" )]
19 |
20 | public interface IComponent extends IEventDispatcher
21 | {
22 | function set index( value:int ):void
23 | function get index():int
24 |
25 | function set name( value:String ):void
26 | function get name():String
27 |
28 | function set parentComponent( value:IComponentContainer ):void
29 | function get parentComponent():IComponentContainer;
30 |
31 | function set scene( value:CadetScene ):void
32 | function get scene():CadetScene;
33 |
34 | function set exportTemplateID( value:String ):void
35 | function get exportTemplateID():String
36 | function set templateID( value:String ):void
37 | function get templateID():String
38 |
39 | function invalidate( invalidationType:String ):void
40 | function validateNow():void
41 |
42 | function dispose():void;
43 | }
44 | }
--------------------------------------------------------------------------------
/examples/cadet3DPhysics/01_boxes/src/components/behaviours/ApplyTorqueBehaviour.as:
--------------------------------------------------------------------------------
1 | package components.behaviours
2 | {
3 | import cadet.core.Component;
4 | import cadet.core.ISteppableComponent;
5 |
6 | import cadet3DPhysics.components.behaviours.RigidBodyBehaviour;
7 |
8 | import flash.geom.Vector3D;
9 |
10 | public class ApplyTorqueBehaviour extends Component implements ISteppableComponent
11 | {
12 | public var rigidBodyBehaviour :RigidBodyBehaviour;
13 | public var torque :Number;
14 | public var targetVelocity :Vector3D;
15 |
16 | public function ApplyTorqueBehaviour( torque:Number = 50, targetVelocity:Vector3D = null )
17 | {
18 | this.torque = torque;
19 |
20 | if ( !targetVelocity ) {
21 | targetVelocity = new Vector3D(2,0,0);
22 | }
23 |
24 | this.targetVelocity = targetVelocity;
25 | }
26 |
27 | override protected function addedToParent():void
28 | {
29 | addSiblingReference( RigidBodyBehaviour, "rigidBodyBehaviour" );
30 | }
31 |
32 | public function step(dt:Number):void
33 | {
34 | // If we're not attached to an Entity with a RigidBodyBehaviour, then skip.
35 | if ( !rigidBodyBehaviour ) return;
36 |
37 | var angularVelocity:Vector3D = rigidBodyBehaviour.getAngularVelocity();
38 |
39 | if (!angularVelocity) return;
40 |
41 | // Calculate a ratio where 0.5 means we're spinning at half the target speed, and 1 means full speed.
42 | var ratio:Number = angularVelocity.x / targetVelocity.x;
43 |
44 | // Scale the torque value by the opposite of the ratio, so as we near the target
45 | // velocity, we reduce the amount of torque applied.
46 | rigidBodyBehaviour.applyTorque(new Vector3D((1-ratio)*torque));
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/util/BitmapDataUtil.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.util
12 | {
13 | import flash.display.BitmapData;
14 | import flash.geom.Matrix;
15 |
16 | public class BitmapDataUtil
17 | {
18 | /**
19 | * Checks if the input bitmap is a valid texture (power of two width/height), if it it simply returns it.
20 | * If not, will create a new bitmap resized to closest power of two.
21 | */
22 | public static function makePowerOfTwo( bitmapData:BitmapData, forceSquare:Boolean = false ):BitmapData
23 | {
24 | if ( bitmapData == null ) return null;
25 |
26 | var width:int = TextureUtils.getBestPowerOf2( bitmapData.width );
27 | var height:int = TextureUtils.getBestPowerOf2( bitmapData.height );
28 |
29 | if ( forceSquare )
30 | {
31 | width = height = Math.max(width,height);
32 | }
33 |
34 | if ( bitmapData.width == width && bitmapData.height == height ) return bitmapData;
35 |
36 | var resizedBitmapData:BitmapData = new BitmapData(width, height, bitmapData.transparent, 0);
37 |
38 | var m:Matrix = new Matrix();
39 | m.scale( width / bitmapData.width, height / bitmapData.height );
40 | resizedBitmapData.draw( bitmapData, m );
41 |
42 | return resizedBitmapData;
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/examples/away3D/02_bunny_mark/src/components/behaviours/BounceBehaviour.as:
--------------------------------------------------------------------------------
1 | package components.behaviours
2 | {
3 | import away3d.entities.Sprite3D;
4 |
5 | import cadet.core.Component;
6 | import cadet.core.ISteppableComponent;
7 |
8 | import flash.geom.Rectangle;
9 | import flash.geom.Vector3D;
10 |
11 | public class BounceBehaviour extends Component implements ISteppableComponent
12 | {
13 | public var velocity :Vector3D;
14 | public var sprite3D :Sprite3D;
15 |
16 | public var gravity :int = 3;
17 |
18 | public var screenRect :Rectangle;
19 |
20 | public function BounceBehaviour()
21 | {
22 |
23 | }
24 |
25 | public function step( dt:Number ):void
26 | {
27 | sprite3D.x += velocity.x;
28 | sprite3D.y += velocity.y;
29 | sprite3D.z += velocity.z;
30 | velocity.y -= gravity;
31 |
32 | if (sprite3D.x > screenRect.right) {
33 | velocity.x *= -1;
34 | sprite3D.x = screenRect.right;
35 | }
36 | else if (sprite3D.x < screenRect.left) {
37 | velocity.x *= -1;
38 | sprite3D.x = screenRect.left;
39 | }
40 |
41 | if (sprite3D.z > screenRect.right) {
42 | velocity.z *= -1;
43 | sprite3D.z = screenRect.right;
44 | }
45 | else if (sprite3D.z < screenRect.left) {
46 | velocity.z *= -1;
47 | sprite3D.z = screenRect.left;
48 | }
49 |
50 | // Ceiling
51 | if (sprite3D.y > screenRect.bottom) {
52 | velocity.y = 0;
53 | sprite3D.y = screenRect.bottom;
54 |
55 | }
56 | // Floor
57 | else if (sprite3D.y < screenRect.top) {
58 | velocity.y *= -0.8;
59 | sprite3D.y = screenRect.top;
60 |
61 | if (Math.random() > 0.5) {
62 | velocity.y += Math.random() * 12;
63 | }
64 | }
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/components/core/Sprite3DComponent.as:
--------------------------------------------------------------------------------
1 | package cadet3D.components.core
2 | {
3 | import away3d.entities.Sprite3D;
4 | import away3d.materials.TextureMaterial;
5 |
6 | import cadet3D.components.materials.AbstractMaterialComponent;
7 | import cadet3D.util.NullBitmapTexture;
8 |
9 | public class Sprite3DComponent extends ObjectContainer3DComponent
10 | {
11 | private var _sprite3D:Sprite3D;
12 | private var _materialComponent:AbstractMaterialComponent;
13 |
14 | public function Sprite3DComponent()
15 | {
16 | _object3D = _sprite3D = new Sprite3D(new TextureMaterial( NullBitmapTexture.instance, true, true, true ), 128, 128);
17 | }
18 |
19 | [Serializable][Inspectable( priority="150" )]
20 | public function get width():Number
21 | {
22 | return _sprite3D.width;
23 | }
24 | public function set width( value:Number ):void
25 | {
26 | _sprite3D.width = value;
27 | }
28 |
29 | [Serializable][Inspectable( priority="151" )]
30 | public function get height():Number
31 | {
32 | return _sprite3D.height;
33 | }
34 | public function set height( value:Number ):void
35 | {
36 | _sprite3D.height = value;
37 | }
38 |
39 | [Serializable][Inspectable( priority="152", editor="ComponentList", scope="scene" )]
40 | public function get materialComponent():AbstractMaterialComponent
41 | {
42 | return _materialComponent;
43 | }
44 |
45 | public function set materialComponent(value : AbstractMaterialComponent) : void
46 | {
47 | _materialComponent = value;
48 | if ( _materialComponent ) {
49 | _sprite3D.material = _materialComponent.material;
50 | } else {
51 | _sprite3D.material = null;
52 | }
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/operations/CollapseTransformsOperation.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.operations
12 | {
13 | import cadet.components.geom.IGeometry;
14 | import cadet.core.IComponent;
15 | import cadet.core.IComponentContainer;
16 | import cadet.util.ComponentUtil;
17 |
18 | import cadet2D.components.transforms.Transform2D;
19 |
20 | import core.app.operations.UndoableCompoundOperation;
21 |
22 | public class CollapseTransformsOperation extends UndoableCompoundOperation
23 | {
24 | private var components :Array;
25 |
26 | public function CollapseTransformsOperation( components:Array )
27 | {
28 | this.components = components;
29 | label = "Collapse Transform(s)";
30 |
31 | for ( var i:int = 0; i < components.length; i++ )
32 | {
33 | var component:IComponentContainer = components[i];
34 | var transform:Transform2D = ComponentUtil.getChildOfType( component, Transform2D ) as Transform2D;
35 | if ( !transform ) continue;
36 | var geometries:Vector. = ComponentUtil.getChildrenOfType( component, IGeometry );
37 | if ( geometries.length == 0 ) continue;;
38 |
39 | for each ( var geometry:IGeometry in geometries )
40 | {
41 | addOperation( new CollapseTransformOperation( geometry, transform ) );
42 | }
43 | }
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/examples/cadet3D/02_bunny_mark/src/components/behaviours/BounceBehaviour.as:
--------------------------------------------------------------------------------
1 | package components.behaviours
2 | {
3 | import flash.geom.Rectangle;
4 | import flash.geom.Vector3D;
5 |
6 | import cadet.core.Component;
7 | import cadet.core.ISteppableComponent;
8 |
9 | import cadet3D.components.core.Sprite3DComponent;
10 |
11 | public class BounceBehaviour extends Component implements ISteppableComponent
12 | {
13 | public var velocity :Vector3D;
14 | public var sprite3D :Sprite3DComponent;
15 |
16 | public var gravity :int = 3;
17 |
18 | public var screenRect :Rectangle;
19 |
20 | public function BounceBehaviour()
21 | {
22 |
23 | }
24 |
25 | public function step( dt:Number ):void
26 | {
27 | sprite3D.x += velocity.x;
28 | sprite3D.y += velocity.y;
29 | sprite3D.z += velocity.z;
30 | velocity.y -= gravity;
31 |
32 | if (sprite3D.x > screenRect.right) {
33 | velocity.x *= -1;
34 | sprite3D.x = screenRect.right;
35 | }
36 | else if (sprite3D.x < screenRect.left) {
37 | velocity.x *= -1;
38 | sprite3D.x = screenRect.left;
39 | }
40 |
41 | if (sprite3D.z > screenRect.right) {
42 | velocity.z *= -1;
43 | sprite3D.z = screenRect.right;
44 | }
45 | else if (sprite3D.z < screenRect.left) {
46 | velocity.z *= -1;
47 | sprite3D.z = screenRect.left;
48 | }
49 |
50 | // Ceiling
51 | if (sprite3D.y > screenRect.bottom) {
52 | velocity.y = 0;
53 | sprite3D.y = screenRect.bottom;
54 |
55 | }
56 | // Floor
57 | else if (sprite3D.y < screenRect.top) {
58 | velocity.y *= -0.8;
59 | sprite3D.y = screenRect.top;
60 |
61 | if (Math.random() > 0.5) {
62 | velocity.y += Math.random() * 12;
63 | }
64 | }
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/validators/ComponentSiblingValidator.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.validators
12 | {
13 | import cadet.core.IComponentContainer;
14 | import cadet.util.ComponentUtil;
15 |
16 | public class ComponentSiblingValidator implements IComponentValidator
17 | {
18 | private var maxSiblingsOfSameType :int = -1;
19 | private var requiredSiblingTypes :Array;
20 |
21 | public function ComponentSiblingValidator( maxSiblingsOfSameType:int = -1, requiredSiblingTypes:Array = null )
22 | {
23 | this.maxSiblingsOfSameType = maxSiblingsOfSameType;
24 | this.requiredSiblingTypes = requiredSiblingTypes || [];
25 | }
26 |
27 | public function validate(componentType:Class, parent:IComponentContainer):Boolean
28 | {
29 | if ( maxSiblingsOfSameType != -1 )
30 | {
31 | var numSameTypeSiblings:int = ComponentUtil.getChildrenOfType( parent, componentType, false ).length;
32 | if ( numSameTypeSiblings >= maxSiblingsOfSameType ) return false;
33 | }
34 |
35 | for each ( var requiredSiblingType:Class in requiredSiblingTypes )
36 | {
37 | var numRequiredSiblings:int = ComponentUtil.getChildrenOfType( parent, requiredSiblingType, false ).length;
38 | if ( numRequiredSiblings == 0 ) return false;
39 | }
40 |
41 | return true;
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/examples/cadet2D/00_boilerplate/bin-debug/extensions/manifests/Cadet2DBox2D.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/examples/cadet2D/02_bunny_mark/src/BunnyMarkSpawner.as:
--------------------------------------------------------------------------------
1 | package
2 | {
3 | import cadet.core.CadetScene;
4 |
5 | import cadet2D.components.renderers.Renderer2D;
6 | import cadet2D.components.textures.TextureComponent;
7 |
8 | import components.processes.BunnySpawner;
9 |
10 | import flash.display.Sprite;
11 | import flash.events.Event;
12 | import flash.geom.Rectangle;
13 |
14 | [SWF( width="700", height="400", backgroundColor="0x002135", frameRate="60" )]
15 | public class BunnyMarkSpawner extends Sprite
16 | {
17 | [Embed(source = "assets/wabbit_alpha.png")]
18 | private var BunnyAsset:Class;
19 |
20 | private var cadetScene:CadetScene;
21 |
22 | public function BunnyMarkSpawner()
23 | {
24 | cadetScene = new CadetScene();
25 |
26 | var renderer:Renderer2D = new Renderer2D();
27 | renderer.viewportWidth = stage.stageWidth;
28 | renderer.viewportHeight = stage.stageHeight;
29 | cadetScene.children.addItem(renderer);
30 | renderer.enable(this);
31 |
32 | // Create the shared TextureComponent
33 | var textureComponent:TextureComponent = new TextureComponent();
34 | textureComponent.bitmapData = new BunnyAsset().bitmapData;
35 | cadetScene.children.addItem(textureComponent);
36 |
37 | // Create the BunnySpawner Process
38 | var bunnySpawner:BunnySpawner = new BunnySpawner();
39 | bunnySpawner.textureComponent = textureComponent;
40 | bunnySpawner.numEntities = 1000;
41 | bunnySpawner.boundsRect = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
42 | cadetScene.children.addItem(bunnySpawner);
43 |
44 | addEventListener( Event.ENTER_FRAME, enterFrameHandler );
45 | }
46 |
47 | private function enterFrameHandler( event:Event ):void
48 | {
49 | cadetScene.step();
50 | }
51 | }
52 | }
53 |
54 |
55 |
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/geom/CompoundGeometry.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.components.geom
12 | {
13 | import cadet.components.geom.IGeometry;
14 | import cadet.core.ComponentContainer;
15 | import cadet.core.IComponent;
16 | import cadet.events.ValidationEvent;
17 |
18 | public class CompoundGeometry extends ComponentContainer implements IGeometry
19 | {
20 | public function CompoundGeometry()
21 | {
22 | name = "CompoundGeometry";
23 | }
24 |
25 | override protected function childAdded(child:IComponent, index:uint):void
26 | {
27 | super.childAdded(child, index);
28 | if ( child is IGeometry == false )
29 | {
30 | throw( new Error( "CompoundGeometry only supports children of type IGeometry" ));
31 | return;
32 | }
33 | child.addEventListener(ValidationEvent.INVALIDATE, invalidateChildHandler);
34 | invalidate("geometry");
35 | }
36 |
37 | override protected function childRemoved(child:IComponent):void
38 | {
39 | super.childRemoved(child);
40 | child.removeEventListener(ValidationEvent.INVALIDATE, invalidateChildHandler);
41 | invalidate("geometry");
42 | }
43 |
44 | private function invalidateChildHandler( event:ValidationEvent ):void
45 | {
46 | invalidate(event.validationType);
47 | }
48 |
49 | public function get label():String { return "Compound Geometry"; }
50 | }
51 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/shaders/vertex/AnimateUVVertexShaderComponent.as:
--------------------------------------------------------------------------------
1 | package cadet2D.components.shaders.vertex
2 | {
3 | import cadet.core.Component;
4 |
5 | import cadet2D.components.shaders.IShaderComponent;
6 |
7 | import starling.display.shaders.IShader;
8 | import starling.display.shaders.vertex.AnimateUVVertexShader;
9 |
10 | public class AnimateUVVertexShaderComponent extends Component implements IShaderComponent
11 | {
12 | private const VALUES :String = "values";
13 |
14 | private var _shader :AnimateUVVertexShader;
15 | private var _uSpeed :Number;
16 | private var _vSpeed :Number;
17 |
18 | public function AnimateUVVertexShaderComponent(name:String="AnimateUVVertexShaderComponent")
19 | {
20 | super(name);
21 |
22 | _shader = new AnimateUVVertexShader();
23 | }
24 |
25 | [Serializable][Inspectable(priority="50") ]
26 | public function get uSpeed():Number
27 | {
28 | return _uSpeed;
29 | }
30 | public function set uSpeed( value:Number ):void
31 | {
32 | _uSpeed = value;
33 | invalidate( VALUES );
34 | }
35 |
36 | [Serializable][Inspectable(priority="51") ]
37 | public function get vSpeed():Number
38 | {
39 | return _vSpeed;
40 | }
41 | public function set vSpeed( value:Number ):void
42 | {
43 | _vSpeed = value;
44 | invalidate( VALUES );
45 | }
46 |
47 | override public function validateNow():void
48 | {
49 | if ( isInvalid( VALUES ) ) {
50 | validateValues();
51 | }
52 |
53 | super.validateNow();
54 | }
55 |
56 | private function validateValues():void
57 | {
58 | _shader.uSpeed = _uSpeed;
59 | _shader.vSpeed = _vSpeed;
60 | }
61 |
62 | public function get shader():IShader
63 | {
64 | return _shader;
65 | }
66 | }
67 | }
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/operations/CenterOriginsOperation.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.operations
12 | {
13 | import cadet.components.geom.IGeometry;
14 | import cadet.core.IComponent;
15 | import cadet.core.IComponentContainer;
16 | import cadet.util.ComponentUtil;
17 |
18 | import cadet2D.components.transforms.Transform2D;
19 |
20 | import core.app.operations.UndoableCompoundOperation;
21 |
22 | public class CenterOriginsOperation extends UndoableCompoundOperation
23 | {
24 | private var components :Array;
25 | private var useCentroid :Boolean;
26 |
27 | public function CenterOriginsOperation( components:Array, useCentroid:Boolean = false )
28 | {
29 | this.components = components;
30 | this.useCentroid = useCentroid;
31 | label = "Center Origin(s)";
32 |
33 | for ( var i:int = 0; i < components.length; i++ )
34 | {
35 | var component:IComponentContainer = components[i];
36 | var transform:Transform2D = ComponentUtil.getChildOfType( component, Transform2D ) as Transform2D;
37 | if ( !transform ) continue;
38 | var geometries:Vector. = ComponentUtil.getChildrenOfType( component, IGeometry );
39 | if ( geometries.length == 0 ) continue;;
40 |
41 | for each ( var geometry:IGeometry in geometries )
42 | {
43 | addOperation( new CenterOriginOperation( geometry, transform, useCentroid ) );
44 | }
45 | }
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/resources/ExternalXMLResourceParser.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CoreApp Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.resources
12 | {
13 | import core.app.controllers.IExternalResourceParser;
14 | import core.app.core.managers.fileSystemProviders.IFileSystemProvider;
15 | import core.app.entities.URI;
16 | import core.app.managers.ResourceManager;
17 | import core.app.resources.ExternalXMLResource;
18 | import core.app.resources.IExternalResource;
19 |
20 | public class ExternalXMLResourceParser implements IExternalResourceParser
21 | {
22 | private var uri :URI;
23 | private var resourceManager :ResourceManager;
24 |
25 | public function ExternalXMLResourceParser()
26 | {
27 | }
28 |
29 | public function parse(uri:URI, assetsURI:URI, resourceManager:ResourceManager, fileSystemProvider:IFileSystemProvider):Array
30 | {
31 | this.uri = uri;
32 | this.resourceManager = resourceManager;
33 |
34 | var extension:String = uri.getExtension(true);
35 | var resourceID:String = uri.path;
36 | if ( resourceID.indexOf(assetsURI.path) != -1 ) {
37 | resourceID = resourceID.replace(assetsURI.path, "");
38 | }
39 |
40 | var resource:IExternalResource;
41 | switch ( extension )
42 | {
43 | case "pex" :
44 | resource = new ExternalXMLResource( resourceID, uri );
45 | resourceManager.addResource(resource);
46 | return [resource];
47 | }
48 |
49 | return null;
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/assets/CadetEngine3DIcons.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3D.assets
12 | {
13 | public class CadetEngine3DIcons
14 | {
15 | [Embed( source = 'Camera.png' )] static public var Camera:Class;
16 | // [Embed( source = 'CameraPan.png' )] static public var CameraPan:Class;
17 | // [Embed( source = 'CameraRotate.png' )] static public var CameraRotate:Class;
18 | // [Embed( source = 'CameraZoom.png' )] static public var CameraZoom:Class;
19 | [Embed( source = 'Cube.png' )] static public var Cube:Class;
20 | [Embed( source = 'DirectionalLight.png' )] static public var DirectionalLight:Class;
21 | [Embed( source = 'Geometry.png' )] static public var Geometry:Class;
22 | [Embed( source = 'PointLight.png' )] static public var PointLight:Class;
23 | [Embed( source = 'Mesh.png' )] static public var Mesh:Class;
24 | [Embed( source = 'Material.png' )] static public var Material:Class;
25 | [Embed( source = 'Plane.png' )] static public var Plane:Class;
26 | [Embed( source = 'Renderer.png' )] static public var Renderer:Class;
27 | // [Embed( source = 'Rotate.png' )] static public var Rotate:Class;
28 | // [Embed( source = 'Scale.png' )] static public var Scale:Class;
29 | [Embed( source = 'Sphere.png' )] static public var Sphere:Class;
30 | // [Embed( source = 'Translate.png' )] static public var Translate:Class;
31 | }
32 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/processes/InputProcess2D.as:
--------------------------------------------------------------------------------
1 | package cadet2D.components.processes
2 | {
3 | import flash.events.Event;
4 |
5 | import cadet.components.processes.IInputMapping;
6 | import cadet.components.processes.InputProcess;
7 |
8 | import cadet2D.components.renderers.Renderer2D;
9 |
10 | import starling.display.DisplayObject;
11 | import starling.events.Touch;
12 | import starling.events.TouchEvent;
13 |
14 | // InputProcess with a notion of Touches (via Starling)
15 | public class InputProcess2D extends InputProcess
16 | {
17 | private var _renderer2D :Renderer2D;
18 |
19 | public function InputProcess2D()
20 | {
21 |
22 | }
23 |
24 | override protected function addedToStageHandler( event:Event = null ):void
25 | {
26 | super.addedToStageHandler(event);
27 | _renderer2D = Renderer2D(_renderer);
28 | _renderer2D.viewport.stage.addEventListener( TouchEvent.TOUCH, touchEventHandler );
29 | }
30 |
31 | override protected function removedFromStageHandler( event:Event = null ):void
32 | {
33 | super.removedFromStageHandler(event);
34 | _renderer2D = Renderer2D(_renderer);
35 | _renderer2D.viewport.stage.removeEventListener( TouchEvent.TOUCH, touchEventHandler );
36 | }
37 |
38 | protected function touchEventHandler( event:TouchEvent ):void
39 | {
40 | if ( !_renderer ) return;
41 |
42 | // Clear touches
43 | clearTouches();
44 |
45 | _renderer2D = Renderer2D(_renderer);
46 | var dispObj:DisplayObject = DisplayObject(_renderer2D.viewport.stage);
47 | var touches:Vector. = event.getTouches(dispObj);
48 |
49 | for each (var touch:Touch in touches)
50 | {
51 | var mapping:IInputMapping = getMappingForInput(touch.phase);
52 | if (mapping) {
53 | inputTable[mapping.name] = true;
54 | }
55 | }
56 | }
57 | }
58 | }
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/textures/TextureAtlasComponent.as:
--------------------------------------------------------------------------------
1 | package cadet2D.components.textures
2 | {
3 | import cadet.core.Component;
4 |
5 | import starling.textures.TextureAtlas;
6 |
7 | public class TextureAtlasComponent extends Component
8 | {
9 | protected var ATLAS :String = "atlas";
10 |
11 | private var _textureAtlas :TextureAtlas;
12 | private var _textureComponent :TextureComponent;
13 | private var _xml :XML;
14 |
15 | private var _atlas :TextureAtlas;
16 |
17 | private var _atlasDirty :Boolean;
18 |
19 | public function TextureAtlasComponent( name:String = "TextureAtlasComponent" )
20 | {
21 | super(name);
22 | }
23 |
24 | [Serializable( type="resource" )][Inspectable(editor="ResourceItemEditor", extensions="[xml]")]
25 | public function set xml( value:XML ):void
26 | {
27 | _xml = value;
28 | invalidate( ATLAS );
29 | }
30 | public function get xml():XML { return _xml; }
31 |
32 | [Serializable][Inspectable( editor="ComponentList", scope="scene" )]
33 | public function set texture( value:TextureComponent ):void
34 | {
35 | _textureComponent = value;
36 | invalidate( ATLAS );
37 | }
38 | public function get texture():TextureComponent { return _textureComponent; }
39 |
40 |
41 | override public function validateNow():void
42 | {
43 | if ( _atlasDirty ) {
44 | invalidate(ATLAS);
45 | }
46 |
47 | if ( isInvalid(ATLAS) )
48 | {
49 | validateAtlas();
50 | }
51 |
52 | super.validateNow();
53 | }
54 |
55 | protected function validateAtlas():void
56 | {
57 | if (!_textureComponent || !_textureComponent.texture ) {
58 | _atlasDirty = true;
59 | return;
60 | }
61 |
62 | _atlas = new TextureAtlas(_textureComponent.texture, _xml );
63 | _atlasDirty = false;
64 | }
65 |
66 | public function get atlas():TextureAtlas
67 | {
68 | return _atlas;
69 | }
70 | }
71 | }
--------------------------------------------------------------------------------
/cadet2D/.flexLibProperties:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/cadet/src/cadet/operations/GetTemplatesAndMergeOperation.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.operations
12 | {
13 | import cadet.core.IComponent;
14 | import cadet.operations.GetTemplateAndMergeOperation;
15 |
16 | import core.app.core.managers.fileSystemProviders.IFileSystemProvider;
17 | import core.app.core.operations.IAsynchronousOperation;
18 | import core.app.core.operations.IUndoableOperation;
19 | import core.app.operations.UndoableCompoundOperation;
20 |
21 | public class GetTemplatesAndMergeOperation extends UndoableCompoundOperation implements IAsynchronousOperation, IUndoableOperation
22 | {
23 | private var components :Array;
24 | private var fileSystemProvider :IFileSystemProvider;
25 | private var domTable :Object;
26 |
27 |
28 | public function GetTemplatesAndMergeOperation( components:Array, fileSystemProvider:IFileSystemProvider, domTable:Object = null )
29 | {
30 | this.components = components;
31 | this.fileSystemProvider = fileSystemProvider;
32 | this.domTable = domTable;
33 | if ( !domTable ) domTable = {};
34 |
35 | for ( var i:int = 0; i < components.length; i++ )
36 | {
37 | var component:IComponent = components[i];
38 | if ( component.templateID == null ) continue;
39 |
40 | var operation:GetTemplateAndMergeOperation = new GetTemplateAndMergeOperation( component.templateID, component, fileSystemProvider, domTable );
41 | addOperation(operation);
42 | }
43 | }
44 |
45 | override public function get label():String
46 | {
47 | return "Get Templates And Merge";
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/components/sounds/SoundComponent.as:
--------------------------------------------------------------------------------
1 | package cadet.components.sounds
2 | {
3 | import flash.media.Sound;
4 | import flash.media.SoundChannel;
5 | import flash.media.SoundTransform;
6 |
7 | import cadet.core.Component;
8 |
9 | public class SoundComponent extends Component implements ISound
10 | {
11 | private var _asset :Sound;
12 | private var _channel :SoundChannel;
13 |
14 | private var _startTime:Number = 0;
15 | private var _loops:uint = 0;
16 | private var _soundTransform:SoundTransform = null;
17 |
18 | public function SoundComponent( name:String = "SoundComponent" )
19 | {
20 | super(name);
21 | }
22 |
23 | // -------------------------------------------------------------------------------------
24 | // INSPECTABLE API
25 | // -------------------------------------------------------------------------------------
26 |
27 | [Serializable( type="resource" )][Inspectable(editor="ResourceItemEditor", extensions="[mp3]")]
28 | public function set asset( value:Sound ):void
29 | {
30 | _asset = value;
31 | }
32 | public function get asset():Sound { return _asset; }
33 |
34 | public function play():Boolean
35 | {
36 | if (!_asset) return false;
37 |
38 | _channel = _asset.play(_startTime, _loops, _soundTransform);
39 |
40 | return true;
41 | }
42 |
43 | public function stop():void
44 | {
45 | if ( _channel ) {
46 | _channel.stop();
47 | }
48 | }
49 |
50 | [Serializable][Inspectable]
51 | public function set startTime( value:Number ):void
52 | {
53 | _startTime = value;
54 | }
55 | public function get startTime():Number { return _startTime; }
56 |
57 | [Serializable][Inspectable]
58 | public function set loops( value:Number ):void
59 | {
60 | _loops = value;
61 | }
62 | public function get loops():Number { return _loops; }
63 |
64 | // -------------------------------------------------------------------------------------
65 |
66 | }
67 | }
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/cadet2DBox2D/src/cadet2DBox2D/components/processes/PhysicsProcessContactListener.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2DBox2D.components.processes
12 | {
13 | import Box2D.Dynamics.Contacts.b2ContactResult;
14 | import Box2D.Dynamics.b2Body;
15 | import Box2D.Dynamics.b2ContactListener;
16 |
17 | import flash.geom.Point;
18 |
19 | import cadet2DBox2D.components.behaviours.RigidBodyBehaviour;
20 | import cadet2DBox2D.events.PhysicsCollisionEvent;
21 |
22 | public class PhysicsProcessContactListener extends b2ContactListener
23 | {
24 | private var physicsProcess :PhysicsProcess;
25 |
26 | public function PhysicsProcessContactListener( physicsProcess:PhysicsProcess )
27 | {
28 | this.physicsProcess = physicsProcess;
29 | }
30 |
31 | override public function Result(result:b2ContactResult):void
32 | {
33 | var bodyA:b2Body = result.shape1.GetBody();
34 | var bodyB:b2Body = result.shape2.GetBody();
35 |
36 | var behaviourA:RigidBodyBehaviour = physicsProcess.getBehaviourForRigidBody(bodyA);
37 | var behaviourB:RigidBodyBehaviour = physicsProcess.getBehaviourForRigidBody(bodyB);
38 |
39 |
40 | physicsProcess.dispatchEvent( new PhysicsCollisionEvent( PhysicsCollisionEvent.COLLISION,
41 | behaviourA,
42 | behaviourB,
43 | new Point( result.position.x * physicsProcess.invScaleFactor, result.position.y * physicsProcess.invScaleFactor ),
44 | new Point( result.normal.x, result.normal.y ),
45 | result.normalImpulse,
46 | result.normalImpulse ) );
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/geom/CircleGeometry.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.components.geom
12 | {
13 | import cadet2D.components.transforms.Transform2D;
14 |
15 | import flash.geom.Matrix;
16 | import flash.geom.Point;
17 |
18 | [Serializable]
19 | public class CircleGeometry extends AbstractGeometry
20 | {
21 | [Serializable]
22 | public var x:Number = 0;
23 | [Serializable]
24 | public var y:Number = 0;
25 | private var _radius :Number;
26 |
27 | public function CircleGeometry( radius:Number = 50 )
28 | {
29 | super("Circle");
30 |
31 | this.radius = radius;
32 | }
33 |
34 | [Serializable][Inspectable]
35 | public function set radius( value:Number ):void
36 | {
37 | _radius = value;
38 | invalidate("geometry");
39 | }
40 | public function get radius():Number { return _radius; }
41 |
42 | public function centre(transform:Transform2D):void
43 | {
44 | //addOperation( new ChangePropertyOperation( circle, "x", 0 ) );
45 | //addOperation( new ChangePropertyOperation( circle, "y", 0 ) );
46 | x = 0;
47 | y = 0;
48 |
49 | var m:Matrix = new Matrix( transform.matrix.a, transform.matrix.b, transform.matrix.c, transform.matrix.d );
50 | var pt:Point = new Point(x, y);
51 | pt = m.transformPoint(pt);
52 |
53 | //addOperation( new ChangePropertyOperation( transform, "x", transform.x+pt.x ) );
54 | //addOperation( new ChangePropertyOperation( transform, "y", transform.y+pt.y ) );
55 | transform.x = transform.x+pt.x;
56 | transform.y = transform.y+pt.y;
57 |
58 | transformConnections( m, transform );
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/geom/AbstractGeometry.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.components.geom
12 | {
13 | import flash.geom.Matrix;
14 | import flash.geom.Point;
15 |
16 | import cadet.components.geom.IGeometry;
17 | import cadet.core.Component;
18 | import cadet.core.IComponent;
19 | import cadet.util.ComponentUtil;
20 |
21 | import cadet2D.components.connections.Connection;
22 | import cadet2D.components.transforms.Transform2D;
23 | import cadet2D.geom.Vertex;
24 |
25 | public class AbstractGeometry extends Component implements IGeometry
26 | {
27 | public function AbstractGeometry( name:String = "AbstractGeometry" )
28 | {
29 | super( name );
30 | }
31 |
32 | protected function transformConnections( m:Matrix, transform:Transform2D ):void
33 | {
34 | if ( transform.scene == null ) return;
35 |
36 | var connections:Vector. = ComponentUtil.getChildrenOfType(transform.scene, Connection, true);
37 | for each ( var connection:Connection in connections )
38 | {
39 | var pt:Point;
40 | if ( connection.transformA == transform )
41 | {
42 | pt = connection.localPosA.toPoint();
43 | pt = m.transformPoint(pt);
44 | connection.localPosA = new Vertex(pt.x, pt.y);
45 | //addOperation( new ChangePropertyOperation( connection, "localPosA", new Vertex(pt.x,pt.y) ) );
46 | }
47 | else if ( connection.transformB == transform )
48 | {
49 | pt = connection.localPosB.toPoint();
50 | pt = m.transformPoint(pt);
51 | connection.localPosB = new Vertex(pt.x, pt.y);
52 | //addOperation( new ChangePropertyOperation( connection, "localPosB", new Vertex(pt.x,pt.y) ) );
53 | }
54 | }
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/components/materials/SkyBoxMaterialComponent.as:
--------------------------------------------------------------------------------
1 | package cadet3D.components.materials
2 | {
3 | import away3d.materials.SkyBoxMaterial;
4 | import away3d.textures.BitmapCubeTexture;
5 |
6 | import cadet.core.Component;
7 | import cadet.events.ValidationEvent;
8 |
9 | import cadet3D.components.textures.BitmapCubeTextureComponent;
10 | import cadet3D.util.NullBitmapCubeTexture;
11 |
12 | import flash.display.BitmapData;
13 |
14 | public class SkyBoxMaterialComponent extends Component
15 | {
16 | private var _skyBoxMaterial:SkyBoxMaterial;
17 | private var _bmpCubeTextureComponent:BitmapCubeTextureComponent;
18 | //private var defaultBitmapData :BitmapData = new BitmapData(256, 256, false, 0xFF0000);
19 |
20 | public function SkyBoxMaterialComponent()
21 | {
22 | _skyBoxMaterial = new SkyBoxMaterial( NullBitmapCubeTexture.getCopy() );
23 | }
24 |
25 | public function get material():SkyBoxMaterial
26 | {
27 | return _skyBoxMaterial;
28 | }
29 |
30 | [Serializable][Inspectable( priority="100", editor="ComponentList", scope="scene" )]
31 | public function set cubeTexture(value : BitmapCubeTextureComponent) : void
32 | {
33 | if ( _bmpCubeTextureComponent ) {
34 | _bmpCubeTextureComponent.removeEventListener(ValidationEvent.INVALIDATE, invalidateTextureHandler);
35 | }
36 |
37 | _bmpCubeTextureComponent = value;
38 |
39 | if ( _bmpCubeTextureComponent ) {
40 | _bmpCubeTextureComponent.addEventListener(ValidationEvent.INVALIDATE, invalidateTextureHandler);
41 | }
42 |
43 | updateCubeTexture();
44 | }
45 | public function get cubeTexture():BitmapCubeTextureComponent
46 | {
47 | return _bmpCubeTextureComponent;
48 | }
49 |
50 |
51 | private function invalidateTextureHandler( event:ValidationEvent ):void
52 | {
53 | updateCubeTexture();
54 | }
55 |
56 | private function updateCubeTexture():void
57 | {
58 | if ( _bmpCubeTextureComponent ) {
59 | _skyBoxMaterial.cubeMap = _bmpCubeTextureComponent.cubeTexture;
60 | } else {
61 | _skyBoxMaterial.cubeMap = NullBitmapCubeTexture.getCopy();
62 | }
63 | }
64 | }
65 | }
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/components/cameras/CameraComponent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3D.components.cameras
12 | {
13 | import away3d.cameras.Camera3D;
14 | import away3d.cameras.lenses.OrthographicLens;
15 | import away3d.cameras.lenses.PerspectiveLens;
16 |
17 | import cadet3D.components.core.ObjectContainer3DComponent;
18 |
19 | public class CameraComponent extends ObjectContainer3DComponent
20 | {
21 | public static const PERSPECTIVE :String = "perspective";
22 | public static const ORTHOGRAPHIC :String = "orthographic";
23 |
24 | protected var _camera :Camera3D;
25 | protected var _lensType :String;
26 |
27 | public function CameraComponent()
28 | {
29 | _object3D = _camera = new Camera3D();
30 | _lensType = PERSPECTIVE;
31 | }
32 |
33 | public function get camera():Camera3D
34 | {
35 | return _camera;
36 | }
37 |
38 | [Serializable][Inspectable( priority="150" )]
39 | public function set lensFar( value:uint ):void
40 | {
41 | _camera.lens.far = value;
42 | }
43 | public function get lensFar():uint
44 | {
45 | return _camera.lens.far;
46 | }
47 |
48 | public function set lensType( value:String ):void
49 | {
50 | if ( value == _lensType ) return;
51 | switch( value )
52 | {
53 | case PERSPECTIVE :
54 | _camera.lens = new PerspectiveLens();
55 | break;
56 | case ORTHOGRAPHIC :
57 | _camera.lens = new OrthographicLens();
58 | break;
59 | default :
60 | throw( new Error( "Invalid lens type : " + value ) );
61 | return;
62 | break;
63 | }
64 | }
65 |
66 | public function get lensType():String
67 | {
68 | return _lensType;
69 | }
70 |
71 | }
72 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/components/processes/TouchInputMapping.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.components.processes
12 | {
13 | import cadet.core.Component;
14 |
15 | import core.events.PropertyChangeEvent;
16 |
17 | public class TouchInputMapping extends Component implements IInputMapping
18 | {
19 | private var _input :String;
20 |
21 | /** Only available for mouse input: the cursor hovers over an object without a
22 | * pressed button. */
23 | public static const HOVER:String = "HOVER";
24 |
25 | /** The finger touched the screen just now, or the mouse button was pressed. */
26 | public static const BEGAN:String = "BEGAN";
27 |
28 | /** The finger moves around on the screen, or the mouse is moved while the button is
29 | * pressed. */
30 | public static const MOVED:String = "MOVED";
31 |
32 | /** The finger or mouse (with pressed button) has not moved since the last frame. */
33 | public static const STATIONARY:String = "STATIONARY";
34 |
35 | /** The finger was lifted from the screen or from the mouse button. */
36 | public static const ENDED:String = "ENDED";
37 |
38 |
39 | public static const mappings:Array = [HOVER, BEGAN, MOVED, STATIONARY, ENDED];
40 |
41 | public function TouchInputMapping()
42 | {
43 | super();
44 | }
45 |
46 | [Serializable][Inspectable( editor="DropDownMenu", dataProvider="[HOVER,BEGAN,MOVED,STATIONARY,ENDED]" )]
47 | public function set input( value:String ):void
48 | {
49 | if ( value )
50 | {
51 | value = value.toUpperCase();
52 | }
53 | _input = value;
54 |
55 | invalidate("code");
56 | dispatchEvent( new PropertyChangeEvent( "propertyChange_input", null, _input ) );
57 | }
58 | public function get input():String { return _input; }
59 | }
60 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/components/lights/LightProbeComponent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3D.components.lights
12 | {
13 | import away3d.lights.LightProbe;
14 |
15 | import cadet.events.ValidationEvent;
16 |
17 | import cadet3D.components.textures.AbstractCubeTextureComponent;
18 | import cadet3D.util.NullBitmapCubeTexture;
19 |
20 | public class LightProbeComponent extends AbstractLightComponent
21 | {
22 | private var _lightProbe :LightProbe;
23 | private var _diffuseMap :AbstractCubeTextureComponent;
24 |
25 | public function LightProbeComponent()
26 | {
27 | _object3D = _light = _lightProbe = new LightProbe(NullBitmapCubeTexture.instance, NullBitmapCubeTexture.instance);
28 | }
29 |
30 | [Serializable][Inspectable( priority="200", editor="ComponentList", scope="scene" )]
31 | public function set diffuseMap( value:AbstractCubeTextureComponent ):void
32 | {
33 | if ( _diffuseMap )
34 | {
35 | _diffuseMap.removeEventListener(ValidationEvent.INVALIDATE, invalidateDiffuseMapHandler);
36 | }
37 | _diffuseMap = value;
38 | if ( _diffuseMap )
39 | {
40 | _diffuseMap.addEventListener(ValidationEvent.INVALIDATE, invalidateDiffuseMapHandler);
41 | }
42 | updateDiffuseMap();
43 | }
44 |
45 | public function get diffuseMap():AbstractCubeTextureComponent
46 | {
47 | return _diffuseMap;
48 | }
49 |
50 |
51 | private function invalidateDiffuseMapHandler( event:ValidationEvent ):void
52 | {
53 | updateDiffuseMap();
54 | }
55 |
56 | private function updateDiffuseMap():void
57 | {
58 | if ( _diffuseMap )
59 | {
60 | _lightProbe.diffuseMap = _diffuseMap.cubeTexture;
61 | }
62 | else
63 | {
64 | _lightProbe.diffuseMap = NullBitmapCubeTexture.instance;
65 | }
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/cadet2DBox2D/Cadet2DBox2D.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/cadet/src/cadet/operations/ValidateAsyncOperation.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.operations
12 | {
13 | import flash.events.Event;
14 | import flash.events.EventDispatcher;
15 | import flash.utils.getTimer;
16 |
17 | import cadet.core.IComponent;
18 | import cadet.core.IComponentContainer;
19 | import cadet.util.ComponentUtil;
20 |
21 | import core.app.core.operations.IAsynchronousOperation;
22 | import core.app.events.OperationProgressEvent;
23 | import core.app.util.AsynchronousUtil;
24 |
25 | public class ValidateAsyncOperation extends EventDispatcher implements IAsynchronousOperation
26 | {
27 | private var scene :IComponentContainer;
28 | private var components :Vector.;
29 | private var totalComponents :int;
30 |
31 | public function ValidateAsyncOperation(scene:IComponentContainer)
32 | {
33 | this.scene = scene;
34 | }
35 |
36 | public function execute():void
37 | {
38 | components = ComponentUtil.getChildren(scene, true);
39 | components = components.reverse();
40 | totalComponents = components.length;
41 | checkQueue();
42 | }
43 |
44 | private function checkQueue():void
45 | {
46 | if ( components.length == 0 )
47 | {
48 | dispatchEvent( new Event( Event.COMPLETE ) );
49 | return;
50 | }
51 |
52 | var start:int = getTimer();
53 | while ( components.length > 0 )
54 | {
55 | var component:IComponent = IComponent(components.pop());
56 | component.validateNow();
57 | if ( (getTimer() - start) > 15 ) break;
58 | }
59 |
60 | dispatchEvent( new OperationProgressEvent( OperationProgressEvent.PROGRESS, (totalComponents-components.length) / totalComponents ) );
61 |
62 | AsynchronousUtil.callLater(checkQueue);
63 | }
64 |
65 | public function get label():String
66 | {
67 | return "Validate Async";
68 | }
69 | }
70 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/operations/GetTemplatesAndMergeXMLOperation.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.operations
12 | {
13 | import flash.events.EventDispatcher;
14 |
15 | import cadet.core.IComponent;
16 | import cadet.operations.GetTemplateAndMergeXMLOperation;
17 |
18 | import core.app.core.serialization.Serializer;
19 | import core.app.operations.CompoundOperation;
20 |
21 | import core.app.core.managers.fileSystemProviders.IFileSystemProvider;
22 | import core.app.core.operations.IAsynchronousOperation;
23 | import core.app.operations.UndoableCompoundOperation;
24 |
25 |
26 | public class GetTemplatesAndMergeXMLOperation extends CompoundOperation implements IAsynchronousOperation
27 | {
28 | private var xmlToMergeInto :XML;
29 | private var fileSystemProvider :IFileSystemProvider;
30 | private var templateXMLTable :Object;
31 |
32 |
33 |
34 | public function GetTemplatesAndMergeXMLOperation( xmlToMergeInto:XML, fileSystemProvider:IFileSystemProvider, templateXMLTable:Object = null )
35 | {
36 | this.xmlToMergeInto = xmlToMergeInto;
37 | this.fileSystemProvider = fileSystemProvider;
38 | this.templateXMLTable = templateXMLTable;
39 | if ( !templateXMLTable ) templateXMLTable = {};
40 |
41 | var x:Namespace = Serializer.x;
42 | var nodesWithTemplateID:XMLList = xmlToMergeInto..*.(name() == "cadet.core::ComponentContainer" && String(attribute("templateID")) != "");
43 |
44 | for ( var i:int = 0; i < nodesWithTemplateID.length(); i++ )
45 | {
46 | var node:XML = nodesWithTemplateID[i];
47 | var operation:GetTemplateAndMergeXMLOperation = new GetTemplateAndMergeXMLOperation( node, fileSystemProvider, templateXMLTable );
48 | addOperation(operation);
49 | }
50 | }
51 |
52 |
53 | override public function get label():String
54 | {
55 | return "Get Templates And Merge";
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/cadet3D/src/cadet3D/components/geom/SphereGeometryComponent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3D.components.geom
12 | {
13 | import away3d.core.base.Geometry;
14 | import away3d.primitives.CubeGeometry;
15 | import away3d.primitives.SphereGeometry;
16 |
17 | import cadet.core.Component;
18 |
19 | public class SphereGeometryComponent extends AbstractGeometryComponent
20 | {
21 | private var sphereGeom :SphereGeometry;
22 |
23 | public function SphereGeometryComponent()
24 | {
25 | _geometry = sphereGeom = new SphereGeometry()
26 | }
27 |
28 | [Serializable][Inspectable( priority="100", editor="NumberInput", min="1", max="9999", numDecimalPlaces="2" )]
29 | public function get radius() : Number
30 | {
31 | return sphereGeom.radius;
32 | }
33 |
34 | public function set radius(value : Number) : void
35 | {
36 | sphereGeom.radius = value;
37 | sphereGeom.subGeometries; // Trigger validatation
38 | invalidate( GEOMETRY );
39 | }
40 |
41 | [Serializable][Inspectable( priority="101", editor="NumberInput", min="4", max="256", numDecimalPlaces="0" )]
42 | public function get segmentsW() : Number
43 | {
44 | return sphereGeom.segmentsW;
45 | }
46 |
47 | public function set segmentsW(value : Number) : void
48 | {
49 | sphereGeom.segmentsW = value;
50 | sphereGeom.subGeometries; // Trigger validatation
51 | invalidate( GEOMETRY );
52 | }
53 |
54 | [Serializable][Inspectable( priority="102", editor="NumberInput", min="4", max="256", numDecimalPlaces="0" )]
55 | public function get segmentsH() : Number
56 | {
57 | return sphereGeom.segmentsH;
58 | }
59 |
60 | public function set segmentsH(value : Number) : void
61 | {
62 | sphereGeom.segmentsH = value;
63 | sphereGeom.subGeometries; // Trigger validatation
64 | invalidate( GEOMETRY );
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/components/textures/TextureComponent.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.components.textures
12 | {
13 | import flash.display.Bitmap;
14 | import flash.display.BitmapData;
15 |
16 | import cadet.core.Component;
17 | import cadet.events.ValidationEvent;
18 |
19 | import starling.core.Starling;
20 | import starling.textures.Texture;
21 |
22 | public class TextureComponent extends Component
23 | {
24 | public static const TEXTURE:String = "texture";
25 |
26 | private var _bitmapData:BitmapData;
27 | private var _texture:Texture;
28 |
29 | public function TextureComponent( name:String = "TextureComponent" )
30 | {
31 | super(name);
32 | }
33 |
34 | [Serializable( type="resource" )][Inspectable(editor="ResourceItemEditor")]
35 | public function set bitmapData( value:BitmapData ):void
36 | {
37 | if ( !value ) return;
38 |
39 | _bitmapData = value;
40 |
41 | invalidate(TEXTURE);
42 | }
43 | public function get bitmapData():BitmapData { return _bitmapData; }
44 |
45 | public function get texture():Texture
46 | {
47 | return _texture;
48 | }
49 |
50 | override public function validateNow():void
51 | {
52 | var textureValidated:Boolean = true;
53 | if ( isInvalid( TEXTURE ) ) {
54 | textureValidated = validateTexture();
55 | }
56 | super.validateNow();
57 |
58 | if (!textureValidated) {
59 | invalidate( TEXTURE );
60 | }
61 | }
62 |
63 | private function validateTexture():Boolean
64 | {
65 | if ( _bitmapData && Starling.context ) {
66 | //trace("validateTexture");
67 | // if ( _texture ) {
68 | // _texture.dispose();
69 | // _texture = null;
70 | // }
71 | _texture = Texture.fromBitmap( new Bitmap(_bitmapData), false );
72 | var event:ValidationEvent = new ValidationEvent(ValidationEvent.VALIDATED, TEXTURE);
73 | dispatchEvent(event);
74 | return true;
75 | }
76 | return false;
77 | }
78 | }
79 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/util/Reference.as:
--------------------------------------------------------------------------------
1 | package cadet.util
2 | {
3 | import cadet.core.IComponent;
4 | import cadet.core.IComponentContainer;
5 | import cadet.events.ComponentContainerEvent;
6 |
7 | public class Reference
8 | {
9 | public var type:Class;
10 | public var host:IComponent;
11 | public var property:String;
12 | public var target:IComponentContainer;
13 |
14 | private var _excludedComponents:Vector.;
15 | private var _excludedTypes:Vector.;
16 |
17 | public function Reference( target:IComponentContainer, type:Class, host:IComponent, property:String, excludedTypes:Vector. = null )
18 | {
19 | init( target, type, host, property, excludedTypes );
20 | }
21 |
22 | public function init( target:IComponentContainer, type:Class, host:IComponent, property:String, excludedTypes:Vector. = null ):void
23 | {
24 | this.target = target;
25 | this.type = type;
26 | this.host = host;
27 | this.property = property;
28 |
29 | target.addEventListener(ComponentContainerEvent.CHILD_ADDED, childAddedHandler);
30 | target.addEventListener(ComponentContainerEvent.CHILD_REMOVED, childRemovedHandler);
31 |
32 | _excludedComponents = new Vector.();
33 | _excludedComponents.push(host);
34 |
35 | _excludedTypes = excludedTypes;
36 |
37 | host[property] = ComponentUtil.getChildOfType(target, type, false, _excludedComponents, _excludedTypes);
38 | }
39 |
40 | public function dispose():void
41 | {
42 | target.removeEventListener(ComponentContainerEvent.CHILD_ADDED, childAddedHandler);
43 | target.removeEventListener(ComponentContainerEvent.CHILD_REMOVED, childRemovedHandler);
44 |
45 | host[property] = null;
46 |
47 | target = null;
48 | host = null;
49 | type = null;
50 | property = null;
51 | }
52 |
53 | private function childAddedHandler( event:ComponentContainerEvent ):void
54 | {
55 | if ( event.child is type && !ComponentUtil.isExcluded(event.child, _excludedComponents, _excludedTypes) )
56 | {
57 | host[property] = event.child;
58 | }
59 | }
60 |
61 | private function childRemovedHandler( event:ComponentContainerEvent ):void
62 | {
63 | // Presumes there will only be one sibling of a type
64 | if ( event.child is type && !ComponentUtil.isExcluded(event.child, _excludedComponents, _excludedTypes) )
65 | {
66 | host[property] = null;
67 | }
68 | }
69 | }
70 | }
--------------------------------------------------------------------------------
/examples/cadet2D/02_bunny_mark/src/BunnyMark.as:
--------------------------------------------------------------------------------
1 | package
2 | {
3 | import cadet.core.CadetScene;
4 |
5 | import cadet2D.components.renderers.Renderer2D;
6 | import cadet2D.components.skins.ImageSkin;
7 | import cadet2D.components.textures.TextureComponent;
8 |
9 | import components.behaviours.BounceBehaviour;
10 |
11 | import flash.display.Sprite;
12 | import flash.events.Event;
13 | import flash.geom.Point;
14 | import flash.geom.Rectangle;
15 |
16 | [SWF( width="700", height="400", backgroundColor="0x002135", frameRate="60" )]
17 | public class BunnyMark extends Sprite
18 | {
19 | [Embed(source = "assets/wabbit_alpha.png")]
20 | private var BunnyAsset:Class;
21 | private var textureComponent:TextureComponent;
22 |
23 | private var numEntities :int = 1000;
24 | private var entityIndex :uint;
25 |
26 | private var cadetScene:CadetScene;
27 |
28 | public function BunnyMark()
29 | {
30 | cadetScene = new CadetScene();
31 |
32 | var renderer:Renderer2D = new Renderer2D();
33 | renderer.viewportWidth = stage.stageWidth;
34 | renderer.viewportHeight = stage.stageHeight;
35 | cadetScene.children.addItem(renderer);
36 | renderer.enable(this);
37 |
38 | // Create the shared TextureComponent
39 | textureComponent = new TextureComponent();
40 | textureComponent.bitmapData = new BunnyAsset().bitmapData;
41 | cadetScene.children.addItem(textureComponent);
42 |
43 | addEventListener( Event.ENTER_FRAME, enterFrameHandler );
44 | }
45 |
46 | private function enterFrameHandler( event:Event ):void
47 | {
48 | if (entityIndex < numEntities) {
49 | entityIndex ++;
50 | createBunny();
51 | }
52 |
53 | cadetScene.step();
54 | }
55 |
56 | private function createBunny():void
57 | {
58 | // Add the BounceBehaviour to the scene
59 | var randomVelocity:Point = new Point(Math.random() * 10, (Math.random() * 10) - 5);
60 | var bounceBehaviour:BounceBehaviour = new BounceBehaviour();
61 | bounceBehaviour.velocity = randomVelocity;
62 | bounceBehaviour.boundsRect = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
63 | cadetScene.children.addItem(bounceBehaviour);
64 |
65 | // Add a Skin to the scene
66 | var skin:ImageSkin = new ImageSkin();
67 | skin.texture = textureComponent;
68 | cadetScene.children.addItem(skin);
69 |
70 | // Pass reference to skin to bounceBehaviour
71 | bounceBehaviour.transform = skin;
72 | }
73 | }
74 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/components/behaviours/EntityUserControlBehaviour.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.components.behaviours
12 | {
13 | import cadet.components.processes.InputProcess;
14 | import cadet.core.Component;
15 | import cadet.core.ISteppableComponent;
16 |
17 | public class EntityUserControlBehaviour extends Component implements ISteppableComponent
18 | {
19 | [Serializable][Inspectable]
20 | public var upMapping :String = "UP";
21 | [Serializable][Inspectable]
22 | public var downMapping :String = "DOWN";
23 | [Serializable][Inspectable]
24 | public var leftMapping :String = "LEFT";
25 | [Serializable][Inspectable]
26 | public var rightMapping :String = "RIGHT";
27 | [Serializable][Inspectable]
28 | public var spaceMapping :String = "SPACE";
29 |
30 | public var inputProcess :InputProcess;
31 | public var entityBehaviour :IEntityUserControlledBehaviour;
32 |
33 | public function EntityUserControlBehaviour()
34 | {
35 | name = "EntityUserControlBehaviour";
36 | }
37 |
38 | override protected function addedToScene():void
39 | {
40 | addSiblingReference(IEntityUserControlledBehaviour, "entityBehaviour");
41 | addSceneReference( InputProcess, "inputProcess" );
42 | }
43 |
44 | public function step(dt:Number):void
45 | {
46 | if ( !entityBehaviour ) return;
47 | if ( !inputProcess ) return;
48 |
49 | if ( inputProcess.isInputDown( upMapping ) )
50 | {
51 | entityBehaviour.up();
52 | }
53 |
54 | if ( inputProcess.isInputDown( downMapping ) )
55 | {
56 | entityBehaviour.down();
57 | }
58 |
59 | if ( inputProcess.isInputDown( leftMapping ) )
60 | {
61 | entityBehaviour.left();
62 | }
63 |
64 | if ( inputProcess.isInputDown( rightMapping ) )
65 | {
66 | entityBehaviour.right();
67 | }
68 |
69 | if ( inputProcess.isInputDown( spaceMapping ) )
70 | {
71 | entityBehaviour.space();
72 | }
73 | }
74 | }
75 | }
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/operations/ConvertToPolygonOperation.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.operations
12 | {
13 | import cadet.core.IComponentContainer;
14 | import cadet2D.components.geom.PolygonGeometry;
15 | import cadet2D.util.VertexUtil;
16 |
17 | import core.app.core.operations.IUndoableOperation;
18 | import core.app.util.IntrospectionUtil;
19 |
20 | public class ConvertToPolygonOperation implements IUndoableOperation
21 | {
22 | private var polygon :PolygonGeometry;
23 | private var result :PolygonGeometry;
24 |
25 | private var parentComponent :IComponentContainer;
26 | private var index :int;
27 |
28 |
29 | public function ConvertToPolygonOperation( polygon:PolygonGeometry )
30 | {
31 | this.polygon = polygon;
32 |
33 | var type:Class = IntrospectionUtil.getType(polygon);
34 | if ( type == PolygonGeometry )
35 | {
36 | result = polygon;
37 | }
38 | else
39 | {
40 | result = new PolygonGeometry();
41 | result.name = polygon.name;
42 | result.exportTemplateID = polygon.exportTemplateID;
43 | result.templateID = polygon.templateID;
44 | var clonedVertices:Array = VertexUtil.copy(polygon.vertices);
45 | result.vertices = clonedVertices;
46 | }
47 | }
48 |
49 | public function execute():void
50 | {
51 | parentComponent = polygon.parentComponent;
52 | if ( parentComponent )
53 | {
54 | index = parentComponent.children.getItemIndex(polygon);
55 |
56 | parentComponent.children.removeItem(polygon);
57 | parentComponent.children.addItem(result);
58 | }
59 | }
60 |
61 | public function undo():void
62 | {
63 | if ( result == polygon ) return;
64 |
65 | if ( parentComponent )
66 | {
67 | parentComponent.children.removeItem(result);
68 | parentComponent.children.addItemAt(polygon, index);
69 | }
70 | }
71 |
72 | public function get label():String { return "Convert To Polygon"; }
73 |
74 |
75 | public function getResult():PolygonGeometry
76 | {
77 | return result;
78 | }
79 |
80 | }
81 | }
--------------------------------------------------------------------------------
/cadet3DPhysics/src/cadet3DPhysics/components/processes/PhysicsProcess.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet3DPhysics.components.processes
12 | {
13 | import awayphysics.dynamics.AWPDynamicsWorld;
14 | import awayphysics.dynamics.AWPRigidBody;
15 |
16 | import cadet.core.Component;
17 | import cadet.core.ISteppableComponent;
18 |
19 | import cadet3DPhysics.components.behaviours.RigidBodyBehaviour;
20 |
21 | import flash.utils.Dictionary;
22 |
23 | public class PhysicsProcess extends Component implements ISteppableComponent
24 | {
25 | private var _physicsWorld : AWPDynamicsWorld;
26 |
27 | private var behaviourTable : Dictionary;
28 |
29 | private var _timeStep : Number = 1.0 / 60;
30 |
31 | public function PhysicsProcess( name:String = "PhysicsProcess" )
32 | {
33 | super( name );
34 | init();
35 | }
36 |
37 | private function init():void
38 | {
39 | /*
40 | scaleFactor = 0.02;
41 | var bounds:b2AABB = new b2AABB();
42 | bounds.lowerBound = new b2Vec2( -10000, -10000 );
43 | bounds.upperBound = new b2Vec2( 10000, 10000 );
44 | _box2D = new b2World( bounds, new b2Vec2( 0, 0 ), true );
45 | _box2D.SetContactListener(new PhysicsProcessContactListener(this));
46 | _box2D.SetDestructionListener(new PhysicsProcessDestructionListener(this));
47 |
48 | gravity = 6;
49 | */
50 |
51 | // init the physics world
52 | _physicsWorld = AWPDynamicsWorld.getInstance();
53 | _physicsWorld.initWithDbvtBroadphase();
54 |
55 | behaviourTable = new Dictionary(true);
56 | }
57 |
58 | public function addRigidBody( behaviour:RigidBodyBehaviour, rigidBody:AWPRigidBody ):void
59 | {
60 | behaviourTable[rigidBody] = behaviour;
61 | _physicsWorld.addRigidBody(rigidBody);
62 | }
63 |
64 | public function removeRigidBody( rigidBody:AWPRigidBody ):void
65 | {
66 | delete behaviourTable[rigidBody];
67 | _physicsWorld.removeRigidBody( rigidBody );
68 | }
69 |
70 | public function step(dt:Number):void
71 | {
72 | _physicsWorld.step(_timeStep, 1, _timeStep);
73 | }
74 | }
75 | }
--------------------------------------------------------------------------------
/cadet/src/cadet/components/processes/KeyboardInputMapping.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet.components.processes
12 | {
13 | import cadet.core.Component;
14 |
15 | import core.events.PropertyChangeEvent;
16 |
17 | public class KeyboardInputMapping extends Component implements IInputMapping
18 | {
19 | private static const KEY_CODE_TABLE :Object = { "UP":38, "DOWN":40, "LEFT":37, "RIGHT":39, "SPACE":32, "ENTER":13, "0":48, "1":49, "2":50, "3":51, "4":52, "5":53, "6":54, "7":55, "8":56, "9":67 };
20 | private static const INPUT_TABLE :Object = { "38":"UP", "40":"DOWN", "37":"LEFT", "39":"RIGHT", "32":"SPACE", "13":"ENTER", "48":"0", "49":"1", "50":"2", "51":"3", "52":"4", "53":"5", "54":"6", "55":"7", "56":"8", "67":"9" };
21 |
22 | private var _input :String;
23 |
24 | public static const UP:String = "UP";
25 | public static const DOWN:String = "DOWN";
26 | public static const LEFT:String = "LEFT";
27 | public static const RIGHT:String = "RIGHT";
28 | public static const SPACE:String = "SPACE";
29 | public static const ENTER:String = "ENTER";
30 |
31 | public function KeyboardInputMapping( name:String = "KeyboardInputMapping" )
32 | {
33 | super(name);
34 | }
35 |
36 | [Serializable][Inspectable( editor="DropDownMenu", dataProvider="[UP,DOWN,LEFT,RIGHT,SPACE,ENTER,0,1,2,3,4,5,6,7,8,9]" )]
37 | public function set input( value:String ):void
38 | {
39 | if ( value )
40 | {
41 | value = value.toUpperCase();
42 | }
43 | _input = value;
44 |
45 | invalidate("code");
46 | dispatchEvent( new PropertyChangeEvent( "propertyChange_input", null, _input ) );
47 | }
48 | public function get input():String { return _input; }
49 |
50 | public function getKeyCode():int
51 | {
52 | return inputToKeyCode(_input);
53 | }
54 |
55 | public static function inputToKeyCode( input:String ):int
56 | {
57 | return KEY_CODE_TABLE[input] ? KEY_CODE_TABLE[input] : -1;
58 | }
59 |
60 | public static function keyCodeToInput( keyCode:int ):String
61 | {
62 | return INPUT_TABLE[keyCode];
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/cadet2D/Cadet2D.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/examples/cadet2D/01_behaviours_skins/src/components/skins/ShadedCircleSkin.as:
--------------------------------------------------------------------------------
1 | package components.skins
2 | {
3 | import flash.display.GradientType;
4 |
5 | import cadet.events.ValidationEvent;
6 |
7 | import cadet2D.components.geom.CircleGeometry;
8 | import cadet2D.components.skins.AbstractSkin2D;
9 |
10 | import starling.core.Starling;
11 | import starling.display.Shape;
12 | import starling.textures.GradientTexture;
13 | import starling.textures.Texture;
14 |
15 | public class ShadedCircleSkin extends AbstractSkin2D
16 | {
17 | private var _circle :CircleGeometry;
18 | private var _shape :Shape;
19 |
20 | private const DISPLAY :String = "display";
21 |
22 | public function ShadedCircleSkin()
23 | {
24 | _displayObject = new Shape();
25 | _shape = Shape(_displayObject);
26 | }
27 |
28 | override protected function addedToParent():void
29 | {
30 | super.addedToParent();
31 | addSiblingReference(CircleGeometry, "circle");
32 | }
33 |
34 | public function set circle( value:CircleGeometry ):void
35 | {
36 | if ( _circle )
37 | {
38 | _circle.removeEventListener(ValidationEvent.INVALIDATE, invalidateCircleHandler);
39 | }
40 |
41 | _circle = value;
42 |
43 | if ( _circle )
44 | {
45 | _circle.addEventListener(ValidationEvent.INVALIDATE, invalidateCircleHandler);
46 | }
47 |
48 | invalidate(DISPLAY);
49 | }
50 | public function get circle():CircleGeometry{ return _circle; }
51 |
52 |
53 | private function invalidateCircleHandler( event:ValidationEvent ):void
54 | {
55 | invalidate(DISPLAY);
56 | }
57 |
58 | override public function validateNow():void
59 | {
60 | if ( isInvalid(DISPLAY) )
61 | {
62 | validateDisplay();
63 | }
64 | super.validateNow()
65 | }
66 |
67 | private function validateDisplay():void
68 | {
69 | _shape.graphics.clear();
70 | if ( !_circle ) return;
71 |
72 | var colors:Array = [0xFFFFFF, 0x909090];
73 | var ratios:Array = [0,255];
74 | var alphas:Array = [1,1];
75 |
76 | // Don't attempt to create the gradientTexture if the Starling.context is unavailable,
77 | // as Texture.fromBitmapData() will throw a missing context error
78 | if (!Starling.context) return;
79 |
80 | var gradientTexture:Texture = GradientTexture.create(128, 128, GradientType.RADIAL, colors, alphas, ratios );
81 | _shape.graphics.beginTextureFill(gradientTexture);
82 | _shape.graphics.drawCircle(circle.x,circle.y,circle.radius);
83 | _shape.graphics.endFill();
84 | }
85 | }
86 | }
--------------------------------------------------------------------------------
/cadet2D/src/cadet2D/util/LinearPathUtil.as:
--------------------------------------------------------------------------------
1 | // =================================================================================================
2 | //
3 | // CadetEngine Framework
4 | // Copyright 2012 Unwrong Ltd. All Rights Reserved.
5 | //
6 | // This program is free software. You can redistribute and/or modify it
7 | // in accordance with the terms of the accompanying license agreement.
8 | //
9 | // =================================================================================================
10 |
11 | package cadet2D.util
12 | {
13 | import cadet2D.geom.Vertex;
14 |
15 | public class LinearPathUtil
16 | {
17 | static public function weld( vertices:Array, minimumDistance:Number ):void
18 | {
19 | var L:int = vertices.length;
20 | if ( L < 3 ) return;
21 | var dis:Number = minimumDistance*minimumDistance;
22 |
23 | while ( true )
24 | {
25 | if ( L < 3 ) break
26 | var found:Boolean = false;
27 | for ( var i:int = 0; i < L-2; i++ )
28 | {
29 | var vertexA:Vertex = vertices[i];
30 | var vertexB:Vertex = vertices[i+1];
31 | var dx:Number = vertexB.x - vertexA.x;
32 | var dy:Number = vertexB.y - vertexA.y;
33 | var d:Number = dx*dx + dy*dy;
34 | if ( d > dis ) continue;
35 | found = true;
36 | vertexA.x += dx*0.5;
37 | vertexA.y += dy*0.5;
38 | vertices.splice(i+1,1);
39 | L--;
40 | }
41 | if ( !found ) break;
42 | }
43 | }
44 |
45 | static public function getLength( vertices:Array ):Number
46 | {
47 | if ( vertices.length < 2 ) return 0;
48 |
49 | var d:Number = 0;
50 | var prevPos:Vertex = vertices[0];
51 | for ( var i:int = 1; i < vertices.length; i++ )
52 | {
53 | var pos:Vertex = vertices[i];
54 | var dx:Number = pos.x - prevPos.x;
55 | var dy:Number = pos.y - prevPos.y;
56 | d += Math.sqrt(dx*dx + dy*dy);
57 | prevPos = pos;
58 | }
59 |
60 | return d;
61 | }
62 |
63 | static public function evaluate( vertices:Array, t:Number, output:Vertex ):Vertex
64 | {
65 | var L:int = vertices.length;
66 |
67 | if ( L == 1 )
68 | {
69 | output.x = vertices[0].x;
70 | output.y = vertices[0].y;
71 | return output;
72 | }
73 |
74 | var ratio:Number = (t * (L-1)) % 1
75 | var index:int = t * (L-1);
76 |
77 | var vertexA:Vertex = vertices[index];
78 | var vertexB:Vertex = vertices[index+1];
79 |
80 | output.x = (1-ratio) * vertexA.x + ratio * vertexB.x;
81 | output.y = (1-ratio) * vertexA.y + ratio * vertexB.y;
82 |
83 | return output;
84 | }
85 | }
86 | }
--------------------------------------------------------------------------------
/examples/cadet2DBox2D/01_boxes/src/Box.as:
--------------------------------------------------------------------------------
1 | package
2 | {
3 | import flash.display.Sprite;
4 | import flash.events.Event;
5 |
6 | import cadet.core.CadetScene;
7 | import cadet.core.ComponentContainer;
8 |
9 | import cadet2D.components.geom.RectangleGeometry;
10 | import cadet2D.components.renderers.Renderer2D;
11 | import cadet2D.components.skins.GeometrySkin;
12 | import cadet2D.components.transforms.Transform2D;
13 |
14 | import cadet2DBox2D.components.behaviours.RigidBodyBehaviour;
15 | import cadet2DBox2D.components.behaviours.RigidBodyMouseDragBehaviour;
16 | import cadet2DBox2D.components.processes.PhysicsProcess;
17 |
18 | [SWF( width="700", height="400", backgroundColor="0x002135", frameRate="60" )]
19 | public class Box extends Sprite
20 | {
21 | private var cadetScene : CadetScene;
22 |
23 | public function Box()
24 | {
25 | cadetScene = new CadetScene();
26 |
27 | var renderer:Renderer2D = new Renderer2D();
28 | renderer.viewportWidth = stage.stageWidth;
29 | renderer.viewportHeight = stage.stageHeight;
30 | cadetScene.children.addItem(renderer);
31 | renderer.enable(this);
32 |
33 | var physicsProcess:PhysicsProcess = new PhysicsProcess();
34 | cadetScene.children.addItem( physicsProcess );
35 |
36 | // var debugDraw:DebugDrawProcess = new DebugDrawProcess();
37 | // cadetScene.children.addItem( debugDraw );
38 |
39 | var rotatingRectangle:ComponentContainer = addRectangleEntity( 300, 0, 60, 60, 46 );
40 |
41 | // Create the floor. We pass 'true' as the 'fixed' property to make the floor static.
42 | addRectangleEntity( -200, stage.stageHeight-50, stage.stageWidth+200, 50, 0, true );
43 |
44 | addEventListener(Event.ENTER_FRAME, enterFrameHandler);
45 | }
46 |
47 | private function addRectangleEntity( x:Number, y:Number, width:Number, height:Number, rotation:Number, fixed:Boolean = false ):ComponentContainer
48 | {
49 | var transform:Transform2D = new Transform2D(x, y, rotation);
50 | var skin:GeometrySkin = new GeometrySkin();
51 |
52 | var entity:ComponentContainer = new ComponentContainer();
53 | entity.children.addItem( transform );
54 | entity.children.addItem( skin );
55 | entity.children.addItem( new RectangleGeometry(width, height) );
56 | entity.children.addItem( new RigidBodyBehaviour(fixed) );
57 | entity.children.addItem( new RigidBodyMouseDragBehaviour() );
58 |
59 | cadetScene.children.addItem(entity);
60 |
61 | return entity;
62 | }
63 |
64 | private function enterFrameHandler( event:Event ):void
65 | {
66 | cadetScene.step();
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------