/* */ package com.sun.j3d.utils.universe;
/* */
/* */ import java.util.HashSet;
/* */ import java.util.Iterator;
/* */ import java.util.Set;
/* */ import javax.media.j3d.PhysicalBody;
/* */ import javax.media.j3d.PhysicalEnvironment;
/* */ import javax.media.j3d.View;
/* */ import javax.vecmath.Point3d;
/* */
/* */ class ConfigView extends ConfigObject
/* */ {
/* 51 */ View j3dView = null;
/* 52 */ Viewer j3dViewer = null;
/* */
/* 57 */ Set screens = new HashSet();
/* */
/* 63 */ boolean stereoEnable = false;
/* */
/* 69 */ boolean antialiasingEnable = false;
/* */
/* 76 */ PhysicalBody physicalBody = null;
/* */
/* 83 */ PhysicalEnvironment physicalEnvironment = null;
/* */
/* 86 */ private double fieldOfView = 0.7853981633974483D;
/* 87 */ private int backClipPolicy = 3;
/* 88 */ private int frontClipPolicy = 3;
/* 89 */ private double backClipDistance = 10.0D;
/* 90 */ private double frontClipDistance = 0.1D;
/* 91 */ private int screenScalePolicy = 0;
/* 92 */ private double screenScale = 1.0D;
/* 93 */ private boolean trackingEnable = false;
/* 94 */ private int viewPolicy = 0;
/* 95 */ private int windowEyepointPolicy = -1;
/* 96 */ private int windowMovementPolicy = -1;
/* 97 */ private int windowResizePolicy = -1;
/* 98 */ private boolean coeCenteringEnableSet = false;
/* 99 */ private boolean coeCenteringEnable = false;
/* 100 */ private Point3d centerEyeInCoexistence = null;
/* */
/* 102 */ private ConfigPhysicalBody configBody = null;
/* 103 */ private ConfigPhysicalEnvironment configEnv = null;
/* 104 */ private ConfigViewPlatform configViewPlatform = null;
/* */
/* */ protected void initialize(ConfigCommand command)
/* */ {
/* */ }
/* */
/* */ protected void setProperty(ConfigCommand command)
/* */ {
/* 120 */ int argc = command.argc;
/* 121 */ Object[] argv = command.argv;
/* 122 */ String attr = null;
/* 123 */ Object val = null;
/* 124 */ String sval = null;
/* 125 */ ConfigScreen cs = null;
/* */
/* 128 */ if (argc != 4) {
/* 129 */ syntaxError("Incorrect number of arguments to " + command.commandName);
/* */ }
/* */
/* 133 */ if (!isName(argv[1])) {
/* 134 */ syntaxError("The first argument to " + command.commandName + " must be the instance name");
/* */ }
/* */
/* 138 */ if (!isName(argv[2])) {
/* 139 */ syntaxError("The second argument to " + command.commandName + " must be a property name");
/* */ }
/* */
/* 143 */ attr = (String)argv[2];
/* 144 */ val = argv[3];
/* */
/* 146 */ if ((attr.equals("Screen")) || (attr.equals("Window"))) {
/* 147 */ if (!(val instanceof String)) {
/* 148 */ syntaxError("Value for " + attr + " must be a name");
/* */ }
/* 150 */ cs = (ConfigScreen)this.configContainer.findConfigObject("Screen", (String)val);
/* */
/* 153 */ if (!this.screens.add(cs)) {
/* 154 */ syntaxError(attr + " \"" + (String)val + "\" has already been added to " + this.instanceName);
/* */ }
/* */
/* */ }
/* 158 */ else if (attr.equals("ViewPlatform")) {
/* 159 */ if (!(val instanceof String)) {
/* 160 */ syntaxError("value for ViewPlatform must be an instance name");
/* */ }
/* */
/* 163 */ this.configViewPlatform = ((ConfigViewPlatform)this.configContainer.findConfigObject("ViewPlatform", (String)val));
/* */
/* 167 */ this.configViewPlatform.addConfigView(this);
/* */ }
/* 169 */ else if (attr.equals("PhysicalEnvironment")) {
/* 170 */ if (!(val instanceof String)) {
/* 171 */ syntaxError("value for PhysicalEnvironment must be an instance name");
/* */ }
/* */
/* 174 */ this.configEnv = ((ConfigPhysicalEnvironment)this.configContainer.findConfigObject("PhysicalEnvironment", (String)val));
/* */ }
/* 178 */ else if (attr.equals("PhysicalBody")) {
/* 179 */ if (!(val instanceof String)) {
/* 180 */ syntaxError("value for PhysicalBody must be an instance name");
/* */ }
/* */
/* 183 */ this.configBody = ((ConfigPhysicalBody)this.configContainer.findConfigObject("PhysicalBody", (String)val));
/* */ }
/* 186 */ else if (attr.equals("BackClipPolicy")) {
/* 187 */ if (!(val instanceof String)) {
/* 188 */ syntaxError("value for BackClipPolicy must be a string");
/* */ }
/* 190 */ sval = (String)val;
/* 191 */ if (sval.equals("PHYSICAL_EYE"))
/* 192 */ this.backClipPolicy = 3;
/* 193 */ else if (sval.equals("PHYSICAL_SCREEN"))
/* 194 */ this.backClipPolicy = 1;
/* 195 */ else if (sval.equals("VIRTUAL_EYE"))
/* 196 */ this.backClipPolicy = 2;
/* 197 */ else if (sval.equals("VIRTUAL_SCREEN"))
/* 198 */ this.backClipPolicy = 0;
/* */ else
/* 200 */ syntaxError("Invalid value for BackClipPolicy " + sval);
/* */ }
/* 202 */ else if (attr.equals("FrontClipPolicy")) {
/* 203 */ if (!(val instanceof String)) {
/* 204 */ syntaxError("value for FrontClipPolicy must be a string");
/* */ }
/* 206 */ sval = (String)val;
/* 207 */ if (sval.equals("PHYSICAL_EYE"))
/* 208 */ this.frontClipPolicy = 3;
/* 209 */ else if (sval.equals("PHYSICAL_SCREEN"))
/* 210 */ this.frontClipPolicy = 1;
/* 211 */ else if (sval.equals("VIRTUAL_EYE"))
/* 212 */ this.frontClipPolicy = 2;
/* 213 */ else if (sval.equals("VIRTUAL_SCREEN"))
/* 214 */ this.frontClipPolicy = 0;
/* */ else
/* 216 */ syntaxError("Invalid value for FrontClipPolicy " + sval);
/* */ }
/* 218 */ else if (attr.equals("ScreenScalePolicy")) {
/* 219 */ if (!(val instanceof String)) {
/* 220 */ syntaxError("value for ScreenScalePolicy must be a string");
/* */ }
/* 222 */ sval = (String)val;
/* 223 */ if (sval.equals("SCALE_SCREEN_SIZE"))
/* 224 */ this.screenScalePolicy = 0;
/* 225 */ else if (sval.equals("SCALE_EXPLICIT"))
/* 226 */ this.screenScalePolicy = 1;
/* */ else
/* 228 */ syntaxError("Invalid value for ScreenScalePolicy " + sval);
/* */ }
/* 230 */ else if (attr.equals("FieldOfView")) {
/* 231 */ if (!(val instanceof Double)) {
/* 232 */ syntaxError("value for FieldOfView must be a number");
/* */ }
/* 234 */ this.fieldOfView = ((Double)val).doubleValue();
/* */ }
/* 236 */ else if (attr.equals("BackClipDistance")) {
/* 237 */ if (!(val instanceof Double)) {
/* 238 */ syntaxError("value for BackClipDistance must be a number");
/* */ }
/* 240 */ this.backClipDistance = ((Double)val).doubleValue();
/* */ }
/* 242 */ else if (attr.equals("FrontClipDistance")) {
/* 243 */ if (!(val instanceof Double)) {
/* 244 */ syntaxError("value for FrontClipDistance must be a number");
/* */ }
/* 246 */ this.frontClipDistance = ((Double)val).doubleValue();
/* */ }
/* 248 */ else if (attr.equals("ScreenScale")) {
/* 249 */ if (!(val instanceof Double)) {
/* 250 */ syntaxError("value for ScreenScale must be a number");
/* */ }
/* 252 */ this.screenScale = ((Double)val).doubleValue();
/* */ }
/* 254 */ else if (attr.equals("TrackingEnable")) {
/* 255 */ if (!(val instanceof Boolean)) {
/* 256 */ syntaxError("value for TrackingEnable must be a boolean");
/* */ }
/* 258 */ this.trackingEnable = ((Boolean)val).booleanValue();
/* */ }
/* 260 */ else if (attr.equals("CoexistenceCenteringEnable")) {
/* 261 */ if (!(val instanceof Boolean)) {
/* 262 */ syntaxError("value for CoexistenceCenteringEnable must be a boolean");
/* */ }
/* */
/* 265 */ this.coeCenteringEnable = ((Boolean)val).booleanValue();
/* 266 */ this.coeCenteringEnableSet = true;
/* */ }
/* 268 */ else if (attr.equals("ViewPolicy")) {
/* 269 */ if (!(val instanceof String)) {
/* 270 */ syntaxError("value for ViewPolicy must be a string");
/* */ }
/* 272 */ sval = (String)val;
/* 273 */ if (sval.equals("SCREEN_VIEW"))
/* 274 */ this.viewPolicy = 0;
/* 275 */ else if (sval.equals("HMD_VIEW"))
/* 276 */ this.viewPolicy = 1;
/* */ else
/* 278 */ syntaxError("Invalid value for ViewPolicy " + sval);
/* */ }
/* 280 */ else if (attr.equals("WindowEyepointPolicy")) {
/* 281 */ if (!(val instanceof String)) {
/* 282 */ syntaxError("value for WindowEyepointPolicy must be a string");
/* */ }
/* */
/* 285 */ sval = (String)val;
/* 286 */ if (sval.equals("RELATIVE_TO_SCREEN"))
/* 287 */ this.windowEyepointPolicy = 0;
/* 288 */ else if (sval.equals("RELATIVE_TO_COEXISTENCE"))
/* 289 */ this.windowEyepointPolicy = 3;
/* 290 */ else if (sval.equals("RELATIVE_TO_WINDOW"))
/* 291 */ this.windowEyepointPolicy = 1;
/* 292 */ else if (sval.equals("RELATIVE_TO_FIELD_OF_VIEW"))
/* 293 */ this.windowEyepointPolicy = 2;
/* */ else
/* 295 */ syntaxError("Invalid value for WindowEyepointPolicy " + sval);
/* */ }
/* 297 */ else if (attr.equals("WindowMovementPolicy")) {
/* 298 */ if (!(val instanceof String)) {
/* 299 */ syntaxError("value for WindowEyeMovementPolicy must be a string");
/* */ }
/* */
/* 302 */ sval = (String)val;
/* 303 */ if (sval.equals("VIRTUAL_WORLD"))
/* 304 */ this.windowMovementPolicy = 0;
/* 305 */ else if (sval.equals("PHYSICAL_WORLD"))
/* 306 */ this.windowMovementPolicy = 1;
/* */ else
/* 308 */ syntaxError("Invalid value for WindowMovementPolicy " + sval);
/* */ }
/* 310 */ else if (attr.equals("WindowResizePolicy")) {
/* 311 */ if (!(val instanceof String)) {
/* 312 */ syntaxError("value for WindowResizePolicy must be a string");
/* */ }
/* */
/* 315 */ sval = (String)val;
/* 316 */ if (sval.equals("VIRTUAL_WORLD"))
/* 317 */ this.windowResizePolicy = 0;
/* 318 */ else if (sval.equals("PHYSICAL_WORLD"))
/* 319 */ this.windowResizePolicy = 1;
/* */ else
/* 321 */ syntaxError("Invalid value for WindowResizePolicy " + sval);
/* */ }
/* 323 */ else if (attr.equals("CenterEyeInCoexistence")) {
/* 324 */ if ((val instanceof Point3d))
/* 325 */ this.centerEyeInCoexistence = ((Point3d)val);
/* */ else {
/* 327 */ syntaxError("value for CenterEyeInCoexistence must be a Point3d");
/* */ }
/* */ }
/* 330 */ else if (attr.equals("StereoEnable")) {
/* 331 */ if (!(val instanceof Boolean)) {
/* 332 */ syntaxError("value for StereoEnable must be a boolean");
/* */ }
/* 334 */ this.stereoEnable = ((Boolean)val).booleanValue();
/* */ }
/* 336 */ else if (attr.equals("AntialiasingEnable")) {
/* 337 */ if (!(val instanceof Boolean)) {
/* 338 */ syntaxError("value for AntialiasingEnable must be a boolean");
/* */ }
/* 340 */ this.antialiasingEnable = ((Boolean)val).booleanValue();
/* */ }
/* */ else {
/* 343 */ syntaxError("Unknown " + command.commandName + " \"" + attr + "\"");
/* */ }
/* */ }
/* */
/* */ protected Viewer createViewer(boolean setVisible)
/* */ {
/* 355 */ this.j3dView = new View();
/* 356 */ this.j3dView.setViewPolicy(this.viewPolicy);
/* */
/* 358 */ if (this.configBody == null)
/* 359 */ this.physicalBody = new PhysicalBody();
/* */ else {
/* 361 */ this.physicalBody = this.configBody.j3dPhysicalBody;
/* */ }
/* 363 */ if (this.configEnv == null)
/* 364 */ this.physicalEnvironment = new PhysicalEnvironment();
/* */ else {
/* 366 */ this.physicalEnvironment = this.configEnv.j3dPhysicalEnvironment;
/* */ }
/* 368 */ this.j3dView.setPhysicalBody(this.physicalBody);
/* 369 */ this.j3dView.setPhysicalEnvironment(this.physicalEnvironment);
/* */
/* 371 */ boolean standardDefaults = true;
/* 372 */ if ((this.coeCenteringEnableSet) && (!this.coeCenteringEnable)) {
/* 373 */ standardDefaults = false;
/* */ }
/* 375 */ if ((this.configEnv != null) && (this.configEnv.coexistenceToTrackerBase != null)) {
/* 376 */ standardDefaults = false;
/* */ }
/* */ else {
/* 379 */ Iterator i = this.screens.iterator();
/* 380 */ while (i.hasNext()) {
/* 381 */ ConfigScreen s = (ConfigScreen)i.next();
/* 382 */ if (s.trackerBaseToImagePlate != null) {
/* 383 */ standardDefaults = false;
/* 384 */ break;
/* */ }
/* */ }
/* */ }
/* */
/* 389 */ if (standardDefaults)
/* */ {
/* 393 */ if (this.windowEyepointPolicy == -1)
/* 394 */ this.windowEyepointPolicy = 2;
/* 395 */ if (this.windowMovementPolicy == -1)
/* 396 */ this.windowMovementPolicy = 1;
/* 397 */ if (this.windowResizePolicy == -1)
/* 398 */ this.windowResizePolicy = 1;
/* 399 */ if (!this.coeCenteringEnableSet)
/* 400 */ this.coeCenteringEnable = true;
/* */ }
/* */ else
/* */ {
/* 404 */ if (this.windowEyepointPolicy == -1)
/* 405 */ this.windowEyepointPolicy = 3;
/* 406 */ if (this.windowMovementPolicy == -1)
/* 407 */ this.windowMovementPolicy = 0;
/* 408 */ if (this.windowResizePolicy == -1)
/* 409 */ this.windowResizePolicy = 0;
/* 410 */ if (!this.coeCenteringEnableSet) {
/* 411 */ this.coeCenteringEnable = false;
/* */ }
/* */ }
/* 414 */ this.j3dView.setWindowEyepointPolicy(this.windowEyepointPolicy);
/* 415 */ this.j3dView.setWindowMovementPolicy(this.windowMovementPolicy);
/* 416 */ this.j3dView.setWindowResizePolicy(this.windowResizePolicy);
/* 417 */ this.j3dView.setCoexistenceCenteringEnable(this.coeCenteringEnable);
/* */
/* 419 */ if (this.centerEyeInCoexistence == null) {
/* 420 */ this.centerEyeInCoexistence = new Point3d(0.0D, 0.0D, 0.4572D);
/* */ }
/* */
/* 423 */ Point3d leftEyeCoe = new Point3d(this.centerEyeInCoexistence);
/* 424 */ Point3d rightEyeCoe = new Point3d(this.centerEyeInCoexistence);
/* */
/* 426 */ if (this.stereoEnable) {
/* 427 */ Point3d leftEyeBody = new Point3d();
/* 428 */ Point3d rightEyeBody = new Point3d();
/* */
/* 430 */ this.physicalBody.getLeftEyePosition(leftEyeBody);
/* 431 */ this.physicalBody.getRightEyePosition(rightEyeBody);
/* */
/* 433 */ leftEyeCoe.add(leftEyeBody);
/* 434 */ rightEyeCoe.add(rightEyeBody);
/* */ }
/* */
/* 437 */ this.j3dView.setLeftManualEyeInCoexistence(leftEyeCoe);
/* 438 */ this.j3dView.setRightManualEyeInCoexistence(rightEyeCoe);
/* */
/* 440 */ this.j3dView.setBackClipPolicy(this.backClipPolicy);
/* 441 */ this.j3dView.setFrontClipPolicy(this.frontClipPolicy);
/* 442 */ this.j3dView.setBackClipDistance(this.backClipDistance);
/* 443 */ this.j3dView.setFrontClipDistance(this.frontClipDistance);
/* */
/* 445 */ this.j3dView.setScreenScalePolicy(this.screenScalePolicy);
/* 446 */ this.j3dView.setScreenScale(this.screenScale);
/* */
/* 448 */ this.j3dView.setFieldOfView(this.fieldOfView);
/* 449 */ this.j3dView.setTrackingEnable(this.trackingEnable);
/* 450 */ this.j3dView.setSceneAntialiasingEnable(this.antialiasingEnable);
/* */
/* 452 */ if (this.screens.size() == 0) {
/* 453 */ throw new IllegalStateException(errorMessage(this.creatingCommand, "View \"" + this.instanceName + "\" has no canvases or screens"));
/* */ }
/* */
/* 458 */ ConfigScreen[] cs = new ConfigScreen[this.screens.size()];
/* 459 */ this.screens.toArray(cs);
/* */
/* 461 */ this.j3dViewer = new Viewer(cs, this, setVisible);
/* 462 */ return this.j3dViewer;
/* */ }
/* */ }
/* Location: Z:\System\Library\Java\Extensions\j3dutils.jar
* Qualified Name: com.sun.j3d.utils.universe.ConfigView
* JD-Core Version: 0.6.2
*/