Hello Tom!
 
I developed this class for a ground. I think I use the 3:rd constructor. But perhaps this isn't the best way, I do not know.
 
Best regards
Fredrik
 
 import java.applet.*;
 import java.awt.*;
 import java.awt.Frame;
 import java.awt.event.*;
 import com.sun.j3d.utils.applet.MainFrame;
 import com.sun.j3d.utils.universe.*;
 import com.sun.j3d.utils.geometry.*;
 import javax.media.j3d.*;
 import javax.vecmath.*;
 import java.awt.event.*;
 import java.util.Enumeration;
 
 
 
 public class Ground extends Shape3D
 {
  float x = 2;
  float y = 4;
  float z = 2;
 
  float posX = 0;
  float posY = 0;
  float posZ = 0;
 
  int type = 0;
 
  String imageName;
 
  public Ground(float x, float y, float z, Point3f point3f, String imageName, Applet applet)
  {
  //System.out.println("TextureGround 1");
   this.x = x;
   this.y = y;
   this.z = z;
 
   posX = point3f.x;
   posY = point3f.y;
   posZ = point3f.z;
 
  QuadArray quadArray = new QuadArray(4, GeometryArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2);
  //Point3f point3f = new Point3f(posX,  posY, posZ);
  quadArray.setCoordinate(0, point3f);
 
  point3f.set(posX, posY, posZ + z);
  quadArray.setCoordinate(1, point3f);
 
  point3f.set(posX + x, posY,  posZ + z);
  quadArray.setCoordinate(2, point3f);
 
  point3f.set(posX + x,  posY, posZ);
  quadArray.setCoordinate(3, point3f);
 

  Point2f point2f = new Point2f(0.0f, 1.0f);
  quadArray.setTextureCoordinate(0, point2f);
 
  point2f.set(0.0f, 0.0f);
  quadArray.setTextureCoordinate(1, point2f);
 
  point2f.set(1.0f, 0.0f);
  quadArray.setTextureCoordinate(2, point2f);
 
  point2f.set(1.0f, 1.0f);
  quadArray.setTextureCoordinate(3, point2f);
 
  setAppearance(new TextureAppearance(imageName, applet));
  setGeometry(quadArray);
  }
 

  public Ground(float x, float y, float z, Point3f point3f, String imageName, Applet applet, int type)
  {
  //System.out.println("TextureGround 2");
   this.x = x;
   this.y = y;
   this.z = z;
 

   posX = point3f.x;
   posY = point3f.y;
   posZ = point3f.z;
 
  QuadArray quadArray = new QuadArray(4, GeometryArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2);
 
  //Point3f point3f = new Point3f(posX,  posY, posZ);
  quadArray.setCoordinate(0, point3f);
 
  point3f.set(posX, posY, posZ + z);
  quadArray.setCoordinate(1, point3f);
 
  point3f.set(posX + x, posY,  posZ + z);
  quadArray.setCoordinate(2, point3f);
 
  point3f.set(posX + x,  posY, posZ);
  quadArray.setCoordinate(3, point3f);
 

  Point2f point2f = new Point2f(0.0f, 1.0f);
  quadArray.setTextureCoordinate(0, point2f);
 
  point2f.set(0.0f, 0.0f);
  quadArray.setTextureCoordinate(1, point2f);
 
  point2f.set(1.0f, 0.0f);
  quadArray.setTextureCoordinate(2, point2f);
 
  point2f.set(1.0f, 1.0f);
  quadArray.setTextureCoordinate(3, point2f);
 
  setAppearance(new TextureAppearance(imageName, applet));
  setGeometry(quadArray);
  }
 
   public Ground(float x, float y, float z, String imageName, Applet applet, int type)
   {
  this.imageName = imageName;
 
  //System.out.println("TextureGround 3");
    this.x = x;
    this.y = y;
    this.z = z;
 
   QuadArray quadArray = new QuadArray(4, GeometryArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2);
 
   Point3f point3f = new Point3f(posX,  posY, posZ);
   quadArray.setCoordinate(0, point3f);
 
  point3f.set(posX, posY, posZ + z);
  quadArray.setCoordinate(1, point3f);
 
  point3f.set(posX + x, posY,  posZ + z);
  quadArray.setCoordinate(2, point3f);
 
  point3f.set(posX + x,  posY, posZ);
  quadArray.setCoordinate(3, point3f);
 

  Point2f point2f = new Point2f(0.0f, 1.0f);
  quadArray.setTextureCoordinate(0, point2f);
 
  point2f.set(0.0f, 0.0f);
  quadArray.setTextureCoordinate(1, point2f);
 
  point2f.set(1.0f, 0.0f);
  quadArray.setTextureCoordinate(2, point2f);
 
  point2f.set(1.0f, 1.0f);
  quadArray.setTextureCoordinate(3, point2f);
 
   setAppearance(new TextureAppearance(imageName, applet));
   setGeometry(quadArray);
  }
 
  public String getImageName()
  {
  return imageName;
 }
 
 
 
}
 
 
-----Ursprungligt meddelande-----
Från: Discussion list for Java 3D API [mailto:[EMAIL PROTECTED]För Tom Govaert
Skickat: den 6 december 2003 13:06
Till: [EMAIL PROTECTED]
Ämne: [JAVA3D] floor texturing

Hi,

 

I’m new to JAVA3D but making progress J

I want to know what is the best way to create a textured floor. Should I use a big box en texture that or are there other and better ways?

 

A small code example would be verry handy. Cuz when I texture the box it ‘spreads’ the picture….

 

Tnx

 

Tom G.

Belgium

=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".

<<image001.jpg>>

Reply via email to