Change method to add instrumentation
Drag forest areas on table
Lock table
The generated cubes should should bound the forest with the forest not extending past the cubes and the cubes width & depth being as close to the area as possible.
-- terrain_obj: the forest template from the bag
-- terrain_pos: location of the forest.
-- terrain_rotation: float, radian, rotation on y-axis
-- terrain_size:
-- table_type: string, e.g. forest, or arid.
function set_forest(terrain_obj, terrain_pos, terrain_rotation, terrain_size, table_type)
print("terrain_rotation=", terrain_rotation)
local options = g_terrain[table_type]['forest']
local multiplier = options['multiplier']
local ntrees = math.floor((terrain_size['x'] + terrain_size['z'])*multiplier)
for i=1,ntrees do
local point = random_point_ellipse(terrain_size['x'] / 2.5, terrain_size['z'] / 2.5)
new_pos = rotate_point_relative(point, terrain_pos, terrain_rotation)
local obj = spawn_model(random_element(options['objects']), new_pos, math.random(1, 359), minimal_collider, true)
terrain_obj.addAttachment(obj)
end
change_texture_terrain(terrain_obj, random_element(options['texture']))
local cube = spawnObject({
position = terrain_pos,
rotation = terrain_obj.getRotation(),
scale = terrain_size,
type = 'BlockRectangle' }
)
cube.setLock(true)
cube.setColorTint({r=1,g=0,b=0,a=0.25})
local cube = spawnObject({
position = terrain_pos,
rotation = terrain_obj.getRotation(),
scale = terrain_obj.getBounds().size,
type = 'BlockRectangle' }
)
cube.setLock(true)
cube.setColorTint({r=0,g=1,b=0,a=0.25})
end
Change method to add instrumentation Drag forest areas on table Lock table
The generated cubes should should bound the forest with the forest not extending past the cubes and the cubes width & depth being as close to the area as possible.
-- terrain_obj: the forest template from the bag -- terrain_pos: location of the forest. -- terrain_rotation: float, radian, rotation on y-axis -- terrain_size: -- table_type: string, e.g. forest, or arid. function set_forest(terrain_obj, terrain_pos, terrain_rotation, terrain_size, table_type) print("terrain_rotation=", terrain_rotation) local options = g_terrain[table_type]['forest'] local multiplier = options['multiplier'] local ntrees = math.floor((terrain_size['x'] + terrain_size['z'])*multiplier) for i=1,ntrees do local point = random_point_ellipse(terrain_size['x'] / 2.5, terrain_size['z'] / 2.5) new_pos = rotate_point_relative(point, terrain_pos, terrain_rotation) local obj = spawn_model(random_element(options['objects']), new_pos, math.random(1, 359), minimal_collider, true) terrain_obj.addAttachment(obj) end change_texture_terrain(terrain_obj, random_element(options['texture'])) local cube = spawnObject({ position = terrain_pos, rotation = terrain_obj.getRotation(), scale = terrain_size, type = 'BlockRectangle' } ) cube.setLock(true) cube.setColorTint({r=1,g=0,b=0,a=0.25}) local cube = spawnObject({ position = terrain_pos, rotation = terrain_obj.getRotation(), scale = terrain_obj.getBounds().size, type = 'BlockRectangle' } ) cube.setLock(true) cube.setColorTint({r=0,g=1,b=0,a=0.25}) end