Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

2.0b IVertexStream.name property and related methods #42

Closed
wants to merge 1 commit into from

2 participants

@osmetanin

I found it useful to have names on IVertexStream objects. For example, to identify animation keyframes. Thus, I've added name property and getStreamByName() method to IVertexStream interface and VertexStream/VertexStreamList classes. Also I've added getVertexStreamByName() and getVertexStreamIndex() methods to Geometry class to easily retrieve vertex stream or its index by name. Hope you'll find it useful too.

@osmetanin osmetanin Added name property and getStreamByName() method to IVertexStream obj…
…ects. Also added getVertexStreamByName() and getVertexStreamIndex() methods to Geometry class
f422157
@promethe42
Owner

Thank you for your feedback!

For example, to identify animation keyframes

Animation keyframes should be done the same way they are done with skinning. You should use TimeLabel and add them a Scalar(Regular)Timeline. That's the way it will be implemented in Minko Studio and we'd rather not provide two ways to do the same thing.

Other things - such as scripting - will interact closely with animations. Therefore, we want to make sure the animation method (skinning vs morphing) does not imply anything on the scripts. And it means that we have to make sure they can both be driven using the same API.

Sorry mate :)

@promethe42 promethe42 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 15, 2012
  1. @osmetanin

    Added name property and getStreamByName() method to IVertexStream obj…

    osmetanin authored
    …ects. Also added getVertexStreamByName() and getVertexStreamIndex() methods to Geometry class
This page is out of date. Refresh to see the latest.
View
34 src/aerys/minko/scene/node/mesh/geometry/Geometry.as
@@ -232,6 +232,40 @@ package aerys.minko.scene.node.mesh.geometry
_vertexStreams[index] = vertexStream;
}
+ /**
+ * Get the IVertexStream objects by name. If there is no such stream, returns null.
+ *
+ * @param name
+ * @return
+ */
+ public function getVertexStreamByName(name : String) : IVertexStream
+ {
+ for (var i : int = 0, n : int = _vertexStreams.length; i < n; i++)
+ {
+ var stream : IVertexStream = _vertexStreams[i].getStreamByName(name);
+
+ if (stream != null)
+ return stream;
+ }
+
+ return null;
+ }
+
+ /**
+ * Get the index of a named IVertexStream object. If there is no such stream, returns -1.
+ *
+ * @param name
+ * @return
+ */
+ public function getVertexStreamIndex(name : String) : int
+ {
+ for (var i : int = 0, n : int = _vertexStreams.length; i < n; i++)
+ if (_vertexStreams[i].getStreamByName(name))
+ return i;
+
+ return -1;
+ }
+
private function vertexStreamBoundsChangedHandler(stream : IVertexStream) : void
{
updateBoundingVolumes();
View
4 src/aerys/minko/type/stream/IVertexStream.as
@@ -6,6 +6,7 @@ package aerys.minko.type.stream
public interface IVertexStream
{
+ function get name() : String;
function get format() : VertexFormat;
function get length() : uint;
@@ -15,6 +16,7 @@ package aerys.minko.type.stream
function disposeLocalData(waitForUpload : Boolean = true) : void;
function deleteVertexByIndex(index : uint) : Boolean;
function getStreamByComponent(component : VertexComponent) : VertexStream;
+ function getStreamByName(name : String) : IVertexStream;
function dispose() : void;
}
-}
+}
View
16 src/aerys/minko/type/stream/VertexStream.as
@@ -22,6 +22,7 @@ package aerys.minko.type.stream
minko_stream var _data : Vector.<Number> = null;
minko_stream var _localDispose : Boolean = false;
+ private var _name : String = null;
private var _usage : uint = 0;
private var _format : VertexFormat = null;
private var _resource : VertexBuffer3DResource = null;
@@ -39,6 +40,16 @@ package aerys.minko.type.stream
private var _changed : Signal = new Signal('VertexStream.changed');
private var _boundsChanged : Signal = new Signal('VertexStream.boundsChanged');
+ public function get name() : String
+ {
+ return _name;
+ }
+
+ public function set name(val : String) : void
+ {
+ _name = val;
+ }
+
public function get format() : VertexFormat
{
return _format;
@@ -192,6 +203,11 @@ package aerys.minko.type.stream
{
return _format.hasComponent(vertexComponent) ? this : null;
}
+
+ public function getStreamByName(name : String) : IVertexStream
+ {
+ return _name == name ? this : null;
+ }
public function get(i : uint) : Number
{
View
33 src/aerys/minko/type/stream/VertexStreamList.as
@@ -9,6 +9,7 @@ package aerys.minko.type.stream
{
use namespace minko_stream;
+ private var _name : String = null;
private var _streams : Vector.<VertexStream> = new Vector.<VertexStream>();
private var _format : VertexFormat = new VertexFormat();
private var _usage : uint = 0;
@@ -16,6 +17,16 @@ package aerys.minko.type.stream
private var _changed : Signal = new Signal('VertexStreamList.changed');
private var _boundsChanged : Signal = new Signal('VertexStream.boundsChanged');
+ public function get name() : String
+ {
+ return _name;
+ }
+
+ public function set name(val : String) : void
+ {
+ _name = val;
+ }
+
public function get usage() : uint
{
return _usage;
@@ -95,6 +106,26 @@ package aerys.minko.type.stream
return null;
}
+
+ public function getStreamByName(name : String) : IVertexStream
+ {
+ if (_name == name)
+ {
+ return this;
+ }
+ else
+ {
+ for (var i : int = 0, n : int = _streams.length; i < n; i++)
+ {
+ var stream : IVertexStream = _streams[i].getStreamByName(name);
+
+ if (stream != null)
+ return stream;
+ }
+ }
+
+ return null;
+ }
public function getVertexStream(id : int = 0) : VertexStream
{
@@ -134,4 +165,4 @@ package aerys.minko.type.stream
_boundsChanged.execute(this);
}
}
-}
+}
Something went wrong with that request. Please try again.