📄 camera.java
字号:
/** * Copyright (c) 1999 Justin Couch Java Source Raw J3D * Tutorial Version History Date Version Programmer * ---------- ------- ------------------------------------------ * 01/08/1998 1.0.0 Justin Couch */package com.bbn.openmap.tools.j3d;// Standard importsimport javax.media.j3d.*;import javax.vecmath.Vector3f;import javax.vecmath.AxisAngle4f;/** * This Camera class was modified from Justin Couch's * http://www.j3d.org tutorial examples. Test class for showing the * use of a View and ViewPlatform * <P> * * Basic view consists of the standard placement. * * @author Justin Couch * @author dietrick */public class Camera implements OM3DConstants { private Group hud_group; private TransformGroup root_tx_grp; private Transform3D location; private ViewPlatform platform; private View view; private DirectionalLight headlight; private PhysicalBody body; private PhysicalEnvironment env; public Camera() { hud_group = new Group(); hud_group.setCapability(Group.ALLOW_CHILDREN_EXTEND); platform = new ViewPlatform(); location = new Transform3D(); root_tx_grp = new TransformGroup(); root_tx_grp.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); root_tx_grp.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); root_tx_grp.setTransform(location); root_tx_grp.addChild(platform); root_tx_grp.addChild(hud_group); // now create the headlight headlight = new DirectionalLight(); headlight.setCapability(Light.ALLOW_STATE_WRITE); headlight.setColor(White); headlight.setInfluencingBounds(LIGHT_BOUNDS); root_tx_grp.addChild(headlight); body = new PhysicalBody(); env = new PhysicalEnvironment(); view = new View(); view.setBackClipDistance(BACK_CLIP_DISTANCE); view.setPhysicalBody(body); view.setPhysicalEnvironment(env); view.attachViewPlatform(platform); } /** * Set the canvas that this camera is using * * @param canvas The canvas that is to be used for this camera */ public void setCanvas(Canvas3D canvas) { view.addCanvas3D(canvas); } /** * Set the location of the camera. This is the location of the * center of the camera relative to whatever is used as its root * group node. * * @param loc The location of the camera */ public void setLocation(Vector3f loc) { location.setTranslation(loc); root_tx_grp.setTransform(location); } /** * Set the orientation of the camera. * * @param angle The orientation of the camera */ public void setOrientation(AxisAngle4f angle) { location.setRotation(angle); root_tx_grp.setTransform(location); } /** * Add some goemetry to the HUD area. This geometry must come * complete with its own parent transform to offset the object by * the appropriate amount. The camera does not do any auto-offsets * of geometry. * * @param geom The geometry to add */ public void addHUDObject(Node geom) { hud_group.addChild(geom); } /** * Enable the headlight that is attached to the camera. * * @param enable True if the light is to be turned on */ public void setHeadLight(boolean enable) { headlight.setEnable(enable); } /** * Get the J3D node that is used to represent the camera * * @return The root TransformGroup of the camera */ public Node getNode() { return root_tx_grp; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -