Exemplo n.º 1
0
    def __init__(self, config):
        super(Model, self).__init__()

        self.config = config
        self.model = config.ui.get_object("model")
        color_str = config.get("System", "model-color")
        self.color = Clutter.Color.from_string(color_str)[1]
        self.loader = config.ui.get_object("loader")
        self.loader.set_from_file(config.get("System", "loader"))

        self.model_data = Mash.Data()
        self.model.set_data(self.model_data)
        self.v_min = Clutter.Vertex()
        self.v_max = Clutter.Vertex()
        self.depth = 0

        self.t = Clutter.PropertyTransition(property_name='rotation-angle-z')
        self.t.set_from(0)
        self.t.set_to(360)
        self.t.set_duration(3000)
        self.t.set_animatable(self.loader)
        self.t.set_repeat_count(-1)
        self.t.start()

        #Set up the light
        self.light_set = Mash.LightSet()
        vp = config.ui.get_object("volume-viewport")

        # Directional
        self.light_directional = Mash.DirectionalLight()
        self.light_set.add_light(self.light_directional)

        # Point light
        self.light_point = Mash.PointLight()
        self.light_set.add_light(self.light_point)
        
        # Add the model the lights to the volume viewport
        vp.add_child(self.light_directional);
        vp.add_child(self.light_point);

        cm = Cogl.Matrix()
        m = Clutter.matrix_init_from_array(cm, [
             1, 0, 0, 0,
             0, -1, 0, 0,
             0, 0, 1, 0,
             0, 0, 0, 1])
        config.ui.get_object("model-flipper").set_transform(m)

        self.model.connect("show", self.model_loaded)

        self.model.set_light_set(self.light_set)
        self.model.set_color(self.color)
Exemplo n.º 2
0
    def __init__(self, config):
        super(Plate, self).__init__()
        self.config = config
        # I want to subclass this, but I'm uncertain how to..
        self.plate = self.config.ui.get_object("plate")
        self.plate_data = Mash.Data()
        self.plate_data.load(0, config.get("System", "plate"))
        self.plate.set_data(self.plate_data)
        color_str = config.get("System", "plate-color")
        self.color = Clutter.Color.from_string(color_str)[1]
        self.plate.set_color(self.color)

        # Position it
        (width, height) = self.plate.get_size()
        v_min = Clutter.Vertex()
        v_max = Clutter.Vertex()
        self.plate_data.get_extents(v_min, v_max)
        depth = v_max.z - v_min.z
        self.plate.set_y(depth / 2.0)
        self.plate.set_x(-width / 2.0)
        self.plate.set_z_position(height / 2.0)

        self.plate.set_light_set(self.config.loader.model.light_set)

        self.probe_points = []
        self.scale_points = []
        self.plate.set_culling(1)
Exemplo n.º 3
0
    def __init__(self, config):
        super(Plate, self).__init__()
        self.config = config
        # I want to subclass this, but I'm uncertain how to..
        self.plate = self.config.ui.get_object("plate")
        plate_file = config.style.get_plate_filename()
        self.plate_data = Mash.Data()
        self.plate_data.load(0, plate_file)
        self.plate.set_data(self.plate_data)
        self.color = self.plate.get_background_color()
        self.plate.set_color(self.color)
        self.scale_created = False

        # Position it
        (width, height) = self.plate.get_size()
        v_min = Clutter.Vertex()
        v_max = Clutter.Vertex()
        self.plate_data.get_extents(v_min, v_max)
        depth = v_max.z - v_min.z
        self.plate.set_y(depth / 2.0)
        self.plate.set_x(-width / 2.0)
        self.plate.set_z_position(height / 2.0)

        self.plate.set_light_set(self.config.model.light_set)

        self.probe_points = []
        self.scale_points = []
        self.plate.set_culling(1)
Exemplo n.º 4
0
    stage = Clutter.Stage()
    stage.set_size(800, 500)
    stage.set_title('Clutter - test mash light')
    stage.set_user_resizable(True)

    stage.connect("destroy", lambda w: Clutter.main_quit())

    model = Toggle.Model()
    model.load_from_file(0, "/home/root/.octoprint/uploads/25mm_cube.stl")
    model.set_color(Clutter.Color.from_string("#55A94BFF")[1])
    model.set_position(400, 200)
    stage.add_child(model)

    #Set up the light
    light_set = Mash.LightSet()
    light_point = Mash.PointLight()
    light_directional = Mash.DirectionalLight()
    light_spot = Mash.SpotLight()

    light_set.add_light(light_point)
    light_set.add_light(light_directional)
    light_set.add_light(light_spot)

    # Add the model the lights to the volume viewport
    stage.add_child(light_point)
    stage.add_child(light_directional)
    stage.add_child(light_spot)

    model.set_light_set(light_set)
Exemplo n.º 5
0
from gi.repository import Clutter, Mx, Mash, Cogl, GObject

# Set up logging
logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
    datefmt='%m-%d %H:%M')

if __name__ == '__main__':
    Clutter.init(None)

    stage = Clutter.Stage()
    stage.set_size(800, 500)
    stage.set_title('Test Mash')
    stage.set_user_resizable(True)

    stage.connect("destroy", lambda w: Clutter.main_quit())

    model = Mash.Model()
    model_data = Mash.Data()
    #path = "suzanne.ply"
    path = "calibration-cube.stl"
    model_data.load(0, path)
    model.set_data(model_data)
    model.set_color(Clutter.Color.from_string("#55A94BFF")[1])
    model.set_position(400, 200)
    stage.add_child(model)

    stage.show_all()
    Clutter.main()
Exemplo n.º 6
0
gi.require_version('Clutter', '1.0')
gi.require_version('Mx', '1.0')
gi.require_version('Mash', '0.3')
from gi.repository import Clutter, Mx, Mash, Cogl, GObject

# Set up logging
logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
    datefmt='%m-%d %H:%M')

if __name__ == '__main__':
    Clutter.init(None)

    stage = Clutter.Stage()
    model = Mash.Model()
    data = Mash.Data()
    model.set_data(data)
    data.load(0, "/home/root/.octoprint/uploads/reel2.stl")
    v1 = Clutter.Vertex()
    v2 = Clutter.Vertex()
    data.get_extents(v1, v2)
    print v1.z
    print v2.z

    print model.get_depth()

    color = Clutter.Color.from_string("#F00F")[1]
    model.set_color(color)
    model.set_progress(1)