<commit_before>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dae.animation.rig;

import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import dae.animation.skeleton.BodyElement;
import dae.prefabs.Prefab;
import dae.prefabs.shapes.DiamondShape;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;
import mlproject.fuzzy.FuzzySystem;

/**
 * A rig provides support for procedural animation for mechanical models. A rig
 * typically is not animated with skinning but has distinct meshes that move
 * indepently without deformations.
 *
 * @author <NAME>
 */
public class Rig extends Prefab implements BodyElement {

    private FuzzySystem fuzzySystem = new FuzzySystem("default");
    private ArrayList<String> targetKeys = new ArrayList<String>();
    private HashMap<String, Prefab> targets = new HashMap<String, Prefab>();

    /**
     * Create a new Rig.
     */
    public Rig() {
        super.setName("rig");
        setLayerName("default");
        setCategory("Animation");
        setType("Rig");
    }

    /**
     * Creates a clone of this rig object.
     *
     * @return a clone of this rig object.
     */
    @Override
    public Spatial clone() {
        Rig rig = new Rig();
        for (Spatial s : children) {
            if (s instanceof BodyElement) {
                Spatial clone = s.clone();
                rig.attachBodyElement((BodyElement) clone);
            } else {
                Spatial modelClone = s.clone();
                rig.attachChild(modelClone);
            }
        }
        rig.fuzzySystem = (FuzzySystem) fuzzySystem.clone();
        for (String targetKey : this.targetKeys) {
            rig.addTargetKey(targetKey);
        }
        AnimationListControl listControl = this.getControl(AnimationListControl.class);
        if (listControl != null) {
            listControl.cloneForSpatial(rig);
        }
        return rig;
    }

    @Override
    public void create(String name, AssetManager manager, String extraInfo) {
        this.setName(name);
        Material rigMaterial = manager.loadMaterial("Materials/RigMaterial.j3m");
        DiamondShape ds = new DiamondShape(0.1f, true);
        Geometry g = new Geometry("rigshape", ds);
        g.setMaterial(rigMaterial);
        attachChild(g);
    }

    /**
     * Attaches a body element to this rig.
     *
     * @param element the element to attach.
     */
    public void attachBodyElement(BodyElement element) {
        if (element instanceof Node) {
            this.attachChild((Node) element);<commit_msg>Removed setName from create method, must be set via ObjectComponent now.<commit_after>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dae.animation.rig;

import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import dae.animation.skeleton.BodyElement;
import dae.prefabs.Prefab;
import dae.prefabs.shapes.DiamondShape;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;
import mlproject.fuzzy.FuzzySystem;

/**
 * A rig provides support for procedural animation for mechanical models. A rig
 * typically is not animated with skinning but has distinct meshes that move
 * indepently without deformations.
 *
 * @author <NAME>
 */
public class Rig extends Prefab implements BodyElement {

    private FuzzySystem fuzzySystem = new FuzzySystem("default");
    private ArrayList<String> targetKeys = new ArrayList<String>();
    private HashMap<String, Prefab> targets = new HashMap<String, Prefab>();

    /**
     * Create a new Rig.
     */
    public Rig() {
        super.setName("rig");
        setLayerName("default");
        setCategory("Animation");
        setType("Rig");
    }

    /**
     * Creates a clone of this rig object.
     *
     * @return a clone of this rig object.
     */
    @Override
    public Spatial clone() {
        Rig rig = new Rig();
        for (Spatial s : children) {
            if (s instanceof BodyElement) {
                Spatial clone = s.clone();
                rig.attachBodyElement((BodyElement) clone);
            } else {
                Spatial modelClone = s.clone();
                rig.attachChild(modelClone);
            }
        }
        rig.fuzzySystem = (FuzzySystem) fuzzySystem.clone();
        for (String targetKey : this.targetKeys) {
            rig.addTargetKey(targetKey);
        }
        AnimationListControl listControl = this.getControl(AnimationListControl.class);
        if (listControl != null) {
            listControl.cloneForSpatial(rig);
        }
        return rig;
    }

    @Override
    public void create(AssetManager manager, String extraInfo) {
        Material rigMaterial = manager.loadMaterial("Materials/RigMaterial.j3m");
        DiamondShape ds = new DiamondShape(0.1f, true);
        Geometry g = new Geometry("rigshape", ds);
        g.setMaterial(rigMaterial);
        attachChild(g);
    }

    /**
     * Attaches a body element to this rig.
     *
     * @param element the element to attach.
     */
    public void attachBodyElement(BodyElement element) {
        if (element instanceof Node) {
            this.attachChild((Node) element);
{'fraction_non_alphanumeric': 0.10166727075027183, 'fraction_numerical': 0.002899601304820587, 'mean_word_length': 2.5884265279583873, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2244559', 'n_tokens_mistral': 1588, 'n_tokens_neox': 1522, 'n_words': 428}