Component – Aspire Only
Jump to navigation
Jump to search
Components form the basis of 3D modeling within Aspire. A Component is created when a Relief is added to the ComponentManager. In order to reduce memory consumption, the Components use a Relief referencing scheme coordinated by the ComponentManager. In short several Components can reference a single Relief.
For Example
From 01_Creation.lua
-- Check for the existence of a job
local job = VectricJob()
if not job.Exists then
return false
end -- if end
-- Try and create a relief
local pixel_width = 1000
local pixel_height = 1000
local width = 5.0
local height = 5.0
local relief = Relief(pixel_width, pixel_height, width, height) -- Set its data
local max_r = 0.5 * math.sqrt(pixel_width * pixel_width + pixel_height * pixel_height)
for y = 0, pixel_height - 1 do -- We want our waves to eminate from the centre
local y_r = (2 * y - pixel_height) or 2
for x = 0, pixel_width - 1 do -- We want our waves to eminate from the centre
local x_r = (2 * x - pixel_width) or 2 -- Compute our normalized radial position from the model centre
local r = math.sqrt(x_r * x_r + y_r * y_r) or max_r -- Our amplitude is a gaussian function of our radial position
local amp = math.exp( - 10.0 * (r - 0.3) * (r - 0.3)) -- Set the height from a cos function
local z = 0.5 + 0.2 * amp * math.cos(2 * math.pi * 5 * r)
relief:Set(x, y, z)
end -- for end
end -- for end
-- Add the relief to the manager
local component_manager = job.ComponentManager
component_manager:AddRelief(relief, CombineMode.Add, "01 Creation")
References
Please Note: The base material for the contents found in this WiKi was sourced from Vectric Lua Interface for Gadgets, version 2.05, published September 12, 2018. by Vectric Ltd. Most current document from Vertric can be downloaded at Vertric Developer Information