use of maspack.widgets.AffineTransformWidget in project artisynth_core by artisynth.
the class RigidBodyAgent method createGeometryPanel.
protected void createGeometryPanel() {
RigidBody protoBody = null;
int numExistingBodies = myModel.rigidBodies().size();
if (numExistingBodies > 0) {
protoBody = myModel.rigidBodies().get(numExistingBodies - 1);
}
myGeometryPanel = new GeometryInertiaPanel(myGeometrySettings, protoBody, /* editing= */
false);
myGeometryPanel.setBorder(GuiUtils.createTitledPanelBorder("Geometry And Inertia"));
if (myGeometrySettings == null) {
GLViewer viewer = myMain.getMain().getViewer();
double width = viewer.distancePerPixel(viewer.getCenter()) * viewer.getScreenWidth() / 6;
double boxScale = 1;
if (width > boxScale) {
for (int i = -1; width > boxScale; i++) {
boxScale *= (i % 3 == 0) ? 2.5 : 2.0;
}
} else {
for (int i = -1; width < boxScale; i++) {
boxScale /= (i % 3 == 0) ? 2.5 : 2.0;
}
}
myGeometryPanel.myBoxWidthsField.setValue(new Vector3d(boxScale, boxScale, boxScale));
}
geometrySelector = myGeometryPanel.myGeometrySelector;
geometrySelector.addValueChangeListener(this);
myGeometryPanel.myBoxWidthsField.addValueChangeListener(this);
myGeometryPanel.myPointRadiusField.addValueChangeListener(this);
myGeometryPanel.myPointSlicesField.addValueChangeListener(this);
myGeometryPanel.myMeshFileField.addValueChangeListener(this);
AffineTransformWidget meshXformWidget = myGeometryPanel.myMeshXformWidget;
meshXformWidget.getTranslationField().addValueChangeListener(this);
myGeometryPanel.myDensityField.setValue(1.0);
scaleField = meshXformWidget.getScaleField();
autoScaleBtn = new JButton("Auto Scale");
autoScaleBtn.addActionListener(this);
scaleField.addMajorComponent(autoScaleBtn);
addWidget(myGeometryPanel);
}
use of maspack.widgets.AffineTransformWidget in project artisynth_core by artisynth.
the class GeometryInertiaPanel method createGeometryWidgets.
// Called once at panel creation time to create all the widgets
// that may be needed for the Geometry.
protected void createGeometryWidgets() {
myBoxWidthsField = new VectorField("widths", new Vector3d(), "%.4g");
myBoxWidthsField.setResultHolder(new Vector3d());
initWidget(myBoxWidthsField);
myPointRadiusField = new DoubleField("radius", 0, "%.4g");
initWidget(myPointRadiusField);
myPointSlicesField = new IntegerField("slices", 12);
initWidget(myPointSlicesField);
myMeshFileField = new FileNameField("file name", "", 20);
initWidget(myMeshFileField);
myMeshXformWidget = new AffineTransformWidget("", "TRS", new RigidTransform3d());
initWidget(myMeshXformWidget);
myMeshXformWidget.unpackFields();
myMeshXformWidget.getTranslationField().setLabelText("offset");
myMeshXformWidget.getScaleField().setLabelText("scale");
myMeshXformWidget.getRotationField().setLabelText("rotation");
myCOMButton = new JButton("COM");
myCOMButton.addActionListener(this);
myCOMButton.setToolTipText("puts mesh origin at its center of mass");
GuiUtils.setFixedSize(myCOMButton, myMeshFileField.getBrowseButton().getPreferredSize());
myMeshXformWidget.getTranslationField().addMajorComponent(myCOMButton);
}
Aggregations