Howto:Dynamic Liveries via Canvas: Difference between revisions

Line 163: Line 163:
To start with, I cloned the EF2000's model and made a copy called "EF2000-canvas.ac", cloned the model XML file in the same way, and changed the paths appropriately to create a completely separate model for this experiment. The model objects which will be subject to the dynamic effects - effectively, the painted surfaces - were isolated from items like the canopy glass, gear and engines and given the same material, named '''CanvasPaint''' and consisting of an image texture: a livery in Air Superiority Grey but without the dirt layer already included. My first experiment will be to create a canvas and try to apply it to the mesh.
To start with, I cloned the EF2000's model and made a copy called "EF2000-canvas.ac", cloned the model XML file in the same way, and changed the paths appropriately to create a completely separate model for this experiment. The model objects which will be subject to the dynamic effects - effectively, the painted surfaces - were isolated from items like the canopy glass, gear and engines and given the same material, named '''CanvasPaint''' and consisting of an image texture: a livery in Air Superiority Grey but without the dirt layer already included. My first experiment will be to create a canvas and try to apply it to the mesh.
[[File:Two-layers.jpg|325px|thumb|left|The two textures concerned, the ASG paintwork and the separate alpha transparency with dirt streaks]]
[[File:Two-layers.jpg|325px|thumb|left|The two textures concerned, the ASG paintwork and the separate alpha transparency with dirt streaks]]
{{-}}
=== Canvas Code ===
From the code snippets above and [[Howto:Using_raster_images_and_nested_canvases]], I've put together my first attempt at some Canvas code. It appears that the canvas is the right size, and both .jpg and .png textures are loaded. But the placement line does not seem to make any difference to the texture on the named model object ("Fuselage").
<syntaxhighlight lang="nasal">
# Create a Canvas dialog window to hold the canvas and show that it's working
var window = canvas.Window.new([512,512],"dialog");
# Create a Canvas in the window and create a containing group called root
var myCanvas = window.createCanvas();
var root = myCanvas.createGroup();
# Add a placement. I believe the second argument relates to model objects, so I have attempted to place it on the object named Fuselage. I don't understand this bit too well, Hooray can you help?
myCanvas.addPlacement({"node": "Fuselage"});
# Put a raster image into the canvas
root.createChild("image")
    .setFile("Aircraft/EF2000/Models/EF2000.png")
    .setSize(2048,2048);
</syntaxhighlight>
80

edits