Back to index

wims  3.65+svn20090927
Public Member Functions | Package Attributes | Private Member Functions
ThreeD Class Reference

An applet to put a 3D model into a page. More...

Inheritance diagram for ThreeD:
Inheritance graph
[legend]
Collaboration diagram for ThreeD:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void init ()
void run ()
void start ()
void stop ()
boolean mouseDown (Event e, int x, int y)
boolean mouseDrag (Event e, int x, int y)
void paint (Graphics g)

Package Attributes

Model3D md
boolean painted = true
float xfac
int prevx
int prevy
float xtheta
float ytheta
float scalefudge = 1
Matrix3D amat = new Matrix3D()
Matrix3D tmat = new Matrix3D()
String mdname = null
String message = null

Private Member Functions

synchronized void setPainted ()

Detailed Description

An applet to put a 3D model into a page.

Definition at line 335 of file ThreeD.java.


Member Function Documentation

void ThreeD.init ( ) [inline]

Definition at line 346 of file ThreeD.java.

                       {
       mdname = getParameter("model");
       try {
           scalefudge = Float.valueOf(getParameter("scale")).floatValue();
       }catch(Exception e){};
       amat.yrot(20);
       amat.xrot(20);
       if (mdname == null)
           mdname = "model.obj";
       resize(size().width <= 20 ? 400 : size().width,
              size().height <= 20 ? 400 : size().height);
    }

Here is the call graph for this function:

boolean ThreeD.mouseDown ( Event  e,
int  x,
int  y 
) [inline]

Definition at line 394 of file ThreeD.java.

                                                    {
       prevx = x;
       prevy = y;
       return true;
    }
boolean ThreeD.mouseDrag ( Event  e,
int  x,
int  y 
) [inline]

Definition at line 399 of file ThreeD.java.

                                                    {
       tmat.unit();
       float xtheta = (prevy - y) * 360.0f / size().width;
       float ytheta = (x - prevx) * 360.0f / size().height;
       tmat.xrot(xtheta);
       tmat.yrot(ytheta);
       amat.mult(tmat);
       if (painted) {
           painted = false;
           repaint();
       }
       prevx = x;
       prevy = y;
       return true;
    }

Here is the call graph for this function:

void ThreeD.paint ( Graphics  g) [inline]

Definition at line 414 of file ThreeD.java.

                                  {
       if (md != null) {
           md.mat.unit();
           md.mat.translate(-(md.xmin + md.xmax) / 2,
                          -(md.ymin + md.ymax) / 2,
                          -(md.zmin + md.zmax) / 2);
           md.mat.mult(amat);
//         md.mat.scale(xfac, -xfac, 8 * xfac / size().width);
           md.mat.scale(xfac, -xfac, 16 * xfac / size().width);
           md.mat.translate(size().width / 2, size().height / 2, 8);
           md.transformed = false;
           md.paint(g);
           setPainted();
       } else if (message != null) {
           g.drawString("Error in model:", 3, 20);
           g.drawString(message, 10, 40);
       }
    }

Here is the call graph for this function:

void ThreeD.run ( ) [inline]

Definition at line 358 of file ThreeD.java.

                      {
       InputStream is = null;
       try {
           Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
           is = new URL(getDocumentBase(), mdname).openStream();
           Model3D m = new Model3D (is);
           md = m;
           m.findBB();
           m.compress();
           float xw = m.xmax - m.xmin;
           float yw = m.ymax - m.ymin;
           float zw = m.zmax - m.zmin;
           if (yw > xw)
              xw = yw;
           if (zw > xw)
              xw = zw;
           float f1 = size().width / xw;
           float f2 = size().height / xw;
           xfac = 0.7f * (f1 < f2 ? f1 : f2) * scalefudge;
       } catch(Exception e) {
           md = null;
           message = e.toString();
       }
       try {
           if (is != null)
              is.close();
       } catch(Exception e) {
       }
       repaint();
    }

Here is the call graph for this function:

synchronized void ThreeD.setPainted ( ) [inline, private]

Definition at line 432 of file ThreeD.java.

                                           {
       painted = true;
       notifyAll();
    }

Here is the caller graph for this function:

void ThreeD.start ( ) [inline]

Definition at line 388 of file ThreeD.java.

                        {
       if (md == null && message == null)
           new Thread(this).start();
    }
void ThreeD.stop ( ) [inline]

Definition at line 392 of file ThreeD.java.

                       {
    }

Member Data Documentation

Matrix3D ThreeD.amat = new Matrix3D() [package]

Definition at line 342 of file ThreeD.java.

Model3D ThreeD.md [package]

Definition at line 336 of file ThreeD.java.

String ThreeD.mdname = null [package]

Definition at line 343 of file ThreeD.java.

String ThreeD.message = null [package]

Definition at line 344 of file ThreeD.java.

Definition at line 337 of file ThreeD.java.

int ThreeD.prevx [package]

Definition at line 339 of file ThreeD.java.

int ThreeD.prevy [package]

Definition at line 339 of file ThreeD.java.

float ThreeD.scalefudge = 1 [package]

Definition at line 341 of file ThreeD.java.

Matrix3D ThreeD.tmat = new Matrix3D() [package]

Definition at line 342 of file ThreeD.java.

float ThreeD.xfac [package]

Definition at line 338 of file ThreeD.java.

float ThreeD.xtheta [package]

Definition at line 340 of file ThreeD.java.

float ThreeD.ytheta [package]

Definition at line 340 of file ThreeD.java.


The documentation for this class was generated from the following file: