Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit f5da0dc9887debc04e2692e29cfe97e7caea43c0 @jgranick committed Jan 17, 2012
Showing with 19,969 additions and 0 deletions.
  1. +142 −0 away3dlite/animators/BonesAnimator.hx
  2. +195 −0 away3dlite/animators/MovieMesh.hx
  3. +133 −0 away3dlite/animators/bones/Bone.hx
  4. +175 −0 away3dlite/animators/bones/Channel.hx
  5. +74 −0 away3dlite/animators/bones/SkinController.hx
  6. +59 −0 away3dlite/animators/bones/SkinVertex.hx
  7. +41 −0 away3dlite/animators/frames/Frame.hx
  8. +199 −0 away3dlite/cameras/Camera3D.hx
  9. +154 −0 away3dlite/cameras/HoverCamera3D.hx
  10. +42 −0 away3dlite/cameras/TargetCamera3D.hx
  11. +33 −0 away3dlite/cameras/lenses/AbstractLens.hx
  12. +30 −0 away3dlite/cameras/lenses/OrthogonalLens.hx
  13. +35 −0 away3dlite/cameras/lenses/PerspectiveLens.hx
  14. +42 −0 away3dlite/cameras/lenses/ZoomFocusLens.hx
  15. +422 −0 away3dlite/containers/ObjectContainer3D.hx
  16. +153 −0 away3dlite/containers/Scene3D.hx
  17. +572 −0 away3dlite/containers/View3D.hx
  18. +360 −0 away3dlite/core/base/Face.hx
  19. +378 −0 away3dlite/core/base/Mesh.hx
  20. +390 −0 away3dlite/core/base/Object3D.hx
  21. +24 −0 away3dlite/core/base/SortType.hx
  22. +447 −0 away3dlite/core/clip/Clipping.hx
  23. +91 −0 away3dlite/core/clip/RectangleClipping.hx
  24. +260 −0 away3dlite/core/render/BasicRenderer.hx
  25. +195 −0 away3dlite/core/render/FastRenderer.hx
  26. +255 −0 away3dlite/core/render/Renderer.hx
  27. +214 −0 away3dlite/core/utils/Cast.hx
  28. +84 −0 away3dlite/core/utils/Debug.hx
  29. +829 −0 away3dlite/debug/AwayStats.hx
  30. +45 −0 away3dlite/events/ClippingEvent.hx
  31. +1 −0 away3dlite/events/Loader3DEvent.hx
  32. +75 −0 away3dlite/events/MaterialEvent.hx
  33. +138 −0 away3dlite/events/MouseEvent3D.hx
  34. +1 −0 away3dlite/events/ParserEvent.hx
  35. +11 −0 away3dlite/haxeutils/FastReflect.hx
  36. +39 −0 away3dlite/haxeutils/FastStd.hx
  37. +108 −0 away3dlite/haxeutils/HaxeUtils.hx
  38. +123 −0 away3dlite/haxeutils/MathUtils.hx
  39. +75 −0 away3dlite/haxeutils/ResourceLoader.hx
  40. +206 −0 away3dlite/haxeutils/xml/E4X.hx
  41. +52 −0 away3dlite/lights/AbstractLight3D.hx
  42. +139 −0 away3dlite/lights/DirectionalLight3D.hx
  43. +110 −0 away3dlite/lights/PointLight3D.hx
  44. +330 −0 away3dlite/loaders/AWData.hx
  45. +334 −0 away3dlite/loaders/AbstractParser.hx
  46. +1,417 −0 away3dlite/loaders/Collada.hx
  47. +1 −0 away3dlite/loaders/Loader3D.hx
  48. +1 −0 away3dlite/loaders/MD2.hx
  49. +544 −0 away3dlite/loaders/MQO.hx
  50. +1 −0 away3dlite/loaders/Max3DS.hx
  51. +81 −0 away3dlite/loaders/data/AnimationData.hx
  52. +20 −0 away3dlite/loaders/data/BoneData.hx
  53. +37 −0 away3dlite/loaders/data/ChannelData.hx
  54. +54 −0 away3dlite/loaders/data/ContainerData.hx
  55. +52 −0 away3dlite/loaders/data/FaceData.hx
  56. +117 −0 away3dlite/loaders/data/GeometryData.hx
  57. +164 −0 away3dlite/loaders/data/MaterialData.hx
  58. +41 −0 away3dlite/loaders/data/MeshData.hx
  59. +22 −0 away3dlite/loaders/data/MeshMaterialData.hx
  60. +44 −0 away3dlite/loaders/data/ObjectData.hx
  61. +1 −0 away3dlite/loaders/utils/AnimationLibrary.hx
  62. +1 −0 away3dlite/loaders/utils/ChannelLibrary.hx
  63. +1 −0 away3dlite/loaders/utils/GeometryLibrary.hx
  64. +1 −0 away3dlite/loaders/utils/MaterialLibrary.hx
  65. +200 −0 away3dlite/loaders/utils/TextureLoadQueue.hx
  66. +24 −0 away3dlite/loaders/utils/TextureLoader.hx
  67. +86 −0 away3dlite/materials/BitmapFileMaterial.hx
  68. +90 −0 away3dlite/materials/BitmapMaterial.hx
  69. +81 −0 away3dlite/materials/ColorMaterial.hx
  70. +218 −0 away3dlite/materials/Dot3BitmapMaterial.hx
  71. +135 −0 away3dlite/materials/Material.hx
  72. +156 −0 away3dlite/materials/MovieMaterial.hx
  73. +99 −0 away3dlite/materials/WireColorMaterial.hx
  74. +80 −0 away3dlite/materials/WireframeMaterial.hx
  75. +357 −0 away3dlite/namespace/Arcane.hx
  76. +76 −0 away3dlite/primitives/AbstractPrimitive.hx
  77. +274 −0 away3dlite/primitives/Cone.hx
  78. +1 −0 away3dlite/primitives/Cube6.hx
  79. +266 −0 away3dlite/primitives/Cylinder.hx
  80. +89 −0 away3dlite/primitives/LineSegment.hx
  81. +194 −0 away3dlite/primitives/Plane.hx
  82. +1 −0 away3dlite/primitives/RegularPolygon.hx
  83. +1 −0 away3dlite/primitives/Skybox6.hx
  84. +213 −0 away3dlite/primitives/Sphere.hx
  85. +204 −0 away3dlite/primitives/Torus.hx
  86. +84 −0 away3dlite/primitives/Trident.hx
  87. +19 −0 away3dlite/sprites/AlignmentType.hx
  88. +243 −0 away3dlite/sprites/Sprite3D.hx
  89. +29 −0 away3dlite/templates/BasicTemplate.hx
  90. +36 −0 away3dlite/templates/FastTemplate.hx
  91. +179 −0 away3dlite/templates/Template.hx
  92. +30 −0 away3dlite/templates/events/Keyboard3DEvent.as
  93. +265 −0 away3dlite/templates/ui/Keyboard3D.as
  94. +11 −0 examples/build/Advanced_Mario1000.hxml
  95. +14 −0 examples/build/Advanced_MultiMario.hxml
  96. +9 −0 examples/build/Basic_InteractiveObjects.hxml
  97. +13 −0 examples/build/Basic_LoadModel.hxml
  98. +7 −0 examples/build/ExCamera.hxml
  99. +9 −0 examples/build/ExCollada.hxml
  100. +9 −0 examples/build/ExLayer.hxml
  101. +10 −0 examples/build/ExLight.hxml
  102. +9 −0 examples/build/ExMD2Cubic.hxml
  103. +9 −0 examples/build/ExMQO.hxml
  104. +9 −0 examples/build/ExSphereSpeedTest.hxml
  105. +436 −0 examples/src/Advanced_Mario1000.hx
  106. BIN examples/src/Advanced_Mario1000.swf
  107. +482 −0 examples/src/Advanced_MultiMario.hx
  108. BIN examples/src/Advanced_MultiMario.swf
  109. +275 −0 examples/src/Basic_InteractiveObjects.hx
  110. +333 −0 examples/src/Basic_LoadModel.hx
  111. BIN examples/src/Basic_LoadModel.swf
  112. +71 −0 examples/src/ExCamera.hx
  113. BIN examples/src/ExCamera.swf
  114. +162 −0 examples/src/ExCollada.hx
  115. BIN examples/src/ExCollada.swf
  116. +126 −0 examples/src/ExLayer.hx
  117. BIN examples/src/ExLayer.swf
  118. +88 −0 examples/src/ExLight.hx
  119. BIN examples/src/ExLight.swf
  120. +157 −0 examples/src/ExMD2Cubic.hx
  121. BIN examples/src/ExMD2Cubic.swf
  122. +168 −0 examples/src/ExMQO.hx
  123. BIN examples/src/ExMQO.swf
  124. +162 −0 examples/src/ExSphereSpeedTest.hx
  125. BIN examples/src/ExSphereSpeedTest.swf
  126. BIN examples/src/assets/Earth2.jpg
  127. BIN examples/src/assets/Messerschmitt_Bf_109.jpg
  128. +1,245 −0 examples/src/assets/Messerschmitt_Bf_109.mqo
  129. BIN examples/src/assets/MoonNormal.jpg
  130. BIN examples/src/assets/blue.jpg
  131. +183 −0 examples/src/assets/chameleon.dae
  132. BIN examples/src/assets/earth.jpg
  133. BIN examples/src/assets/f360.3ds
  134. BIN examples/src/assets/floor.jpg
  135. BIN examples/src/assets/fskin.jpg
  136. BIN examples/src/assets/fsking.jpg
  137. BIN examples/src/assets/fskingr.jpg
  138. BIN examples/src/assets/fskiny.jpg
  139. BIN examples/src/assets/green.jpg
  140. +1,638 −0 examples/src/assets/mario_testrun.dae
  141. BIN examples/src/assets/mario_tex.jpg
  142. BIN examples/src/assets/moon.jpg
  143. BIN examples/src/assets/normalmap.jpg
  144. BIN examples/src/assets/peterskybox1.jpg
  145. BIN examples/src/assets/peterskybox2.jpg
  146. BIN examples/src/assets/pg.md2
  147. BIN examples/src/assets/pg.png
  148. BIN examples/src/assets/position.png
  149. BIN examples/src/assets/red.jpg
  150. BIN examples/src/assets/shadow.png
  151. BIN examples/src/assets/signature_lite.fla
  152. BIN examples/src/assets/signature_lite.swf
  153. BIN examples/src/assets/signature_lite_katopz.fla
  154. BIN examples/src/assets/signature_lite_katopz.swf
  155. BIN examples/src/assets/signature_lite_peter.fla
  156. BIN examples/src/assets/signature_lite_peter.swf
  157. BIN examples/src/assets/stars.jpg
  158. BIN examples/src/assets/texture0.jpg
  159. BIN examples/src/assets/torso_marble256.jpg
  160. BIN examples/src/assets/torso_normal_256.jpg
  161. BIN examples/src/assets/torsov2.MD2
  162. BIN examples/src/assets/yellow.jpg
  163. +8 −0 haxelib.xml
  164. +181 −0 net/hires/debug/Stats.hx
@@ -0,0 +1,142 @@
+//OK
+
+package away3dlite.animators;
+import away3dlite.animators.bones.Channel;
+import away3dlite.animators.bones.SkinController;
+import away3dlite.animators.bones.SkinVertex;
+import away3dlite.containers.ObjectContainer3D;
+import away3dlite.core.utils.Debug;
+import flash.utils.TypedDictionary;
+import flash.Vector;
+
+/**
+ * hold the animation information for a bones animation imported from a collada object
+ *
+ * @see away3dlite.loaders.Collada
+ */
+class BonesAnimator
+{
+ private var _channels:Vector<Channel>;
+ private var _skinControllers:Vector<SkinController>;
+ private var _skinController:SkinController;
+ private var _skinVertices:Vector<SkinVertex>;
+ private var _uniqueSkinVertices:TypedDictionary<SkinVertex, Int>;
+ private var _skinVertex:SkinVertex;
+
+ /**
+ * Defines wether the animation will loop
+ */
+ public var loop:Bool;
+
+ /**
+ * Defines the total length of the animation in seconds
+ */
+ public var length:Float;
+
+ /**
+ * Defines the start of the animation in seconds
+ */
+ public var start:Float;
+
+ public function new()
+ {
+ Debug.trace(" + bonesAnimator");
+ _channels = new Vector<Channel>();
+ _skinControllers = new Vector<SkinController>();
+ _skinVertices = new Vector<SkinVertex>();
+ _uniqueSkinVertices = new TypedDictionary<SkinVertex, Int>(true);
+ loop = true;
+ length = 0;
+ }
+
+ /**
+ * Updates all channels in the animation with the given time in seconds.
+ *
+ * @param time Defines the time in seconds of the playhead of the animation.
+ * @param interpolate [optional] Defines whether the animation interpolates between channel points Defaults to true.
+ */
+ public function update(time:Float, ?interpolate:Bool = true):Void
+ {
+ if (time > start + length ) {
+ if (loop) {
+ time = start + (time - start) % length;
+ }else{
+ time = start + length;
+ }
+ } else if (time < start) {
+ if (loop) {
+ time = start + (time - start) % length + length;
+ }else{
+ time = start;
+ }
+ }
+
+ // ensure vertex list is populated
+ if (!_skinVertices.fixed)
+ populateVertices();
+
+ //update channels
+ for (channel in _channels)
+ channel.update(time, interpolate);
+
+ //update skincontrollers
+ for (_skinController in _skinControllers)
+ _skinController.update();
+
+ //update skinvertices
+ for (_skinVertex in _skinVertices)
+ _skinVertex.update();
+ }
+
+ /**
+ * Populates the skin vertex list from the set of unique vertices
+ */
+ public function populateVertices():Void
+ {
+ _skinVertices.fixed = false;
+ for (skinVertex in _uniqueSkinVertices.keys())
+ _skinVertices.push(skinVertex);
+
+ _skinVertices.fixed = true;
+ }
+
+ /**
+ * Clones the animation data into a new <code>BonesAnimator</code> object.
+ */
+ public function clone(object:ObjectContainer3D):BonesAnimator
+ {
+ var bonesAnimator:BonesAnimator = new BonesAnimator();
+
+ bonesAnimator.loop = loop;
+ bonesAnimator.length = length;
+ bonesAnimator.start = start;
+
+ for (channel in _channels)
+ bonesAnimator.addChannel(channel.clone(object));
+
+ _skinVertices.fixed = false;
+ return bonesAnimator;
+ }
+
+ /**
+ * Adds an animation channel to the animation timeline.
+ */
+ public function addChannel(channel:Channel):Void
+ {
+ _channels.push(channel);
+ }
+
+ /**
+ * Adds a <code>SkinController</code> and all associated <code>SkinVertex</code> objects to the animation.
+ */
+ public function addSkinController(skinController:SkinController):Void
+ {
+ if (_skinControllers.indexOf(skinController) != -1)
+ return;
+
+ _skinControllers.push(skinController);
+
+ for (_skinVertex in skinController.skinVertices)
+ _uniqueSkinVertices.set(_skinVertex, 1);
+ }
+}
@@ -0,0 +1,195 @@
+//OK
+//?
+
+package away3dlite.animators;
+import away3dlite.animators.frames.Frame;
+import away3dlite.core.base.Mesh;
+import flash.events.Event;
+import flash.Lib;
+import flash.Vector;
+
+
+//use namespace arcane;
+
+/**
+ * Animates a series of <code>Frame</code> objects in sequence in a mesh.
+ */
+class MovieMesh extends Mesh
+{
+ /*
+ * Three kinds of animation sequences:
+ * [1] Normal (sequential, just playing)
+ * [2] Loop (a loop)
+ * [3] Stop (stopped, not animating)
+ */
+ public static inline var ANIM_NORMAL:Int = 1;
+ public static inline var ANIM_LOOP:Int = 2;
+ public static inline var ANIM_STOP:Int = 4;
+ private var framesLength:Int;
+
+ //Keep track of the current frame number and animation
+ private var _currentFrame:Int;
+ private var _addFrame:Int;
+ private var _interp:Float;
+ private var _begin:Int;
+ private var _end:Int;
+ private var _type:Int;
+ private var _ctime:Float;
+ private var _otime:Float;
+
+ private var labels:Hash<Keyframe>;
+ private var _currentLabel:String;
+
+ private function onEnterFrame(?event:Event):Void
+ {
+ _ctime = Lib.getTimer();
+
+ var cframe:Frame;
+ var nframe:Frame;
+ var i:Int = _vertices.length;
+
+ cframe = frames[_currentFrame];
+ nframe = frames[(_currentFrame + 1) % framesLength];
+
+ // TODO : optimize
+ var _cframe_vertices:Vector<Float> = cframe.vertices;
+ var _nframe_vertices:Vector<Float> = nframe.vertices;
+
+ while (i-- != 0)
+ _vertices[i] = _cframe_vertices[i] + _interp*(_nframe_vertices[i] - _cframe_vertices[i]);
+
+ if (_type != ANIM_STOP) {
+ _interp += fps * (_ctime - _otime) / 1000;
+
+ if (_interp > 1) {
+ _addFrame = Std.int(_interp);
+
+ if (_type == ANIM_LOOP && _currentFrame + _addFrame >= _end)
+ keyframe = _begin + _currentFrame + _addFrame - _end;
+ else
+ keyframe += _addFrame;
+
+ _interp -= _addFrame;
+ }
+ }
+ _otime = _ctime;
+ }
+
+ /**
+ * Number of animation frames to display per second
+ */
+ public var fps:Int;
+
+ /**
+ * The array of frames that make up the animation sequence.
+ */
+ public var frames:Vector<Frame>;
+
+ /**
+ * Creates a new <code>MovieMesh</code> object that provides a "keyframe animation"/"vertex animation"/"mesh deformation" framework for subclass loaders.
+ */
+ public function new()
+ {
+ super();
+
+ frames = new Vector<Frame>();
+ fps = 24;
+ framesLength = 0;
+ _currentFrame = 0;
+ _interp = 0;
+ _ctime = 0;
+ _otime = 0;
+ labels = new Hash<Keyframe>();
+ }
+
+ /**
+ * Adds a new frame to the animation timeline.
+ */
+ public function addFrame(frame:Frame):Void
+ {
+ //var _name:String = frame.name.slice(0, frame.name.length - 3);
+ //HAXE_EQ
+ var _name = frame.name.substr(0, frame.name.length - 3);
+
+ if (!labels.exists(_name))
+ labels.set(_name, { begin:framesLength, end:framesLength } );
+ else
+ {
+ //HAXE_MODIFYIED
+ //MUST_OPTIMIZE
+ var label = labels.get(_name);
+ label.end++;
+ labels.set(_name, label);
+ }
+
+ frames.push(frame);
+
+ framesLength++;
+ }
+
+ /**
+ * Begins a looping sequence in the animation.
+ *
+ * @param begin The starting frame position.
+ * @param end The ending frame position.
+ */
+ public function loop(begin:Int, end:Int):Void
+ {
+ if (framesLength > 0) {
+ _begin = (begin % framesLength);
+ _end = (end % framesLength);
+ } else {
+ _begin = begin;
+ _end = end;
+ }
+
+ keyframe = begin;
+ _type = ANIM_LOOP;
+
+ addEventListener(Event.ENTER_FRAME, onEnterFrame);
+ }
+
+ /**
+ * Plays a pre-defined labelled sequence of animation frames.
+ */
+ public function play(?label:String = ""):Void
+ {
+ //HAXE_MOD
+ if (labels == null)
+ return;
+
+ if (_currentLabel != label) {
+ _currentLabel = label;
+ var keylabel = labels.get(label);
+ loop(keylabel.begin, keylabel.end);
+ }
+
+ addEventListener(Event.ENTER_FRAME, onEnterFrame);
+ }
+
+ /**
+ * Stops the animation.
+ */
+ public function stop():Void
+ {
+ _type = ANIM_STOP;
+
+ removeEventListener(Event.ENTER_FRAME, onEnterFrame);
+ }
+
+ /**
+ * Defines the current keyframe.
+ */
+ public var keyframe(get_keyframe, set_keyframe):Int;
+ private inline function get_keyframe():Int
+ {
+ return _currentFrame;
+ }
+
+ private function set_keyframe(i:Int):Int
+ {
+ return _currentFrame = i % framesLength;
+ }
+}
+
+typedef Keyframe = { begin:Int, end:Int };
Oops, something went wrong.

0 comments on commit f5da0dc

Please sign in to comment.