Parcourir la source

Merge pull request #278 from rsredsq/RED-HAXE-UPDATE

Added audio, ui variables to haxe api.
JoshEngebretson il y a 10 ans
Parent
commit
cc0bcb1536

+ 9 - 1
Script/Packages/Atomic/Atomic3D.json

@@ -15,19 +15,27 @@
 		},
 		"AnimationState" : {
 			"AnimationState" : ["AnimatedModel", "Animation"]
+		},
+		"CustomGeometry" : {
+			"SetMaterial" : ["Material"]
 		}
 
 	},
 	"typescript_decl" : {
-
 		"StaticModel" : [
 			"setMaterialIndex(index:number, material:Material);"
+		],
+		"CustomGeometry" : [
+			"setMaterialIndex(index:number, material:Material);"
 		]
 	},
 
 	"haxe_decl" : {
 		"StaticModel" : [
 			"function setMaterialIndex(index:UInt, material:Material):Void;"
+		],
+		"CustomGeometry" : [
+			"function setMaterialIndex(index:UInt, material:Material):Void;"
 		]
 	}
 

+ 21 - 0
Source/AtomicJS/Javascript/JSAtomic3D.cpp

@@ -1,5 +1,6 @@
 
 #include <Atomic/Atomic3D/StaticModel.h>
+#include <Atomic/Atomic3D/CustomGeometry.h>
 
 #include "JSAtomic3D.h"
 
@@ -24,6 +25,22 @@ static int StaticModel_SetMaterialIndex(duk_context* ctx) {
     return 0;
 }
 
+static int CustomGeometry_SetMaterialIndex(duk_context* ctx) {
+
+    unsigned index = (unsigned)duk_require_number(ctx, 0);
+    Material* material = js_to_class_instance<Material>(ctx, 1, 0);
+
+    duk_push_this(ctx);
+
+    // event receiver
+    CustomGeometry* geometry = js_to_class_instance<CustomGeometry>(ctx, -1, 0);
+
+
+    geometry->SetMaterial(index, material);
+
+    return 0;
+}
+
 void jsapi_init_atomic3d(JSVM* vm)
 {
     duk_context* ctx = vm->GetJSContext();
@@ -33,6 +50,10 @@ void jsapi_init_atomic3d(JSVM* vm)
     duk_put_prop_string(ctx, -2, "setMaterialIndex");
     duk_pop(ctx); // pop AObject prototype
 
+    js_class_get_prototype(ctx, "Atomic", "CustomGeometry");
+    duk_push_c_function(ctx, CustomGeometry_SetMaterialIndex, 2);
+    duk_put_prop_string(ctx, -2, "setMaterialIndex");
+    duk_pop(ctx); // pop AObject prototype
 }
 
 }

+ 2 - 0
Source/ToolCore/JSBind/JSBHaxe.cpp

@@ -83,6 +83,8 @@ namespace ToolCore
             source_ += "    public static var input: Input;\n";
             source_ += "    public static var fileSystem: FileSystem;\n";
             source_ += "    public static var network: Network;\n";
+            source_ += "    public static var ui: UI;\n";
+            source_ += "    public static var audio: Audio;\n";
         }
     }