Package mgui.interfaces.maps
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
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
Camera3D.CameraLightSource
Nested classes/interfaces inherited from interface mgui.interfaces.xml.XMLObject
XMLObject.XMLEncoding, XMLObject.XMLType
-
Field Summary
Fields Modifier and Type Field Description org.jogamp.vecmath.Point3d
centerOfRotation
double
distance
protected javax.swing.Icon
icon
org.jogamp.vecmath.Vector3d
lineOfSight
double
minDistance
org.jogamp.vecmath.Point3d
targetPt
org.jogamp.vecmath.Vector2d
translateXY
org.jogamp.vecmath.Vector3d
upVector
Fields inherited from class mgui.interfaces.AbstractInterfaceObject
isDestroyed, tree_nodes
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description void
addLightSource(org.jogamp.java3d.DirectionalLight light)
Add a directional light which moves with this camera's line of sight, with zero offsetvoid
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.void
addListener(Camera3DListener c)
void
fireCameraAngleChanged()
void
fireCameraListeners(CameraEvent.EventType type)
void
fixUpVector()
Attribute<?>
getAttribute(java.lang.String attrName)
Returns a specific attribute for this object.AttributeList
getAttributes()
Returns the list of current attributes for this object.java.lang.Object
getAttributeValue(java.lang.String name)
Gets the value of attributename
, ornull
if it does not exist.protected org.jogamp.vecmath.AxisAngle4d
getAxisX(org.jogamp.vecmath.Vector3d v, double a)
protected org.jogamp.vecmath.AxisAngle4d
getAxisY(org.jogamp.vecmath.Vector3d v, double a)
org.jogamp.java3d.Transform3D
getCameraRotation(double distance, org.jogamp.vecmath.Point3d center)
Returns a transform corresponding to this camera's rotation, but not translation.org.jogamp.java3d.Transform3D
getCameraTransform()
Returns a transform to apply to ViewPlatform, corresponding to this camera.org.jogamp.vecmath.Point3d
getCenterOfRotation()
double
getDistance()
java.lang.String
getDTD()
Returns the Data Type Declaration (DTD) for this object's XML representationorg.jogamp.vecmath.Point3d
getLensPoint()
org.jogamp.vecmath.Vector3d
getLineOfSight()
java.lang.String
getLocalName()
Returns the local name associated with this XML object.double
getMinDistance()
java.lang.String
getName()
Gets the name for this object.javax.swing.Icon
getObjectIcon()
Returns theIcon
associated with this object.java.lang.String
getShortXML(int tab)
Returns a short XML representation of this object.org.jogamp.vecmath.Point3d
getTargetPoint()
org.jogamp.vecmath.Vector2d
getTranslateXY()
java.lang.String
getTreeLabel()
Returns the label text to appear in a tree node.org.jogamp.vecmath.Vector3d
getUpVector()
java.lang.String
getXML()
Returns this object's XML representation as a single string.java.lang.String
getXML(int tab)
Returns this object's XML representation as a single string.XMLObject
getXMLInstance(org.xml.sax.Attributes attributes)
java.lang.String
getXMLSchema()
Returns the XML schema for this object's XML representationvoid
handleXMLElementEnd(java.lang.String localName)
Handles the end of an XML element.void
handleXMLElementStart(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)
Handles the start of an XML element.void
handleXMLString(java.lang.String s)
Handles a string within an XML element.protected void
init()
void
printCamera()
void
removeLightSource(org.jogamp.java3d.DirectionalLight light)
void
removeListener(Camera3DListener c)
protected void
rotateVector(org.jogamp.vecmath.Vector3d v, org.jogamp.vecmath.Vector3d r, double x, double y)
void
rotateX(double r)
void
rotateY(double r)
void
setAttribute(java.lang.String attrName, java.lang.Object newValue)
Sets a value for a specific attribute.void
setAttributes(AttributeList thisList)
Sets the list of attributes for this object.void
setCenterOfRotation(org.jogamp.vecmath.Point3d p)
void
setCenterOfRotation(org.jogamp.vecmath.Point3f p)
void
setDistance(double d)
void
setFromCamera(Camera3D camera)
Sets this camera fromcamera
.void
setFromCamera(Camera3D camera, boolean set_center, boolean set_distance)
protected void
setIcon()
void
setLineOfSight(float x, float y, float z)
void
setLineOfSight(org.jogamp.vecmath.Vector3d v)
void
setListen(boolean b)
void
setMinDistance(double m)
void
setName(java.lang.String name)
Sets the name for this object.void
setRotationPoint(org.jogamp.vecmath.Point3d r)
void
setTargetPoint(org.jogamp.vecmath.Point3d t)
void
setTranslateXY(org.jogamp.vecmath.Vector2d vxy)
void
setTreeNode(InterfaceTreeNode treeNode)
Sets the children for this node'sInterfaceTreeNode
.void
setUpVector(double x, double y, double z)
void
setUpVector(org.jogamp.vecmath.Vector3d uv)
java.lang.String
toString()
void
translateX(double t)
void
translateY(double t)
void
updateLightSources()
void
writeXML(int tab, java.io.Writer writer)
Writes the XML representation of this object to file.void
writeXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar)
Writes the XML representation of this object to file, asXMLType.Normal
.void
writeXML(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar)
Writes the XML representation of this object to file.void
zoomDistance(double z)
Methods inherited from class mgui.interfaces.AbstractInterfaceObject
clean, destroy, isDestroyed, issueTreeNode, updateTreeNodes
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
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 interfaceNamedObject
- Overrides:
setName
in classAbstractInterfaceObject
-
getName
public java.lang.String getName()Description copied from interface:NamedObject
Gets the name for this object.- Specified by:
getName
in interfaceNamedObject
- Overrides:
getName
in classAbstractInterfaceObject
- 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
-
removeListener
-
setListen
public void setListen(boolean b) -
fireCameraAngleChanged
public void fireCameraAngleChanged() -
fireCameraListeners
-
setTreeNode
Description copied from interface:TreeObject
Sets the children for this node'sInterfaceTreeNode
.- Specified by:
setTreeNode
in interfaceTreeObject
- Overrides:
setTreeNode
in classAbstractInterfaceObject
-
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 interfaceTreeObject
- Overrides:
getTreeLabel
in classAbstractInterfaceObject
- Returns:
-
setIcon
protected void setIcon() -
getObjectIcon
public javax.swing.Icon getObjectIcon()Description copied from interface:IconObject
Returns theIcon
associated with this object.- Specified by:
getObjectIcon
in interfaceIconObject
- Returns:
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
getAttribute
Description copied from interface:AttributeObject
Returns a specific attribute for this object.- Specified by:
getAttribute
in interfaceAttributeObject
- Returns:
-
getAttributes
Description copied from interface:AttributeObject
Returns the list of current attributes for this object.- Specified by:
getAttributes
in interfaceAttributeObject
- 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 interfaceAttributeObject
-
setAttributes
Description copied from interface:AttributeObject
Sets the list of attributes for this object.- Specified by:
setAttributes
in interfaceAttributeObject
-
getAttributeValue
public java.lang.Object getAttributeValue(java.lang.String name)Description copied from interface:AttributeObject
Gets the value of attributename
, ornull
if it does not exist.- Specified by:
getAttributeValue
in interfaceAttributeObject
- Parameters:
name
- Name of the attribute- Returns:
- the value of attribute
name
, ornull
if it does not exist
-
setFromCamera
Sets this camera fromcamera
.- Parameters:
camera
-
-
setFromCamera
-
getDTD
public java.lang.String getDTD()Description copied from interface:XMLObject
Returns the Data Type Declaration (DTD) for this object's XML representationSee http://en.wikipedia.org/wiki/Document_Type_Definition for a description.
-
getXMLSchema
public java.lang.String getXMLSchema()Description copied from interface:XMLObject
Returns the XML schema for this object's XML representation- Specified by:
getXMLSchema
in interfaceXMLObject
- 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 theXMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater)
functions to write larger objects to file. -
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 interfaceXMLObject
- 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 theXMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater)
functions to write larger objects to file. -
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 interfaceXMLObject
- Parameters:
localName
- Local name of the elementattributes
- Set of element attributestype
- TheXMLType
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 interfaceXMLObject
- 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 interfaceXMLObject
- 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 interfaceXMLObject
- Returns:
-
getXMLInstance
-
writeXML
public void writeXML(int tab, java.io.Writer writer) throws java.io.IOExceptionDescription 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 ofXMLFormat.Ascii
will be used. -
writeXML
public void writeXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription copied from interface:XMLObject
Writes the XML representation of this object to file, asXMLType.Normal
. The default format ofXMLFormat.Ascii
will be used. The basic contract for this method is that it should not write a newline character at its start or end. -
writeXML
public void writeXML(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription 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 ofXMLFormat.Ascii
will be used.
-