Search in sources :

Example 6 with ModelComponent

use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.

the class MuscleElementDesc method setExcitationColors.

void setExcitationColors(RenderProps props) {
    ModelComponent gparent = getGrandParent();
    if (gparent instanceof MuscleBundle) {
        MuscleBundle bundle = (MuscleBundle) gparent;
        float[] excitationColor = bundle.myExcitationColor;
        if (excitationColor != null) {
            double s = Math.min(getNetExcitation() / bundle.myMaxColoredExcitation, 1);
            float[] baseColor;
            if (myDirectionColor == null) {
                myDirectionColor = new float[4];
            }
            myDirectionColor[3] = (float) props.getAlpha();
            baseColor = props.getLineColorF();
            ColorUtils.interpolateColor(myDirectionColor, baseColor, excitationColor, s);
            if (myWidgetColor == null) {
                myWidgetColor = new float[4];
            }
            baseColor = props.getFaceColorF();
            ColorUtils.interpolateColor(myWidgetColor, baseColor, excitationColor, s);
            myWidgetColor[3] = (float) props.getAlpha();
        } else {
            myDirectionColor = null;
            myWidgetColor = null;
        }
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent)

Example 7 with ModelComponent

use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.

the class AuxMaterialElementDesc method render.

public void render(Renderer renderer, RenderProps props, int flags) {
    double widgetSize = 0;
    double rad = 0;
    FractionRenderType renderType = AuxMaterialBundle.DEFAULT_FRACTION_RENDER_TYPE;
    ModelComponent gparent = getGrandParent();
    if (gparent instanceof AuxMaterialBundle) {
        AuxMaterialBundle bundle = (AuxMaterialBundle) gparent;
        widgetSize = bundle.getElementWidgetSize();
        rad = bundle.getFractionRenderRadius();
        renderType = bundle.getFractionRenderType();
    }
    if (widgetSize != 0 || rad > 0) {
        Shading savedShading = renderer.setPropsShading(props);
        renderer.setFaceColoring(props, myWidgetColor, isSelected());
        if (widgetSize != 0) {
            myElement.renderWidget(renderer, widgetSize, props);
        }
        if (rad > 0) {
            renderFraction(renderer, props, rad, renderType);
        }
        renderer.setShading(savedShading);
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent) Shading(maspack.render.Renderer.Shading) FractionRenderType(artisynth.core.femmodels.AuxMaterialBundle.FractionRenderType)

Example 8 with ModelComponent

use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.

the class PointSkinAttachment method getSoftReferences.

@Override
public void getSoftReferences(List<ModelComponent> refs) {
    super.getSoftReferences(refs);
    Point point = getPoint();
    if (point != null) {
        refs.add(point);
    }
    for (int i = 0; i < myNumConnections; i++) {
        ModelComponent m = myConnections[i].getMaster();
        if (m != null) {
            refs.add(myConnections[i].getMaster());
        }
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent) Point(artisynth.core.mechmodels.Point) Point(artisynth.core.mechmodels.Point)

Example 9 with ModelComponent

use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.

the class FemNode3d method connectToHierarchy.

@Override
public void connectToHierarchy() {
    super.connectToHierarchy();
    // paranoid; do this in both connect and disconnect
    myNodeNeighbors.clear();
    clearIndirectNeighbors();
    ModelComponent gp = getGrandParent();
    if (gp instanceof FemModel3d) {
        FemModel3d fem = (FemModel3d) gp;
        if (fem.isFrameRelative()) {
            setFrame(fem.getFrame());
        }
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent)

Example 10 with ModelComponent

use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.

the class AddPropertyPane method getPropFromString.

/**
 * finds a property as defined by the input string. Everything after the "."
 * should be property names.
 *
 * @param pathName
 * @return true if property can be found from the string input.
 */
private Property getPropFromString(String pathName) {
    if (pathName == null) {
        return null;
    }
    // System.out.println("looking for Property path: " + pathName);
    if (// the path could contain properties,
    pathName.indexOf(".") != -1) // or
    // even sub properties
    {
        String compName = pathName.substring(0, pathName.indexOf("."));
        String propPath = pathName.substring(pathName.indexOf(".") + 1, pathName.length());
        System.out.println("comp: " + compName + "; prop: " + propPath);
        // propPath is everything after the . - e.g. renderProps.visible
        ModelComponent component = getCompFromStr(compName);
        if (component != null) {
            return RecursePropString(propPath, component);
        } else {
            return null;
        }
    } else {
        return null;
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent)

Aggregations

ModelComponent (artisynth.core.modelbase.ModelComponent)53 RootModel (artisynth.core.workspace.RootModel)9 Property (maspack.properties.Property)8 CompositeComponent (artisynth.core.modelbase.CompositeComponent)5 ArrayList (java.util.ArrayList)5 Point (artisynth.core.mechmodels.Point)4 Renderable (maspack.render.Renderable)4 InternalErrorException (maspack.util.InternalErrorException)4 HasCoordinateFrame (artisynth.core.modelbase.HasCoordinateFrame)3 Traceable (artisynth.core.modelbase.Traceable)3 WayPoint (artisynth.core.probes.WayPoint)3 Point (java.awt.Point)3 LinkedList (java.util.LinkedList)3 CompositeProperty (maspack.properties.CompositeProperty)3 FractionRenderType (artisynth.core.femmodels.AuxMaterialBundle.FractionRenderType)2 FemModel3d (artisynth.core.femmodels.FemModel3d)2 HexElement (artisynth.core.femmodels.HexElement)2 DirectionRenderType (artisynth.core.femmodels.MuscleBundle.DirectionRenderType)2 RemoveComponentsCommand (artisynth.core.gui.editorManager.RemoveComponentsCommand)2 ExcitationComponent (artisynth.core.mechmodels.ExcitationComponent)2