forked from LeenkxTeam/LNXSDK
Repe [T3DU] Update - 31f26d171bba0355ce2a77031e3aad4c64dbc7e9
This commit is contained in:
@ -14,6 +14,7 @@ import iron.object.SpeakerObject;
|
||||
import iron.object.DecalObject;
|
||||
import iron.object.ProbeObject;
|
||||
import iron.object.Tilesheet;
|
||||
import iron.object.CurveObject;
|
||||
import iron.data.CameraData;
|
||||
import iron.data.MeshData;
|
||||
import iron.data.LightData;
|
||||
@ -64,6 +65,7 @@ class Scene {
|
||||
#end
|
||||
public var empties: Array<Object>;
|
||||
public var animations: Array<Animation>;
|
||||
public var tilesheets: Array<Tilesheet>;
|
||||
#if lnx_skin
|
||||
public var armatures: Array<Armature>;
|
||||
#end
|
||||
@ -110,6 +112,7 @@ class Scene {
|
||||
#end
|
||||
empties = [];
|
||||
animations = [];
|
||||
tilesheets = [];
|
||||
#if lnx_skin
|
||||
armatures = [];
|
||||
#end
|
||||
@ -135,6 +138,14 @@ class Scene {
|
||||
|
||||
// Startup scene
|
||||
active.addScene(format.name, null, function(sceneObject: Object) {
|
||||
|
||||
if (format.properties != null) {
|
||||
sceneObject.properties = new Map();
|
||||
for (p in format.properties) {
|
||||
sceneObject.properties.set(p.name, cleanValue(p.value));
|
||||
}
|
||||
}
|
||||
|
||||
// Create traits bottom-up (children first, then parents)
|
||||
createTraitsBottomUp(sceneObject);
|
||||
|
||||
@ -342,6 +353,7 @@ class Scene {
|
||||
if (terrainStream != null) terrainStream.update(active.camera);
|
||||
#end
|
||||
for (anim in animations) anim.update(Time.delta);
|
||||
for (tilesheet in tilesheets) tilesheet.update();
|
||||
for (e in empties) if (e != null && e.parent != null) e.transform.update();
|
||||
}
|
||||
|
||||
@ -441,6 +453,11 @@ class Scene {
|
||||
return g;
|
||||
}
|
||||
|
||||
public function removeFromGroups(object: Object) {
|
||||
if (groups == null) return;
|
||||
for (name in groups.keys()) getGroup(name).remove(object);
|
||||
}
|
||||
|
||||
public function addMeshObject(data: MeshData, materials: Vector<MaterialData>, parent: Object = null): MeshObject {
|
||||
var object = new MeshObject(data, materials);
|
||||
parent != null ? object.setParent(parent) : object.setParent(root);
|
||||
@ -450,6 +467,12 @@ class Scene {
|
||||
return object;
|
||||
}
|
||||
|
||||
public function addCurveObject(data: TCurveData, parent: Object = null): CurveObject {
|
||||
var object = new CurveObject(data);
|
||||
parent != null ? object.setParent(parent) : object.setParent(root);
|
||||
return object;
|
||||
}
|
||||
|
||||
public function addLightObject(data: LightData, parent: Object = null): LightObject {
|
||||
var object = new LightObject(data);
|
||||
parent != null ? object.setParent(parent) : object.setParent(root);
|
||||
@ -709,6 +732,10 @@ class Scene {
|
||||
else done(ro);
|
||||
});
|
||||
}
|
||||
else if (o.type == "curve_object") {
|
||||
var object = addCurveObject(Data.getCurveRawByName(format.curve_datas, o.data_ref), parent);
|
||||
returnObject(object, o, done);
|
||||
}
|
||||
else done(null);
|
||||
}
|
||||
|
||||
@ -889,11 +916,13 @@ class Scene {
|
||||
}
|
||||
else { #end // lnx_skin
|
||||
#if lnx_stream
|
||||
streamMeshObject(
|
||||
if ((o.particle_refs == null || o.particle_refs.length == 0) && o.is_particle == null && parent != null)
|
||||
streamMeshObject(object_file, data_ref, sceneName, null, materials, parent, parentObject, o, done);
|
||||
else
|
||||
returnMeshObject(object_file, data_ref, sceneName, null, materials, parent, parentObject, o, done);
|
||||
#else
|
||||
returnMeshObject(
|
||||
returnMeshObject(object_file, data_ref, sceneName, null, materials, parent, parentObject, o, done);
|
||||
#end
|
||||
object_file, data_ref, sceneName, null, materials, parent, parentObject, o, done);
|
||||
#if lnx_skin
|
||||
}
|
||||
#end
|
||||
@ -968,20 +997,24 @@ class Scene {
|
||||
#end
|
||||
if (o.properties != null) {
|
||||
object.properties = new Map();
|
||||
for (p in o.properties) object.properties.set(p.name, p.value);
|
||||
for (p in o.properties) {
|
||||
object.properties.set(p.name, cleanValue(p.value));
|
||||
}
|
||||
}
|
||||
|
||||
if (o.vertex_groups != null) {
|
||||
object.vertex_groups = new Map();
|
||||
for (p in o.vertex_groups){
|
||||
var verts = [];
|
||||
for(i in 0...Std.int(p.value.length/3)){
|
||||
var x = Std.parseFloat(p.value[i*3]);
|
||||
var y = Std.parseFloat(p.value[i*3+1]);
|
||||
var z = Std.parseFloat(p.value[i*3+2]);
|
||||
verts.push(new iron.math.Vec4(x, y, z, 1));
|
||||
cast(object, MeshObject).vertexGroups = new Map();
|
||||
for (p in o.vertex_groups) {
|
||||
var verts:Array<iron.math.Vec4> = [];
|
||||
|
||||
var data:kha.arrays.Float32Array = cast p.value;
|
||||
|
||||
if (data != null) {
|
||||
for (i in 0...Std.int(data.length / 3)) {
|
||||
verts.push(new iron.math.Vec4(data[i * 3], data[i * 3 + 1], data[i * 3 + 2], 1.0));
|
||||
}
|
||||
}
|
||||
object.vertex_groups.set(p.name, verts);
|
||||
cast(object, MeshObject).vertexGroups.set(p.name, verts);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1145,4 +1178,16 @@ class Scene {
|
||||
public function notifyOnRemove(f: Void->Void) {
|
||||
traitRemoves.push(f);
|
||||
}
|
||||
|
||||
static function cleanValue(val: Dynamic): Dynamic {
|
||||
if (val == null) return null;
|
||||
if (untyped val.buffer != null) {
|
||||
var data: kha.arrays.Float32Array = cast val;
|
||||
return [for (i in 0...data.length) data[i]];
|
||||
}
|
||||
if (Std.isOfType(val, Array)) {
|
||||
return [for (item in (cast val: Array<Dynamic>)) cleanValue(item)];
|
||||
}
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user