Skip to main content
gamedev.net
🔒 Locked

[java] Rendering a static 2D Image over a Java 3D Screen

Started by BlackDragon777 1 reply 1.2k views
Original Post
BlackDragon777
BlackDragon777
Hello. I want to render a 2d logo over a 3d object screen. I would like to avoid texture mapping a plain if I can. I saw the sprite3D class I have tried using it. My problem I guess is with loading an image. I have a gif,jpg, and png versino of my image. I have tried loading all of them however none will load. Here is my code

Image img;
 CompositingMode cm = new CompositingMode();
 cm.setBlending(CompositingMode.ALPHA);
   
 Appearance appearance = new Appearance();
 appearance.setCompositingMode(cm);
  
  
 img = loadImage("c:/top.jpg");
 sprite3D = new Sprite3D(false,new Image2D(Image2D.RGB,img),appearance);
The error I get is, Exception in thread "main" java.lang.ClassCastException: [I at sun.awt.image.ByteInterleavedRaster.getDataElements(Unknown Source) at javax.microedition.m3g.Image2D.<init>(Image2D.java:216) at mot.psm.renderEnv.RenderEnvM3G.initWindow(RenderEnvM3G.java:319) at mot.psm.renderEnv.RenderEnvM3G.<init>(RenderEnvM3G.java:129) at mot.psm.framework.m3g.Avatar.main(Avatar.java:1703) Any ideas?
BlackDragon777
BlackDragon777
By the way, my loadimage code looks like

	private Image loadImage(String s) {		InputStream is;		Image img = null;		try {			String fs = s;			is = new FileInputStream(new File(fs));			img = ImageIO.read(is);		}		catch (FileNotFoundException e) {			e.printStackTrace();		}		catch (IOException e) {			e.printStackTrace();		}		return img;	}
Son of Cain
Son of Cain
What are you casting?

If not you, then some method you're calling is expecting a specific implemention of a super class, and receiving the other - and when it performs the casting in its body, it throws the exception.

Son Of Cain
a.k.a javabeats at yahoo.ca

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.