Class Camera3D

java.lang.Object
mgui.interfaces.AbstractInterfaceObject
mgui.interfaces.maps.Camera3D
All Implemented Interfaces:
AttributeObject, InterfaceObject, NamedObject, TreeObject, CleanableObject, XMLObject, IconObject

public class Camera3D
extends AbstractInterfaceObject
implements AttributeObject, XMLObject, IconObject
Represents a particular camera position in R3, defined by a center of rotation, line of sight vector, and a distance. The "up" position of the camera is defined by an addition vector.

In addition, the camera can be associated with an arbitrary number of directed light sources, which are defined - and move - with respect to the camera's line of sight.

Since:
1.0
Version:
1.0
Author:
Andrew Reid
  • Field Details

    • centerOfRotation

      public org.jogamp.vecmath.Point3d centerOfRotation
    • lineOfSight

      public org.jogamp.vecmath.Vector3d lineOfSight
    • distance

      public double distance
    • minDistance

      public double minDistance
    • upVector

      public org.jogamp.vecmath.Vector3d upVector
    • targetPt

      public org.jogamp.vecmath.Point3d targetPt
    • translateXY

      public org.jogamp.vecmath.Vector2d translateXY
    • icon

      protected javax.swing.Icon icon
  • Constructor Details

    • Camera3D

      public Camera3D()
    • Camera3D

      public Camera3D​(java.lang.String name)
  • Method Details

    • init

      protected void init()
    • setName

      public void setName​(java.lang.String name)
      Description copied from interface: NamedObject
      Sets the name for this object.
      Specified by:
      setName in interface NamedObject
      Overrides:
      setName in class AbstractInterfaceObject
    • getName

      public java.lang.String getName()
      Description copied from interface: NamedObject
      Gets the name for this object.
      Specified by:
      getName in interface NamedObject
      Overrides:
      getName in class AbstractInterfaceObject
      Returns:
    • setTargetPoint

      public void setTargetPoint​(org.jogamp.vecmath.Point3d t)
    • getLensPoint

      public org.jogamp.vecmath.Point3d getLensPoint()
    • setRotationPoint

      public void setRotationPoint​(org.jogamp.vecmath.Point3d r)
    • setLineOfSight

      public void setLineOfSight​(float x, float y, float z)
    • setLineOfSight

      public void setLineOfSight​(org.jogamp.vecmath.Vector3d v)
    • setUpVector

      public void setUpVector​(org.jogamp.vecmath.Vector3d uv)
    • setUpVector

      public void setUpVector​(double x, double y, double z)
    • fixUpVector

      public void fixUpVector()
    • setDistance

      public void setDistance​(double d)
    • setMinDistance

      public void setMinDistance​(double m)
    • setTranslateXY

      public void setTranslateXY​(org.jogamp.vecmath.Vector2d vxy)
    • getTargetPoint

      public org.jogamp.vecmath.Point3d getTargetPoint()
    • setCenterOfRotation

      public void setCenterOfRotation​(org.jogamp.vecmath.Point3f p)
    • setCenterOfRotation

      public void setCenterOfRotation​(org.jogamp.vecmath.Point3d p)
    • getCenterOfRotation

      public org.jogamp.vecmath.Point3d getCenterOfRotation()
    • getLineOfSight

      public org.jogamp.vecmath.Vector3d getLineOfSight()
    • getUpVector

      public org.jogamp.vecmath.Vector3d getUpVector()
    • getDistance

      public double getDistance()
    • getMinDistance

      public double getMinDistance()
    • getTranslateXY

      public org.jogamp.vecmath.Vector2d getTranslateXY()
    • zoomDistance

      public void zoomDistance​(double z)
    • rotateX

      public void rotateX​(double r)
    • rotateY

      public void rotateY​(double r)
    • addLightSource

      public void addLightSource​(org.jogamp.java3d.DirectionalLight light)
      Add a directional light which moves with this camera's line of sight, with zero offset
      Parameters:
      light -
      offset -
    • addLightSource

      public void addLightSource​(org.jogamp.java3d.DirectionalLight light, org.jogamp.vecmath.Vector2d offset)
      Add a directional light which moves with this camera's line of sight, offset by a specific vector.
      Parameters:
      light -
      offset -
    • removeLightSource

      public void removeLightSource​(org.jogamp.java3d.DirectionalLight light)
    • updateLightSources

      public void updateLightSources()
    • rotateVector

      protected void rotateVector​(org.jogamp.vecmath.Vector3d v, org.jogamp.vecmath.Vector3d r, double x, double y)
    • getAxisY

      protected org.jogamp.vecmath.AxisAngle4d getAxisY​(org.jogamp.vecmath.Vector3d v, double a)
    • getAxisX

      protected org.jogamp.vecmath.AxisAngle4d getAxisX​(org.jogamp.vecmath.Vector3d v, double a)
    • translateX

      public void translateX​(double t)
    • translateY

      public void translateY​(double t)
    • getCameraTransform

      public org.jogamp.java3d.Transform3D getCameraTransform()
      Returns a transform to apply to ViewPlatform, corresponding to this camera.
      Returns:
    • getCameraRotation

      public org.jogamp.java3d.Transform3D getCameraRotation​(double distance, org.jogamp.vecmath.Point3d center)
      Returns a transform corresponding to this camera's rotation, but not translation.
      Returns:
    • printCamera

      public void printCamera()
    • addListener

      public void addListener​(Camera3DListener c)
    • removeListener

      public void removeListener​(Camera3DListener c)
    • setListen

      public void setListen​(boolean b)
    • fireCameraAngleChanged

      public void fireCameraAngleChanged()
    • fireCameraListeners

      public void fireCameraListeners​(CameraEvent.EventType type)
    • setTreeNode

      public void setTreeNode​(InterfaceTreeNode treeNode)
      Description copied from interface: TreeObject
      Sets the children for this node's InterfaceTreeNode.
      Specified by:
      setTreeNode in interface TreeObject
      Overrides:
      setTreeNode in class AbstractInterfaceObject
    • getTreeLabel

      public java.lang.String getTreeLabel()
      Description copied from interface: TreeObject
      Returns the label text to appear in a tree node.
      Specified by:
      getTreeLabel in interface TreeObject
      Overrides:
      getTreeLabel in class AbstractInterfaceObject
      Returns:
    • setIcon

      protected void setIcon()
    • getObjectIcon

      public javax.swing.Icon getObjectIcon()
      Description copied from interface: IconObject
      Returns the Icon associated with this object.
      Specified by:
      getObjectIcon in interface IconObject
      Returns:
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • getAttribute

      public Attribute<?> getAttribute​(java.lang.String attrName)
      Description copied from interface: AttributeObject
      Returns a specific attribute for this object.
      Specified by:
      getAttribute in interface AttributeObject
      Returns:
    • getAttributes

      public AttributeList getAttributes()
      Description copied from interface: AttributeObject
      Returns the list of current attributes for this object.
      Specified by:
      getAttributes in interface AttributeObject
      Returns:
    • setAttribute

      public void setAttribute​(java.lang.String attrName, java.lang.Object newValue)
      Description copied from interface: AttributeObject
      Sets a value for a specific attribute.
      Specified by:
      setAttribute in interface AttributeObject
    • setAttributes

      public void setAttributes​(AttributeList thisList)
      Description copied from interface: AttributeObject
      Sets the list of attributes for this object.
      Specified by:
      setAttributes in interface AttributeObject
    • getAttributeValue

      public java.lang.Object getAttributeValue​(java.lang.String name)
      Description copied from interface: AttributeObject
      Gets the value of attribute name, or null if it does not exist.
      Specified by:
      getAttributeValue in interface AttributeObject
      Parameters:
      name - Name of the attribute
      Returns:
      the value of attribute name, or null if it does not exist
    • setFromCamera

      public void setFromCamera​(Camera3D camera)
      Sets this camera from camera.
      Parameters:
      camera -
    • setFromCamera

      public void setFromCamera​(Camera3D camera, boolean set_center, boolean set_distance)
    • getDTD

      public java.lang.String getDTD()
      Description copied from interface: XMLObject
      Returns the Data Type Declaration (DTD) for this object's XML representation

      See http://en.wikipedia.org/wiki/Document_Type_Definition for a description.

      Specified by:
      getDTD in interface XMLObject
      Returns:
    • getXMLSchema

      public java.lang.String getXMLSchema()
      Description copied from interface: XMLObject
      Returns the XML schema for this object's XML representation

      See http://en.wikipedia.org/wiki/XML_schema.

      Specified by:
      getXMLSchema in interface XMLObject
      Returns:
    • getXML

      public java.lang.String getXML​(int tab)
      Description copied from interface: XMLObject
      Returns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use the XMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater) functions to write larger objects to file.
      Specified by:
      getXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the opening XML wrapper
      Returns:
    • getShortXML

      public java.lang.String getShortXML​(int tab)
      Description copied from interface: XMLObject
      Returns a short XML representation of this object.
      Specified by:
      getShortXML in interface XMLObject
      Returns:
    • getXML

      public java.lang.String getXML()
      Description copied from interface: XMLObject
      Returns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use the XMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater) functions to write larger objects to file.
      Specified by:
      getXML in interface XMLObject
      Returns:
    • handleXMLElementStart

      public void handleXMLElementStart​(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)
      Description copied from interface: XMLObject
      Handles the start of an XML element.
      Specified by:
      handleXMLElementStart in interface XMLObject
      Parameters:
      localName - Local name of the element
      attributes - Set of element attributes
      type - The XMLType of this element
    • handleXMLElementEnd

      public void handleXMLElementEnd​(java.lang.String localName)
      Description copied from interface: XMLObject
      Handles the end of an XML element.
      Specified by:
      handleXMLElementEnd in interface XMLObject
      Parameters:
      localName - Local name of the element
    • handleXMLString

      public void handleXMLString​(java.lang.String s)
      Description copied from interface: XMLObject
      Handles a string within an XML element.
      Specified by:
      handleXMLString in interface XMLObject
      Parameters:
      s - String to handle
    • getLocalName

      public java.lang.String getLocalName()
      Description copied from interface: XMLObject
      Returns the local name associated with this XML object.
      Specified by:
      getLocalName in interface XMLObject
      Returns:
    • getXMLInstance

      public XMLObject getXMLInstance​(org.xml.sax.Attributes attributes)
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer) throws java.io.IOException
      Description copied from interface: XMLObject
      Writes the XML representation of this object to file. The basic contract for this method is that it should not write a newline character at its start or end. The default format of XMLFormat.Ascii will be used.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      Throws:
      java.io.IOException
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer, ProgressUpdater progress_bar) throws java.io.IOException
      Description copied from interface: XMLObject
      Writes the XML representation of this object to file, as XMLType.Normal. The default format of XMLFormat.Ascii will be used. The basic contract for this method is that it should not write a newline character at its start or end.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      progress_bar - Optional progress updater (may be null)
      Throws:
      java.io.IOException
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar) throws java.io.IOException
      Description copied from interface: XMLObject
      Writes the XML representation of this object to file. The basic contract for this method is that it should not write a newline character at its start or end. The default format of XMLFormat.Ascii will be used.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      options - XMLOutputOptions defining the write parameters
      progress_bar - Optional progress updater (may be null)
      Throws:
      java.io.IOException