Search in sources :

Example 11 with Renderable

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

the class MultiPointSpring method computeDefaultMaxWrapDisplacement.

private double computeDefaultMaxWrapDisplacement() {
    double mind = Double.POSITIVE_INFINITY;
    CompositeComponent comp = ComponentUtils.nearestEncapsulatingAncestor(this);
    if (comp instanceof Renderable) {
        mind = RenderableUtils.getRadius((Renderable) comp) / 10;
    }
    for (Wrappable w : myWrappables) {
        if (w instanceof HasSurfaceMesh) {
            PolygonalMesh mesh = ((HasSurfaceMesh) w).getSurfaceMesh();
            if (mesh != null) {
                OBB obb = new OBB(mesh);
                Vector3d widths = new Vector3d();
                obb.getWidths(widths);
                double hw = widths.minElement() / 2;
                if (hw < mind) {
                    mind = hw / 2;
                }
            }
        }
    }
    if (mind == Double.POSITIVE_INFINITY) {
        mind = 1.0;
    }
    return mind;
}
Also used : Renderable(maspack.render.Renderable) PolygonalMesh(maspack.geometry.PolygonalMesh) OBB(maspack.geometry.OBB)

Example 12 with Renderable

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

the class SimpleCollide method setTopObject.

private void setTopObject(Collidable comp, ObjectType type) {
    Renderable rcomp = (Renderable) comp;
    ((TransformableGeometry) comp).transformGeometry(new RigidTransform3d(0, /*-0.3*/
    0.0, mySeparation));
    ((TransformableGeometry) comp).transformGeometry(AffineTransform3d.createScaling(myTopScale));
    RenderProps.setFaceColor(rcomp, Color.red);
    switch(type) {
        case FemEllipsoid:
        case FemSphere:
        case FemCube:
            {
                RenderProps.setPointColor(rcomp, Color.gray);
                RenderProps.setAlpha(rcomp, 0.3);
                RenderProps.setDrawEdges(rcomp, true);
                RenderProps.setVisible(((FemModel3d) rcomp).getElements(), false);
                break;
            }
        case House:
            {
                ((TransformableGeometry) comp).transformGeometry(new RigidTransform3d(0, 0, 2 * mySeparation, 1, 1, 0, Math.toRadians(170)));
                break;
            }
        case Box:
        case Molar:
        case Bin:
        case Paw:
            {
                break;
            }
        default:
            {
                throw new InternalErrorException("Unimplemented type " + type);
            }
    }
    myTopObject = comp;
    myTopType = type;
}
Also used : TransformableGeometry(artisynth.core.modelbase.TransformableGeometry) RigidTransform3d(maspack.matrix.RigidTransform3d) Renderable(maspack.render.Renderable) FemModel3d(artisynth.core.femmodels.FemModel3d) InternalErrorException(maspack.util.InternalErrorException)

Aggregations

Renderable (maspack.render.Renderable)12 RigidTransform3d (maspack.matrix.RigidTransform3d)6 Point3d (maspack.matrix.Point3d)5 ModelComponent (artisynth.core.modelbase.ModelComponent)4 PolygonalMesh (maspack.geometry.PolygonalMesh)4 HasCoordinateFrame (artisynth.core.modelbase.HasCoordinateFrame)3 TransformableGeometry (artisynth.core.modelbase.TransformableGeometry)3 WayPoint (artisynth.core.probes.WayPoint)3 FemModel3d (artisynth.core.femmodels.FemModel3d)2 FemNode3d (artisynth.core.femmodels.FemNode3d)2 RigidBody (artisynth.core.mechmodels.RigidBody)2 Model (artisynth.core.modelbase.Model)2 IsRenderable (maspack.render.IsRenderable)2 InternalErrorException (maspack.util.InternalErrorException)2 FemElement (artisynth.core.femmodels.FemElement)1 FemMarker (artisynth.core.femmodels.FemMarker)1 FemNode (artisynth.core.femmodels.FemNode)1 EditorBase (artisynth.core.gui.editorManager.EditorBase)1 AxialSpring (artisynth.core.mechmodels.AxialSpring)1 FixedMeshBody (artisynth.core.mechmodels.FixedMeshBody)1