11 package com.generalrobotix.ui.view.vsensor;
13 import java.awt.Canvas;
14 import java.awt.EventQueue;
15 import java.awt.FlowLayout;
16 import java.awt.Graphics;
17 import java.awt.image.BufferedImage;
21 import javax.media.j3d.*;
22 import javax.vecmath.*;
56 private PhysicalEnvironment
penv_;
69 public Camera_impl(CameraParameter param,
boolean offScreen) {
77 height_ = param.height;
79 image_ =
new ImageData();
81 image_.width = param_.width;
82 image_.height = param_.height;
84 image_.octetData =
new byte[1];
85 image_.longData =
new int[1];
86 image_.floatData =
new float[1];
89 CameraType cameraType = param.type;
91 if (cameraType == CameraType.MONO)
92 image_.format = PixelFormat.GRAY;
94 image_.format = PixelFormat.ARGB;
98 BufferedImage bimageRead =
null;
99 ImageComponent2D readImage =
null;
100 if (cameraType == CameraType.COLOR || cameraType == CameraType.COLOR_DEPTH ||
101 cameraType == CameraType.MONO || cameraType == CameraType.MONO_DEPTH) {
102 bimageRead =
new BufferedImage(width_, height_, BufferedImage.TYPE_INT_RGB);
103 readImage =
new ImageComponent2D(ImageComponent.FORMAT_RGB, bimageRead);
107 DepthComponentFloat readDepthFloat =
null;
108 if (cameraType == CameraType.DEPTH
109 || cameraType == CameraType.COLOR_DEPTH
110 || cameraType == CameraType.MONO_DEPTH) {
111 readDepthFloat =
new DepthComponentFloat(width_, height_);
116 if (cameraType != CameraType.NONE) {
117 if (cameraType == CameraType.COLOR
118 || cameraType == CameraType.MONO)
119 rasterType = Raster.RASTER_COLOR;
121 else if (cameraType == CameraType.DEPTH)
122 rasterType = Raster.RASTER_DEPTH;
125 rasterType = Raster.RASTER_COLOR_DEPTH;
127 raster_ =
new Raster(
128 new Point3f(), rasterType,
129 0, 0, width_, height_,
130 readImage, readDepthFloat
138 bgVp_ =
new BranchGroup();
139 bgVp_.setCapability(BranchGroup.ALLOW_DETACH);
140 bgVp_.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
141 bgVp_.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
142 bgVp_.setUserData(param_.defName);
144 tgVp_ =
new TransformGroup();
145 tgVp_.setCapability(TransformGroup.ALLOW_CHILDREN_READ);
146 tgVp_.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
147 tgVp_.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
149 vplatform_ =
new ViewPlatform();
152 view_.setFrontClipPolicy(View.VIRTUAL_EYE);
153 view_.setBackClipPolicy(View.VIRTUAL_EYE);
154 view_.setFrontClipDistance(param.frontClipDistance);
155 view_.setBackClipDistance(param.backClipDistance);
156 view_.setFieldOfView(param.fieldOfView);
158 pbody_ =
new PhysicalBody();
160 penv_ =
new PhysicalEnvironment();
184 bgVp_.addChild(tgVp_);
185 tgVp_.addChild(vplatform_);
186 view_.addCanvas3D(canvas_);
187 view_.attachViewPlatform(vplatform_);
188 view_.setPhysicalBody(pbody_);
189 view_.setPhysicalEnvironment(penv_);
195 frm_ =
new JFrame(param.sensorName);
196 frm_.setSize(width_ + 20, height_ + 30);
197 frm_.getContentPane().setLayout(
new FlowLayout());
200 canvas2.setSize(width_, height_);
201 frm_.getContentPane().add(canvas2);
203 frm_.getContentPane().add(canvas_);
206 frm_.setResizable(
false);
207 frm_.setAlwaysOnTop(
true);
210 @SuppressWarnings(
"serial")
212 BufferedImage bImage_;
214 if (bImage_ ==
null){
215 bImage_ =
new BufferedImage(width_, height_, BufferedImage.TYPE_INT_ARGB);
220 g.drawImage(bImage_, 0, 0,
null);
234 System.out.println(
"Camera_impl::destroy()");
241 EventQueue.invokeLater(
new Runnable () {
243 frm_.setVisible(
false);
274 return frm_.isVisible();
278 if (
frm_.isVisible() !=
b){
285 }
catch(Exception e){}
293 int frame = (
int)(time*
param_.frameRate);
322 if (
param_.type == CameraType.COLOR ||
323 param_.type == CameraType.COLOR_DEPTH){
327 if (
param_.type == CameraType.MONO ||
328 param_.type == CameraType.MONO_DEPTH){
332 if (
param_.type == CameraType.DEPTH ||
333 param_.type == CameraType.COLOR_DEPTH){
TransformGroup getTransformGroup()
#define null
our own NULL pointer
png_bytep png_bytep png_size_t length
static final GraphicsConfiguration graphicsConfiguration
void updateView(double time)
BranchGroup getBranchGroup()
float [] getDepthBuffer()
CameraParameter getCameraParameter()
float [] getDepthBuffer()
void setVisible(boolean b)
PhysicalEnvironment penv_
Camera_impl(CameraParameter param, boolean offScreen)