18 package com.generalrobotix.ui.item;
21 import java.io.IOException;
24 import javax.media.j3d.*;
25 import javax.vecmath.*;
27 import org.eclipse.jface.action.Action;
28 import org.eclipse.jface.dialogs.InputDialog;
29 import org.eclipse.jface.dialogs.MessageDialog;
30 import org.eclipse.osgi.util.NLS;
31 import org.eclipse.swt.SWT;
32 import org.eclipse.swt.widgets.FileDialog;
33 import org.w3c.dom.Element;
34 import org.w3c.dom.NodeList;
48 @SuppressWarnings({
"unchecked",
"serial" })
53 public static final String TITLE =
"Model";
54 public static final String DEFAULT_DIR =
"/../model";
55 public static final String FILE_EXTENSION =
"*";
56 private static final double DEFAULT_RADIUS = 0.05;
59 private static final String robotIcon =
"robot.png";
60 private static final String envIcon =
"environment.png";
62 private boolean isRobot_ =
true;
65 private boolean bModified_ =
false;
67 public BranchGroup bgRoot_ =
new BranchGroup();
68 public Vector<GrxLinkItem> links_ =
new Vector<GrxLinkItem>();
69 public Vector<GrxExtraJointItem> extraJoints_ =
new Vector<GrxExtraJointItem>();
72 public Map<String, GrxLinkItem> nameToLink_ =
new HashMap<String, GrxLinkItem>();
75 private List<Camera_impl> cameraList_ =
new ArrayList<Camera_impl>();
77 public ShapeInfo[] shapes =
null;
78 public AppearanceInfo[] appearances =
null;
79 public MaterialInfo[] materials =
null;
80 public TextureInfo[] textures =
null;
98 notifyObservers(
"Modified");
106 public static final int MODIFIED_OK=0;
107 public static final int MODIFIED_NG=1;
108 public static final int MODIFIED_NOT=2;
111 String mes =
MessageBundle.
get(
"GrxProjectItem.dialog.message.changeModel.mes");
112 mes = NLS.bind(mes,
new String[]{getName()});
114 MessageDialog msgDlg =
119 MessageDialog.INFORMATION,
120 new String[] {MessageBundle.get(
"GrxProjectItem.dialog.message.changeModel.btn.save"),
121 MessageBundle.get(
"GrxProjectItem.dialog.message.changeModel.btn.reverse"),
122 MessageBundle.get(
"GrxProjectItem.dialog.message.changeModel.btn.cancel")},
125 switch(msgDlg.open())
159 notifyObservers(
"ClearModified");
170 File
f =
new File(getURL(
true));
177 File
f =
new File(getURL(
true));
178 List<GrxModelItem> sameModels = getSameUrlModels();
179 Iterator<GrxModelItem> it = sameModels.iterator();
190 String url = getURL(
true);
191 if (bModified_ || url ==
null || url.equals(
""))
200 class MenuChangeType
extends Action {
201 public MenuChangeType() {
209 _setModelType(!isRobot_);
212 MenuChangeType menuChangeType_ =
new MenuChangeType();
224 bgRoot_.setCapability(BranchGroup.ALLOW_DETACH);
225 bgRoot_.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
226 bgRoot_.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
227 bgRoot_.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
233 bgRoot_.addChild(link.
bg_);
235 setProperty(
"url",
"");
267 setMenuItem(
new Action(){
268 public String getText(){
return MessageBundle.
get(
"GrxModelItem.menu.reload"); }
270 boolean ret = load0(file_);
272 List<GrxModelItem> sameModels = getSameUrlModels();
273 Iterator<GrxModelItem> it = sameModels.iterator();
275 it.next().load0(file_);
281 setMenuItem(menuChangeType_);
284 setMenuItem(
new Action(){
285 public String getText() {
return MessageBundle.
get(
"GrxModelItem.menu.save"); }
287 String url = getStr(
"url");
288 if (url ==
null || url.equals(
"")){
301 setMenuItem(
new Action(){
302 public String getText() {
return MessageBundle.
get(
"GrxModelItem.menu.saveAs"); }
313 setMenuItem(
new Action(){
314 public String getText() {
return MessageBundle.
get(
"GrxModelItem.menu.addExtraJoint"); }
316 InputDialog dialog =
new InputDialog(
null, getText(),
317 MessageBundle.
get(
"GrxModelItem.dialog.message.extraJointName"),
null,
null);
318 if ( dialog.open() == InputDialog.OK && dialog.getValue() !=
null)
319 addExtraJoint( dialog.getValue() );
352 fdlg.setFilterPath(getDefaultDir().getAbsolutePath());
353 String fPath = fdlg.open();
354 if( fPath !=
null ) {
355 fPath = fPath.replace(
'\\',
'/');
358 setDefaultDirectory(
new File(fPath).getParent());
376 if (links_.size() > 0){
377 return links_.get(0);
389 if (element_ !=
null) {
390 NodeList props = element_.getElementsByTagName(PROPERTY_TAG);
391 for (
int j = 0; j < props.getLength(); j++) {
392 Element propEl = (Element) props.item(j);
393 String key = propEl.getAttribute(
"name");
394 String
val = propEl.getAttribute(
"value");
395 if(key.contains(
"NumOfAABB")){
396 setProperty(key,
val);
397 String[] linkName = key.split(
"\\.");
398 nameToLink_.get(linkName[0]).setProperty(
"NumOfAABB",
val);
401 if (!propertyChanged(key,
val)){
402 setProperty(key,
val);
408 if (getStr(
"markRadius")==
null) setDbl(
"markRadius", DEFAULT_RADIUS);
410 _setModelType(isTrue(
"isRobot", isRobot_));
412 if (getDblAry(rootLink().getName()+
".translation",
null) ==
null &&
413 getDblAry(rootLink().getName()+
".rotation",
null) ==
null)
414 updateInitialTransformRoot();
416 for (
int i=0;
i<jointToLink_.length;
i++) {
418 Double d = getDbl(l.
getName()+
".angle",
null);
420 setDbl(l.
getName()+
".angle", 0.0);
424 makeAABBforSameUrlModels();
426 for (
int i=0;
i<links_.size();
i++) {
429 String s = this.getProperty(l.
getName()+
".mode",
null);
431 setProperty(l.
getName()+
".mode",
"Torque");
443 if (super.propertyChanged(property,
value)){
444 }
else if(property.equals(
"isRobot")){
445 _setModelType(
value);
446 }
else if(property.equals(
"controlTime")){
448 double t = Double.parseDouble(
value);
450 setProperty(
"controlTime",
value);
452 }
catch(Exception ex){
454 }
else if(property.equals(rootLink().getName()+
".translation")){
455 if (rootLink().localTranslation(
value)){
456 setProperty(rootLink().getName()+
".translation",
value);
457 calcForwardKinematics();
459 }
else if(property.equals(rootLink().getName()+
".rotation")){
460 if (rootLink().localRotation(
value)){
461 setProperty(rootLink().getName()+
".rotation",
value);
462 calcForwardKinematics();
464 }
else if(property.equals(rootLink().getName()+
".velocity")){
465 setProperty(rootLink().getName()+
".velocity",
value);
466 rootLink().setProperty(
"velocity",
value);
467 }
else if(property.equals(rootLink().getName()+
".angularVelocity")){
468 setProperty(rootLink().getName()+
".angularVelocity",
value);
469 rootLink().setProperty(
"angulaerVelocity",
value);
471 for (
int j = 0; j < links_.size(); j++){
473 if (property.equals(link.
getName()+
".angle")){
475 calcForwardKinematics();
479 }
else if(property.equals(link.
getName()+
".jointVelocity")){
483 }
else if(property.equals(link.
getName()+
".NumOfAABB")){
488 }
else if(property.equals(link.
getName()+
".mode")){
505 Boolean
b = Boolean.parseBoolean(
value);
521 menuChangeType_.setText(
MessageBundle.
get(
"GrxModelItem.menu.changeRobot") );
523 setVisibleCoM(
false);
524 setVisibleCoMonFloor(
false);
526 setProperty(
"isRobot", String.valueOf(isRobot_));
537 double radius = getDbl(
"markRadius", DEFAULT_RADIUS);
540 tgCom_ = (TransformGroup)switchCom_.getChild(0);
541 tgComZ0_ = (TransformGroup)switchComZ0_.getChild(0);
542 TransformGroup root = getTransformGroupRoot();
543 root.addChild(switchCom_);
544 root.addChild(switchComZ0_);
547 modifier.
init_ =
true;
550 Color3f color =
new Color3f(0.0
f, 1.0
f, 0.0
f);
552 root.addChild(switchBb_);
562 boolean ret = load0(
f);
564 List<GrxModelItem> sameModels = getSameUrlModels();
565 if(!sameModels.isEmpty()){
568 for(
int i=0;
i<model.
links_.size();
i++){
569 if(!model.
links_.get(
i).getStr(
"NumOfAABB").equals(
"original data")){
570 links_.get(
i).
setInt(
"NumOfAABB", model.
links_.get(
i).getInt(
"NumOfAABB",1));
571 setInt(links_.get(
i).getName()+
".NumOfAABB", model.
links_.get(
i).getInt(
"NumOfAABB",1));
587 long load_stime = System.currentTimeMillis();
591 url =
f.getCanonicalPath();
592 }
catch (IOException e) {
597 ModelLoader mloader = ModelLoaderHelper.narrow(
599 mloader._non_existent();
601 bInfo_ = mloader.loadBodyInfo(getURL(
true));
602 boolean ret = registerCharacter();
603 long load_etime = System.currentTimeMillis();
604 System.out.println(
"load time = " + (load_etime-load_stime) +
"ms");
606 }
catch(ModelLoaderException me){
610 url +
"\n\n" + me.description);
611 System.out.println(
"Failed to load vrml model:" + url);
612 me.printStackTrace();
614 }
catch (Exception ex) {
618 System.out.println(
"Failed to load vrml model:" + url);
619 ex.printStackTrace();
626 return registerCharacter();
630 manager_.focusedItem(
null);
631 manager_.setSelectedItem(
this,
false);
633 bgRoot_ =
new BranchGroup();
634 bgRoot_.setCapability(BranchGroup.ALLOW_DETACH);
635 bgRoot_.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
636 bgRoot_.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
637 bgRoot_.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
639 LinkInfo[] linkInfoList = bInfo_.links();
642 if (rootLink() !=
null){
646 for (
int i=0;
i<cameraList_.size();
i++){
647 cameraList_.get(
i).destroy();
654 int massZeroLink = -1;
655 for (
int i = 0;
i < linkInfoList.length;
i++) {
661 nameToLink_.put(link.
getName(), link);
662 if(linkInfoList[
i].mass <= 0.0)
665 if(massZeroLink >= 0)
666 MessageDialog.openWarning(
null, getName(), linkInfoList[massZeroLink].
name+
"::"+
668 System.out.println(
"links_.size() = "+links_.size());
672 for(
int i = 0 ;
i < links_.size() ;
i++ ) {
673 if( links_.get(
i).parentIndex_ < 0 ){
674 if( rootIndex < 0 ) {
677 System.out.println(
"Error. Two or more root node exist." );
682 System.out.println(
"Error, root node doesn't exist." );
687 jointToLink_ =
new int[jointCount];
688 for (
int i=0;
i<jointCount;
i++) {
689 for (
int j=0; j<links_.size(); j++) {
690 if (links_.get(j).jointId_ ==
i) {
696 ExtraJointInfo[] extraJointList = bInfo_.extraJoints();
697 extraJoints_.clear();
698 for (
int i = 0;
i < extraJointList.length;
i++) {
700 extraJoints_.add(extraJoint);
704 long stime = System.currentTimeMillis();
706 _loadVrmlScene(linkInfoList);
711 long etime = System.currentTimeMillis();
712 System.out.println(
"_loadVrmlScene time = " + (etime-stime) +
"ms");
714 calcForwardKinematics();
715 updateInitialTransformRoot();
716 updateInitialJointValues();
719 setProperty(
"isRobot", Boolean.toString(isRobot_));
720 for (
int i=0;
i<links_.size();
i++) {
723 setProperty(l.
getName()+
".mode",
"Torque");
728 manager_.setSelectedItem(
this,
true);
745 bgRoot_.addChild(link.
bg_);
772 shapes = bInfo_.shapes();
773 appearances = bInfo_.appearances();
774 materials = bInfo_.materials();
775 textures = bInfo_.textures();
777 int numLinks = links.length;
778 for(
int linkIndex = 0; linkIndex < numLinks; linkIndex++) {
786 sensor.
addShape(
new Matrix4d(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1));
789 hwc.
addShape(
new Matrix4d(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1));
793 setDblAry(rootLink().getName()+
".translation", rootLink().localTranslation());
794 setDblAry(rootLink().getName()+
".rotation", rootLink().localRotation());
795 setDblAry(rootLink().getName()+
".velocity",
new double[]{0,0,0} );
796 setDblAry(rootLink().getName()+
".angularVelocity",
new double[]{0,0,0} );
798 for (
int i=0;
i<links_.size();
i++) {
799 Node
n = links_.get(
i).tg_.getChild(0);
800 if (
n.getCapability(Node.ENABLE_PICK_REPORTING))
801 n.clearCapability(Node.ENABLE_PICK_REPORTING);
813 ModelLoader mloader = ModelLoaderHelper.narrow(
815 mloader._non_existent();
816 BodyInfo bInfo = mloader.loadBodyInfo(
f.getCanonicalPath());
817 LinkInfo[] linkInfoList = bInfo.links();
818 int numOfLink = links_.size();
819 int numOfJoint = getDOF();
820 Vector<String> sensorType =
new Vector<String>();
824 sensorNames[
i] =
new Vector<String>();
827 for(
int j=0; j<names.length; j++)
828 sensorNames[
i].add(names[j]);
832 for (
int i = 0;
i < linkInfoList.length;
i++) {
833 if(linkInfoList[
i].parentIndex < 0 ){
834 linkInfoList[
i].parentIndex = (short) links_.indexOf(parentLink);
835 rootIndex =
i+numOfLink;
837 linkInfoList[
i].parentIndex += numOfLink;
838 for(
int j=0; j<linkInfoList[
i].childIndices.length; j++)
839 linkInfoList[
i].childIndices[j] += numOfLink;
840 if(linkInfoList[
i].jointId >= 0){
841 linkInfoList[
i].jointId += numOfJoint;
844 SensorInfo[] sensors = linkInfoList[
i].sensors;
845 for(
int j=0; j<sensors.length; j++){
846 int type = sensorType.indexOf(sensors[j].
type);
847 sensors[j].id += sensorNames[
type].size();
848 String sensorName = sensors[j].name;
849 for(
int k=0; sensorNames[
type].indexOf(sensorName)!=-1; k++)
850 sensorName = sensors[j].
name +
"_" + k;
851 sensors[j].name = sensorName;
853 String linkName = linkInfoList[
i].name;
854 for(
int j=0; nameToLink_.get(linkName)!=
null; j++ )
855 linkName = linkInfoList[
i].
name +
"_" + j;
857 nameToLink_.put(linkName, link);
860 jointToLink_ =
new int[numOfJoint+jointCount];
861 for (
int i=0;
i<numOfJoint+jointCount;
i++) {
862 for (
int j=0; j<links_.size(); j++) {
863 if (links_.get(j).jointId_ ==
i) {
868 for(
int i=numOfLink;
i<numOfLink+linkInfoList.length;
i++)
871 shapes = bInfo.shapes();
872 appearances = bInfo.appearances();
873 materials = bInfo.materials();
874 textures = bInfo.textures();
876 for(
int linkIndex = numOfLink; linkIndex < links_.size(); linkIndex++) {
884 sensor.
addShape(
new Matrix4d(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1));
887 hwc.
addShape(
new Matrix4d(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1));
891 }
catch(Exception ex){
902 private LineArray nline =
null;
906 Point3f[] vertices =
new Point3f[geom.getVertexCount()];
907 Vector3f[] normals =
new Vector3f[geom.getVertexCount()];
908 for (
int i=0;
i<geom.getVertexCount();
i++) {
909 vertices[
i] =
new Point3f();
910 normals[
i] =
new Vector3f();
912 geom.getCoordinates(0, vertices);
913 geom.getNormals(0, normals);
914 Point3f[] nvertices =
new Point3f[vertices.length * 2];
916 for (
int i=0;
i<vertices.length;
i++ ){
918 T.transform(normals[
i]);
919 normals[
i].normalize();
920 T.transform(vertices[
i]);
922 nvertices[
n++] =
new Point3f( vertices[
i] );
923 nvertices[
n++] =
new Point3f( vertices[
i].x + scale * normals[
i].x,
924 vertices[
i].y + scale * normals[
i].y,
925 vertices[
i].z + scale * normals[
i].z );
927 nline =
new LineArray(nvertices.length, GeometryArray.COORDINATES);
928 nline.setCoordinates(0, nvertices);
941 boolean isAllPosProvided =
true;
943 for (
int i=0;
i<jointToLink_.length;
i++)
944 links_.get(jointToLink_[
i]).jointValue(q[
i]);
946 for (
int i=0;
i<links_.size();
i++) {
947 if (lpos[
i].p ==
null || lpos[
i].R ==
null)
948 isAllPosProvided =
false;
951 links_.get(
i).localTranslation(lpos[0].p);
952 links_.get(
i).localRotation(lpos[0].R);
954 links_.get(
i).absTransform(lpos[
i].p, lpos[
i].R);
957 if (isAllPosProvided)
960 calcForwardKinematics();
969 _setTransform(0, pos, rot);
978 Vector3d pos =
new Vector3d();
979 Matrix3d rot =
new Matrix3d();
981 _setTransform(0, pos, rot);
1001 for (
int j = 0; j < links_.size(); j++){
1013 rootLink().setJointValuesWithinLimit();
1020 Transform3D t3d =
new Transform3D();
1021 Matrix3d m3d =
new Matrix3d();
1022 Vector3d v3d =
new Vector3d();
1024 getTransformGroupRoot().getTransform(t3d);
1026 setDblAry(rootLink().getName()+
".translation",
new double[]{v3d.x, v3d.y, v3d.z});
1030 setDblAry(rootLink().getName()+
".rotation",
new double[]{a4d.x, a4d.y, a4d.z, a4d.angle});
1046 for (
int i=0;
i<jointToLink_.length;
i++) {
1056 rootLink().calcForwardKinematics();
1064 if (switchCom_.getWhichChild() == Switch.CHILD_ALL ||
1065 switchComZ0_.getWhichChild() == Switch.CHILD_ALL) {
1066 Vector3d v3d =
new Vector3d();
1068 Vector3d vz0 =
new Vector3d(v3d);
1071 Transform3D t3d =
new Transform3D();
1073 tgCom_.setTransform(t3d);
1078 tgComZ0_.setTransform(t3d);
1087 Transform3D t3d =
new Transform3D();
1088 getTransformGroupRoot().getTransform(t3d);
1089 Vector3d p =
new Vector3d();
1104 double totalMass = 0.0;
1106 for (
int i = 0;
i < links_.size();
i++) {
1109 Vector3d absCom = link.
absCoM();
1113 pos.scale(1.0 / totalMass);
1117 List<GrxSensorItem> sensors =
new ArrayList<GrxSensorItem>();
1118 rootLink().gatherSensors(
type, sensors);
1119 if (sensors.size() > 0){
1127 List<GrxSensorItem> l = getSensors(
type);
1131 String[] ret =
new String[l.size()];
1132 for (
int i=0;
i<ret.length;
i++)
1133 ret[l.get(
i).id_] = l.get(
i).getName();
1138 return rootLink().tg_;
1147 Transform3D t3d =
new Transform3D();
1148 link.
tg_.getTransform(t3d);
1149 Matrix3d mat =
new Matrix3d();
1150 Vector3d vec =
new Vector3d();
1153 double[] ret =
new double[12];
1155 ret[3] = mat.m00; ret[4] = mat.m01; ret[5] = mat.m02;
1156 ret[6] = mat.m10; ret[7] = mat.m11; ret[8] = mat.m12;
1157 ret[9] = mat.m20; ret[10]= mat.m21; ret[11]= mat.m22;
1163 double[] ret = getTransformArray(link);
1165 double[] p = getDblAry(link.
getName()+
".translation",
null);
1166 if (p !=
null && p.length == 3) {
1167 System.arraycopy(p, 0, ret, 0, 3);
1170 double[] r = getDblAry(link.
getName()+
".rotation",
null);
1171 if (r !=
null && r.length == 4) {
1172 Matrix3d mat =
new Matrix3d();
1174 ret[3] = mat.m00; ret[4] = mat.m01; ret[5] = mat.m02;
1175 ret[6] = mat.m10; ret[7] = mat.m11; ret[8] = mat.m12;
1176 ret[9] = mat.m20; ret[10]= mat.m21; ret[11]= mat.m22;
1183 double[] ret = {0,0,0,0,0,0};
1184 double[] v = getDblAry(link.
getName()+
".velocity",
null);
1185 if (v !=
null && v.length == 3) {
1186 System.arraycopy(v, 0, ret, 0, 3);
1188 double[] w = getDblAry(link.
getName()+
".angularVelocity",
null);
1189 if (w !=
null && w.length == 3) {
1190 System.arraycopy(w, 0, ret, 3, 3);
1197 if (jointToLink_ ==
null)
1199 return jointToLink_.length;
1203 String[] names =
new String[jointToLink_.length];
1204 for (
int i=0;
i<jointToLink_.length;
i++)
1205 names[
i] = links_.get(jointToLink_[
i]).getName();
1210 double[] vals =
new double[jointToLink_.length];
1211 for (
int i=0;
i<jointToLink_.length;
i++)
1212 vals[
i] = links_.get(jointToLink_[
i]).jointValue_;
1217 double[] ret =
new double[jointToLink_.length];
1218 for (
int i=0;
i<ret.length;
i++) {
1227 double[] ret =
new double[jointToLink_.length];
1228 for (
int i=0;
i<ret.length;
i++) {
1231 ret[
i] = getDbl(jname+
".jointVelocity", 0.0);
1245 double[] ret =
new double[links_.size()];
1246 for (
int i=0;
i<ret.length;
i++) {
1247 String lname = links_.get(
i).getName();
1248 String mode = getStr(lname+
".mode",
"Torque");
1249 ret[
i] = mode.equals(
"HighGain") ? 1.0 : 0.0;
1259 super.setSelected(
b);
1276 if (
b) resizeBoundingBox();
1277 switchBb_.setWhichChild(
b ? Switch.CHILD_ALL : Switch.CHILD_NONE);
1283 public void delete() {
1285 Iterator<Camera_impl> it = cameraList_.iterator();
1287 it.next().destroy();
1288 if(bgRoot_.isLive()) bgRoot_.detach();
1291 for (
int i=0;
i<collisionPairItems.length;
i++) {
1293 String
name = getName();
1294 if(
name.equals(
item.getStr(
"objectName1",
""))){
1296 }
else if(
name.equals(
item.getStr(
"objectName2",
""))){
1302 for (
int i=0;
i<extraJointItems.length;
i++) {
1304 String
name = getName();
1305 if(
name.equals(
item.getStr(
"object1Name",
""))){
1307 }
else if(
name.equals(
item.getStr(
"object2Name",
""))){
1321 modifier.
init_ =
true;
1325 TransformGroup tg = getTransformGroupRoot();
1326 Transform3D t3dLocal =
new Transform3D();
1327 tg.getTransform(t3dLocal);
1329 for (
int i=0;
i<links_.size();
i++) {
1332 Shape3D shapeNode = (Shape3D)switchBb_.getChild(0);
1333 Geometry gm = (Geometry)shapeNode.getGeometry(0);
1336 if (gm instanceof QuadArray) {
1337 QuadArray qa = (QuadArray) gm;
1338 qa.setCoordinates(0, p3fW);
1348 switchCom_.setWhichChild(
b? Switch.CHILD_ALL:Switch.CHILD_NONE);
1349 calcForwardKinematics();
1351 switchCom_.setWhichChild(Switch.CHILD_NONE);
1361 switchComZ0_.setWhichChild(
b? Switch.CHILD_ALL:Switch.CHILD_NONE);
1362 calcForwardKinematics();
1364 switchComZ0_.setWhichChild(Switch.CHILD_NONE);
1373 setWireFrame(
b, bgRoot_);
1382 if (node instanceof Switch) {
1384 }
else if (node instanceof Group) {
1385 Group g = (Group) node;
1386 for (
int i = 0;
i < g.numChildren();
i++)
1387 setWireFrame(
b, g.getChild(
i));
1389 }
else if (node instanceof
Link) {
1391 SharedGroup sg = l.getSharedGroup();
1392 for (
int i = 0;
i < sg.numChildren();
i++)
1393 setWireFrame(
b, sg.getChild(
i));
1395 }
else if (node instanceof Shape3D) {
1396 Shape3D s3d = (Shape3D) node;
1397 Appearance app = s3d.getAppearance();
1399 PolygonAttributes pa = app.getPolygonAttributes();
1402 pa.setPolygonMode(PolygonAttributes.POLYGON_LINE);
1404 pa.setPolygonMode(PolygonAttributes.POLYGON_FILL);
1412 Iterator<GrxLinkItem> it = links_.iterator();
1414 it.next().setVisibleAABB(
b);
1422 setTransparencyMode(
b, bgRoot_);
1431 if (node instanceof Switch) {
1433 }
else if (node instanceof Group) {
1434 Group g = (Group) node;
1435 for (
int i = 0;
i < g.numChildren();
i++)
1436 setTransparencyMode(
b, g.getChild(
i));
1438 }
else if (node instanceof
Link) {
1440 SharedGroup sg = l.getSharedGroup();
1441 for (
int i = 0;
i < sg.numChildren();
i++)
1442 setTransparencyMode(
b, sg.getChild(
i));
1444 }
else if (node instanceof Shape3D) {
1445 Shape3D s3d = (Shape3D) node;
1446 Appearance app = s3d.getAppearance();
1448 TransparencyAttributes ta = app.getTransparencyAttributes();
1451 ta.setTransparency(0.5
f);
1452 ta.setTransparencyMode(TransparencyAttributes.FASTEST);
1454 ta.setTransparency(0
f);
1455 ta.setTransparencyMode(TransparencyAttributes.NONE);
1507 ret.
bInfo_ = (BodyInfo)bInfo_._duplicate();
1510 ret.
links_ =
new Vector<GrxLinkItem>(links_);
1547 return nameToLink_.get(
name);
1551 short[] depth =
new short[links_.size()];
1552 for(
int i=0;
i<links_.size();
i++)
1553 depth[
i] = links_.get(
i).getInt(
"NumOfAABB", 1).shortValue();
1556 mloader._non_existent();
1557 ModelLoadOption
option =
new ModelLoadOption();
1558 option.readImage =
false;
1559 option.AABBtype = AABBdataType.AABB_NUM;
1562 return mloader.getBodyInfoEx(getURL(
false),
option);
1563 }
catch(Exception e){
1574 LinkInfo[] links = bInfo_.links();
1575 shapes = bInfo_.shapes();
1576 appearances = bInfo_.appearances();
1577 materials = bInfo_.materials();
1578 textures = bInfo_.textures();
1580 int numLinks = links.length;
1581 for(
int i = 0;
i < numLinks;
i++) {
1582 links_.get(
i).clearAABB();
1583 TransformedShapeIndex[] tsi = links[
i].shapeIndices;
1584 for(
int j=0; j<tsi.length; j++){
1585 links_.get(
i).makeAABB(shapes[tsi[j].shapeIndex], tsi[j].transformMatrix );
1588 notifyObservers(
"BodyInfoChange");
1593 Iterator<GrxModelItem> it = models.iterator();
1594 while(it.hasNext()){
1596 if(!model.
getURL(
true).equals(getURL(
true)) || model ==
this)
1603 BodyInfo bodyInfo = getBodyInfoFromModelLoader();
1605 List<GrxModelItem> sameModels = getSameUrlModels();
1606 Iterator<GrxModelItem> it = sameModels.iterator();
1607 while(it.hasNext()){
1609 for(
int i=0;
i<links_.size();
i++){
1610 String
value = links_.get(
i).getStr(
"NumOfAABB");
1611 _model.
nameToLink_.get(links_.get(
i).getName()).setProperty(
"NumOfAABB",
value);
1623 String oldName = getName();
1625 super.rename(newName);
1630 Iterator it = mcoll.
values().iterator();
1634 if(oldName.equals(ci.getProperty(
"objectName1")))
1637 if(oldName.equals(ci.getProperty(
"objectName2")))
1644 Iterator it = mcoll.
values().iterator();
1648 if(oldName.equals(extraJoint.getProperty(
"object1Name")))
1651 if(oldName.equals(extraJoint.getProperty(
"object2Name")))
1659 if(key.matches(
".+\\.mode"))
1662 }
else if(key.equals(
"isRobot")){
1665 return super.GetValueEditType(key);
1669 extraJoints_.remove(extraJoint);
1675 this.extraJoints_.add(extraJoint);