add method for setting material color
This commit is contained in:
@@ -218,6 +218,9 @@ class _ExampleWidgetState extends State<ExampleWidget> {
|
|||||||
.build();
|
.build();
|
||||||
_filamentController.setMorphAnimationData(_cube!, animation);
|
_filamentController.setMorphAnimationData(_cube!, animation);
|
||||||
}, "animate morph weights #3 and #4"),
|
}, "animate morph weights #3 and #4"),
|
||||||
|
_item(() {
|
||||||
|
_filamentController.setMaterialColor(_cube!, "Cone", 0, Colors.purple);
|
||||||
|
}, "set cone material color to purple")
|
||||||
];
|
];
|
||||||
if (_animations != null) {
|
if (_animations != null) {
|
||||||
children.addAll(_animations!.map((a) => _item(() {
|
children.addAll(_animations!.map((a) => _item(() {
|
||||||
|
|||||||
@@ -615,7 +615,18 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
|||||||
case "setCameraFocusDistance":
|
case "setCameraFocusDistance":
|
||||||
set_camera_focus_distance(viewer, call.arguments as! Float)
|
set_camera_focus_distance(viewer, call.arguments as! Float)
|
||||||
result(true)
|
result(true)
|
||||||
|
case "setMaterialColor":
|
||||||
|
guard let args = call.arguments as? [Any], args.count == 5,
|
||||||
|
let assetManager = args[0] as? Int64,
|
||||||
|
let asset = args[1] as? EntityId,
|
||||||
|
let meshName = args[2] as? String,
|
||||||
|
let materialIndex = args[3] as? Int32,
|
||||||
|
let color = args[4] as? [Double] else {
|
||||||
|
result(FlutterError(code: "INVALID_ARGUMENTS", message: "Expected correct arguments for setMaterialColor", details: nil))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
set_material_color(unsafeBitCast(assetManager, to:UnsafeMutableRawPointer.self), asset, meshName, materialIndex, Float(color[0]), Float(color[1]), Float(color[2]), Float(color[3]))
|
||||||
|
result(true)
|
||||||
|
|
||||||
case "hideMesh":
|
case "hideMesh":
|
||||||
guard let args = call.arguments as? [Any], args.count == 3,
|
guard let args = call.arguments as? [Any], args.count == 3,
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ namespace polyvox {
|
|||||||
const utils::Entity* getLightEntities(EntityId e) const noexcept;
|
const utils::Entity* getLightEntities(EntityId e) const noexcept;
|
||||||
size_t getLightEntityCount(EntityId e) const noexcept;
|
size_t getLightEntityCount(EntityId e) const noexcept;
|
||||||
void updateAnimations();
|
void updateAnimations();
|
||||||
|
bool setMaterialColor(EntityId e, const char* meshName, int materialInstance, const float r, const float g, const float b, const float a);
|
||||||
|
|
||||||
bool setMorphAnimationBuffer(
|
bool setMorphAnimationBuffer(
|
||||||
EntityId entityId,
|
EntityId entityId,
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ void remove_asset(const void* const viewer, EntityId asset);
|
|||||||
void clear_assets(const void* const viewer);
|
void clear_assets(const void* const viewer);
|
||||||
void load_texture(void* assetManager, EntityId asset, const char *assetPath, int renderableIndex);
|
void load_texture(void* assetManager, EntityId asset, const char *assetPath, int renderableIndex);
|
||||||
void set_texture(void* assetManager, EntityId asset);
|
void set_texture(void* assetManager, EntityId asset);
|
||||||
|
bool set_material_color(void* assetManager, EntityId asset, const char* meshName, int materialIndex, const float r, const float g, const float b, const float a);
|
||||||
void transform_to_unit_cube(void* assetManager, EntityId asset);
|
void transform_to_unit_cube(void* assetManager, EntityId asset);
|
||||||
void set_position(void* assetManager, EntityId asset, float x, float y, float z);
|
void set_position(void* assetManager, EntityId asset, float x, float y, float z);
|
||||||
void set_rotation(void* assetManager, EntityId asset, float rads, float x, float y, float z);
|
void set_rotation(void* assetManager, EntityId asset, float rads, float x, float y, float z);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -337,6 +337,10 @@ extern "C" {
|
|||||||
// ((AssetManager*)assetManager)->setTexture();
|
// ((AssetManager*)assetManager)->setTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool set_material_color(void* assetManager, EntityId asset, const char* meshName, int materialIndex, const float r, const float g, const float b, const float a) {
|
||||||
|
return ((AssetManager*)assetManager)->setMaterialColor(asset, meshName, materialIndex, r, g, b, a);
|
||||||
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void transform_to_unit_cube(void* assetManager, EntityId asset) {
|
FLUTTER_PLUGIN_EXPORT void transform_to_unit_cube(void* assetManager, EntityId asset) {
|
||||||
((AssetManager*)assetManager)->transformToUnitCube(asset);
|
((AssetManager*)assetManager)->transformToUnitCube(asset);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,13 +260,12 @@ class FilamentController {
|
|||||||
///
|
///
|
||||||
void setMorphAnimationData(
|
void setMorphAnimationData(
|
||||||
FilamentEntity asset, MorphAnimationData animation) async {
|
FilamentEntity asset, MorphAnimationData animation) async {
|
||||||
print("SETTING animation with ${animation.data}");
|
|
||||||
await _channel.invokeMethod("setMorphAnimation", [
|
await _channel.invokeMethod("setMorphAnimation", [
|
||||||
_assetManager,
|
_assetManager,
|
||||||
asset,
|
asset,
|
||||||
animation.meshName,
|
animation.meshName,
|
||||||
animation.data,
|
animation.data,
|
||||||
animation.morphIndices,
|
animation.animatedMorphIndices,
|
||||||
animation.numMorphTargets,
|
animation.numMorphTargets,
|
||||||
animation.numFrames,
|
animation.numFrames,
|
||||||
animation.frameLengthInMs
|
animation.frameLengthInMs
|
||||||
@@ -402,6 +401,22 @@ class FilamentController {
|
|||||||
await _channel.invokeMethod("setTexture", [_assetManager, asset]);
|
await _channel.invokeMethod("setTexture", [_assetManager, asset]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setMaterialColor(FilamentEntity asset, String meshName,
|
||||||
|
int materialIndex, Color color) async {
|
||||||
|
await _channel.invokeMethod("setMaterialColor", [
|
||||||
|
_assetManager,
|
||||||
|
asset,
|
||||||
|
meshName,
|
||||||
|
materialIndex,
|
||||||
|
[
|
||||||
|
color.red.toDouble() / 255.0,
|
||||||
|
color.green.toDouble() / 255.0,
|
||||||
|
color.blue.toDouble() / 255.0,
|
||||||
|
color.alpha.toDouble() / 255.0
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
void transformToUnitCube(FilamentEntity asset) async {
|
void transformToUnitCube(FilamentEntity asset) async {
|
||||||
await _channel.invokeMethod("transformToUnitCube", [_assetManager, asset]);
|
await _channel.invokeMethod("transformToUnitCube", [_assetManager, asset]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user