// (C) 2001 SyGem Software import java.awt.*; import java.applet.*; import com.sygem.jazz3d3.*; import com.sygem.jazz3d3.primitive.Cube3d; public class tiledUV extends Applet implements Runnable { Thread m_ce; World myWorld; int light1; int pid; int downx = 0; int downy = 0; double ddx = 0; double ddy = 0; boolean down = false; boolean antialias = false; boolean bilinear = false; //Construct the applet public tiledUV() { } //Initialize the applet public void init() { myWorld = new World(this); setLayout(new BorderLayout()); add("Center",myWorld); myWorld.setDelay(1); Texture t1 = TextureLoader.loadImage("images/Jazz3D_logo_large.gif"); RenderTexturedHQ tex = new RenderTexturedHQ(); tex.setDrawingMode(Render.NOSHADE); int tt = tex.setTexture(t1); Cube3d sp1 = new Cube3d(0,0,8); sp1.getFace(0).setUV(0,0,3,0,3,3,0,3); sp1.getFace(1).setUV(0.2,0.2,0.8,0.2,0.8,0.8,0.2,0.8); sp1.getFace(2).setUV(0,0,2,0,2,2,0,2); sp1.setRenderer(tex); pid = myWorld.addObject(sp1); Light l1 = new Light(0,0,1); myWorld.addLight(l1); } //Start the applet public void start() { if (m_ce == null) { m_ce = new Thread(this); m_ce.start(); } } //Stop the applet public void stop() { if (m_ce != null) { m_ce.stop(); m_ce = null; } } //Destroy the applet public void destroy() { } public void run() { int iCount = 0; long lTime0 = System.currentTimeMillis(); double z; ddx = 0.16; ddy = 0.35; z = 0.21; myWorld.prep(); m_ce.setPriority(Thread.MAX_PRIORITY); while (true) { myWorld.getParentObject(pid).rotateWorld(ddy,ddx,z); myWorld.redraw(); } } public boolean mouseDown(Event evt, int x, int y) { downx = x; downy = y; down = true; return true; } public boolean mouseUp(Event evt, int x, int y) { down = false; return true; } public boolean mouseDrag(Event evt, int x, int y) { if (down) { double dx = x - downx; double dy = y - downy; ddx = (dx / (this.size().width))*10.0; ddy = (dy / (this.size().height))*10.0; } return true; } public boolean keyDown(Event evt,int key) { if ((char)key=='a') {antialias=!antialias; myWorld.setAntiAliasing(antialias); return true; } if ((char)key=='b') {bilinear=!bilinear; myWorld.setBilinear(bilinear); return true; } return true; } }