edu.ohiou.cs456_badabing.sceneapi.basic
Class ANode

java.lang.Object
  extended by edu.ohiou.cs456_badabing.sceneapi.basic.ANode
Direct Known Subclasses:
LightNode, Map, MaterialGroupNode, ModelNode, PieChart, Sphere

public class ANode
extends java.lang.Object

Super class for all other nodes in the tree.

Description: Super class for all other nodes in the tree.

Copyright: Lev A Neiman 2008

Company: Ohio University EECS


Field Summary
protected  java.util.LinkedList children
          References to the children nodes.
protected  int display_list
          if this does not equal to -1 then it refers to some Display List in memory.
protected  java.lang.String name
          prbl should make this private later on if i still use it.
protected static int no_disp_list
          if display_list == -1 then we know it can't refer to valid OpenGL display list, since they cannot be negative.
protected  ANode parent
          reference to the parent node.
protected  boolean ppop
          if this is true, then modelview matrix is not pushed and poped around rendering this node.
protected  Coordinate rotation
          what is the vector about which this node is rotated, relative to its parent?
 float rotation_angle
          what is the angle of rotation about that vector?
protected  Coordinate scale
          how big is this node compared to its parent? 1.0 is same size.
 boolean show
           
protected  Coordinate translation
          how far away is this node from its parent?
 
Constructor Summary
ANode()
          default constructor
ANode(int list)
          constructor
ANode(java.lang.String name)
          constructor
 
Method Summary
 void addChild(ANode child)
          add child to this node.
static int countNodes(ANode root)
          counts the number of nodes in the tree with root as root.
private static int countNodes(ANode root, int count)
          counts the number of nodes in the tree with root as root.
static void drawCube(GLAutoDrawable g)
          renders a simple cube.
 java.lang.String getName()
           
static Coordinate getNormal(Coordinate a, Coordinate b, Coordinate c)
          computes a normal between (a-c)x(b-c)
static void hideTree(ANode root)
           
private  void init()
          initializes member variables to their default values.
 boolean pushPop()
           
 void render(GLAutoDrawable g)
          This method should be typically called from render in all derived classes.
static void renderTree(GLAutoDrawable contex, ANode root)
          This static function renders the tree with root as the root.
 Coordinate rotation()
           
 Coordinate scale()
           
 void setName(java.lang.String name)
           
 void setParent(ANode parent)
          set parent on this node.
 void setPushPop(boolean a)
           
static void showTree(ANode root)
           
 Coordinate translation()
          returns translation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

translation

protected Coordinate translation
how far away is this node from its parent?


scale

protected Coordinate scale
how big is this node compared to its parent? 1.0 is same size.


rotation

protected Coordinate rotation
what is the vector about which this node is rotated, relative to its parent?


rotation_angle

public float rotation_angle
what is the angle of rotation about that vector?


no_disp_list

protected static final int no_disp_list
if display_list == -1 then we know it can't refer to valid OpenGL display list, since they cannot be negative.

See Also:
Constant Field Values

display_list

protected int display_list
if this does not equal to -1 then it refers to some Display List in memory.


ppop

protected boolean ppop
if this is true, then modelview matrix is not pushed and poped around rendering this node.


name

protected java.lang.String name
prbl should make this private later on if i still use it.


children

protected java.util.LinkedList children
References to the children nodes. Uses Java's LinkedList data structure.


parent

protected ANode parent
reference to the parent node.


show

public boolean show
Constructor Detail

ANode

public ANode()
default constructor


ANode

public ANode(java.lang.String name)
constructor

Parameters:
name - String - name for this node.

ANode

public ANode(int list)
constructor

Parameters:
list - int - display list that this node will call.
Method Detail

translation

public Coordinate translation()
returns translation

Returns:
Coordinate

scale

public Coordinate scale()

rotation

public Coordinate rotation()

getName

public java.lang.String getName()

setName

public void setName(java.lang.String name)

init

private void init()
initializes member variables to their default values.


addChild

public void addChild(ANode child)
add child to this node.

Parameters:
child - ANode

setParent

public void setParent(ANode parent)
set parent on this node.

Parameters:
parent - ANode

render

public void render(GLAutoDrawable g)
This method should be typically called from render in all derived classes. This one just modifies the current ModelView matrix by this node's offset, rotation and scale.

Parameters:
g - GLAutoDrawable

hideTree

public static void hideTree(ANode root)

showTree

public static void showTree(ANode root)

renderTree

public static void renderTree(GLAutoDrawable contex,
                              ANode root)
This static function renders the tree with root as the root.

Parameters:
contex - GLAutoDrawable
root - ANode

countNodes

public static int countNodes(ANode root)
counts the number of nodes in the tree with root as root.

Parameters:
root - ANode - root to the tree to count nodes of.
Returns:
int - number of nodes in root.

countNodes

private static int countNodes(ANode root,
                              int count)
counts the number of nodes in the tree with root as root.

Parameters:
root - ANode - root to the tree to count nodes of.
count - int - current count.
Returns:
int - number of nodes in root.

pushPop

public boolean pushPop()

setPushPop

public void setPushPop(boolean a)

getNormal

public static Coordinate getNormal(Coordinate a,
                                   Coordinate b,
                                   Coordinate c)
computes a normal between (a-c)x(b-c)

Parameters:
a - Coordinate
b - Coordinate
c - Coordinate
Returns:
Coordinate

drawCube

public static void drawCube(GLAutoDrawable g)
renders a simple cube.

Parameters:
g - GLAutoDrawable