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 classCamera3D.CameraLightSourceNested classes/interfaces inherited from interface mgui.interfaces.xml.XMLObject
XMLObject.XMLEncoding, XMLObject.XMLType -
Field Summary
Fields Modifier and Type Field Description org.jogamp.vecmath.Point3dcenterOfRotationdoubledistanceprotected javax.swing.Iconiconorg.jogamp.vecmath.Vector3dlineOfSightdoubleminDistanceorg.jogamp.vecmath.Point3dtargetPtorg.jogamp.vecmath.Vector2dtranslateXYorg.jogamp.vecmath.Vector3dupVectorFields inherited from class mgui.interfaces.AbstractInterfaceObject
isDestroyed, tree_nodes -
Constructor Summary
-
Method Summary
Modifier and Type Method Description voidaddLightSource(org.jogamp.java3d.DirectionalLight light)Add a directional light which moves with this camera's line of sight, with zero offsetvoidaddLightSource(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.voidaddListener(Camera3DListener c)voidfireCameraAngleChanged()voidfireCameraListeners(CameraEvent.EventType type)voidfixUpVector()Attribute<?>getAttribute(java.lang.String attrName)Returns a specific attribute for this object.AttributeListgetAttributes()Returns the list of current attributes for this object.java.lang.ObjectgetAttributeValue(java.lang.String name)Gets the value of attributename, ornullif it does not exist.protected org.jogamp.vecmath.AxisAngle4dgetAxisX(org.jogamp.vecmath.Vector3d v, double a)protected org.jogamp.vecmath.AxisAngle4dgetAxisY(org.jogamp.vecmath.Vector3d v, double a)org.jogamp.java3d.Transform3DgetCameraRotation(double distance, org.jogamp.vecmath.Point3d center)Returns a transform corresponding to this camera's rotation, but not translation.org.jogamp.java3d.Transform3DgetCameraTransform()Returns a transform to apply to ViewPlatform, corresponding to this camera.org.jogamp.vecmath.Point3dgetCenterOfRotation()doublegetDistance()java.lang.StringgetDTD()Returns the Data Type Declaration (DTD) for this object's XML representationorg.jogamp.vecmath.Point3dgetLensPoint()org.jogamp.vecmath.Vector3dgetLineOfSight()java.lang.StringgetLocalName()Returns the local name associated with this XML object.doublegetMinDistance()java.lang.StringgetName()Gets the name for this object.javax.swing.IcongetObjectIcon()Returns theIconassociated with this object.java.lang.StringgetShortXML(int tab)Returns a short XML representation of this object.org.jogamp.vecmath.Point3dgetTargetPoint()org.jogamp.vecmath.Vector2dgetTranslateXY()java.lang.StringgetTreeLabel()Returns the label text to appear in a tree node.org.jogamp.vecmath.Vector3dgetUpVector()java.lang.StringgetXML()Returns this object's XML representation as a single string.java.lang.StringgetXML(int tab)Returns this object's XML representation as a single string.XMLObjectgetXMLInstance(org.xml.sax.Attributes attributes)java.lang.StringgetXMLSchema()Returns the XML schema for this object's XML representationvoidhandleXMLElementEnd(java.lang.String localName)Handles the end of an XML element.voidhandleXMLElementStart(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)Handles the start of an XML element.voidhandleXMLString(java.lang.String s)Handles a string within an XML element.protected voidinit()voidprintCamera()voidremoveLightSource(org.jogamp.java3d.DirectionalLight light)voidremoveListener(Camera3DListener c)protected voidrotateVector(org.jogamp.vecmath.Vector3d v, org.jogamp.vecmath.Vector3d r, double x, double y)voidrotateX(double r)voidrotateY(double r)voidsetAttribute(java.lang.String attrName, java.lang.Object newValue)Sets a value for a specific attribute.voidsetAttributes(AttributeList thisList)Sets the list of attributes for this object.voidsetCenterOfRotation(org.jogamp.vecmath.Point3d p)voidsetCenterOfRotation(org.jogamp.vecmath.Point3f p)voidsetDistance(double d)voidsetFromCamera(Camera3D camera)Sets this camera fromcamera.voidsetFromCamera(Camera3D camera, boolean set_center, boolean set_distance)protected voidsetIcon()voidsetLineOfSight(float x, float y, float z)voidsetLineOfSight(org.jogamp.vecmath.Vector3d v)voidsetListen(boolean b)voidsetMinDistance(double m)voidsetName(java.lang.String name)Sets the name for this object.voidsetRotationPoint(org.jogamp.vecmath.Point3d r)voidsetTargetPoint(org.jogamp.vecmath.Point3d t)voidsetTranslateXY(org.jogamp.vecmath.Vector2d vxy)voidsetTreeNode(InterfaceTreeNode treeNode)Sets the children for this node'sInterfaceTreeNode.voidsetUpVector(double x, double y, double z)voidsetUpVector(org.jogamp.vecmath.Vector3d uv)java.lang.StringtoString()voidtranslateX(double t)voidtranslateY(double t)voidupdateLightSources()voidwriteXML(int tab, java.io.Writer writer)Writes the XML representation of this object to file.voidwriteXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar)Writes the XML representation of this object to file, asXMLType.Normal.voidwriteXML(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar)Writes the XML representation of this object to file.voidzoomDistance(double z)Methods inherited from class mgui.interfaces.AbstractInterfaceObject
clean, destroy, isDestroyed, issueTreeNode, updateTreeNodesMethods 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:NamedObjectSets the name for this object.- Specified by:
setNamein interfaceNamedObject- Overrides:
setNamein classAbstractInterfaceObject
-
getName
public java.lang.String getName()Description copied from interface:NamedObjectGets the name for this object.- Specified by:
getNamein interfaceNamedObject- Overrides:
getNamein 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:TreeObjectSets the children for this node'sInterfaceTreeNode.- Specified by:
setTreeNodein interfaceTreeObject- Overrides:
setTreeNodein classAbstractInterfaceObject
-
getTreeLabel
public java.lang.String getTreeLabel()Description copied from interface:TreeObjectReturns the label text to appear in a tree node.- Specified by:
getTreeLabelin interfaceTreeObject- Overrides:
getTreeLabelin classAbstractInterfaceObject- Returns:
-
setIcon
protected void setIcon() -
getObjectIcon
public javax.swing.Icon getObjectIcon()Description copied from interface:IconObjectReturns theIconassociated with this object.- Specified by:
getObjectIconin interfaceIconObject- Returns:
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
getAttribute
Description copied from interface:AttributeObjectReturns a specific attribute for this object.- Specified by:
getAttributein interfaceAttributeObject- Returns:
-
getAttributes
Description copied from interface:AttributeObjectReturns the list of current attributes for this object.- Specified by:
getAttributesin interfaceAttributeObject- Returns:
-
setAttribute
public void setAttribute(java.lang.String attrName, java.lang.Object newValue)Description copied from interface:AttributeObjectSets a value for a specific attribute.- Specified by:
setAttributein interfaceAttributeObject
-
setAttributes
Description copied from interface:AttributeObjectSets the list of attributes for this object.- Specified by:
setAttributesin interfaceAttributeObject
-
getAttributeValue
public java.lang.Object getAttributeValue(java.lang.String name)Description copied from interface:AttributeObjectGets the value of attributename, ornullif it does not exist.- Specified by:
getAttributeValuein interfaceAttributeObject- Parameters:
name- Name of the attribute- Returns:
- the value of attribute
name, ornullif it does not exist
-
setFromCamera
Sets this camera fromcamera.- Parameters:
camera-
-
setFromCamera
-
getDTD
public java.lang.String getDTD()Description copied from interface:XMLObjectReturns 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:XMLObjectReturns the XML schema for this object's XML representation- Specified by:
getXMLSchemain interfaceXMLObject- Returns:
-
getXML
public java.lang.String getXML(int tab)Description copied from interface:XMLObjectReturns 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:XMLObjectReturns a short XML representation of this object.- Specified by:
getShortXMLin interfaceXMLObject- Returns:
-
getXML
public java.lang.String getXML()Description copied from interface:XMLObjectReturns 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:XMLObjectHandles the start of an XML element.- Specified by:
handleXMLElementStartin interfaceXMLObject- Parameters:
localName- Local name of the elementattributes- Set of element attributestype- TheXMLTypeof this element
-
handleXMLElementEnd
public void handleXMLElementEnd(java.lang.String localName)Description copied from interface:XMLObjectHandles the end of an XML element.- Specified by:
handleXMLElementEndin interfaceXMLObject- Parameters:
localName- Local name of the element
-
handleXMLString
public void handleXMLString(java.lang.String s)Description copied from interface:XMLObjectHandles a string within an XML element.- Specified by:
handleXMLStringin interfaceXMLObject- Parameters:
s- String to handle
-
getLocalName
public java.lang.String getLocalName()Description copied from interface:XMLObjectReturns the local name associated with this XML object.- Specified by:
getLocalNamein interfaceXMLObject- Returns:
-
getXMLInstance
-
writeXML
public void writeXML(int tab, java.io.Writer writer) throws java.io.IOExceptionDescription copied from interface:XMLObjectWrites 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.Asciiwill be used. -
writeXML
public void writeXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription copied from interface:XMLObjectWrites the XML representation of this object to file, asXMLType.Normal. The default format ofXMLFormat.Asciiwill 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:XMLObjectWrites 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.Asciiwill be used.
-