Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (592)
Games in Android Showcase (168)
games submitted by our members
Games in WIP (645)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Using Raster  (Read 1654 times)
0 Members and 1 Guest are viewing this topic.
Offline Malohkan

Senior Devvie

while (true) System.out.println("WOO!!!!");

« Posted 2006-08-14 20:03:20 »

Well although this is probably a silly question that I should have been able to find the answers to, I've spent enough time searching that I think I'm ready to call out for help.  I'm using a Raster in my scene:
image =;
ImageComponent2D image2D = new ImageComponent2D(ImageComponent2D.FORMAT_RGBA, image);
Raster raster = new Raster();
raster.setSize(image.getWidth(), image.getHeight());

then I create a new Shape3D(raster) and use it in my scene.

I'm having two problems with this.  My first problem is that the position of the Raster is at the top left of the image.  I want it to be at the center.  In Java2D I would just translate by (-image.getWidth()/2, -image.getHeight()/2) but I've found no such equivalent here.  I tried setting the Raster position to that and it flies off the screen, obviously using a different scale.  Then I tried (-.5, -.5) which was closer but that moved it too far.  I read that it uses "object coordinates" so I assume that it's referring to the scale of my scene as thats what it appears to be doing.  But why in the world would it have its own personal embedded method to do that when I can just attach the Shape3D to a TransformGroup and move it in my scene like every other Geometry object?

My second problem is with the alpha.  I tried loading in a .gif with single color transparency and a .png with an alpha channel.  I made sure that in Java2D they are loaded in properly with the alpha working.  I put them in my code here in Java3D and I just get the white background to the image.  I tried mucking with the Appearance stuff but I can't find the answer there either.  I assume if the answer is anywhere that's where it is.  Could someone help me with that also?

Admin and Game Developer at
Play Rimscape!    |    Play Conquer!
Offline Mr. Gol

Senior Devvie

Medals: 1

« Reply #1 - Posted 2006-08-15 10:25:11 »

About your second problem: the default appearance is white, so that's why the background is white. Secondly, image transparancy is only useful when the object itself is transparent. You should make its appearance transparent first:

Shape3D shape=new Shape3D();
Appearance appearance=new Appearance();
TransparencyAttributes ta=new (TransparencyAttributes.FASTEST,1f);

I haven't got a clue about your first problem though, sorry.
Offline Malohkan

Senior Devvie

while (true) System.out.println("WOO!!!!");

« Reply #2 - Posted 2006-08-15 15:26:58 »

I tried your suggestion and the image disappears completely.  I also tried:

and that didn't have any effect.  Have any other ideas?

Admin and Game Developer at
Play Rimscape!    |    Play Conquer!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Mr. Gol

Senior Devvie

Medals: 1

« Reply #3 - Posted 2006-08-20 12:26:00 »

Strange that it didn't work, it did work for me when I made a shadow out of an image. But I'm still convinced the object appearing white is caused because the object itself has trhe default appearance.
Offline JAW

Senior Devvie

Medals: 2

« Reply #4 - Posted 2006-09-05 22:29:31 »

Hm, I draw an Image on a compatible BufferedImage, and BufferedImage has a function to get the raster. This works.

Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Za\'Anzabar (17 views)
2015-06-29 05:44:54

TritonDreyja (34 views)
2015-06-24 17:10:40

CopyableCougar4 (29 views)
2015-06-23 00:34:45

BurntPizza (32 views)
2015-06-21 20:36:46

cookiecompiler (77 views)
2015-06-11 15:42:53

cookiecompiler (39 views)
2015-06-11 15:41:14

NegativeZero (66 views)
2015-06-11 09:49:18

Fairy Tailz (89 views)
2015-06-11 01:59:47

chrislo27 (61 views)
2015-06-06 18:12:44

Burnsalan20 (74 views)
2015-06-05 03:00:51
How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!