Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (115)
games submitted by our members
Games in WIP (563)
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 1535 times)
0 Members and 1 Guest are viewing this topic.
Offline Malohkan

Senior Member




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:
1  
2  
3  
4  
5  
6  
7  
image = ImageIO.read(getURL());
           
ImageComponent2D image2D = new ImageComponent2D(ImageComponent2D.FORMAT_RGBA, image);
Raster raster = new Raster();
raster.setType(Raster.RASTER_COLOR);
raster.setImage(image2D);
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
GameLizard.com
Play Rimscape!    |    Play Conquer!
Offline Mr. Gol

Senior Member


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:

1  
2  
3  
4  
5  
6  
Shape3D shape=new Shape3D();
shape.setGeometry(raster);
Appearance appearance=new Appearance();
TransparencyAttributes ta=new (TransparencyAttributes.FASTEST,1f);
appaearance.setTransparencyAttributes(ta);
shape.setAppearance(appearance);


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

Senior Member




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:
transparency.setTransparencyMode(TransparencyAttributes.NICEST);

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

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

Senior Member


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 Member


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.

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

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

radar3301 (11 views)
2014-09-21 23:33:17

BurntPizza (29 views)
2014-09-21 02:42:18

BurntPizza (19 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (27 views)
2014-09-20 20:14:06

BurntPizza (30 views)
2014-09-19 03:14:18

Dwinin (47 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (102 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!