Search in sources :

Example 1 with HasRenderProps

use of maspack.render.HasRenderProps in project artisynth_core by artisynth.

the class PointTracingProbe method initRenderProps.

private void initRenderProps(ModelComponent comp) {
    RenderProps newProps = createRenderProps();
    if (comp instanceof HasRenderProps) {
        HasRenderProps rcomp = (HasRenderProps) comp;
        RenderProps compProps = rcomp.getRenderProps();
        if (compProps == null) {
            compProps = rcomp.createRenderProps();
        }
        newProps.set(compProps);
        // line and point colors of render props to match
        if (compProps.getPointColorMode() == PropertyMode.Explicit) {
            float[] pointColor = compProps.getPointColorF();
            newProps.setPointColor(pointColor);
            newProps.setLineColor(pointColor);
        }
    }
    newProps.setLineWidth(3);
    setRenderProps(newProps);
}
Also used : HasRenderProps(maspack.render.HasRenderProps) HasRenderProps(maspack.render.HasRenderProps) RenderProps(maspack.render.RenderProps)

Example 2 with HasRenderProps

use of maspack.render.HasRenderProps in project artisynth_core by artisynth.

the class IsRenderableHolder method init.

private void init(IsRenderable renderable) {
    if (renderable == null) {
        throw new IllegalArgumentException("Cannot hold a null object");
    }
    myRenderable = renderable;
    myProps = new PropertyList(IsRenderableHolder.class, RenderableComponentBase.class);
    myProps.add("renderProps * *", "render properties", null);
    if (myRenderable instanceof HasProperties) {
        myProps.addReadOnly("renderable", "the held renderable object");
    }
    if (myRenderable instanceof HasRenderProps) {
        myHasRenderProps = (HasRenderProps) myRenderable;
        getRenderPropsMethod = null;
        setRenderPropsMethod = null;
        createRenderPropsMethod = null;
    } else {
        myHasRenderProps = null;
        // try to find methods
        Class<?> clazz = myRenderable.getClass();
        getRenderPropsMethod = getMethod(clazz, "getRenderProps");
        setRenderPropsMethod = getMethod(clazz, "setRenderProps", RenderProps.class);
        createRenderPropsMethod = getMethod(clazz, "createRenderProps");
    }
    if (myRenderable instanceof Scannable) {
        myScannable = (Scannable) myRenderable;
        writeMethod = null;
        scanMethod = null;
    } else {
        myScannable = null;
        Class<?> clazz = myRenderable.getClass();
        writeMethod = getMethod(clazz, "write", PrintWriter.class, NumberFormat.class, Object.class);
        scanMethod = getMethod(clazz, "scan", ReaderTokenizer.class, CompositeComponent.class);
    }
}
Also used : HasRenderProps(maspack.render.HasRenderProps) HasProperties(maspack.properties.HasProperties) HasRenderProps(maspack.render.HasRenderProps) RenderProps(maspack.render.RenderProps) PropertyList(maspack.properties.PropertyList) ReaderTokenizer(maspack.util.ReaderTokenizer) Scannable(maspack.util.Scannable) PrintWriter(java.io.PrintWriter) NumberFormat(maspack.util.NumberFormat)

Example 3 with HasRenderProps

use of maspack.render.HasRenderProps in project artisynth_core by artisynth.

the class VectorTracingProbe method initRenderProps.

private void initRenderProps(ModelComponent comp) {
    RenderProps newProps = createRenderProps();
    if (comp instanceof HasRenderProps) {
        HasRenderProps rcomp = (HasRenderProps) comp;
        RenderProps compProps = rcomp.getRenderProps();
        if (compProps == null) {
            compProps = rcomp.createRenderProps();
        }
        newProps.set(compProps);
        // line and point colors of render props to match
        if (compProps.getPointColorMode() == PropertyMode.Explicit) {
            float[] pointColor = compProps.getPointColorF();
            newProps.setPointColor(pointColor);
            newProps.setLineColor(pointColor);
        }
    }
    newProps.setLineWidth(3);
    newProps.setLineStyle(LineStyle.CYLINDER);
    setRenderProps(newProps);
}
Also used : HasRenderProps(maspack.render.HasRenderProps) HasRenderProps(maspack.render.HasRenderProps) RenderProps(maspack.render.RenderProps)

Aggregations

HasRenderProps (maspack.render.HasRenderProps)3 RenderProps (maspack.render.RenderProps)3 PrintWriter (java.io.PrintWriter)1 HasProperties (maspack.properties.HasProperties)1 PropertyList (maspack.properties.PropertyList)1 NumberFormat (maspack.util.NumberFormat)1 ReaderTokenizer (maspack.util.ReaderTokenizer)1 Scannable (maspack.util.Scannable)1