ViewInfo.java
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * General Robotix Inc.
8  * National Institute of Advanced Industrial Science and Technology (AIST)
9  */
17 package com.generalrobotix.ui.view.tdview;
18 
19 import javax.media.j3d.*;
20 import javax.vecmath.*;
21 
22 public class ViewInfo {
23  /* View のモードを示すフラグ */
24  public static final int VIEW_MODE_FIXED = 0;
25  public static final int VIEW_MODE_WALK = 1;
26  public static final int VIEW_MODE_ROOM = 2;
27  public static final int VIEW_MODE_PARALLEL = 4;
28  public static final int MODE_MASK =
29  VIEW_MODE_WALK | VIEW_MODE_ROOM | VIEW_MODE_PARALLEL;
30 
31  public static final int FRONT_VIEW = 8;
32  public static final int BACK_VIEW = 16;
33  public static final int LEFT_VIEW = 32;
34  public static final int RIGHT_VIEW = 64;
35  public static final int TOP_VIEW = 128;
36  public static final int BOTTOM_VIEW = 256;
37  public static final int VIEW_MASK =
38  FRONT_VIEW | BACK_VIEW | LEFT_VIEW | RIGHT_VIEW | TOP_VIEW | BOTTOM_VIEW;
39 
40  private int mode_; // モード
41  private double distance_; // 原点からの距離
42 
43  protected Transform3D transform_;
44 
45  public double fieldOfView;
46  public double frontClipDistance = 0.5;
47  public double backClipDistance = 200;
48 
50 
56  public ViewInfo(int mode, double dist) {
57  transform_ = new Transform3D();
58  setDistance(dist);
59  setViewMode(mode);
60  setDirection(mode);
61  }
62 
67  public void setViewMode(int mode) {
68  if ((mode_ & VIEW_MASK) == VIEW_MODE_FIXED) return;
69  mode_ = (mode & MODE_MASK) | (mode_ & VIEW_MASK);
70  if (listener_ != null) {
71  listener_.viewModeChanged(mode);
72  }
73  }
74 
79  public void setDistance(double dist) {
80  distance_ = dist;
81  }
82 
87  public void setDirection(int dir) {
88  // VIEW_MODE_PARALELL以外のモードではセットできない
89  //if ((mode_ & MODE_MASK) != VIEW_MODE_PARALLEL) return;
90  mode_ = (mode_ & MODE_MASK) | (dir & VIEW_MASK);
91  Matrix3d rot = new Matrix3d();
92  Vector3d pos = new Vector3d();
93  switch (mode_ & VIEW_MASK) {
94  case FRONT_VIEW:
95  pos.set(new double[]{distance_, 0.0, 0.0});
96  rot.set(
97  new Matrix3d(
98  0.0, 0.0, 1.0,
99  1.0, 0.0, 0.0,
100  0.0, 1.0, 0.0
101  )
102  );
103  break;
104  case BACK_VIEW:
105  pos.set(new double[]{-distance_, 0.0, 0.0});
106  rot.set(
107  new Matrix3d(
108  0.0, 0.0, -1.0,
109  -1.0, 0.0, 0.0,
110  0.0, 1.0, 0.0
111  )
112  );
113  break;
114  case LEFT_VIEW:
115  pos.set(new double[]{0.0, distance_, 0.0});
116  rot.set(
117  new Matrix3d(
118  -1.0, 0.0, 0.0,
119  0.0, 0.0, 1.0,
120  0.0, 1.0, 0.0
121  )
122  );
123  break;
124  case RIGHT_VIEW:
125  pos.set(new double[]{0.0, -distance_, 0.0});
126  rot.set(
127  new Matrix3d(
128  1.0, 0.0, 0.0,
129  0.0, 0.0, -1.0,
130  0.0, 1.0, 0.0
131  )
132  );
133  break;
134  case TOP_VIEW:
135  pos.set(new double[]{0.0, 0.0, distance_});
136  rot.set(
137  new Matrix3d(
138  0.0, 1.0, 0.0,
139  -1.0, 0.0, 0.0,
140  0.0, 0.0, 1.0
141  )
142  );
143  break;
144  case BOTTOM_VIEW:
145  pos.set(new double[]{0.0, 0.0, -distance_});
146  rot.set(
147  new Matrix3d(
148  0.0, 1.0, 0.0,
149  1.0, 0.0, 0.0,
150  0.0, 0.0, -1.0
151  )
152  );
153  break;
154  }
155  transform_.setTranslation(pos);
156  transform_.setRotation(rot);
157  }
158 
163  public int getViewMode() {
164  return (mode_ & MODE_MASK);
165  }
166 
167  public int getDirection() {
168  return (mode_ & VIEW_MASK);
169  }
170 
175  public Transform3D getTransform() {
176  return transform_;
177  }
178 
179  public void setTransform(Transform3D transform) {
180  transform_.set(transform);
181  }
182 
184  listener_ = ViewModeChangeMulticaster.add(listener_, listener);
185  }
186 
188  listener_ = ViewModeChangeMulticaster.remove(listener_, listener);
189  }
190 }
#define null
our own NULL pointer
Definition: IceTypes.h:57
static ViewModeChangeListener add(ViewModeChangeListener listener1, ViewModeChangeListener listener2)
void removeViewModeChangeListener(ViewModeChangeListener listener)
Definition: ViewInfo.java:187
static ViewModeChangeListener remove(ViewModeChangeListener listener, ViewModeChangeListener old)
void setTransform(Transform3D transform)
Definition: ViewInfo.java:179
void addViewModeChangeListener(ViewModeChangeListener listener)
Definition: ViewInfo.java:183


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Sep 8 2022 02:24:05