Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-fbx

Source of release 0.12.1

0.12.1 / src / convert / options.lucb

## FBX scene to GeometrySet conversion, after docs/MAPPING.md. This
## fragment holds the options and the warnings every other fragment shares:
## geometry.lucb reads meshes and their layer elements, topology.lucb their
## polygons, build.lucb merges them into one mesh, attributes.lucb fills
## attributes from the layers, placement.lucb places points and instances,
## and load.lucb runs the whole import.
from luce_std import math
import memory
from luce_geocore.core import parallel as pool
import errors
import budget
from document import Document, Property, ArrayJob, Element, element_size, scalar_integer
from scene import Scene, Hierarchy, Kind, Model, Settings, Axis, Animation, Trs, Quat, absent
from luce_geocore.geocore import Vector3, Matrix4, Mesh
from luce_geocore.kernel import Float3, Attribute, AttributeStore, Domain, DataType, Role, TableBuilder, GeometrySet, Placement, assembled, put_attribute, mesh_dispose, set_put_detail, empty_set, dispose_set, mesh_component, Instances, new_instances, instances_component, Curves, curves_assembled, curves_type
from luce_geocore.core.growing import Growing
from luce_geocore.core.shared import Column
import strings

## What a load does.
pub struct ImportOptions:
    ## Keep each model's geometry in its own space, placed by an instance
    ## row ("Keep hierarchy"), instead of merging everything into one mesh.
    pub var keep_hierarchy: bool = false
    ## Load a geometry several models share once, as instances.
    pub var instancing: bool = true
    ## Turn the file's axes to Y-up and scale it to meters.
    pub var convert_units: bool = false
    ## Import the file's normals as `N` (off: geocore's face normals).
    pub var normals: bool = true
    ## The time in seconds animation is evaluated at; NaN reads the file's
    ## properties as they are (no animation).
    pub var time: f64 = math.nan
    ## Or a frame at the file's frame rate (used when `time` is NaN).
    pub var frame: f64 = math.nan
    ## Apply blend shapes and skins.
    pub var deform: bool = true

## Messages about what a load left out or changed, one line each, each once.
pub struct Warnings:
    pub var text: Growing[u8]

    pub func init():
        self.text = Growing[u8]()

    pub func close():
        self.text.close()

    ## Add `message` unless it is there already.
    pub func add(message: str) -> !:
        let held = (str)self.text.view()
        var start: usize = 0
        while start < held.length:
            var end = start
            while end < held.length and held.bytes[end] != 10: end += 1
            if (str)held.bytes[start..<end] == message: return
            start = end + 1
        for byte in message.bytes: try self.text.push(byte)
        try self.text.push(10)

    ## Add "<count><text>".
    pub func count(number: usize, text: str) -> !:
        var line: u8[256] = ---
        try self.add(try strings.format(line, f"{number}{text}"))

## Elements per parallel chunk.
let grain: usize = 16384