Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #218 from t3du/GetObjectGeom
Browse files Browse the repository at this point in the history
Vertex Groups for Objects
  • Loading branch information
luboslenco authored Nov 22, 2024
2 parents 3053964 + 03327c6 commit 0456d3e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Sources/iron/Scene.hx
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,20 @@ class Scene {
for (p in o.properties) object.properties.set(p.name, 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));
}
object.vertex_groups.set(p.name, verts);
}
}

// If the scene is still initializing, traits will be created later
// to ensure that object references for trait properties are valid
if (!active.initializing) createTraits(o.traits, object);
Expand Down
10 changes: 10 additions & 0 deletions Sources/iron/data/SceneFormat.hx
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ typedef TObj = {
@:optional public var lod_material: Null<Bool>;
@:optional public var traits: Array<TTrait>;
@:optional public var properties: Array<TProperty>;
@:optional public var vertex_groups: Array<TVertex_groups>;
@:optional public var constraints: Array<TConstraint>;
@:optional public var dimensions: Float32Array; // Geometry objects
@:optional public var object_actions: Array<String>;
Expand Down Expand Up @@ -470,6 +471,15 @@ typedef TProperty = {
public var value: Dynamic;
}

#if js
typedef TVertex_groups = {
#else
@:structInit class TVertex_groups {
#end
public var name: String;
public var value: Dynamic;
}

#if js
typedef TGroup = {
#else
Expand Down
2 changes: 2 additions & 0 deletions Sources/iron/object/Object.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package iron.object;

import iron.Trait;
import iron.data.SceneFormat;
import iron.math.Vec4;

class Object {
static var uidCounter = 0;
Expand All @@ -25,6 +26,7 @@ class Object {
public var culled = false; // Object was culled last frame
public var culledMesh = false;
public var culledShadow = false;
public var vertex_groups: Map<String, Array<Vec4>> = null;
public var properties: Map<String, Dynamic> = null;
var isEmpty = false;

Expand Down

0 comments on commit 0456d3e

Please sign in to comment.