Search in sources :

Example 1 with MeshComponent

use of artisynth.core.mechmodels.MeshComponent in project artisynth_core by artisynth.

the class MeshBodyEditor method applyAction.

public void applyAction(String actionCommand, LinkedList<ModelComponent> selection, Rectangle popupBounds) {
    if (containsMultipleSelection(selection, MeshComponent.class)) {
        if (containsSingleSelection(selection, MeshComponent.class)) {
            if (actionCommand == "Save local mesh as ...") {
                MeshComponent body = (MeshComponent) selection.get(0);
                MeshBase mesh = body.getMesh();
                EditorUtils.saveMesh(mesh, null);
            } else if (actionCommand == "Save world mesh as ...") {
                MeshComponent body = (MeshComponent) selection.get(0);
                MeshBase mesh = body.getMesh();
                EditorUtils.saveMesh(mesh, mesh != null ? mesh.getMeshToWorld() : null);
            } else if (actionCommand == "Add mesh inspector") {
                MeshComponent body = (MeshComponent) selection.get(0);
                MechModel mech = (MechModel) body.getGrandParent();
                EditablePolygonalMeshComp editMesh = new EditablePolygonalMeshComp((PolygonalMesh) body.getMesh());
                double size = RenderableUtils.getRadius(editMesh);
                RenderProps.setVisible(editMesh, true);
                RenderProps.setPointStyle(editMesh, Renderer.PointStyle.SPHERE);
                RenderProps.setPointRadius(editMesh, 0.05 * size);
                mech.addRenderable(editMesh);
            }
        }
    }
}
Also used : MeshComponent(artisynth.core.mechmodels.MeshComponent) MechModel(artisynth.core.mechmodels.MechModel) EditablePolygonalMeshComp(artisynth.core.renderables.EditablePolygonalMeshComp) MeshBase(maspack.geometry.MeshBase)

Example 2 with MeshComponent

use of artisynth.core.mechmodels.MeshComponent in project artisynth_core by artisynth.

the class MeshBodyEditor method addActions.

public void addActions(EditActionMap actions, SelectionManager selManager) {
    LinkedList<ModelComponent> selection = selManager.getCurrentSelection();
    if (containsMultipleSelection(selection, MeshComponent.class)) {
        if (containsSingleSelection(selection, MeshComponent.class)) {
            MeshComponent body = (MeshComponent) selection.get(0);
            actions.add(this, "Save local mesh as ...");
            actions.add(this, "Save world mesh as ...");
            if (body.getMesh() instanceof PolygonalMesh && body.getGrandParent() instanceof MechModel) {
                actions.add(this, "Add mesh inspector");
            }
        }
    }
}
Also used : MeshComponent(artisynth.core.mechmodels.MeshComponent) MechModel(artisynth.core.mechmodels.MechModel) PolygonalMesh(maspack.geometry.PolygonalMesh)

Aggregations

MechModel (artisynth.core.mechmodels.MechModel)2 MeshComponent (artisynth.core.mechmodels.MeshComponent)2 EditablePolygonalMeshComp (artisynth.core.renderables.EditablePolygonalMeshComp)1 MeshBase (maspack.geometry.MeshBase)1 PolygonalMesh (maspack.geometry.PolygonalMesh)1