Sign in to follow this  
BlackDragon777

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

Recommended Posts

BlackDragon777    163
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?

Share this post


Link to post
Share on other sites
BlackDragon777    163
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;
}

Share this post


Link to post
Share on other sites
Son of Cain    480
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this