|
@@ -9,7 +9,7 @@ package h3d.scene;
|
|
public var FAllocated = 0x20;
|
|
public var FAllocated = 0x20;
|
|
public var FAlwaysSync = 0x40;
|
|
public var FAlwaysSync = 0x40;
|
|
public var FInheritCulled = 0x80;
|
|
public var FInheritCulled = 0x80;
|
|
- public var FNoSerialize = 0x100;
|
|
|
|
|
|
+ public var FModelRoot = 0x100;
|
|
public var FIgnoreBounds = 0x200;
|
|
public var FIgnoreBounds = 0x200;
|
|
public var FIgnoreCollide = 0x400;
|
|
public var FIgnoreCollide = 0x400;
|
|
public var FIgnoreParentTransform = 0x800;
|
|
public var FIgnoreParentTransform = 0x800;
|
|
@@ -30,11 +30,11 @@ package h3d.scene;
|
|
It can be used to create a virtual container that does not display anything but can contain other objects
|
|
It can be used to create a virtual container that does not display anything but can contain other objects
|
|
so the various transforms are inherited to its children.
|
|
so the various transforms are inherited to its children.
|
|
**/
|
|
**/
|
|
-class Object implements hxd.impl.Serializable {
|
|
|
|
|
|
+class Object {
|
|
|
|
|
|
static inline var ROT2RAD = -0.017453292519943295769236907684886;
|
|
static inline var ROT2RAD = -0.017453292519943295769236907684886;
|
|
|
|
|
|
- @:s var flags : ObjectFlags;
|
|
|
|
|
|
+ var flags : ObjectFlags;
|
|
var children : Array<Object>;
|
|
var children : Array<Object>;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -50,37 +50,37 @@ class Object implements hxd.impl.Serializable {
|
|
/**
|
|
/**
|
|
The name of the object, can be used to retrieve an object within a tree by using `getObjectByName` (default null)
|
|
The name of the object, can be used to retrieve an object within a tree by using `getObjectByName` (default null)
|
|
**/
|
|
**/
|
|
- @:s public var name : Null<String>;
|
|
|
|
|
|
+ public var name : Null<String>;
|
|
|
|
|
|
/**
|
|
/**
|
|
The x position of the object relative to its parent.
|
|
The x position of the object relative to its parent.
|
|
**/
|
|
**/
|
|
- @:s public var x(default,set) : Float;
|
|
|
|
|
|
+ public var x(default,set) : Float;
|
|
|
|
|
|
/**
|
|
/**
|
|
The y position of the object relative to its parent.
|
|
The y position of the object relative to its parent.
|
|
**/
|
|
**/
|
|
- @:s public var y(default, set) : Float;
|
|
|
|
|
|
+ public var y(default, set) : Float;
|
|
|
|
|
|
/**
|
|
/**
|
|
The z position of the object relative to its parent.
|
|
The z position of the object relative to its parent.
|
|
**/
|
|
**/
|
|
- @:s public var z(default, set) : Float;
|
|
|
|
|
|
+ public var z(default, set) : Float;
|
|
|
|
|
|
/**
|
|
/**
|
|
The amount of scaling along the X axis of this object (default 1.0)
|
|
The amount of scaling along the X axis of this object (default 1.0)
|
|
**/
|
|
**/
|
|
- @:s public var scaleX(default,set) : Float;
|
|
|
|
|
|
+ public var scaleX(default,set) : Float;
|
|
|
|
|
|
/**
|
|
/**
|
|
The amount of scaling along the Y axis of this object (default 1.0)
|
|
The amount of scaling along the Y axis of this object (default 1.0)
|
|
**/
|
|
**/
|
|
- @:s public var scaleY(default, set) : Float;
|
|
|
|
|
|
+ public var scaleY(default, set) : Float;
|
|
|
|
|
|
/**
|
|
/**
|
|
The amount of scaling along the Z axis of this object (default 1.0)
|
|
The amount of scaling along the Z axis of this object (default 1.0)
|
|
**/
|
|
**/
|
|
- @:s public var scaleZ(default,set) : Float;
|
|
|
|
|
|
+ public var scaleZ(default,set) : Float;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -93,7 +93,7 @@ class Object implements hxd.impl.Serializable {
|
|
/**
|
|
/**
|
|
Follow a given object or joint as if it was our parent. Ignore defaultTransform when set.
|
|
Follow a given object or joint as if it was our parent. Ignore defaultTransform when set.
|
|
**/
|
|
**/
|
|
- @:s public var follow(default, set) : Object;
|
|
|
|
|
|
+ public var follow(default, set) : Object;
|
|
|
|
|
|
/**
|
|
/**
|
|
When follow is set, only follow the position and ignore both scale and rotation.
|
|
When follow is set, only follow the position and ignore both scale and rotation.
|
|
@@ -105,7 +105,7 @@ class Object implements hxd.impl.Serializable {
|
|
It is used by the animation system.
|
|
It is used by the animation system.
|
|
**/
|
|
**/
|
|
public var defaultTransform(default, set) : h3d.Matrix;
|
|
public var defaultTransform(default, set) : h3d.Matrix;
|
|
- @:s public var currentAnimation(default, null) : h3d.anim.Animation;
|
|
|
|
|
|
+ public var currentAnimation(default, null) : h3d.anim.Animation;
|
|
|
|
|
|
/**
|
|
/**
|
|
Inform that the object is not to be displayed and his animation doesn't have to be sync. Unlike visible, this doesn't apply to children unless inheritCulled is set to true.
|
|
Inform that the object is not to be displayed and his animation doesn't have to be sync. Unlike visible, this doesn't apply to children unless inheritCulled is set to true.
|
|
@@ -133,9 +133,9 @@ class Object implements hxd.impl.Serializable {
|
|
public var ignoreCollide(get, set) : Bool;
|
|
public var ignoreCollide(get, set) : Bool;
|
|
|
|
|
|
/**
|
|
/**
|
|
- When enabled, the object can be serialized (default : true)
|
|
|
|
|
|
+ Tag the object as a model root
|
|
**/
|
|
**/
|
|
- public var allowSerialize(get, set) : Bool;
|
|
|
|
|
|
+ public var modelRoot(get, set) : Bool;
|
|
|
|
|
|
/**
|
|
/**
|
|
When enabled, the object will not follow its parent transform
|
|
When enabled, the object will not follow its parent transform
|
|
@@ -196,7 +196,7 @@ class Object implements hxd.impl.Serializable {
|
|
inline function get_inheritCulled() return flags.has(FInheritCulled);
|
|
inline function get_inheritCulled() return flags.has(FInheritCulled);
|
|
inline function get_ignoreBounds() return flags.has(FIgnoreBounds);
|
|
inline function get_ignoreBounds() return flags.has(FIgnoreBounds);
|
|
inline function get_ignoreCollide() return flags.has(FIgnoreCollide);
|
|
inline function get_ignoreCollide() return flags.has(FIgnoreCollide);
|
|
- inline function get_allowSerialize() return !flags.has(FNoSerialize);
|
|
|
|
|
|
+ inline function get_modelRoot() return !flags.has(FModelRoot);
|
|
inline function get_ignoreParentTransform() return flags.has(FIgnoreParentTransform);
|
|
inline function get_ignoreParentTransform() return flags.has(FIgnoreParentTransform);
|
|
inline function get_cullingColliderInherited() return flags.has(FCullingColliderInherited);
|
|
inline function get_cullingColliderInherited() return flags.has(FCullingColliderInherited);
|
|
inline function set_posChanged(b) return flags.set(FPosChanged, b || follow != null);
|
|
inline function set_posChanged(b) return flags.set(FPosChanged, b || follow != null);
|
|
@@ -209,7 +209,7 @@ class Object implements hxd.impl.Serializable {
|
|
inline function set_ignoreBounds(b) return flags.set(FIgnoreBounds, b);
|
|
inline function set_ignoreBounds(b) return flags.set(FIgnoreBounds, b);
|
|
inline function set_inheritCulled(b) return flags.set(FInheritCulled, b);
|
|
inline function set_inheritCulled(b) return flags.set(FInheritCulled, b);
|
|
inline function set_ignoreCollide(b) return flags.set(FIgnoreCollide, b);
|
|
inline function set_ignoreCollide(b) return flags.set(FIgnoreCollide, b);
|
|
- inline function set_allowSerialize(b) return !flags.set(FNoSerialize, !b);
|
|
|
|
|
|
+ inline function set_modelRoot(b) return !flags.set(FModelRoot, !b);
|
|
inline function set_ignoreParentTransform(b) { if( b != ignoreParentTransform ) posChanged = true; return flags.set(FIgnoreParentTransform, b); }
|
|
inline function set_ignoreParentTransform(b) { if( b != ignoreParentTransform ) posChanged = true; return flags.set(FIgnoreParentTransform, b); }
|
|
inline function set_cullingColliderInherited(b) return flags.set(FCullingColliderInherited, b);
|
|
inline function set_cullingColliderInherited(b) return flags.set(FCullingColliderInherited, b);
|
|
|
|
|
|
@@ -968,74 +968,4 @@ class Object implements hxd.impl.Serializable {
|
|
return new hxd.impl.ArrayIterator(children);
|
|
return new hxd.impl.ArrayIterator(children);
|
|
}
|
|
}
|
|
|
|
|
|
- #if (hxbit && !macro && heaps_enable_serialize)
|
|
|
|
- function customSerialize( ctx : hxbit.Serializer ) {
|
|
|
|
-
|
|
|
|
- var children = [for( o in children ) if( o.allowSerialize ) o];
|
|
|
|
- ctx.addInt(children.length);
|
|
|
|
- for( o in children )
|
|
|
|
- ctx.addKnownRef(o);
|
|
|
|
- ctx.addDouble(qRot.x);
|
|
|
|
- ctx.addDouble(qRot.y);
|
|
|
|
- ctx.addDouble(qRot.z);
|
|
|
|
- ctx.addDouble(qRot.w);
|
|
|
|
-
|
|
|
|
- ctx.addBool(defaultTransform != null);
|
|
|
|
- if( defaultTransform != null ) {
|
|
|
|
- ctx.addFloat(defaultTransform._11);
|
|
|
|
- ctx.addFloat(defaultTransform._12);
|
|
|
|
- ctx.addFloat(defaultTransform._13);
|
|
|
|
- ctx.addFloat(defaultTransform._21);
|
|
|
|
- ctx.addFloat(defaultTransform._22);
|
|
|
|
- ctx.addFloat(defaultTransform._23);
|
|
|
|
- ctx.addFloat(defaultTransform._31);
|
|
|
|
- ctx.addFloat(defaultTransform._32);
|
|
|
|
- ctx.addFloat(defaultTransform._33);
|
|
|
|
- ctx.addFloat(defaultTransform._41);
|
|
|
|
- ctx.addFloat(defaultTransform._42);
|
|
|
|
- ctx.addFloat(defaultTransform._43);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- static var COUNT = 0;
|
|
|
|
-
|
|
|
|
- function customUnserialize( ctx : hxbit.Serializer ) {
|
|
|
|
- children = [for( i in 0...ctx.getInt() ) ctx.getKnownRef(Object)];
|
|
|
|
- qRot = new h3d.Quat(ctx.getDouble(), ctx.getDouble(), ctx.getDouble(), ctx.getDouble());
|
|
|
|
-
|
|
|
|
- if( ctx.getBool() ) {
|
|
|
|
- defaultTransform = new h3d.Matrix();
|
|
|
|
- defaultTransform.loadValues([
|
|
|
|
- ctx.getFloat(),
|
|
|
|
- ctx.getFloat(),
|
|
|
|
- ctx.getFloat(),
|
|
|
|
- 0,
|
|
|
|
- ctx.getFloat(),
|
|
|
|
- ctx.getFloat(),
|
|
|
|
- ctx.getFloat(),
|
|
|
|
- 0,
|
|
|
|
- ctx.getFloat(),
|
|
|
|
- ctx.getFloat(),
|
|
|
|
- ctx.getFloat(),
|
|
|
|
- 0,
|
|
|
|
- ctx.getFloat(),
|
|
|
|
- ctx.getFloat(),
|
|
|
|
- ctx.getFloat(),
|
|
|
|
- 1
|
|
|
|
- ]);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // init
|
|
|
|
- for( c in children )
|
|
|
|
- c.parent = this;
|
|
|
|
- allocated = false;
|
|
|
|
- posChanged = true;
|
|
|
|
- absPos = new h3d.Matrix();
|
|
|
|
- absPos.identity();
|
|
|
|
- if( currentAnimation != null )
|
|
|
|
- @:privateAccess currentAnimation.initAndBind(this);
|
|
|
|
- }
|
|
|
|
- #end
|
|
|
|
-
|
|
|
|
}
|
|
}
|