• Advertisement
Sign in to follow this  

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

This topic is 4326 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
Sign in to follow this  

  • Advertisement