List of usage examples for javax.media.j3d ImageComponent FORMAT_RGB
int FORMAT_RGB
To view the source code for javax.media.j3d ImageComponent FORMAT_RGB.
Click Source Link
From source file:ReadRaster.java
public BranchGroup createSceneGraph(BufferedImage bImage, Raster readRaster) { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); // Create a Raster shape. Add it to the root of the subgraph ImageComponent2D drawImageComponent = new ImageComponent2D(ImageComponent.FORMAT_RGB, bImage); Raster drawRaster = new Raster(new Point3f(0.0f, 0.0f, 0.0f), Raster.RASTER_COLOR, 0, 0, bImage.getWidth(), bImage.getHeight(), drawImageComponent, null); Shape3D shape = new Shape3D(drawRaster); drawRaster.setCapability(Raster.ALLOW_IMAGE_WRITE); objRoot.addChild(shape);/* w ww .j a v a2 s. c o m*/ // Ceate the transform greup node and initialize it to the // identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at runtime. Add it to the // root of the subgraph. TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); TransformGroup cubeScale = new TransformGroup(); Transform3D t3d = new Transform3D(); t3d.setTranslation(new Vector3d(-0.5, 0.5, 0.0)); cubeScale.setTransform(t3d); cubeScale.addChild(objTrans); objRoot.addChild(cubeScale); // Create a simple shape leaf node, add it to the scene graph. objTrans.addChild(new ColorCube(0.3)); // Create a new Behavior object that will perform the desired // operation on the specified transform object and add it into // the scene graph. Transform3D yAxis = new Transform3D(); Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0); myRotationInterpolator rotator = new myRotationInterpolator(drawRaster, readRaster, rotationAlpha, objTrans, yAxis, 0.0f, (float) Math.PI * 2.0f); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); rotator.setSchedulingBounds(bounds); objTrans.addChild(rotator); // Have Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:MultiTextureTest.java
public Texture createLightMap() { int width = 128; int height = 128; BufferedImage bimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); int[] rgbArray = new int[width * height]; int index, index2; int rgbInc = 256 / (width / 2 - 20); int rgbValue = 0; int k = width / 2 - 5; int i, j, rgb; rgb = 0xff;//from w ww. j a v a 2s . c o m rgbValue = rgb | (rgb << 8) | (rgb << 16) | (rgb << 24); for (i = width / 2 - 1, j = 0; j < 10; j++, i--) { rgbArray[i] = rgbValue; } for (; i > 8; i--, rgb -= rgbInc) { rgbValue = rgb | (rgb << 8) | (rgb << 16) | (rgb << 24); rgbArray[i] = rgbValue; } for (; i >= 0; i--) { rgbArray[i] = rgbValue; } for (i = 0; i < width / 2; i++) { rgbValue = rgbArray[i]; index = i; index2 = (width - i - 1); for (j = 0; j < height; j++) { rgbArray[index] = rgbArray[index2] = rgbValue; index += width; index2 += width; } } bimage.setRGB(0, 0, width, height, rgbArray, 0, width); ImageComponent2D grayImage = new ImageComponent2D(ImageComponent.FORMAT_RGB, bimage); lightTex = new Texture2D(Texture.BASE_LEVEL, Texture.RGB, width, height); lightTex.setImage(0, grayImage); return lightTex; }
From source file:ReadRaster.java
public void init() { int width = 128; int height = 128; ImageComponent2D readImageComponent = new ImageComponent2D(ImageComponent.FORMAT_RGB, width, height); Raster readRaster = new Raster(new Point3f(0.0f, 0.0f, 0.0f), Raster.RASTER_COLOR, 0, 0, width, height, readImageComponent, null);/* w ww.ja v a 2s .co m*/ setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D c = new myCanvas3D(config, readRaster); add("Center", c); // Create a simple scene and attach it to the virtual universe BufferedImage bImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); BranchGroup scene = createSceneGraph(bImage, readRaster); u = new SimpleUniverse(c); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(scene); }
From source file:ReadRaster.java
public void processStimulus(Enumeration criteria) { synchronized (readRaster) { bImage = readRaster.getImage().getImage(); }// w w w . j av a 2 s .com newImageComponent = new ImageComponent2D(ImageComponent.FORMAT_RGB, bImage); drawRaster.setImage(newImageComponent); super.processStimulus(criteria); }
From source file:J3dSwingFrame.java
/** * Set the texture on our goemetry//from w ww. j a v a2 s . c o m * <P> * Always specified as a URL so that we may fetch it from anywhere. * * @param url * The url to the image. */ public void setTexture(URL url) { Toolkit tk = Toolkit.getDefaultToolkit(); Image src_img = tk.createImage(url); BufferedImage buf_img = null; if (!(src_img instanceof BufferedImage)) { // create a component anonymous inner class to give us the image // observer we need to get the width and height of the source image. Component obs = new Component() { }; int width = src_img.getWidth(obs); int height = src_img.getHeight(obs); // construct the buffered image from the source data. buf_img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics g = buf_img.getGraphics(); g.drawImage(src_img, 0, 0, null); g.dispose(); } else buf_img = (BufferedImage) src_img; src_img.flush(); ImageComponent img_comp = new ImageComponent2D(ImageComponent.FORMAT_RGB, buf_img); texture = new Texture2D(Texture.BASE_LEVEL, Texture.RGB, img_comp.getWidth(), img_comp.getHeight()); appearance.setTexture(texture); buf_img.flush(); }
From source file:Human1.java
private BufferedImage doRender(int width, int height) { BufferedImage bImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); ImageComponent2D buffer = new ImageComponent2D(ImageComponent.FORMAT_RGB, bImage); //buffer.setYUp(true); setOffScreenBuffer(buffer);// ww w. j a va2s . com renderOffScreenBuffer(); waitForOffScreenRendering(); bImage = getOffScreenBuffer().getImage(); return bImage; }