1 package com.generalrobotix.ui.item;
3 import javax.media.j3d.BadTransformException;
4 import javax.media.j3d.Switch;
5 import javax.media.j3d.Transform3D;
6 import javax.media.j3d.TransformGroup;
7 import javax.vecmath.Color3f;
8 import javax.vecmath.Matrix3d;
9 import javax.vecmath.Vector3d;
18 @SuppressWarnings(
"serial")
28 super(name, manager_, model_);
29 setIcon(
"segment1.png");
31 tgCom_ = (TransformGroup)switchCom_.getChild(0);
32 tg_.addChild(switchCom_);
34 if(segmentInfo !=
null){
35 transform(segmentInfo.transformMatrix);
36 centerOfMass(segmentInfo.centerOfMass);
37 momentOfInertia(segmentInfo.inertia);
38 mass(segmentInfo.mass);
40 int n = segmentInfo.shapeIndices.length;
41 for(
int i=0;
i<
n;
i++)
42 addTransformedShapeIndex(linkInfo.shapeIndices[segmentInfo.shapeIndices[
i]]);
43 buildShapeTransforms(linkInfo.inlinedShapeTransformMatrices);
46 transform(
new double[]{ 1.0, 0.0, 0.0, 0.0,
48 0.0, 0.0, 1.0, 0.0 });
49 centerOfMass(
new double[]{0.0, 0.0, 0.0});
50 momentOfInertia(
new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0});
56 private void mass(
double mass){
60 if (model_ !=
null) model_.notifyModified();
64 if(inertia ==
null || inertia.length != 9)
return;
65 momentOfInertia_ = inertia;
66 setDblAry(
"momentsOfInertia", inertia);
68 if (model_ !=
null) model_.notifyModified();
72 if (centerOfMass ==
null || centerOfMass.length != 3)
return;
73 centerOfMass_ = centerOfMass;
74 setDblAry(
"centerOfMass", centerOfMass);
75 Transform3D t3d =
new Transform3D();
76 tgCom_.getTransform(t3d);
77 t3d.setTranslation(
new Vector3d(centerOfMass_));
78 tgCom_.setTransform(t3d);
79 if (model_ !=
null) model_.notifyModified();
83 if (property.equals(
"name")){
85 }
else if(property.equals(
"translation")){
88 }
else if(property.equals(
"rotation")){
91 }
else if(property.equals(
"centerOfMass")){
92 centerOfMass(getDblAry(value));
94 }
else if(property.equals(
"momentsOfInertia")){
95 momentOfInertia(getDblAry(value));
97 }
else if(property.equals(
"mass")){
110 switchCom_.setWhichChild(b? Switch.CHILD_ALL:Switch.CHILD_NONE);
114 Matrix3d I =
new Matrix3d(momentOfInertia_);
116 Transform3D t3d =
new Transform3D();
117 tgCom_.getTransform(t3d);
120 tgCom_.setTransform(t3d);
121 }
catch(BadTransformException ex){
122 System.out.println(
"BadTransformException in _updateScaleOfBall");
double[] momentOfInertia_
void centerOfMass(double[] centerOfMass)
void _updateScaleOfBall()
#define null
our own NULL pointer
png_infop png_charpp name
item corresponds to a robot model
boolean propertyChanged(String property, String value)
static Vector3d calcScale(Matrix3d I, double m)
void momentOfInertia(double[] inertia)
プラグイン管理クラス GrxUIの核になるクラス。プラグインのロード等の、初期化を実行する。 プラグインとそ...
functions to make various basic shapes
void setFocused(boolean b)
GrxSegmentItem(String name, GrxPluginManager manager_, GrxModelItem model_, LinkInfo linkInfo, SegmentInfo segmentInfo)
static Switch createBall(double radius, Color3f c)
create ball with switch node