aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Gouesse <[email protected]>2014-08-08 22:02:24 +0200
committerJulien Gouesse <[email protected]>2014-08-08 22:02:24 +0200
commitd8553c06068332a2e604f1336238e5cdf12c762c (patch)
treecbd1b37833a82868bd30621ba1cf053f2853c6ed
parent2835439b704b945e3121b5a9f17d207bc5b2c5ea (diff)
Removes tons of warnings
-rw-r--r--ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/AttachmentPoint.java1
-rw-r--r--ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/Joint.java3
-rw-r--r--ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/Skeleton.java3
-rw-r--r--ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/SkeletonPose.java3
-rw-r--r--ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/SkinnedMesh.java1
-rw-r--r--ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/BinaryLERPSource.java3
-rw-r--r--ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/ClipSource.java2
-rw-r--r--ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/FrozenTreeSource.java3
-rw-r--r--ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/ManagedTransformSource.java3
-rw-r--r--ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/AbstractAnimationChannel.java4
-rw-r--r--ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/AnimationClip.java3
-rw-r--r--ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/InterpolatedDoubleChannel.java3
-rw-r--r--ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/InterpolatedFloatChannel.java3
-rw-r--r--ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/TransformChannel.java1
-rw-r--r--ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/TransformData.java3
-rw-r--r--ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/TriggerChannel.java3
-rw-r--r--ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/layer/LayerLERPBlender.java5
-rw-r--r--ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/state/AbstractTwoStateLerpTransition.java1
-rw-r--r--ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/util/SkinUtils.java1
-rw-r--r--ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaInputPipe.java1
-rw-r--r--ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaMaterialUtils.java3
-rw-r--r--ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaNodeUtils.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingVolume.java3
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/bounding/TreeComparator.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/bounding/UsageTreeController.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/image/util/AbiLoader.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/image/util/TgaLoader.java72
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/image/util/dds/DdsLoader.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/ControllerState.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/control/FirstPersonControl.java3
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/control/OrbitCamControl.java5
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/AnyControllerCondition.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/AnyKeyCondition.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/BasicTriggersApplier.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/ControllerComponentActiveCondition.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/ControllerComponentCondition.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/ControllerCondition.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyControllerWrapper.java6
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyFocusWrapper.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyKeyboardWrapper.java6
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyMouseWrapper.java6
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/KeyHeldCondition.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/KeyPressedCondition.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/KeyReleasedCondition.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonClickedCondition.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonCondition.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonPressedCondition.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonReleasedCondition.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseMovedCondition.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseWheelMovedCondition.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/intersection/PickResults.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/light/Light.java11
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractFBOTextureRenderer.java15
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractPbufferTextureRenderer.java9
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractRenderer.java8
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/Camera.java5
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/queue/AbstractRenderBucket.java7
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/queue/OpaqueRenderBucket.java21
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/queue/OrthoRenderBucket.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/queue/TransparentRenderBucket.java5
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/state/LightUtil.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/state/RenderState.java3
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/AbstractBufferData.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/ByteBufferData.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/FloatBufferData.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/IntBufferData.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/ShortBufferData.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/Spatial.java5
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/controller/ComplexSpatialController.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/event/SceneGraphManager.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/extension/PassNodeState.java3
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/hint/SceneHints.java3
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/DeleteVBOsVisitor.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/SetModelBoundVisitor.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/UpdateModelBoundVisitor.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/spline/CatmullRomSpline.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/GameTask.java5
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/LittleEndianDataInput.java15
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/LittleEndianRandomAccessDataInput.java15
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/TextureKey.java3
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/Timer.java5
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryExporter.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryImporter.java21
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryInputCapsule.java41
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryOutputCapsule.java41
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMInputCapsule.java41
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMOutputCapsule.java41
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/export/xml/XMLExporter.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/export/xml/XMLImporter.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/geom/SharedCopyLogic.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/resource/RelativeResourceLocator.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/resource/SimpleResourceLocator.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/resource/StringResourceSource.java7
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/resource/URLResourceSource.java7
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/scenegraph/DisplayListDelegate.java3
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/scenegraph/SceneCompiler.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/shader/ShaderVariable.java3
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/stat/StatType.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/DefColorFadeController.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/LineGrapher.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TabledLabelGrapher.java1
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TimedAreaGrapher.java2
-rw-r--r--ardor3d-core/src/test/java/com/ardor3d/renderer/queue/RenderBucketTypeTest.java59
-rw-r--r--ardor3d-core/src/test/java/com/ardor3d/util/TestLittleEndianDataInput.java18
-rw-r--r--ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/AnimationEntry.java3
-rw-r--r--ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/Particle.java3
-rw-r--r--ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/ParticleAppearanceRamp.java3
-rw-r--r--ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/ParticleInfluence.java3
-rw-r--r--ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/RampEntry.java3
-rw-r--r--ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/TexAnimation.java3
-rw-r--r--ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/LineSegmentEmitter.java3
-rw-r--r--ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/MeshEmitter.java3
-rw-r--r--ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/PointEmitter.java3
-rw-r--r--ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/RectangleEmitter.java3
-rw-r--r--ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/RingEmitter.java3
-rw-r--r--ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/SavableParticleEmitter.java1
-rw-r--r--ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/ProjectedGrid.java2
-rw-r--r--ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/WaterHeightGenerator.java1
-rw-r--r--ardor3d-effects/src/main/java/com/ardor3d/extension/shadow/map/ParallelSplitShadowMapPass.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/ExampleRunner.java24
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/PropertiesDialog.java8
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/applet/JoglBaseApplet.java8
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/basic/JoglBasicExample.java3
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/basic/MouseManagerExample.java5
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/basic/ShapesExample.java1
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/basic/SwitchNodeExample.java1
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/benchmark/ball/BubbleMarkExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/benchmark/ball/BubbleMarkUIExample.java6
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/canvas/RotatingCubeGame.java8
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/collision/CollisionTreeExample.java1
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/effect/BloomExample.java14
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/effect/NewDynamicSmokerExample.java1
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/effect/ParallelSplitShadowMapExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/effect/ProjectedGridExample.java5
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/effect/ProjectedGridWaterExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/effect/QuadImposterExample.java1
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/effect/TrailExample.java9
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/effect/WaterExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/interpolation/InterpolationControllerBase.java3
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationBlinnPhongExample.java9
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationCopyExample.java10
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationDemoExample.java1
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationStateExample.java11
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ColladaExample.java4
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ColladaManualAnimationExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/FireballTrigger.java1
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/PrimitiveSkeletonExample.java3
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ScenegraphTree.java9
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/BillboardNodeExample.java1
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DegenerateTrianglesExample.java1
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DisplayListDelegateExample.java1
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DisplayListExample.java1
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/GeneratedTexturesExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/GeometryInstancingExample.java3
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/MandelbrotExplorerExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/ManyLightsExample.java1
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/PointCubeExample.java4
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/RenderEffectsExample.java1
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/RenderQueueExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/RenderTextureCubeMapExample.java1
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/StereoExample.java3
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/Texture3DExample.java1
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/UpdateTextureExample.java1
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/VBOSpeedExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/ViewportExample.java1
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExample.java3
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExampleMultiTextured.java3
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ArrayTerrainExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ImageMapTerrainExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/terrain/InMemoryTerrainExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ProceduralTerrainExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ShadowedTerrainExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ShapesPlusProceduralTerrainExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/terrain/TerrainWaterExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ZupTerrainExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/ui/BMTextExample.java2
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/ui/RotatingUIExample.java1
-rw-r--r--ardor3d-examples/src/main/java/com/ardor3d/example/ui/SimpleUIExample.java5
-rw-r--r--ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java2
-rw-r--r--ardor3d-math/src/main/java/com/ardor3d/math/Line3.java1
-rw-r--r--ardor3d-math/src/main/java/com/ardor3d/math/Line3Base.java5
-rw-r--r--ardor3d-math/src/main/java/com/ardor3d/math/functions/ArchimedeanSpiralFunction3D.java1
-rw-r--r--ardor3d-math/src/main/java/com/ardor3d/math/functions/CheckerFunction3D.java1
-rw-r--r--ardor3d-math/src/main/java/com/ardor3d/math/functions/CylinderFunction3D.java1
-rw-r--r--ardor3d-math/src/main/java/com/ardor3d/math/functions/FbmFunction3D.java1
-rw-r--r--ardor3d-math/src/main/java/com/ardor3d/math/functions/Functions.java15
-rw-r--r--ardor3d-math/src/main/java/com/ardor3d/math/functions/GridPatternFunction3D.java1
-rw-r--r--ardor3d-math/src/main/java/com/ardor3d/math/functions/MandelbrotFunction3D.java1
-rw-r--r--ardor3d-math/src/main/java/com/ardor3d/math/functions/MapperFunction3D.java1
-rw-r--r--ardor3d-math/src/main/java/com/ardor3d/math/functions/MeshFunction3D.java1
-rw-r--r--ardor3d-math/src/main/java/com/ardor3d/math/functions/RidgeFunction3D.java1
-rw-r--r--ardor3d-math/src/main/java/com/ardor3d/math/functions/TurbulenceFunction3D.java1
-rw-r--r--ardor3d-math/src/main/java/com/ardor3d/math/functions/VoroniFunction3D.java1
-rw-r--r--ardor3d-swt/src/main/java/com/ardor3d/framework/swt/SwtCanvas.java3
-rw-r--r--ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtFocusWrapper.java4
-rw-r--r--ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtKeyboardWrapper.java4
-rw-r--r--ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtMouseManager.java6
-rw-r--r--ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtMouseWrapper.java7
-rw-r--r--ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/Terrain.java1
-rw-r--r--ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/TerrainGridCache.java4
-rw-r--r--ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/TextureGridCache.java4
-rw-r--r--ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/Luminance12ToRGBFunction.java1
-rw-r--r--ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/Luminance8ToRGBFunction.java1
-rw-r--r--ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGB8ToRGBAFunction.java1
-rw-r--r--ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGB8ToRGBFunction.java1
-rw-r--r--ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGBA8ToRGBAFunction.java1
-rw-r--r--ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGBA8ToRGBFunction.java1
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/AbstractLabelUIComponent.java4
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/AbstractUITextEntryComponent.java4
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIComponent.java4
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIFrame.java1
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIFrameBar.java4
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIHud.java2
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIMenuItem.java1
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIScrollBar.java2
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIScrollPanel.java2
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UISliderKnob.java4
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UITabbedPane.java1
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/event/FrameDragListener.java4
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/event/FrameResizeListener.java4
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/model/DefaultSliderModel.java7
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/parser/ForumLikeMarkupParser.java1
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/util/TransformedSubTex.java1
224 files changed, 889 insertions, 123 deletions
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/AttachmentPoint.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/AttachmentPoint.java
index be9f18d..d263e29 100644
--- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/AttachmentPoint.java
+++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/AttachmentPoint.java
@@ -102,6 +102,7 @@ public class AttachmentPoint implements PoseListener {
* Move our managed spatial to align with the referenced joint's position in the given pose, modified by our offset.
* See class javadoc for more information.
*/
+ @Override
public void poseUpdated(final SkeletonPose pose) {
// only update if we have something attached.
if (_attachment != null) {
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/Joint.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/Joint.java
index b5a0e4e..f4a6202 100644
--- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/Joint.java
+++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/Joint.java
@@ -98,10 +98,12 @@ public class Joint implements Savable {
// Methods for Savable
// /////////////////
+ @Override
public Class<? extends Joint> getClassTag() {
return this.getClass();
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_name, "name", null);
capsule.write(_index, "index", (short) 0);
@@ -109,6 +111,7 @@ public class Joint implements Savable {
capsule.write(_inverseBindPose, "inverseBindPose", (Savable) Transform.IDENTITY);
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
final String name = capsule.readString("name", null);
try {
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/Skeleton.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/Skeleton.java
index ba4d69e..ec92cca 100644
--- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/Skeleton.java
+++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/Skeleton.java
@@ -80,15 +80,18 @@ public class Skeleton implements Savable {
// Methods for Savable
// /////////////////
+ @Override
public Class<? extends Skeleton> getClassTag() {
return this.getClass();
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_name, "name", null);
capsule.write(_joints, "joints", null);
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
final String name = capsule.readString("name", null);
final Joint[] joints = CapsuleUtils.asArray(capsule.readSavableArray("joints", null), Joint.class);
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/SkeletonPose.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/SkeletonPose.java
index a0fa4c1..41d2fdb 100644
--- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/SkeletonPose.java
+++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/SkeletonPose.java
@@ -234,15 +234,18 @@ public class SkeletonPose implements Savable {
// Methods for Savable
// /////////////////
+ @Override
public Class<? extends SkeletonPose> getClassTag() {
return this.getClass();
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_skeleton, "skeleton", null);
capsule.write(_localTransforms, "localTransforms", null);
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
final Skeleton skeleton = (Skeleton) capsule.readSavable("skeleton", null);
final Transform[] localTransforms = CapsuleUtils.asArray(capsule.readSavableArray("localTransforms", null),
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/SkinnedMesh.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/SkinnedMesh.java
index aef1d9a..2859105 100644
--- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/SkinnedMesh.java
+++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/SkinnedMesh.java
@@ -483,6 +483,7 @@ public class SkinnedMesh extends Mesh implements PoseListener {
/**
* Calls to apply our pose on pose update.
*/
+ @Override
public void poseUpdated(final SkeletonPose pose) {
// custom behavior?
if (_customApplier != null) {
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/BinaryLERPSource.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/BinaryLERPSource.java
index 5edb64d..13e0284 100644
--- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/BinaryLERPSource.java
+++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/BinaryLERPSource.java
@@ -47,6 +47,7 @@ public class BinaryLERPSource extends AbstractTwoPartSource {
setSourceB(sourceB);
}
+ @Override
public Map<String, ? extends Object> getSourceData(final AnimationManager manager) {
// grab our data maps from the two sources
final Map<String, ? extends Object> sourceAData = getSourceA() != null ? getSourceA().getSourceData(manager)
@@ -58,6 +59,7 @@ public class BinaryLERPSource extends AbstractTwoPartSource {
.combineSourceData(sourceAData, sourceBData, manager.getValuesStore().get(getBlendKey()));
}
+ @Override
public boolean setTime(final double globalTime, final AnimationManager manager) {
// set our time on the two sub sources
boolean foundActive = false;
@@ -70,6 +72,7 @@ public class BinaryLERPSource extends AbstractTwoPartSource {
return foundActive;
}
+ @Override
public void resetClips(final AnimationManager manager, final double globalStartTime) {
// reset our two sub sources
if (getSourceA() != null) {
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/ClipSource.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/ClipSource.java
index 9674c8f..99107f7 100644
--- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/ClipSource.java
+++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/ClipSource.java
@@ -61,6 +61,7 @@ public class ClipSource implements BlendTreeSource {
/**
* Sets the current time on our AnimationClip instance, accounting for looping and time scaling.
*/
+ @Override
public boolean setTime(final double globalTime, final AnimationManager manager) {
final AnimationClipInstance instance = manager.getClipInstance(_clip);
if (instance.isActive()) {
@@ -98,6 +99,7 @@ public class ClipSource implements BlendTreeSource {
return instance.isActive();
}
+ @Override
public void resetClips(final AnimationManager manager, final double globalStartTime) {
manager.resetClipInstance(_clip, globalStartTime);
}
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/FrozenTreeSource.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/FrozenTreeSource.java
index 192d522..db7aee5 100644
--- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/FrozenTreeSource.java
+++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/FrozenTreeSource.java
@@ -31,6 +31,7 @@ public class FrozenTreeSource implements BlendTreeSource {
_time = frozenTime;
}
+ @Override
public Map<String, ? extends Object> getSourceData(final AnimationManager manager) {
return _source.getSourceData(manager);
}
@@ -38,6 +39,7 @@ public class FrozenTreeSource implements BlendTreeSource {
/**
* Ignores the command to reset our subtree.
*/
+ @Override
public void resetClips(final AnimationManager manager, final double globalStartTime) {
_source.resetClips(manager, 0);
}
@@ -45,6 +47,7 @@ public class FrozenTreeSource implements BlendTreeSource {
/**
* Ignores the command to set time on our subtree
*/
+ @Override
public boolean setTime(final double globalTime, final AnimationManager manager) {
_source.setTime(_time, manager);
return true;
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/ManagedTransformSource.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/ManagedTransformSource.java
index 1806e6a..c2eae12 100644
--- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/ManagedTransformSource.java
+++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/ManagedTransformSource.java
@@ -113,6 +113,7 @@ public class ManagedTransformSource implements BlendTreeSource {
/**
* Returns an immutable COPY of our local source data.
*/
+ @Override
public Map<String, JointData> getSourceData(final AnimationManager manager) {
return ImmutableMap.copyOf(data);
}
@@ -120,6 +121,7 @@ public class ManagedTransformSource implements BlendTreeSource {
/**
* Does nothing.
*/
+ @Override
public boolean setTime(final double globalTime, final AnimationManager manager) {
return true;
}
@@ -127,6 +129,7 @@ public class ManagedTransformSource implements BlendTreeSource {
/**
* Does nothing.
*/
+ @Override
public void resetClips(final AnimationManager manager, final double globalStartTime) {
; // ignore
}
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/AbstractAnimationChannel.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/AbstractAnimationChannel.java
index 199f80e..17eaba3 100644
--- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/AbstractAnimationChannel.java
+++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/AbstractAnimationChannel.java
@@ -42,7 +42,7 @@ public abstract class AbstractAnimationChannel implements Savable {
_channelName = channelName;
_times = times == null ? null : new float[times.length];
if (_times != null) {
- System.arraycopy(times, 0, _times, 0, times.length);
+ System.arraycopy(times, 0, _times, 0, _times.length);
}
}
@@ -190,11 +190,13 @@ public abstract class AbstractAnimationChannel implements Savable {
// Methods for Savable
// /////////////////
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_channelName, "channelName", null);
capsule.write(_times, "times", null);
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
final String channelName = capsule.readString("channelName", null);
final float[] times = capsule.readFloatArray("times", null);
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/AnimationClip.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/AnimationClip.java
index cb10165..cc89913 100644
--- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/AnimationClip.java
+++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/AnimationClip.java
@@ -157,15 +157,18 @@ public class AnimationClip implements Savable {
// Methods for Savable
// /////////////////
+ @Override
public Class<? extends AnimationClip> getClassTag() {
return this.getClass();
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_name, "name", null);
capsule.writeSavableList(_channels, "channels", null);
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
final String name = capsule.readString("name", null);
try {
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/InterpolatedDoubleChannel.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/InterpolatedDoubleChannel.java
index 25dc43e..d2efc88 100644
--- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/InterpolatedDoubleChannel.java
+++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/InterpolatedDoubleChannel.java
@@ -43,7 +43,7 @@ public class InterpolatedDoubleChannel extends AbstractAnimationChannel {
super(channelName, times);
_values = values == null ? null : new double[values.length];
if (_values != null) {
- System.arraycopy(values, 0, _values, 0, values.length);
+ System.arraycopy(values, 0, _values, 0, _values.length);
}
}
@@ -133,6 +133,7 @@ public class InterpolatedDoubleChannel extends AbstractAnimationChannel {
// Methods for Savable
// /////////////////
+ @Override
public Class<? extends InterpolatedDoubleChannel> getClassTag() {
return this.getClass();
}
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/InterpolatedFloatChannel.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/InterpolatedFloatChannel.java
index 17f24d3..d1b4cd2 100644
--- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/InterpolatedFloatChannel.java
+++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/InterpolatedFloatChannel.java
@@ -43,7 +43,7 @@ public class InterpolatedFloatChannel extends AbstractAnimationChannel {
super(channelName, times);
_values = values == null ? null : new float[values.length];
if (_values != null) {
- System.arraycopy(values, 0, _values, 0, values.length);
+ System.arraycopy(values, 0, _values, 0, _values.length);
}
}
@@ -133,6 +133,7 @@ public class InterpolatedFloatChannel extends AbstractAnimationChannel {
// Methods for Savable
// /////////////////
+ @Override
public Class<? extends InterpolatedFloatChannel> getClassTag() {
return this.getClass();
}
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/TransformChannel.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/TransformChannel.java
index 07598f5..9738dcb 100644
--- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/TransformChannel.java
+++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/TransformChannel.java
@@ -269,6 +269,7 @@ public class TransformChannel extends AbstractAnimationChannel {
// Methods for Savable
// /////////////////
+ @Override
public Class<? extends TransformChannel> getClassTag() {
return this.getClass();
}
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/TransformData.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/TransformData.java
index 15d4bc3..a9b59b8 100644
--- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/TransformData.java
+++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/TransformData.java
@@ -172,16 +172,19 @@ public class TransformData implements Savable {
// Methods for Savable
// /////////////////
+ @Override
public Class<? extends TransformData> getClassTag() {
return this.getClass();
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_rotation, "rotation", new Quaternion(Quaternion.IDENTITY));
capsule.write(_scale, "scale", new Vector3(Vector3.ONE));
capsule.write(_translation, "translation", new Vector3(Vector3.ZERO));
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
setRotation((Quaternion) capsule.readSavable("rotation", new Quaternion(Quaternion.IDENTITY)));
setScale((Vector3) capsule.readSavable("scale", new Vector3(Vector3.ONE)));
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/TriggerChannel.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/TriggerChannel.java
index e6af818..47eabd9 100644
--- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/TriggerChannel.java
+++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/clip/TriggerChannel.java
@@ -43,7 +43,7 @@ public class TriggerChannel extends AbstractAnimationChannel {
super(channelName, times);
_keys = keys == null ? null : new String[keys.length];
if (_keys != null) {
- System.arraycopy(keys, 0, _keys, 0, keys.length);
+ System.arraycopy(keys, 0, _keys, 0, _keys.length);
}
}
@@ -132,6 +132,7 @@ public class TriggerChannel extends AbstractAnimationChannel {
// Methods for Savable
// /////////////////
+ @Override
public Class<? extends TriggerChannel> getClassTag() {
return this.getClass();
}
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/layer/LayerLERPBlender.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/layer/LayerLERPBlender.java
index d1c8043..f4883c0 100644
--- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/layer/LayerLERPBlender.java
+++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/layer/LayerLERPBlender.java
@@ -32,10 +32,12 @@ public class LayerLERPBlender implements LayerBlender {
/** Our second layer... generally the layer we were added to. */
private AnimationLayer _layerB;
+ @Override
public String getBlendKey() {
return _blendKey;
}
+ @Override
public void setBlendKey(final String blendKey) {
_blendKey = blendKey;
}
@@ -44,6 +46,7 @@ public class LayerLERPBlender implements LayerBlender {
return _layerA;
}
+ @Override
public void setLayerA(final AnimationLayer layer) {
_layerA = layer;
}
@@ -52,10 +55,12 @@ public class LayerLERPBlender implements LayerBlender {
return _layerB;
}
+ @Override
public void setLayerB(final AnimationLayer layer) {
_layerB = layer;
}
+ @Override
public Map<String, ? extends Object> getBlendedSourceData(final AnimationManager manager) {
// grab our data maps from the two layers...
// set A
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/state/AbstractTwoStateLerpTransition.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/state/AbstractTwoStateLerpTransition.java
index 57d9d6f..a838755 100644
--- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/state/AbstractTwoStateLerpTransition.java
+++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/state/AbstractTwoStateLerpTransition.java
@@ -200,6 +200,7 @@ public abstract class AbstractTwoStateLerpTransition extends AbstractTransitionS
return BinaryLERPSource.combineSourceData(sourceAData, sourceBData, getPercent(), _sourceData);
}
+ @Override
public void replaceState(final AbstractFiniteState currentState, final AbstractFiniteState newState) {
if (newState != null) {
if (getStateA() == currentState) {
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/util/SkinUtils.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/util/SkinUtils.java
index d94373c..204b515 100644
--- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/util/SkinUtils.java
+++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/util/SkinUtils.java
@@ -29,6 +29,7 @@ public class SkinUtils {
*/
public static void setAutoUpdateBounds(final Spatial root, final boolean doUpdate) {
root.acceptVisitor(new Visitor() {
+ @Override
public void visit(final Spatial spatial) {
// we only care about SkinnedMesh
if (spatial instanceof SkinnedMesh) {
diff --git a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaInputPipe.java b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaInputPipe.java
index d883756..f42d2e5 100644
--- a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaInputPipe.java
+++ b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaInputPipe.java
@@ -77,7 +77,6 @@ public class ColladaInputPipe {
float_param, bool_param, int_param, name_param, idref_param
}
- @SuppressWarnings("unchecked")
public ColladaInputPipe(final ColladaDOMUtil colladaDOMUtil, final Element input) {
// Setup our type
try {
diff --git a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaMaterialUtils.java b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaMaterialUtils.java
index e4572ff..2f1edce 100644
--- a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaMaterialUtils.java
+++ b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaMaterialUtils.java
@@ -359,7 +359,6 @@ public class ColladaMaterialUtils {
if ("texture".equals(element.getName()) && _loadTextures) {
populateTextureState(mesh, element, effect, loadedTextures, info, null);
}
- @SuppressWarnings("unchecked")
final List<Element> children = element.getChildren();
if (children != null) {
for (final Element child : children) {
@@ -535,7 +534,6 @@ public class ColladaMaterialUtils {
}
}
- @SuppressWarnings("unchecked")
public void bindMaterials(final Element bindMaterial) {
if (bindMaterial == null || bindMaterial.getChildren().isEmpty()) {
return;
@@ -553,7 +551,6 @@ public class ColladaMaterialUtils {
}
}
- @SuppressWarnings("unchecked")
public void unbindMaterials(final Element bindMaterial) {
if (bindMaterial == null || bindMaterial.getChildren().isEmpty()) {
return;
diff --git a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaNodeUtils.java b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaNodeUtils.java
index 165ad89..049fd18 100644
--- a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaNodeUtils.java
+++ b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaNodeUtils.java
@@ -64,7 +64,6 @@ public class ColladaNodeUtils {
* The collada root element
* @return Scene as an Node or null if not found
*/
- @SuppressWarnings("unchecked")
public Node getVisualScene(final Element colladaRoot) {
if (colladaRoot.getChild("scene") == null) {
logger.warning("No scene found in collada file!");
@@ -159,7 +158,6 @@ public class ColladaNodeUtils {
* @param asset
* @return
*/
- @SuppressWarnings("unchecked")
public AssetData parseAsset(final Element asset) {
final AssetData assetData = new AssetData();
@@ -202,7 +200,6 @@ public class ColladaNodeUtils {
return assetData;
}
- @SuppressWarnings("unchecked")
private void parseContributor(final AssetData assetData, final Element contributor) {
for (final Element child : contributor.getChildren()) {
if ("author".equals(child.getName())) {
@@ -240,7 +237,6 @@ public class ColladaNodeUtils {
* @param dNode
* @return a new Ardor3D node, created from the given <node> element
*/
- @SuppressWarnings("unchecked")
private Node buildNode(final Element dNode, JointNode jointNode) {
final NodeType nodeType = getNodeType(dNode);
final JointNode jointChildNode;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingVolume.java b/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingVolume.java
index 19a9822..3b6a94b 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingVolume.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingVolume.java
@@ -250,14 +250,17 @@ public abstract class BoundingVolume implements Serializable, Savable {
*/
public abstract BoundingVolume asType(Type newType);
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_center, "center", new Vector3(Vector3.ZERO));
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
_center.set((Vector3) capsule.readSavable("center", new Vector3(Vector3.ZERO)));
}
+ @Override
public Class<? extends BoundingVolume> getClassTag() {
return this.getClass();
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/bounding/TreeComparator.java b/ardor3d-core/src/main/java/com/ardor3d/bounding/TreeComparator.java
index 9f4626e..c4057e0 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/bounding/TreeComparator.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/bounding/TreeComparator.java
@@ -37,6 +37,7 @@ public class TreeComparator implements Comparator<PrimitiveKey> {
_mesh = mesh;
}
+ @Override
public int compare(final PrimitiveKey o1, final PrimitiveKey o2) {
if (o1.equals(o2)) {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/bounding/UsageTreeController.java b/ardor3d-core/src/main/java/com/ardor3d/bounding/UsageTreeController.java
index ba4d285..a868610 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/bounding/UsageTreeController.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/bounding/UsageTreeController.java
@@ -34,6 +34,7 @@ public class UsageTreeController implements CollisionTreeController {
* @param desiredSize
* the final size of the cache to attempt to reach.
*/
+ @Override
public void clean(final Map<Mesh, CollisionTree> cache, final List<Mesh> protectedList, final int desiredSize) {
// get the ordered keyset (this will be ordered with oldest to newest).
diff --git a/ardor3d-core/src/main/java/com/ardor3d/image/util/AbiLoader.java b/ardor3d-core/src/main/java/com/ardor3d/image/util/AbiLoader.java
index b69ffa8..8b0133d 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/image/util/AbiLoader.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/image/util/AbiLoader.java
@@ -33,6 +33,7 @@ public final class AbiLoader implements ImageLoader {
* @throws IOException
* if an error occurs during read.
*/
+ @Override
public Image load(final InputStream is, final boolean flip) throws IOException {
return (Image) new BinaryImporter().load(is);
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/image/util/TgaLoader.java b/ardor3d-core/src/main/java/com/ardor3d/image/util/TgaLoader.java
index 1d81fbb..67d2a07 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/image/util/TgaLoader.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/image/util/TgaLoader.java
@@ -378,49 +378,51 @@ public final class TgaLoader implements ImageLoader {
}
} else if (imageType == TYPE_COLORMAPPED) {
- final int bytesPerIndex = pixelDepth / 8;
+ if (cMapEntries != null) {
+ final int bytesPerIndex = pixelDepth / 8;
- if (bytesPerIndex == 1) {
- for (int i = 0; i <= (height - 1); i++) {
- if (!flip) {
- rawDataIndex = (height - 1 - i) * width * dl;
- }
- for (int j = 0; j < width; j++) {
- final int index = dis.readUnsignedByte();
- if (index >= cMapEntries.length || index < 0) {
- throw new Ardor3dException("TGA: Invalid color map entry referenced: " + index);
- }
- final ColorMapEntry entry = cMapEntries[index];
- rawData[rawDataIndex++] = entry.red;
- rawData[rawDataIndex++] = entry.green;
- rawData[rawDataIndex++] = entry.blue;
- if (dl == 4) {
- rawData[rawDataIndex++] = entry.alpha;
+ if (bytesPerIndex == 1) {
+ for (int i = 0; i <= (height - 1); i++) {
+ if (!flip) {
+ rawDataIndex = (height - 1 - i) * width * dl;
}
+ for (int j = 0; j < width; j++) {
+ final int index = dis.readUnsignedByte();
+ if (index >= cMapEntries.length || index < 0) {
+ throw new Ardor3dException("TGA: Invalid color map entry referenced: " + index);
+ }
+ final ColorMapEntry entry = cMapEntries[index];
+ rawData[rawDataIndex++] = entry.red;
+ rawData[rawDataIndex++] = entry.green;
+ rawData[rawDataIndex++] = entry.blue;
+ if (dl == 4) {
+ rawData[rawDataIndex++] = entry.alpha;
+ }
+ }
}
- }
- } else if (bytesPerIndex == 2) {
- for (int i = 0; i <= (height - 1); i++) {
- if (!flip) {
- rawDataIndex = (height - 1 - i) * width * dl;
- }
- for (int j = 0; j < width; j++) {
- final int index = flipEndian(dis.readShort());
- if (index >= cMapEntries.length || index < 0) {
- throw new Ardor3dException("TGA: Invalid color map entry referenced: " + index);
+ } else if (bytesPerIndex == 2) {
+ for (int i = 0; i <= (height - 1); i++) {
+ if (!flip) {
+ rawDataIndex = (height - 1 - i) * width * dl;
}
- final ColorMapEntry entry = cMapEntries[index];
- rawData[rawDataIndex++] = entry.red;
- rawData[rawDataIndex++] = entry.green;
- rawData[rawDataIndex++] = entry.blue;
- if (dl == 4) {
- rawData[rawDataIndex++] = entry.alpha;
+ for (int j = 0; j < width; j++) {
+ final int index = flipEndian(dis.readShort());
+ if (index >= cMapEntries.length || index < 0) {
+ throw new Ardor3dException("TGA: Invalid color map entry referenced: " + index);
+ }
+ final ColorMapEntry entry = cMapEntries[index];
+ rawData[rawDataIndex++] = entry.red;
+ rawData[rawDataIndex++] = entry.green;
+ rawData[rawDataIndex++] = entry.blue;
+ if (dl == 4) {
+ rawData[rawDataIndex++] = entry.alpha;
+ }
}
}
+ } else {
+ throw new Ardor3dException("TGA: unknown colormap indexing size used: " + bytesPerIndex);
}
- } else {
- throw new Ardor3dException("TGA: unknown colormap indexing size used: " + bytesPerIndex);
}
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/image/util/dds/DdsLoader.java b/ardor3d-core/src/main/java/com/ardor3d/image/util/dds/DdsLoader.java
index 8d551ac..494c76c 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/image/util/dds/DdsLoader.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/image/util/dds/DdsLoader.java
@@ -56,6 +56,7 @@ import com.google.common.collect.Lists;
public class DdsLoader implements ImageLoader {
private static final Logger logger = Logger.getLogger(DdsLoader.class.getName());
+ @Override
public Image load(final InputStream is, final boolean flipVertically) throws IOException {
final LittleEndianDataInput in = new LittleEndianDataInput(is);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/ControllerState.java b/ardor3d-core/src/main/java/com/ardor3d/input/ControllerState.java
index 15d3106..28f4c6d 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/ControllerState.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/ControllerState.java
@@ -107,6 +107,7 @@ public class ControllerState {
public List<ControllerEvent> getEvents() {
Collections.sort(_eventsSinceLastState, new Comparator<ControllerEvent>() {
+ @Override
public int compare(final ControllerEvent o1, final ControllerEvent o2) {
return (int) (o2.getNanos() - o1.getNanos());
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/control/FirstPersonControl.java b/ardor3d-core/src/main/java/com/ardor3d/input/control/FirstPersonControl.java
index d93f9c0..a7467d8 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/control/FirstPersonControl.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/control/FirstPersonControl.java
@@ -227,6 +227,7 @@ public class FirstPersonControl {
// Test boolean to allow us to ignore first mouse event. First event can wildly vary based on platform.
private boolean firstPing = true;
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
final MouseState mouse = inputStates.getCurrent().getMouseState();
if (mouse.getDx() != 0 || mouse.getDy() != 0) {
@@ -249,6 +250,7 @@ public class FirstPersonControl {
final Predicate<TwoInputStates> keysHeld = new Predicate<TwoInputStates>() {
Key[] keys = new Key[] { Key.W, Key.A, Key.S, Key.D, Key.LEFT, Key.RIGHT, Key.UP, Key.DOWN };
+ @Override
public boolean apply(final TwoInputStates states) {
for (final Key k : keys) {
if (states.getCurrent() != null && states.getCurrent().getKeyboardState().isDown(k)) {
@@ -260,6 +262,7 @@ public class FirstPersonControl {
};
final TriggerAction moveAction = new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
FirstPersonControl.this.move(source.getCanvasRenderer().getCamera(), inputStates.getCurrent()
.getKeyboardState(), tpf);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/control/OrbitCamControl.java b/ardor3d-core/src/main/java/com/ardor3d/input/control/OrbitCamControl.java
index 2be9c8b..4025b66 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/control/OrbitCamControl.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/control/OrbitCamControl.java
@@ -349,8 +349,8 @@ public class OrbitCamControl {
public void setupMouseTriggers(final LogicalLayer layer, final boolean dragOnly) {
// Mouse look
- final Predicate<TwoInputStates> someMouseDown = Predicates.or(TriggerConditions.leftButtonDown(), Predicates
- .or(TriggerConditions.rightButtonDown(), TriggerConditions.middleButtonDown()));
+ final Predicate<TwoInputStates> someMouseDown = Predicates.or(TriggerConditions.leftButtonDown(),
+ Predicates.or(TriggerConditions.rightButtonDown(), TriggerConditions.middleButtonDown()));
final Predicate<TwoInputStates> scrollWheelMoved = new MouseWheelMovedCondition();
final Predicate<TwoInputStates> dragged = Predicates.and(TriggerConditions.mouseMoved(), someMouseDown);
final TriggerAction mouseAction = new TriggerAction() {
@@ -358,6 +358,7 @@ public class OrbitCamControl {
// Test boolean to allow us to ignore first mouse event. First event can wildly vary based on platform.
private boolean firstPing = true;
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
final MouseState mouse = inputStates.getCurrent().getMouseState();
if (mouse.getDx() != 0 || mouse.getDy() != 0) {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/AnyControllerCondition.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/AnyControllerCondition.java
index 8626a5f..084c5e1 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/AnyControllerCondition.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/AnyControllerCondition.java
@@ -15,6 +15,7 @@ import com.google.common.base.Predicate;
public final class AnyControllerCondition implements Predicate<TwoInputStates> {
+ @Override
public boolean apply(final TwoInputStates states) {
final ControllerState oldState = states.getPrevious().getControllerState();
final ControllerState currentState = states.getCurrent().getControllerState();
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/AnyKeyCondition.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/AnyKeyCondition.java
index 5ab407f..c6074d8 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/AnyKeyCondition.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/AnyKeyCondition.java
@@ -17,6 +17,7 @@ import com.google.common.base.Predicate;
* Applicable whenever 'any' key has been pressed.
*/
public class AnyKeyCondition implements Predicate<TwoInputStates> {
+ @Override
public boolean apply(final TwoInputStates twoInputStates) {
final InputState currentState = twoInputStates.getCurrent();
final InputState previousState = twoInputStates.getPrevious();
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/BasicTriggersApplier.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/BasicTriggersApplier.java
index 5b77235..f3324c8 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/BasicTriggersApplier.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/BasicTriggersApplier.java
@@ -16,6 +16,7 @@ import com.ardor3d.framework.Canvas;
public class BasicTriggersApplier implements LogicalTriggersApplier {
+ @Override
public void checkAndPerformTriggers(final Set<InputTrigger> triggers, final Canvas source,
final TwoInputStates states, final double tpf) {
for (final InputTrigger trigger : triggers) {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/ControllerComponentActiveCondition.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/ControllerComponentActiveCondition.java
index 6289c88..75ecf72 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/ControllerComponentActiveCondition.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/ControllerComponentActiveCondition.java
@@ -24,6 +24,7 @@ public final class ControllerComponentActiveCondition implements Predicate<TwoIn
componentNames = components;
}
+ @Override
public boolean apply(final TwoInputStates states) {
final Map<String, Float> currentStates = states.getCurrent().getControllerState()
.getControllerComponentValues(controllerName);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/ControllerComponentCondition.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/ControllerComponentCondition.java
index a088149..8e6b5ec 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/ControllerComponentCondition.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/ControllerComponentCondition.java
@@ -33,6 +33,7 @@ public final class ControllerComponentCondition implements Predicate<TwoInputSta
componentName = component;
}
+ @Override
public boolean apply(final TwoInputStates states) {
boolean apply = false;
final ControllerState currentState = states.getCurrent().getControllerState();
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/ControllerCondition.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/ControllerCondition.java
index 757b2b6..ea20d0f 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/ControllerCondition.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/ControllerCondition.java
@@ -29,6 +29,7 @@ public final class ControllerCondition implements Predicate<TwoInputStates> {
controllerName = controller;
}
+ @Override
public boolean apply(final TwoInputStates states) {
boolean apply = false;
final ControllerState currentState = states.getCurrent().getControllerState();
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyControllerWrapper.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyControllerWrapper.java
index 2194704..86b5d68 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyControllerWrapper.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyControllerWrapper.java
@@ -19,25 +19,31 @@ public class DummyControllerWrapper implements ControllerWrapper {
public static final DummyControllerWrapper INSTANCE = new DummyControllerWrapper();
PeekingIterator<ControllerEvent> empty = new PeekingIterator<ControllerEvent>() {
+ @Override
public boolean hasNext() {
return false;
}
+ @Override
public void remove() {}
+ @Override
public ControllerEvent peek() {
return null;
}
+ @Override
public ControllerEvent next() {
return null;
}
};
+ @Override
public PeekingIterator<ControllerEvent> getEvents() {
return empty;
}
+ @Override
public void init() {
; // ignore, does nothing
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyFocusWrapper.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyFocusWrapper.java
index 7ff0c3e..57d2e79 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyFocusWrapper.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyFocusWrapper.java
@@ -18,10 +18,12 @@ import com.ardor3d.input.FocusWrapper;
public class DummyFocusWrapper implements FocusWrapper {
public static final DummyFocusWrapper INSTANCE = new DummyFocusWrapper();
+ @Override
public void init() {
; // ignore, does nothing
}
+ @Override
public boolean getAndClearFocusLost() {
return false;
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyKeyboardWrapper.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyKeyboardWrapper.java
index 3de004e..d17287f 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyKeyboardWrapper.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyKeyboardWrapper.java
@@ -22,25 +22,31 @@ public class DummyKeyboardWrapper implements KeyboardWrapper {
PeekingIterator<KeyEvent> empty = new PeekingIterator<KeyEvent>() {
+ @Override
public boolean hasNext() {
return false;
}
+ @Override
public void remove() {}
+ @Override
public KeyEvent peek() {
return null;
}
+ @Override
public KeyEvent next() {
return null;
}
};
+ @Override
public PeekingIterator<KeyEvent> getEvents() {
return empty;
}
+ @Override
public void init() {
; // ignore, does nothing.
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyMouseWrapper.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyMouseWrapper.java
index dc47f24..a9b1e74 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyMouseWrapper.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyMouseWrapper.java
@@ -22,25 +22,31 @@ public class DummyMouseWrapper implements MouseWrapper {
PeekingIterator<MouseState> empty = new PeekingIterator<MouseState>() {
+ @Override
public boolean hasNext() {
return false;
}
+ @Override
public void remove() {}
+ @Override
public MouseState peek() {
return null;
}
+ @Override
public MouseState next() {
return null;
}
};
+ @Override
public PeekingIterator<MouseState> getEvents() {
return empty;
}
+ @Override
public void init() {
; // ignore, does nothing
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/KeyHeldCondition.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/KeyHeldCondition.java
index ce2b600..cc244dc 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/KeyHeldCondition.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/KeyHeldCondition.java
@@ -37,6 +37,7 @@ public final class KeyHeldCondition implements Predicate<TwoInputStates> {
this.key = key;
}
+ @Override
public boolean apply(final TwoInputStates states) {
return states.getCurrent().getKeyboardState().isDown(key);
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/KeyPressedCondition.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/KeyPressedCondition.java
index cdb19d6..67b7a85 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/KeyPressedCondition.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/KeyPressedCondition.java
@@ -38,6 +38,7 @@ public final class KeyPressedCondition implements Predicate<TwoInputStates> {
this.key = key;
}
+ @Override
public boolean apply(final TwoInputStates states) {
final InputState currentState = states.getCurrent();
final InputState previousState = states.getPrevious();
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/KeyReleasedCondition.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/KeyReleasedCondition.java
index b08f5ef..0bb6ece 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/KeyReleasedCondition.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/KeyReleasedCondition.java
@@ -38,6 +38,7 @@ public final class KeyReleasedCondition implements Predicate<TwoInputStates> {
this.key = key;
}
+ @Override
public boolean apply(final TwoInputStates states) {
final InputState currentState = states.getCurrent();
final InputState previousState = states.getPrevious();
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonClickedCondition.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonClickedCondition.java
index 4c2a5ff..4b3c601 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonClickedCondition.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonClickedCondition.java
@@ -39,6 +39,7 @@ public final class MouseButtonClickedCondition implements Predicate<TwoInputStat
_button = button;
}
+ @Override
public boolean apply(final TwoInputStates states) {
final InputState currentState = states.getCurrent();
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonCondition.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonCondition.java
index af19920..54625ae 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonCondition.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonCondition.java
@@ -42,6 +42,7 @@ public final class MouseButtonCondition implements Predicate<TwoInputStates> {
}
}
+ @Override
public boolean apply(final TwoInputStates states) {
final InputState currentState = states.getCurrent();
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonPressedCondition.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonPressedCondition.java
index a460517..69f9110 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonPressedCondition.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonPressedCondition.java
@@ -39,6 +39,7 @@ public final class MouseButtonPressedCondition implements Predicate<TwoInputStat
_button = button;
}
+ @Override
public boolean apply(final TwoInputStates states) {
final InputState currentState = states.getCurrent();
final InputState previousState = states.getPrevious();
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonReleasedCondition.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonReleasedCondition.java
index f9b0ebb..ea3744d 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonReleasedCondition.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseButtonReleasedCondition.java
@@ -39,6 +39,7 @@ public final class MouseButtonReleasedCondition implements Predicate<TwoInputSta
_button = button;
}
+ @Override
public boolean apply(final TwoInputStates states) {
final InputState currentState = states.getCurrent();
final InputState previousState = states.getPrevious();
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseMovedCondition.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseMovedCondition.java
index cf3b47d..9cc2acd 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseMovedCondition.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseMovedCondition.java
@@ -19,6 +19,7 @@ import com.google.common.base.Predicate;
*/
@Immutable
public final class MouseMovedCondition implements Predicate<TwoInputStates> {
+ @Override
public boolean apply(final TwoInputStates states) {
final InputState currentState = states.getCurrent();
final InputState previousState = states.getPrevious();
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseWheelMovedCondition.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseWheelMovedCondition.java
index 59ccb97..1f68e11 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseWheelMovedCondition.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/MouseWheelMovedCondition.java
@@ -19,6 +19,7 @@ import com.google.common.base.Predicate;
*/
@Immutable
public final class MouseWheelMovedCondition implements Predicate<TwoInputStates> {
+ @Override
public boolean apply(final TwoInputStates states) {
final InputState currentState = states.getCurrent();
final InputState previousState = states.getPrevious();
diff --git a/ardor3d-core/src/main/java/com/ardor3d/intersection/PickResults.java b/ardor3d-core/src/main/java/com/ardor3d/intersection/PickResults.java
index 402b934..283dc27 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/intersection/PickResults.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/intersection/PickResults.java
@@ -129,6 +129,7 @@ public abstract class PickResults {
*/
private static class DistanceComparator implements Comparator<PickData> {
+ @Override
public int compare(final PickData o1, final PickData o2) {
if (o1.getIntersectionRecord().getClosestDistance() <= o2.getIntersectionRecord().getClosestDistance()) {
return -1;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/light/Light.java b/ardor3d-core/src/main/java/com/ardor3d/light/Light.java
index cf1a9cd..3bd3037 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/light/Light.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/light/Light.java
@@ -202,7 +202,7 @@ public abstract class Light implements Serializable, Savable {
* the specular color value of the light.
*/
public void setSpecular(final ReadOnlyColorRGBA specular) {
- this._specular.set(specular);
+ _specular.set(specular);
}
/**
@@ -221,7 +221,7 @@ public abstract class Light implements Serializable, Savable {
* the diffuse color value for this light.
*/
public void setDiffuse(final ReadOnlyColorRGBA diffuse) {
- this._diffuse.set(diffuse);
+ _diffuse.set(diffuse);
}
/**
@@ -240,7 +240,7 @@ public abstract class Light implements Serializable, Savable {
* the ambient color value for this light.
*/
public void setAmbient(final ReadOnlyColorRGBA ambient) {
- this._ambient.set(ambient);
+ _ambient.set(ambient);
}
/**
@@ -316,9 +316,10 @@ public abstract class Light implements Serializable, Savable {
}
public void setName(final String name) {
- this._name = name;
+ _name = name;
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_ambient, "ambient", new ColorRGBA(DEFAULT_AMBIENT));
capsule.write(_diffuse, "diffuse", new ColorRGBA(DEFAULT_DIFFUSE));
@@ -334,6 +335,7 @@ public abstract class Light implements Serializable, Savable {
capsule.write(_name, "name", null);
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
_ambient.set((ColorRGBA) capsule.readSavable("ambient", new ColorRGBA(DEFAULT_AMBIENT)));
_diffuse.set((ColorRGBA) capsule.readSavable("diffuse", new ColorRGBA(DEFAULT_DIFFUSE)));
@@ -349,6 +351,7 @@ public abstract class Light implements Serializable, Savable {
_name = capsule.readString("name", null);
}
+ @Override
public Class<? extends Light> getClassTag() {
return this.getClass();
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractFBOTextureRenderer.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractFBOTextureRenderer.java
index f7a8c2e..0bf54fb 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractFBOTextureRenderer.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractFBOTextureRenderer.java
@@ -102,18 +102,22 @@ public abstract class AbstractFBOTextureRenderer implements TextureRenderer {
*
* @return the camera this renderer is using.
*/
+ @Override
public Camera getCamera() {
return _camera;
}
+ @Override
public void setBackgroundColor(final ReadOnlyColorRGBA c) {
_backgroundColor.set(c);
}
+ @Override
public ReadOnlyColorRGBA getBackgroundColor() {
return _backgroundColor;
}
+ @Override
public void render(final Spatial toDraw, final Texture tex, final int clear) {
try {
ContextManager.getCurrentContext().pushFBOTextureRenderer(this);
@@ -140,6 +144,7 @@ public abstract class AbstractFBOTextureRenderer implements TextureRenderer {
}
}
+ @Override
public void render(final Scene toDraw, final Texture tex, final int clear) {
try {
ContextManager.getCurrentContext().pushFBOTextureRenderer(this);
@@ -166,6 +171,7 @@ public abstract class AbstractFBOTextureRenderer implements TextureRenderer {
}
}
+ @Override
public void render(final List<? extends Spatial> toDraw, final Texture tex, final int clear) {
try {
ContextManager.getCurrentContext().pushFBOTextureRenderer(this);
@@ -257,10 +263,12 @@ public abstract class AbstractFBOTextureRenderer implements TextureRenderer {
toDraw.renderUnto(_parentRenderer);
}
+ @Override
public int getWidth() {
return _width;
}
+ @Override
public int getHeight() {
return _height;
}
@@ -269,22 +277,27 @@ public abstract class AbstractFBOTextureRenderer implements TextureRenderer {
return _parentRenderer;
}
+ @Override
public void setMultipleTargets(final boolean multi) {
- // ignore. Does not matter to FBO.
+ // ignore. Does not matter to FBO.
}
+ @Override
public void enforceState(final RenderState state) {
_enforcedStates.put(state.getType(), state);
}
+ @Override
public void enforceStates(final EnumMap<StateType, RenderState> states) {
_enforcedStates.putAll(states);
}
+ @Override
public void clearEnforcedState(final StateType type) {
_enforcedStates.remove(type);
}
+ @Override
public void clearEnforcedStates() {
_enforcedStates.clear();
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractPbufferTextureRenderer.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractPbufferTextureRenderer.java
index a428526..565f531 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractPbufferTextureRenderer.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractPbufferTextureRenderer.java
@@ -139,39 +139,48 @@ public abstract class AbstractPbufferTextureRenderer implements TextureRenderer
*
* @return the camera this renderer is using.
*/
+ @Override
public Camera getCamera() {
return _camera;
}
+ @Override
public void setBackgroundColor(final ReadOnlyColorRGBA c) {
_backgroundColor.set(c);
_bgColorDirty = true;
}
+ @Override
public ReadOnlyColorRGBA getBackgroundColor() {
return _backgroundColor;
}
+ @Override
public int getWidth() {
return _width;
}
+ @Override
public int getHeight() {
return _height;
}
+ @Override
public void enforceState(final RenderState state) {
_enforcedStates.put(state.getType(), state);
}
+ @Override
public void enforceStates(final EnumMap<StateType, RenderState> states) {
_enforcedStates.putAll(states);
}
+ @Override
public void clearEnforcedState(final StateType type) {
_enforcedStates.remove(type);
}
+ @Override
public void clearEnforcedStates() {
_enforcedStates.clear();
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractRenderer.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractRenderer.java
index 8aa7f94..c3b04fd 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractRenderer.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractRenderer.java
@@ -58,22 +58,27 @@ public abstract class AbstractRenderer implements Renderer {
}
}
+ @Override
public boolean isInOrthoMode() {
return _inOrthoMode;
}
+ @Override
public ReadOnlyColorRGBA getBackgroundColor() {
return _backgroundColor;
}
+ @Override
public RenderQueue getQueue() {
return _queue;
}
+ @Override
public boolean isProcessingQueue() {
return _processingQueue;
}
+ @Override
public void applyState(final StateType type, final RenderState state) {
if (Constants.stats) {
StatCollector.startStat(StatType.STAT_STATES_TIMER);
@@ -165,12 +170,14 @@ public abstract class AbstractRenderer implements Renderer {
_stencilClearValue = stencilClearValue;
}
+ @Override
public boolean isClipTestEnabled() {
final RenderContext context = ContextManager.getCurrentContext();
final RendererRecord record = context.getRendererRecord();
return record.isClippingTestEnabled();
}
+ @Override
public RenderState getProperRenderState(final StateType type, final RenderState current) {
final RenderContext context = ContextManager.getCurrentContext();
@@ -189,6 +196,7 @@ public abstract class AbstractRenderer implements Renderer {
}
}
+ @Override
public void setRenderLogic(final RenderLogic renderLogic) {
this.renderLogic = renderLogic;
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/Camera.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/Camera.java
index 3b72a92..c8e3c33 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/Camera.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/Camera.java
@@ -1498,6 +1498,7 @@ public class Camera implements Savable, Externalizable {
renderer.setModelViewMatrix(_matrixBuffer);
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_location, "location", new Vector3(Vector3.ZERO));
capsule.write(_left, "left", new Vector3(Vector3.UNIT_X));
@@ -1524,6 +1525,7 @@ public class Camera implements Savable, Externalizable {
capsule.write(_depthRangeFar, "depthRangeFar", 1.0);
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
_location.set((Vector3) capsule.readSavable("location", new Vector3(Vector3.ZERO)));
_left.set((Vector3) capsule.readSavable("left", new Vector3(Vector3.UNIT_X)));
@@ -1550,6 +1552,7 @@ public class Camera implements Savable, Externalizable {
_depthRangeFar = capsule.readDouble("depthRangeFar", 1.0);
}
+ @Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
_location.set((Vector3) in.readObject());
_left.set((Vector3) in.readObject());
@@ -1576,6 +1579,7 @@ public class Camera implements Savable, Externalizable {
_depthRangeFar = in.readDouble();
}
+ @Override
public void writeExternal(final ObjectOutput out) throws IOException {
out.writeObject(_location);
out.writeObject(_left);
@@ -1609,6 +1613,7 @@ public class Camera implements Savable, Externalizable {
+ " left - " + Arrays.toString(getLeft().toArray(null));
}
+ @Override
public Class<? extends Camera> getClassTag() {
return getClass();
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/AbstractRenderBucket.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/AbstractRenderBucket.java
index 3350df3..89f21c8 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/AbstractRenderBucket.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/AbstractRenderBucket.java
@@ -37,6 +37,7 @@ public class AbstractRenderBucket implements RenderBucket {
_tempList = new Spatial[_currentList.length];
}
+ @Override
public void add(final Spatial spatial) {
spatial._queueDistance = Double.NEGATIVE_INFINITY;
if (_currentListSize >= _currentList.length) {
@@ -51,6 +52,7 @@ public class AbstractRenderBucket implements RenderBucket {
_currentList[_currentListSize++] = spatial;
}
+ @Override
public void remove(final Spatial spatial) {
int index = 0;
for (int i = 0; i < _currentListSize; i++) {
@@ -66,6 +68,7 @@ public class AbstractRenderBucket implements RenderBucket {
_currentListSize--;
}
+ @Override
public void clear() {
if (_currentListSize > 0) {
Arrays.fill(_currentList, 0, _currentListSize, null);
@@ -73,12 +76,14 @@ public class AbstractRenderBucket implements RenderBucket {
}
}
+ @Override
public void render(final Renderer renderer) {
for (int i = 0; i < _currentListSize; i++) {
_currentList[i].draw(renderer);
}
}
+ @Override
public void sort() {
// only sort if we have more than one item in our bucket.
if (_currentListSize > 1) {
@@ -98,6 +103,7 @@ public class AbstractRenderBucket implements RenderBucket {
}
}
+ @Override
public void pushBucket() {
_listStack.push(_currentList);
if (_listStackPool.isEmpty()) {
@@ -110,6 +116,7 @@ public class AbstractRenderBucket implements RenderBucket {
_currentListSize = 0;
}
+ @Override
public void popBucket() {
if (_currentList != null) {
_listStackPool.push(_currentList);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/OpaqueRenderBucket.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/OpaqueRenderBucket.java
index f74e9a3..a5de698 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/OpaqueRenderBucket.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/OpaqueRenderBucket.java
@@ -27,6 +27,7 @@ public class OpaqueRenderBucket extends AbstractRenderBucket {
}
private class OpaqueComparator implements Comparator<Spatial> {
+ @Override
public int compare(final Spatial o1, final Spatial o2) {
if (o1 instanceof Mesh && o2 instanceof Mesh) {
return compareByStates((Mesh) o1, (Mesh) o2);
@@ -50,12 +51,20 @@ public class OpaqueRenderBucket extends AbstractRenderBucket {
private int compareByStates(final Mesh mesh1, final Mesh mesh2) {
final TextureState ts1 = (TextureState) mesh1.getWorldRenderState(RenderState.StateType.Texture);
final TextureState ts2 = (TextureState) mesh2.getWorldRenderState(RenderState.StateType.Texture);
- if (ts1 == ts2) {
- return 0;
- } else if (ts1 == null && ts2 != null) {
- return -1;
- } else if (ts2 == null && ts1 != null) {
- return 1;
+ if (ts1 == null) {
+ if (ts2 == null) {
+ return 0;
+ } else {
+ return -1;
+ }
+ } else {
+ if (ts2 == null) {
+ return 1;
+ } else {
+ if (ts1 == ts2) {
+ return 0;
+ }
+ }
}
for (int x = 0, maxIndex = Math.min(ts1.getMaxTextureIndexUsed(), ts2.getMaxTextureIndexUsed()); x <= maxIndex; x++) {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/OrthoRenderBucket.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/OrthoRenderBucket.java
index fa4f8c3..3655bc1 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/OrthoRenderBucket.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/OrthoRenderBucket.java
@@ -38,6 +38,7 @@ public class OrthoRenderBucket extends AbstractRenderBucket {
}
private static class OrthoComparator implements Comparator<Spatial> {
+ @Override
public int compare(final Spatial o1, final Spatial o2) {
if (o2.getSceneHints().getOrthoOrder() == o1.getSceneHints().getOrthoOrder()) {
return 0;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/TransparentRenderBucket.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/TransparentRenderBucket.java
index fe3e73d..06953aa 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/TransparentRenderBucket.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/queue/TransparentRenderBucket.java
@@ -16,10 +16,10 @@ import com.ardor3d.renderer.ContextManager;
import com.ardor3d.renderer.RenderContext;
import com.ardor3d.renderer.Renderer;
import com.ardor3d.renderer.state.CullState;
-import com.ardor3d.renderer.state.RenderState;
-import com.ardor3d.renderer.state.ZBufferState;
import com.ardor3d.renderer.state.CullState.Face;
+import com.ardor3d.renderer.state.RenderState;
import com.ardor3d.renderer.state.RenderState.StateType;
+import com.ardor3d.renderer.state.ZBufferState;
import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.scenegraph.Spatial;
import com.ardor3d.scenegraph.hint.TransparencyType;
@@ -120,6 +120,7 @@ public class TransparentRenderBucket extends AbstractRenderBucket {
}
private class TransparentComparator implements Comparator<Spatial> {
+ @Override
public int compare(final Spatial o1, final Spatial o2) {
final double d1 = distanceToCam(o1);
final double d2 = distanceToCam(o2);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/LightUtil.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/LightUtil.java
index 112a955..643f462 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/LightUtil.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/LightUtil.java
@@ -32,6 +32,7 @@ public abstract class LightUtil {
_sp = sp;
}
+ @Override
public int compare(final Light l1, final Light l2) {
final double v1 = getValueFor(l1, _sp.getWorldBound());
final double v2 = getValueFor(l2, _sp.getWorldBound());
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/RenderState.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/RenderState.java
index 560daf7..4f4bef5 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/RenderState.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/RenderState.java
@@ -196,14 +196,17 @@ public abstract class RenderState implements Savable {
return stack.peek();
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_enabled, "enabled", true);
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
_enabled = capsule.readBoolean("enabled", true);
}
+ @Override
public Class<? extends RenderState> getClassTag() {
return this.getClass();
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/AbstractBufferData.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/AbstractBufferData.java
index 9274fb0..6eb0b3d 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/AbstractBufferData.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/AbstractBufferData.java
@@ -39,6 +39,7 @@ public abstract class AbstractBufferData<T extends Buffer> {
static {
ContextManager.addContextCleanListener(new ContextCleanListener() {
+ @Override
public void cleanForContext(final RenderContext renderContext) {
AbstractBufferData.cleanAllVBOs(null, renderContext);
}
@@ -301,6 +302,7 @@ public abstract class AbstractBufferData<T extends Buffer> {
else {
GameTaskQueueManager.getManager(ContextManager.getContextForRef(glref)).render(
new RendererCallable<Void>() {
+ @Override
public Void call() throws Exception {
getRenderer().deleteVBOs(idMap.get(glref));
return null;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ByteBufferData.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ByteBufferData.java
index 4091e06..7f34ce3 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ByteBufferData.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ByteBufferData.java
@@ -50,6 +50,7 @@ public class ByteBufferData extends IndexBufferData<ByteBuffer> implements Savab
_buffer = buffer;
}
+ @Override
public Class<? extends ByteBufferData> getClassTag() {
return getClass();
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/FloatBufferData.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/FloatBufferData.java
index 19d0a16..3f5c383 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/FloatBufferData.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/FloatBufferData.java
@@ -126,6 +126,7 @@ public class FloatBufferData extends AbstractBufferData<FloatBuffer> implements
return copy;
}
+ @Override
public Class<? extends FloatBufferData> getClassTag() {
return getClass();
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IntBufferData.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IntBufferData.java
index 219a729..6290f88 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IntBufferData.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IntBufferData.java
@@ -49,6 +49,7 @@ public class IntBufferData extends IndexBufferData<IntBuffer> implements Savable
_buffer = buffer;
}
+ @Override
public Class<? extends IntBufferData> getClassTag() {
return getClass();
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java
index b81eb1c..f238cb4 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java
@@ -238,6 +238,7 @@ public class Mesh extends Spatial implements Renderable, Pickable {
return store;
}
+ @Override
public void render(final Renderer renderer) {
if (isVisible()) {
render(renderer, getMeshData());
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ShortBufferData.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ShortBufferData.java
index 5d8f8f8..7d23a84 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ShortBufferData.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ShortBufferData.java
@@ -50,6 +50,7 @@ public class ShortBufferData extends IndexBufferData<ShortBuffer> implements Sav
_buffer = buffer;
}
+ @Override
public Class<? extends ShortBufferData> getClassTag() {
return getClass();
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Spatial.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Spatial.java
index 14d8da4..dc837f3 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Spatial.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Spatial.java
@@ -258,6 +258,7 @@ public abstract class Spatial implements Savable, Hintable {
/**
* @see Hintable#getParentHintable()
*/
+ @Override
public Hintable getParentHintable() {
return _parent;
}
@@ -267,6 +268,7 @@ public abstract class Spatial implements Savable, Hintable {
*
* @return the scene hints set on this Spatial
*/
+ @Override
public SceneHints getSceneHints() {
return _sceneHints;
}
@@ -1349,6 +1351,7 @@ public abstract class Spatial implements Savable, Hintable {
/**
* @see Savable#getClassTag()
*/
+ @Override
public Class<? extends Spatial> getClassTag() {
return this.getClass();
}
@@ -1360,6 +1363,7 @@ public abstract class Spatial implements Savable, Hintable {
* Signals that an I/O exception has occurred.
* @see Savable#read(InputCapsule)
*/
+ @Override
public void read(final InputCapsule capsule) throws IOException {
_name = capsule.readString("name", null);
@@ -1398,6 +1402,7 @@ public abstract class Spatial implements Savable, Hintable {
* Signals that an I/O exception has occurred.
* @see Savable#write(OutputCapsule)
*/
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_name, "name", null);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/controller/ComplexSpatialController.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/controller/ComplexSpatialController.java
index 909a004..a8c028d 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/controller/ComplexSpatialController.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/controller/ComplexSpatialController.java
@@ -199,8 +199,10 @@ public abstract class ComplexSpatialController<T extends Spatial> implements Spa
return RepeatType.CYCLE.equals(getRepeatType());
}
+ @Override
public abstract void update(double time, T caller);
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_repeatType, "repeatType", RepeatType.CLAMP);
capsule.write(_minTime, "minTime", 0);
@@ -209,6 +211,7 @@ public abstract class ComplexSpatialController<T extends Spatial> implements Spa
capsule.write(_active, "active", true);
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
_repeatType = capsule.readEnum("repeatType", RepeatType.class, RepeatType.CLAMP);
_minTime = capsule.readDouble("minTime", 0);
@@ -217,6 +220,7 @@ public abstract class ComplexSpatialController<T extends Spatial> implements Spa
_active = capsule.readBoolean("active", true);
}
+ @Override
@SuppressWarnings("rawtypes")
public Class<? extends ComplexSpatialController> getClassTag() {
return this.getClass();
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/event/SceneGraphManager.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/event/SceneGraphManager.java
index 3300c6d..ba65860 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/event/SceneGraphManager.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/event/SceneGraphManager.java
@@ -47,6 +47,7 @@ public class SceneGraphManager implements DirtyEventListener {
_listeners.remove(listener);
}
+ @Override
public boolean spatialDirty(final Spatial spatial, final DirtyType dirtyType) {
for (final DirtyEventListener listener : _listeners) {
listener.spatialDirty(spatial, dirtyType);
@@ -54,6 +55,7 @@ public class SceneGraphManager implements DirtyEventListener {
return false;
}
+ @Override
public boolean spatialClean(final Spatial spatial, final DirtyType dirtyType) {
for (final DirtyEventListener listener : _listeners) {
listener.spatialClean(spatial, dirtyType);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/extension/PassNodeState.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/extension/PassNodeState.java
index c34d4f9..abbc917 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/extension/PassNodeState.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/extension/PassNodeState.java
@@ -99,16 +99,19 @@ public class PassNodeState implements Savable, Serializable {
_enabled = enabled;
}
+ @Override
public Class<? extends PassNodeState> getClassTag() {
return this.getClass();
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
final OutputCapsule oc = capsule;
oc.write(_enabled, "enabled", true);
oc.write(_passStates.values().toArray(new RenderState[0]), "passStates", null);
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
final InputCapsule ic = capsule;
_enabled = ic.readBoolean("enabled", true);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/hint/SceneHints.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/hint/SceneHints.java
index 36a239c..5bde95b 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/hint/SceneHints.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/hint/SceneHints.java
@@ -448,10 +448,12 @@ public class SceneHints implements Savable {
// Methods for Savable
// /////////////////
+ @Override
public Class<? extends SceneHints> getClassTag() {
return this.getClass();
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
_orthoOrder = capsule.readInt("orthoOrder", 0);
_cullHint = capsule.readEnum("cullMode", CullHint.class, CullHint.Inherit);
@@ -478,6 +480,7 @@ public class SceneHints implements Savable {
}
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_orthoOrder, "orthoOrder", 0);
capsule.write(_cullHint, "cullMode", CullHint.Inherit);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/DeleteVBOsVisitor.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/DeleteVBOsVisitor.java
index 03c075a..d9299d8 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/DeleteVBOsVisitor.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/DeleteVBOsVisitor.java
@@ -22,6 +22,7 @@ public class DeleteVBOsVisitor implements Visitor {
_deleter = deleter;
}
+ @Override
public void visit(final Spatial spatial) {
if (spatial instanceof Mesh) {
final Mesh mesh = (Mesh) spatial;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/SetModelBoundVisitor.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/SetModelBoundVisitor.java
index 9e809df..509c37f 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/SetModelBoundVisitor.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/SetModelBoundVisitor.java
@@ -21,6 +21,7 @@ public class SetModelBoundVisitor implements Visitor {
_bound = bound;
}
+ @Override
public void visit(final Spatial spatial) {
if (spatial instanceof Mesh) {
((Mesh) spatial).setModelBound(_bound.clone(null));
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/UpdateModelBoundVisitor.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/UpdateModelBoundVisitor.java
index b313613..f3e3525 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/UpdateModelBoundVisitor.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/UpdateModelBoundVisitor.java
@@ -14,6 +14,7 @@ import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.scenegraph.Spatial;
public class UpdateModelBoundVisitor implements Visitor {
+ @Override
public void visit(final Spatial spatial) {
if (spatial instanceof Mesh) {
((Mesh) spatial).updateModelBound();
diff --git a/ardor3d-core/src/main/java/com/ardor3d/spline/CatmullRomSpline.java b/ardor3d-core/src/main/java/com/ardor3d/spline/CatmullRomSpline.java
index 14ceb0c..0d39f4a 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/spline/CatmullRomSpline.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/spline/CatmullRomSpline.java
@@ -32,6 +32,7 @@ public class CatmullRomSpline implements Spline {
/**
* @see #interpolate(ReadOnlyVector3, ReadOnlyVector3, ReadOnlyVector3, ReadOnlyVector3, double, Vector3)
*/
+ @Override
public Vector3 interpolate(final ReadOnlyVector3 p0, final ReadOnlyVector3 p1, final ReadOnlyVector3 p2,
final ReadOnlyVector3 p3, final double t) {
@@ -56,6 +57,7 @@ public class CatmullRomSpline implements Spline {
* The results from the interpolation will be stored in this vector.
* @return The result vector as a convenience.
*/
+ @Override
public Vector3 interpolate(final ReadOnlyVector3 p0, final ReadOnlyVector3 p1, final ReadOnlyVector3 p2,
final ReadOnlyVector3 p3, final double t, final Vector3 result) {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/GameTask.java b/ardor3d-core/src/main/java/com/ardor3d/util/GameTask.java
index 6811d5c..70b4dc4 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/GameTask.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/GameTask.java
@@ -42,6 +42,7 @@ public class GameTask<V> implements Future<V> {
* @param mayInterruptIfRunning
* ignored by this implementation.
*/
+ @Override
public boolean cancel(final boolean mayInterruptIfRunning) {
_stateLock.lock();
try {
@@ -58,6 +59,7 @@ public class GameTask<V> implements Future<V> {
}
}
+ @Override
public V get() throws InterruptedException, ExecutionException {
_stateLock.lock();
try {
@@ -73,6 +75,7 @@ public class GameTask<V> implements Future<V> {
}
}
+ @Override
public V get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException,
TimeoutException {
_stateLock.lock();
@@ -92,6 +95,7 @@ public class GameTask<V> implements Future<V> {
}
}
+ @Override
public boolean isCancelled() {
_stateLock.lock();
try {
@@ -101,6 +105,7 @@ public class GameTask<V> implements Future<V> {
}
}
+ @Override
public boolean isDone() {
_stateLock.lock();
try {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/LittleEndianDataInput.java b/ardor3d-core/src/main/java/com/ardor3d/util/LittleEndianDataInput.java
index c3c8ec4..914364e 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/LittleEndianDataInput.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/LittleEndianDataInput.java
@@ -41,6 +41,7 @@ public class LittleEndianDataInput implements DataInput {
_stream = new BufferedInputStream(in);
}
+ @Override
public final int readUnsignedShort() throws IOException {
return (_stream.read() & 0xff) | ((_stream.read() & 0xff) << 8);
}
@@ -53,31 +54,38 @@ public class LittleEndianDataInput implements DataInput {
.read() & 0xff)) << 24));
}
+ @Override
public final boolean readBoolean() throws IOException {
return (_stream.read() != 0);
}
+ @Override
public final byte readByte() throws IOException {
return (byte) _stream.read();
}
+ @Override
public final int readUnsignedByte() throws IOException {
return _stream.read();
}
+ @Override
public final short readShort() throws IOException {
return (short) readUnsignedShort();
}
+ @Override
public final char readChar() throws IOException {
return (char) readUnsignedShort();
}
+ @Override
public final int readInt() throws IOException {
return ((_stream.read() & 0xff) | ((_stream.read() & 0xff) << 8) | ((_stream.read() & 0xff) << 16) | ((_stream
.read() & 0xff) << 24));
}
+ @Override
public final long readLong() throws IOException {
return ((_stream.read() & 0xff) | ((long) (_stream.read() & 0xff) << 8)
| ((long) (_stream.read() & 0xff) << 16) | ((long) (_stream.read() & 0xff) << 24)
@@ -85,18 +93,22 @@ public class LittleEndianDataInput implements DataInput {
| ((long) (_stream.read() & 0xff) << 48) | ((long) (_stream.read() & 0xff) << 56));
}
+ @Override
public final float readFloat() throws IOException {
return Float.intBitsToFloat(readInt());
}
+ @Override
public final double readDouble() throws IOException {
return Double.longBitsToDouble(readLong());
}
+ @Override
public final void readFully(final byte b[]) throws IOException {
readFully(b, 0, b.length);
}
+ @Override
public final void readFully(final byte b[], final int off, final int len) throws IOException {
// this may look over-complicated, but the problem is that the InputStream.read() methods are
// not guaranteed to fill up the buffer you pass to it. So we need to loop until we have filled
@@ -114,14 +126,17 @@ public class LittleEndianDataInput implements DataInput {
}
}
+ @Override
public final int skipBytes(final int n) throws IOException {
return (int) _stream.skip(n);
}
+ @Override
public final String readLine() throws IOException {
throw new IOException("Unsupported operation");
}
+ @Override
public final String readUTF() throws IOException {
throw new IOException("Unsupported operation");
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/LittleEndianRandomAccessDataInput.java b/ardor3d-core/src/main/java/com/ardor3d/util/LittleEndianRandomAccessDataInput.java
index 33ced8f..e32140d 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/LittleEndianRandomAccessDataInput.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/LittleEndianRandomAccessDataInput.java
@@ -59,6 +59,7 @@ public class LittleEndianRandomAccessDataInput implements DataInput {
_contents = contents;
}
+ @Override
public final int readUnsignedShort() throws IOException {
return (readByte() & 0xff) | ((readByte() & 0xff) << 8);
}
@@ -67,48 +68,59 @@ public class LittleEndianRandomAccessDataInput implements DataInput {
return ((readByte() & 0xff) | ((readByte() & 0xff) << 8) | ((readByte() & 0xff) << 16) | (((long) (readByte() & 0xff)) << 24));
}
+ @Override
public final boolean readBoolean() throws IOException {
return (readByte() != 0);
}
+ @Override
public final byte readByte() throws IOException {
return _contents.get();
}
+ @Override
public final int readUnsignedByte() throws IOException {
return readByte() & 0xff;
}
+ @Override
public final short readShort() throws IOException {
return (short) readUnsignedShort();
}
+ @Override
public final char readChar() throws IOException {
return (char) readUnsignedShort();
}
+ @Override
public final int readInt() throws IOException {
return ((readByte() & 0xff) | ((readByte() & 0xff) << 8) | ((readByte() & 0xff) << 16) | ((readByte() & 0xff) << 24));
}
+ @Override
public final long readLong() throws IOException {
return ((readByte() & 0xff) | ((long) (readByte() & 0xff) << 8) | ((long) (readByte() & 0xff) << 16)
| ((long) (readByte() & 0xff) << 24) | ((long) (readByte() & 0xff) << 32)
| ((long) (readByte() & 0xff) << 40) | ((long) (readByte() & 0xff) << 48) | ((long) (readByte() & 0xff) << 56));
}
+ @Override
public final float readFloat() throws IOException {
return Float.intBitsToFloat(readInt());
}
+ @Override
public final double readDouble() throws IOException {
return Double.longBitsToDouble(readLong());
}
+ @Override
public final void readFully(final byte b[]) throws IOException {
readFully(b, 0, b.length);
}
+ @Override
public final void readFully(final byte b[], final int off, final int len) throws IOException {
if (len - off + _contents.position() > _contents.capacity()) {
throw new EOFException("EOF reached");
@@ -117,6 +129,7 @@ public class LittleEndianRandomAccessDataInput implements DataInput {
}
}
+ @Override
public final int skipBytes(final int n) throws IOException {
if (_contents.remaining() >= n) {
_contents.position(_contents.position() + n);
@@ -155,6 +168,7 @@ public class LittleEndianRandomAccessDataInput implements DataInput {
* @throws IOException
* if this method is called.
*/
+ @Override
public final String readLine() throws IOException {
throw new IOException("operation unsupported.");
}
@@ -165,6 +179,7 @@ public class LittleEndianRandomAccessDataInput implements DataInput {
* @throws IOException
* if this method is called.
*/
+ @Override
public final String readUTF() throws IOException {
throw new IOException("operation unsupported.");
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/TextureKey.java b/ardor3d-core/src/main/java/com/ardor3d/util/TextureKey.java
index a8b7bb9..fe0274b 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/TextureKey.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/TextureKey.java
@@ -394,10 +394,12 @@ final public class TextureKey implements Savable {
// Methods for Savable
// /////////////////
+ @Override
public Class<? extends TextureKey> getClassTag() {
return this.getClass();
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_source, "source", null);
capsule.write(_flipped, "flipped", false);
@@ -406,6 +408,7 @@ final public class TextureKey implements Savable {
capsule.write(_id, "id", null);
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
_source = (ResourceSource) capsule.readSavable("source", null);
_flipped = capsule.readBoolean("flipped", false);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/Timer.java b/ardor3d-core/src/main/java/com/ardor3d/util/Timer.java
index 4f99a60..40ccaed 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/Timer.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/Timer.java
@@ -27,22 +27,27 @@ public class Timer implements ReadOnlyTimer {
_startTime = System.nanoTime();
}
+ @Override
public double getTimeInSeconds() {
return getTime() * INVERSE_TIMER_RESOLUTION;
}
+ @Override
public long getTime() {
return System.nanoTime() - _startTime;
}
+ @Override
public long getResolution() {
return TIMER_RESOLUTION;
}
+ @Override
public double getFrameRate() {
return _fps;
}
+ @Override
public double getTimePerFrame() {
return _tpf;
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryExporter.java b/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryExporter.java
index 1c3359c..471e053 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryExporter.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryExporter.java
@@ -147,6 +147,7 @@ public class BinaryExporter implements Ardor3dExporter {
_compression = compression;
}
+ @Override
public void save(final Savable object, final OutputStream os) throws IOException {
try {
GZIPOutputStream zos = new GZIPOutputStream(os) {
@@ -297,6 +298,7 @@ public class BinaryExporter implements Ardor3dExporter {
return bytes;
}
+ @Override
public void save(final Savable object, final File file) throws IOException {
final File parentDirectory = file.getParentFile();
if (parentDirectory != null && !parentDirectory.exists()) {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryImporter.java b/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryImporter.java
index 6e2c847..3c0a4d2 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryImporter.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryImporter.java
@@ -50,6 +50,7 @@ public class BinaryImporter implements Ardor3dImporter {
public BinaryImporter() {}
+ @Override
public Savable load(final InputStream is) throws IOException {
return load(is, null, null);
}
@@ -155,6 +156,7 @@ public class BinaryImporter implements Ardor3dImporter {
}
}
+ @Override
public Savable load(final URL url) throws IOException {
return load(url, null);
}
@@ -166,6 +168,7 @@ public class BinaryImporter implements Ardor3dImporter {
return rVal;
}
+ @Override
public Savable load(final File file) throws IOException {
return load(file, null);
}
@@ -177,6 +180,7 @@ public class BinaryImporter implements Ardor3dImporter {
return rVal;
}
+ @Override
public Savable load(final byte[] data) throws IOException {
final ByteArrayInputStream bais = new ByteArrayInputStream(data);
final Savable rVal = load(bais);
@@ -243,15 +247,14 @@ public class BinaryImporter implements Ardor3dImporter {
+ "Some types may require the annotation SavableFactory. Please double check.", e);
throw new Ardor3dException(e);
} catch (final NoSuchMethodException e) {
- logger
- .logp(
- Level.SEVERE,
- this.getClass().toString(),
- "readObject(int)",
- e.getMessage()
- + " \n"
- + "Method specified in annotation does not appear to exist or has an invalid method signature.",
- e);
+ logger.logp(
+ Level.SEVERE,
+ this.getClass().toString(),
+ "readObject(int)",
+ e.getMessage()
+ + " \n"
+ + "Method specified in annotation does not appear to exist or has an invalid method signature.",
+ e);
throw new Ardor3dException(e);
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryInputCapsule.java b/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryInputCapsule.java
index ade60ff..3d99d16 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryInputCapsule.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryInputCapsule.java
@@ -227,6 +227,7 @@ public class BinaryInputCapsule implements InputCapsule {
}
}
+ @Override
public BitSet readBitSet(final String name, final BitSet defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -235,6 +236,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (BitSet) _fieldData.get(field._alias);
}
+ @Override
public boolean readBoolean(final String name, final boolean defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -243,6 +245,7 @@ public class BinaryInputCapsule implements InputCapsule {
return ((Boolean) _fieldData.get(field._alias)).booleanValue();
}
+ @Override
public boolean[] readBooleanArray(final String name, final boolean[] defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -251,6 +254,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (boolean[]) _fieldData.get(field._alias);
}
+ @Override
public boolean[][] readBooleanArray2D(final String name, final boolean[][] defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -259,6 +263,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (boolean[][]) _fieldData.get(field._alias);
}
+ @Override
public byte readByte(final String name, final byte defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -267,6 +272,7 @@ public class BinaryInputCapsule implements InputCapsule {
return ((Byte) _fieldData.get(field._alias)).byteValue();
}
+ @Override
public byte[] readByteArray(final String name, final byte[] defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -275,6 +281,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (byte[]) _fieldData.get(field._alias);
}
+ @Override
public byte[][] readByteArray2D(final String name, final byte[][] defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -283,6 +290,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (byte[][]) _fieldData.get(field._alias);
}
+ @Override
public ByteBuffer readByteBuffer(final String name, final ByteBuffer defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -291,6 +299,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (ByteBuffer) _fieldData.get(field._alias);
}
+ @Override
@SuppressWarnings("unchecked")
public List<ByteBuffer> readByteBufferList(final String name, final List<ByteBuffer> defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
@@ -300,6 +309,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (List<ByteBuffer>) _fieldData.get(field._alias);
}
+ @Override
public double readDouble(final String name, final double defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -308,6 +318,7 @@ public class BinaryInputCapsule implements InputCapsule {
return ((Double) _fieldData.get(field._alias)).doubleValue();
}
+ @Override
public double[] readDoubleArray(final String name, final double[] defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -316,6 +327,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (double[]) _fieldData.get(field._alias);
}
+ @Override
public double[][] readDoubleArray2D(final String name, final double[][] defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -324,6 +336,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (double[][]) _fieldData.get(field._alias);
}
+ @Override
public float readFloat(final String name, final float defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -332,6 +345,7 @@ public class BinaryInputCapsule implements InputCapsule {
return ((Float) _fieldData.get(field._alias)).floatValue();
}
+ @Override
public float[] readFloatArray(final String name, final float[] defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -340,6 +354,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (float[]) _fieldData.get(field._alias);
}
+ @Override
public float[][] readFloatArray2D(final String name, final float[][] defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -348,6 +363,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (float[][]) _fieldData.get(field._alias);
}
+ @Override
public FloatBuffer readFloatBuffer(final String name, final FloatBuffer defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -356,6 +372,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (FloatBuffer) _fieldData.get(field._alias);
}
+ @Override
@SuppressWarnings("unchecked")
public List<FloatBuffer> readFloatBufferList(final String name, final List<FloatBuffer> defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
@@ -365,6 +382,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (List<FloatBuffer>) _fieldData.get(field._alias);
}
+ @Override
public int readInt(final String name, final int defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -373,6 +391,7 @@ public class BinaryInputCapsule implements InputCapsule {
return ((Integer) _fieldData.get(field._alias)).intValue();
}
+ @Override
public int[] readIntArray(final String name, final int[] defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -381,6 +400,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (int[]) _fieldData.get(field._alias);
}
+ @Override
public int[][] readIntArray2D(final String name, final int[][] defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -389,6 +409,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (int[][]) _fieldData.get(field._alias);
}
+ @Override
public IntBuffer readIntBuffer(final String name, final IntBuffer defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -397,6 +418,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (IntBuffer) _fieldData.get(field._alias);
}
+ @Override
public long readLong(final String name, final long defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -405,6 +427,7 @@ public class BinaryInputCapsule implements InputCapsule {
return ((Long) _fieldData.get(field._alias)).longValue();
}
+ @Override
public long[] readLongArray(final String name, final long[] defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -413,6 +436,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (long[]) _fieldData.get(field._alias);
}
+ @Override
public long[][] readLongArray2D(final String name, final long[][] defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -421,6 +445,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (long[][]) _fieldData.get(field._alias);
}
+ @Override
public Savable readSavable(final String name, final Savable defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -438,6 +463,7 @@ public class BinaryInputCapsule implements InputCapsule {
}
}
+ @Override
public Savable[] readSavableArray(final String name, final Savable[] defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -466,6 +492,7 @@ public class BinaryInputCapsule implements InputCapsule {
}
}
+ @Override
public Savable[][] readSavableArray2D(final String name, final Savable[][] defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -548,6 +575,7 @@ public class BinaryInputCapsule implements InputCapsule {
return map;
}
+ @Override
@SuppressWarnings("unchecked")
public <E extends Savable> List<E> readSavableList(final String name, final List<E> defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
@@ -564,6 +592,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (List<E>) value;
}
+ @Override
@SuppressWarnings("unchecked")
public <E extends Savable> List<E>[] readSavableListArray(final String name, final List<E>[] defVal)
throws IOException {
@@ -589,6 +618,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (List<E>[]) value;
}
+ @Override
@SuppressWarnings("unchecked")
public <E extends Savable> List<E>[][] readSavableListArray2D(final String name, final List<E>[][] defVal)
throws IOException {
@@ -617,6 +647,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (List<E>[][]) value;
}
+ @Override
@SuppressWarnings("unchecked")
public <K extends Savable, V extends Savable> Map<K, V> readSavableMap(final String name, final Map<K, V> defVal)
throws IOException {
@@ -634,6 +665,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (Map<K, V>) value;
}
+ @Override
@SuppressWarnings("unchecked")
public <V extends Savable> Map<String, V> readStringSavableMap(final String name, final Map<String, V> defVal)
throws IOException {
@@ -652,6 +684,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (Map<String, V>) value;
}
+ @Override
public short readShort(final String name, final short defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -660,6 +693,7 @@ public class BinaryInputCapsule implements InputCapsule {
return ((Short) _fieldData.get(field._alias)).shortValue();
}
+ @Override
public short[] readShortArray(final String name, final short[] defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -668,6 +702,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (short[]) _fieldData.get(field._alias);
}
+ @Override
public short[][] readShortArray2D(final String name, final short[][] defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -676,6 +711,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (short[][]) _fieldData.get(field._alias);
}
+ @Override
public ShortBuffer readShortBuffer(final String name, final ShortBuffer defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -684,6 +720,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (ShortBuffer) _fieldData.get(field._alias);
}
+ @Override
public String readString(final String name, final String defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -692,6 +729,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (String) _fieldData.get(field._alias);
}
+ @Override
public String[] readStringArray(final String name, final String[] defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -700,6 +738,7 @@ public class BinaryInputCapsule implements InputCapsule {
return (String[]) _fieldData.get(field._alias);
}
+ @Override
public String[][] readStringArray2D(final String name, final String[][] defVal) throws IOException {
final BinaryClassField field = _cObj._nameFields.get(name);
if (field == null || !_fieldData.containsKey(field._alias)) {
@@ -1389,6 +1428,7 @@ public class BinaryInputCapsule implements InputCapsule {
public ID[] values;
}
+ @Override
public <T extends Enum<T>> T readEnum(final String name, final Class<T> enumType, final T defVal)
throws IOException {
final String eVal = readString(name, defVal != null ? defVal.name() : null);
@@ -1399,6 +1439,7 @@ public class BinaryInputCapsule implements InputCapsule {
}
}
+ @Override
@SuppressWarnings("unchecked")
public <T extends Enum<T>> T[] readEnumArray(final String name, final Class<T> enumType, final T[] defVal)
throws IOException {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryOutputCapsule.java b/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryOutputCapsule.java
index 82a14dd..996cbd7 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryOutputCapsule.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryOutputCapsule.java
@@ -53,6 +53,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
_forceDirectNioBuffers = forceDirectNioBuffers;
}
+ @Override
public void write(final byte value, final String name, final byte defVal) throws IOException {
if (value == defVal) {
return;
@@ -61,6 +62,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final byte[] value, final String name, final byte[] defVal) throws IOException {
if (value == defVal) {
return;
@@ -69,6 +71,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final byte[][] value, final String name, final byte[][] defVal) throws IOException {
if (value == defVal) {
return;
@@ -77,6 +80,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final int value, final String name, final int defVal) throws IOException {
if (value == defVal) {
return;
@@ -85,6 +89,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final int[] value, final String name, final int[] defVal) throws IOException {
if (value == defVal) {
return;
@@ -93,6 +98,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final int[][] value, final String name, final int[][] defVal) throws IOException {
if (value == defVal) {
return;
@@ -101,6 +107,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final float value, final String name, final float defVal) throws IOException {
if (value == defVal) {
return;
@@ -109,6 +116,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final float[] value, final String name, final float[] defVal) throws IOException {
if (value == defVal) {
return;
@@ -117,6 +125,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final float[][] value, final String name, final float[][] defVal) throws IOException {
if (value == defVal) {
return;
@@ -125,6 +134,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final double value, final String name, final double defVal) throws IOException {
if (value == defVal) {
return;
@@ -133,6 +143,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final double[] value, final String name, final double[] defVal) throws IOException {
if (value == defVal) {
return;
@@ -141,6 +152,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final double[][] value, final String name, final double[][] defVal) throws IOException {
if (value == defVal) {
return;
@@ -149,6 +161,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final long value, final String name, final long defVal) throws IOException {
if (value == defVal) {
return;
@@ -157,6 +170,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final long[] value, final String name, final long[] defVal) throws IOException {
if (value == defVal) {
return;
@@ -165,6 +179,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final long[][] value, final String name, final long[][] defVal) throws IOException {
if (value == defVal) {
return;
@@ -173,6 +188,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final short value, final String name, final short defVal) throws IOException {
if (value == defVal) {
return;
@@ -181,6 +197,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final short[] value, final String name, final short[] defVal) throws IOException {
if (value == defVal) {
return;
@@ -189,6 +206,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final short[][] value, final String name, final short[][] defVal) throws IOException {
if (value == defVal) {
return;
@@ -197,6 +215,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final boolean value, final String name, final boolean defVal) throws IOException {
if (value == defVal) {
return;
@@ -205,6 +224,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final boolean[] value, final String name, final boolean[] defVal) throws IOException {
if (value == defVal) {
return;
@@ -213,6 +233,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final boolean[][] value, final String name, final boolean[][] defVal) throws IOException {
if (value == defVal) {
return;
@@ -221,6 +242,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final String value, final String name, final String defVal) throws IOException {
if (value == null ? defVal == null : value.equals(defVal)) {
return;
@@ -229,6 +251,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final String[] value, final String name, final String[] defVal) throws IOException {
if (value == defVal) {
return;
@@ -237,6 +260,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final String[][] value, final String name, final String[][] defVal) throws IOException {
if (value == defVal) {
return;
@@ -245,6 +269,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final BitSet value, final String name, final BitSet defVal) throws IOException {
if (value == defVal) {
return;
@@ -253,6 +278,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final Savable object, final String name, final Savable defVal) throws IOException {
if (object == defVal) {
return;
@@ -261,6 +287,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(object);
}
+ @Override
public void write(final Savable[] objects, final String name, final Savable[] defVal) throws IOException {
if (objects == defVal) {
return;
@@ -269,6 +296,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(objects);
}
+ @Override
public void write(final Savable[][] objects, final String name, final Savable[][] defVal) throws IOException {
if (objects == defVal) {
return;
@@ -277,6 +305,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(objects);
}
+ @Override
public void write(final FloatBuffer value, final String name, final FloatBuffer defVal) throws IOException {
if (value == defVal) {
return;
@@ -285,6 +314,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final IntBuffer value, final String name, final IntBuffer defVal) throws IOException {
if (value == defVal) {
return;
@@ -293,6 +323,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final ByteBuffer value, final String name, final ByteBuffer defVal) throws IOException {
if (value == defVal) {
return;
@@ -301,6 +332,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void write(final ShortBuffer value, final String name, final ShortBuffer defVal) throws IOException {
if (value == defVal) {
return;
@@ -309,6 +341,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
write(value);
}
+ @Override
public void writeFloatBufferList(final List<FloatBuffer> array, final String name, final List<FloatBuffer> defVal)
throws IOException {
if (array == defVal) {
@@ -318,6 +351,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
writeFloatBufferArrayList(array);
}
+ @Override
public void writeByteBufferList(final List<ByteBuffer> array, final String name, final List<ByteBuffer> defVal)
throws IOException {
if (array == defVal) {
@@ -327,6 +361,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
writeByteBufferArrayList(array);
}
+ @Override
public void writeSavableList(final List<? extends Savable> array, final String name,
final List<? extends Savable> defVal) throws IOException {
if (array == defVal) {
@@ -336,6 +371,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
writeSavableArrayList(array);
}
+ @Override
public void writeSavableListArray(final List<? extends Savable>[] array, final String name,
final List<? extends Savable>[] defVal) throws IOException {
if (array == defVal) {
@@ -345,6 +381,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
writeSavableArrayListArray(array);
}
+ @Override
public void writeSavableListArray2D(final List<? extends Savable>[][] array, final String name,
final List<? extends Savable>[][] defVal) throws IOException {
if (array == defVal) {
@@ -354,6 +391,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
writeSavableArrayListArray2D(array);
}
+ @Override
public void writeSavableMap(final Map<? extends Savable, ? extends Savable> map, final String name,
final Map<? extends Savable, ? extends Savable> defVal) throws IOException {
if (map == defVal) {
@@ -363,6 +401,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
writeSavableMap(map);
}
+ @Override
public void writeStringSavableMap(final Map<String, ? extends Savable> map, final String name,
final Map<String, ? extends Savable> defVal) throws IOException {
if (map == defVal) {
@@ -987,6 +1026,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
_baos.write(array);
}
+ @Override
public void write(final Enum<?> value, final String name, final Enum<?> defVal) throws IOException {
if (value == defVal) {
return;
@@ -998,6 +1038,7 @@ public class BinaryOutputCapsule implements OutputCapsule {
}
}
+ @Override
public void write(final Enum<?>[] value, final String name) throws IOException {
if (value == null) {
write(NULL_OBJECT);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMInputCapsule.java b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMInputCapsule.java
index 00babb9..2a92b9e 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMInputCapsule.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMInputCapsule.java
@@ -94,6 +94,7 @@ public class DOMInputCapsule implements InputCapsule {
return null;
}
+ @Override
public byte readByte(final String name, final byte defVal) throws IOException {
byte ret = defVal;
try {
@@ -106,6 +107,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public byte[] readByteArray(final String name, final byte[] defVal) throws IOException {
byte[] ret = defVal;
try {
@@ -133,6 +135,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public byte[][] readByteArray2D(final String name, final byte[][] defVal) throws IOException {
byte[][] ret = defVal;
try {
@@ -169,6 +172,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public int readInt(final String name, final int defVal) throws IOException {
int ret = defVal;
try {
@@ -184,6 +188,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public int[] readIntArray(final String name, final int[] defVal) throws IOException {
int[] ret = defVal;
try {
@@ -211,6 +216,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public int[][] readIntArray2D(final String name, final int[][] defVal) throws IOException {
int[][] ret = defVal;
try {
@@ -247,6 +253,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public float readFloat(final String name, final float defVal) throws IOException {
float ret = defVal;
try {
@@ -262,6 +269,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public float[] readFloatArray(final String name, final float[] defVal) throws IOException {
float[] ret = defVal;
try {
@@ -289,6 +297,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public float[][] readFloatArray2D(final String name, final float[][] defVal) throws IOException {
float[][] ret = defVal;
try {
@@ -322,6 +331,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public double readDouble(final String name, final double defVal) throws IOException {
double ret = defVal;
try {
@@ -337,6 +347,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public double[] readDoubleArray(final String name, final double[] defVal) throws IOException {
double[] ret = defVal;
try {
@@ -364,6 +375,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public double[][] readDoubleArray2D(final String name, final double[][] defVal) throws IOException {
double[][] ret = defVal;
try {
@@ -400,6 +412,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public long readLong(final String name, final long defVal) throws IOException {
long ret = defVal;
try {
@@ -415,6 +428,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public long[] readLongArray(final String name, final long[] defVal) throws IOException {
long[] ret = defVal;
try {
@@ -442,6 +456,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public long[][] readLongArray2D(final String name, final long[][] defVal) throws IOException {
long[][] ret = defVal;
try {
@@ -478,6 +493,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public short readShort(final String name, final short defVal) throws IOException {
short ret = defVal;
try {
@@ -493,6 +509,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public short[] readShortArray(final String name, final short[] defVal) throws IOException {
short[] ret = defVal;
try {
@@ -520,6 +537,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public short[][] readShortArray2D(final String name, final short[][] defVal) throws IOException {
short[][] ret = defVal;
try {
@@ -556,6 +574,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public boolean readBoolean(final String name, final boolean defVal) throws IOException {
boolean ret = defVal;
try {
@@ -571,6 +590,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public boolean[] readBooleanArray(final String name, final boolean[] defVal) throws IOException {
boolean[] ret = defVal;
try {
@@ -598,6 +618,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public boolean[][] readBooleanArray2D(final String name, final boolean[][] defVal) throws IOException {
boolean[][] ret = defVal;
try {
@@ -634,6 +655,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public String readString(final String name, final String defVal) throws IOException {
String ret = defVal;
try {
@@ -646,6 +668,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public String[] readStringArray(final String name, final String[] defVal) throws IOException {
String[] ret = defVal;
try {
@@ -682,6 +705,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public String[][] readStringArray2D(final String name, final String[][] defVal) throws IOException {
String[][] ret = defVal;
try {
@@ -718,6 +742,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public BitSet readBitSet(final String name, final BitSet defVal) throws IOException {
BitSet ret = defVal;
try {
@@ -739,6 +764,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public Savable readSavable(final String name, final Savable defVal) throws IOException {
Savable ret = defVal;
@@ -880,6 +906,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public Savable[] readSavableArray(final String name, final Savable[] defVal) throws IOException {
Savable[] ret = defVal;
try {
@@ -912,6 +939,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public Savable[][] readSavableArray2D(final String name, final Savable[][] defVal) throws IOException {
Savable[][] ret = defVal;
try {
@@ -944,6 +972,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
@SuppressWarnings("unchecked")
public <E extends Savable> List<E> readSavableList(final String name, final List<E> defVal) throws IOException {
List<E> ret = defVal;
@@ -975,6 +1004,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
@SuppressWarnings("unchecked")
public <E extends Savable> List<E>[] readSavableListArray(final String name, final List<E>[] defVal)
throws IOException {
@@ -1007,6 +1037,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public <E extends Savable> List<E>[][] readSavableListArray2D(final String name, final List<E>[][] defVal)
throws IOException {
@@ -1034,6 +1065,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public List<FloatBuffer> readFloatBufferList(final String name, final List<FloatBuffer> defVal) throws IOException {
List<FloatBuffer> ret = defVal;
try {
@@ -1062,6 +1094,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
@SuppressWarnings("unchecked")
public <K extends Savable, V extends Savable> Map<K, V> readSavableMap(final String name, final Map<K, V> defVal)
throws IOException {
@@ -1090,6 +1123,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
@SuppressWarnings("unchecked")
public <V extends Savable> Map<String, V> readStringSavableMap(final String name, final Map<String, V> defVal)
throws IOException {
@@ -1125,6 +1159,7 @@ public class DOMInputCapsule implements InputCapsule {
/**
* reads from currentElem if name is null
*/
+ @Override
public FloatBuffer readFloatBuffer(final String name, final FloatBuffer defVal) throws IOException {
FloatBuffer ret = defVal;
try {
@@ -1155,6 +1190,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public IntBuffer readIntBuffer(final String name, final IntBuffer defVal) throws IOException {
IntBuffer ret = defVal;
try {
@@ -1181,6 +1217,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public ByteBuffer readByteBuffer(final String name, final ByteBuffer defVal) throws IOException {
ByteBuffer ret = defVal;
try {
@@ -1207,6 +1244,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public ShortBuffer readShortBuffer(final String name, final ShortBuffer defVal) throws IOException {
ShortBuffer ret = defVal;
try {
@@ -1233,6 +1271,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public List<ByteBuffer> readByteBufferList(final String name, final List<ByteBuffer> defVal) throws IOException {
List<ByteBuffer> ret = defVal;
try {
@@ -1261,6 +1300,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
public <T extends Enum<T>> T readEnum(final String name, final Class<T> enumType, final T defVal)
throws IOException {
T ret = defVal;
@@ -1277,6 +1317,7 @@ public class DOMInputCapsule implements InputCapsule {
return ret;
}
+ @Override
@SuppressWarnings("unchecked")
public <T extends Enum<T>> T[] readEnumArray(final String name, final Class<T> enumType, final T[] defVal)
throws IOException {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMOutputCapsule.java b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMOutputCapsule.java
index ce2e9c7..bf781a1 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMOutputCapsule.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMOutputCapsule.java
@@ -72,6 +72,7 @@ public class DOMOutputCapsule implements OutputCapsule {
return s;
}
+ @Override
public void write(final byte value, final String name, final byte defVal) throws IOException {
if (value == defVal) {
return;
@@ -79,6 +80,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement.setAttribute(name, String.valueOf(value));
}
+ @Override
public void write(byte[] value, final String name, final byte[] defVal) throws IOException {
final StringBuilder buf = new StringBuilder();
if (value == null) {
@@ -97,6 +99,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) _currentElement.getParentNode();
}
+ @Override
public void write(byte[][] value, final String name, final byte[][] defVal) throws IOException {
final StringBuilder buf = new StringBuilder();
if (value == null) {
@@ -119,6 +122,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) _currentElement.getParentNode();
}
+ @Override
public void write(final int value, final String name, final int defVal) throws IOException {
if (value == defVal) {
return;
@@ -126,6 +130,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement.setAttribute(name, String.valueOf(value));
}
+ @Override
public void write(final int[] value, final String name, final int[] defVal) throws IOException {
final StringBuilder buf = new StringBuilder();
if (value == null) {
@@ -148,6 +153,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) _currentElement.getParentNode();
}
+ @Override
public void write(final int[][] value, final String name, final int[][] defVal) throws IOException {
if (value == null) {
return;
@@ -166,6 +172,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) el.getParentNode();
}
+ @Override
public void write(final float value, final String name, final float defVal) throws IOException {
if (value == defVal) {
return;
@@ -173,6 +180,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement.setAttribute(name, String.valueOf(value));
}
+ @Override
public void write(float[] value, final String name, final float[] defVal) throws IOException {
final StringBuilder buf = new StringBuilder();
if (value == null) {
@@ -191,6 +199,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) _currentElement.getParentNode();
}
+ @Override
public void write(final float[][] value, final String name, final float[][] defVal) throws IOException {
final StringBuilder buf = new StringBuilder();
if (value == null) {
@@ -216,6 +225,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) _currentElement.getParentNode();
}
+ @Override
public void write(final double value, final String name, final double defVal) throws IOException {
if (value == defVal) {
return;
@@ -223,6 +233,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement.setAttribute(name, String.valueOf(value));
}
+ @Override
public void write(double[] value, final String name, final double[] defVal) throws IOException {
final StringBuilder buf = new StringBuilder();
if (value == null) {
@@ -241,6 +252,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) _currentElement.getParentNode();
}
+ @Override
public void write(final double[][] value, final String name, final double[][] defVal) throws IOException {
if (value == null) {
return;
@@ -259,6 +271,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) el.getParentNode();
}
+ @Override
public void write(final long value, final String name, final long defVal) throws IOException {
if (value == defVal) {
return;
@@ -266,6 +279,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement.setAttribute(name, String.valueOf(value));
}
+ @Override
public void write(long[] value, final String name, final long[] defVal) throws IOException {
final StringBuilder buf = new StringBuilder();
if (value == null) {
@@ -284,6 +298,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) _currentElement.getParentNode();
}
+ @Override
public void write(final long[][] value, final String name, final long[][] defVal) throws IOException {
if (value == null) {
return;
@@ -302,6 +317,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) el.getParentNode();
}
+ @Override
public void write(final short value, final String name, final short defVal) throws IOException {
if (value == defVal) {
return;
@@ -309,6 +325,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement.setAttribute(name, String.valueOf(value));
}
+ @Override
public void write(short[] value, final String name, final short[] defVal) throws IOException {
final StringBuilder buf = new StringBuilder();
if (value == null) {
@@ -327,6 +344,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) _currentElement.getParentNode();
}
+ @Override
public void write(final short[][] value, final String name, final short[][] defVal) throws IOException {
if (value == null) {
return;
@@ -345,6 +363,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) el.getParentNode();
}
+ @Override
public void write(final boolean value, final String name, final boolean defVal) throws IOException {
if (value == defVal) {
return;
@@ -352,6 +371,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement.setAttribute(name, String.valueOf(value));
}
+ @Override
public void write(boolean[] value, final String name, final boolean[] defVal) throws IOException {
final StringBuilder buf = new StringBuilder();
if (value == null) {
@@ -370,6 +390,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) _currentElement.getParentNode();
}
+ @Override
public void write(final boolean[][] value, final String name, final boolean[][] defVal) throws IOException {
if (value == null) {
return;
@@ -388,6 +409,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) el.getParentNode();
}
+ @Override
public void write(final String value, final String name, final String defVal) throws IOException {
if (value == null || value.equals(defVal)) {
return;
@@ -395,6 +417,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement.setAttribute(name, encodeString(value));
}
+ @Override
public void write(String[] value, final String name, final String[] defVal) throws IOException {
final Element el = appendElement(name);
@@ -414,6 +437,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) _currentElement.getParentNode();
}
+ @Override
public void write(final String[][] value, final String name, final String[][] defVal) throws IOException {
if (value == null) {
return;
@@ -432,6 +456,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) el.getParentNode();
}
+ @Override
public void write(final BitSet value, final String name, final BitSet defVal) throws IOException {
if (value == null || value.equals(defVal)) {
return;
@@ -446,6 +471,7 @@ public class DOMOutputCapsule implements OutputCapsule {
}
+ @Override
public void write(final Savable object, String name, final Savable defVal) throws IOException {
if (object == null) {
return;
@@ -488,6 +514,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = old;
}
+ @Override
public void write(final Savable[] objects, final String name, final Savable[] defVal) throws IOException {
if (objects == null) {
return;
@@ -515,6 +542,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = old;
}
+ @Override
public void write(final Savable[][] value, final String name, final Savable[][] defVal) throws IOException {
if (value == null) {
return;
@@ -534,6 +562,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) _currentElement.getParentNode();
}
+ @Override
public void writeSavableList(final List<? extends Savable> array, final String name,
final List<? extends Savable> defVal) throws IOException {
if (array == null) {
@@ -559,6 +588,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = old;
}
+ @Override
public void writeSavableListArray(final List<? extends Savable>[] objects, final String name,
final List<? extends Savable>[] defVal) throws IOException {
if (objects == null) {
@@ -586,6 +616,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = old;
}
+ @Override
public void writeSavableListArray2D(final List<? extends Savable>[][] value, final String name,
final List<? extends Savable>[][] defVal) throws IOException {
if (value == null) {
@@ -606,6 +637,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) el.getParentNode();
}
+ @Override
public void writeFloatBufferList(final List<FloatBuffer> array, final String name, final List<FloatBuffer> defVal)
throws IOException {
if (array == null) {
@@ -622,6 +654,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) el.getParentNode();
}
+ @Override
public void writeSavableMap(final Map<? extends Savable, ? extends Savable> map, final String name,
final Map<? extends Savable, ? extends Savable> defVal) throws IOException {
if (map == null) {
@@ -645,6 +678,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) stringMap.getParentNode();
}
+ @Override
public void writeStringSavableMap(final Map<String, ? extends Savable> map, final String name,
final Map<String, ? extends Savable> defVal) throws IOException {
if (map == null) {
@@ -668,6 +702,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) stringMap.getParentNode();
}
+ @Override
public void write(final FloatBuffer value, final String name, final FloatBuffer defVal) throws IOException {
if (value == null) {
return;
@@ -688,6 +723,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) el.getParentNode();
}
+ @Override
public void write(final IntBuffer value, final String name, final IntBuffer defVal) throws IOException {
if (value == null) {
return;
@@ -711,6 +747,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) el.getParentNode();
}
+ @Override
public void write(final ByteBuffer value, final String name, final ByteBuffer defVal) throws IOException {
if (value == null) {
return;
@@ -734,6 +771,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) el.getParentNode();
}
+ @Override
public void write(final ShortBuffer value, final String name, final ShortBuffer defVal) throws IOException {
if (value == null) {
return;
@@ -757,6 +795,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement = (Element) el.getParentNode();
}
+ @Override
public void writeByteBufferList(final List<ByteBuffer> array, final String name, final List<ByteBuffer> defVal)
throws IOException {
if (array == null) {
@@ -774,6 +813,7 @@ public class DOMOutputCapsule implements OutputCapsule {
}
+ @Override
public void write(final Enum<?> value, final String name, final Enum<?> defVal) throws IOException {
if (value == defVal || value == null) {
return;
@@ -781,6 +821,7 @@ public class DOMOutputCapsule implements OutputCapsule {
_currentElement.setAttribute(name, String.valueOf(value));
}
+ @Override
public void write(final Enum<?>[] value, final String name) throws IOException {
if (value == null) {
return;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/XMLExporter.java b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/XMLExporter.java
index e23bf32..76ee29e 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/XMLExporter.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/XMLExporter.java
@@ -34,6 +34,7 @@ public class XMLExporter implements Ardor3dExporter {
}
+ @Override
public void save(final Savable object, final OutputStream os) throws IOException {
try {
// Initialize Document when saving so we don't retain state of previous exports
@@ -49,6 +50,7 @@ public class XMLExporter implements Ardor3dExporter {
}
}
+ @Override
public void save(final Savable object, final File f) throws IOException {
save(object, new FileOutputStream(f));
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/XMLImporter.java b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/XMLImporter.java
index a5caa2a..f177ee0 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/XMLImporter.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/XMLImporter.java
@@ -32,6 +32,7 @@ public class XMLImporter implements Ardor3dImporter {
public XMLImporter() {}
+ @Override
public Savable load(final InputStream is) throws IOException {
try {
final DOMInputCapsule _domIn = new DOMInputCapsule(DocumentBuilderFactory.newInstance()
@@ -48,14 +49,17 @@ public class XMLImporter implements Ardor3dImporter {
}
}
+ @Override
public Savable load(final URL url) throws IOException {
return load(url.openStream());
}
+ @Override
public Savable load(final File f) throws IOException {
return load(new FileInputStream(f));
}
+ @Override
public Savable load(final byte[] data) throws IOException {
return load(new ByteArrayInputStream(data));
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/geom/SharedCopyLogic.java b/ardor3d-core/src/main/java/com/ardor3d/util/geom/SharedCopyLogic.java
index 048086f..56d4461 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/geom/SharedCopyLogic.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/geom/SharedCopyLogic.java
@@ -27,6 +27,7 @@ import com.ardor3d.scenegraph.Spatial;
public class SharedCopyLogic implements CopyLogic {
private static final Logger logger = Logger.getLogger(SharedCopyLogic.class.getName());
+ @Override
public Spatial copy(final Spatial source, final AtomicBoolean recurse) {
recurse.set(false);
if (source instanceof Node) {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/resource/RelativeResourceLocator.java b/ardor3d-core/src/main/java/com/ardor3d/util/resource/RelativeResourceLocator.java
index 5f959f9..47f2f58 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/resource/RelativeResourceLocator.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/resource/RelativeResourceLocator.java
@@ -34,6 +34,7 @@ public class RelativeResourceLocator implements ResourceLocator {
return _baseSource;
}
+ @Override
public ResourceSource locateResource(String resourceName) {
// Trim off any prepended local dir.
while (resourceName.startsWith("./") && resourceName.length() > 2) {
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/resource/SimpleResourceLocator.java b/ardor3d-core/src/main/java/com/ardor3d/util/resource/SimpleResourceLocator.java
index 580f408..bb6734d 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/resource/SimpleResourceLocator.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/resource/SimpleResourceLocator.java
@@ -71,6 +71,7 @@ public class SimpleResourceLocator implements ResourceLocator {
return _baseDir;
}
+ @Override
public ResourceSource locateResource(final String resourceName) {
return doRecursiveLocate(cleanup(resourceName));
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/resource/StringResourceSource.java b/ardor3d-core/src/main/java/com/ardor3d/util/resource/StringResourceSource.java
index 69a2339..7c60292 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/resource/StringResourceSource.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/resource/StringResourceSource.java
@@ -60,6 +60,7 @@ public class StringResourceSource implements ResourceSource {
/**
* Returns "string resource" as strings have no name.
*/
+ @Override
public String getName() {
return "string resource";
}
@@ -67,6 +68,7 @@ public class StringResourceSource implements ResourceSource {
/**
* Returns null and logs a warning as this is not supported.
*/
+ @Override
public ResourceSource getRelativeSource(final String name) {
if (logger.isLoggable(Level.WARNING)) {
logger.logp(Level.WARNING, getClass().getName(), "getRelativeSource(String)",
@@ -75,6 +77,7 @@ public class StringResourceSource implements ResourceSource {
return null;
}
+ @Override
public String getType() {
return _type;
}
@@ -82,6 +85,7 @@ public class StringResourceSource implements ResourceSource {
/**
* Grabs our data as a UTF8 byte array and returns it in a ByteArrayInputStream.
*/
+ @Override
public InputStream openStream() throws IOException {
return new ByteArrayInputStream(_data.getBytes("UTF8"));
}
@@ -90,15 +94,18 @@ public class StringResourceSource implements ResourceSource {
// Methods for Savable
// /////////////////
+ @Override
public Class<?> getClassTag() {
return StringResourceSource.class;
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
_data = capsule.readString("data", null);
_type = capsule.readString("type", null);
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_data, "data", null);
capsule.write(_type, "type", null);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/resource/URLResourceSource.java b/ardor3d-core/src/main/java/com/ardor3d/util/resource/URLResourceSource.java
index 9bcc3c0..a2769a2 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/resource/URLResourceSource.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/resource/URLResourceSource.java
@@ -76,6 +76,7 @@ public class URLResourceSource implements ResourceSource {
_type = type;
}
+ @Override
public ResourceSource getRelativeSource(final String name) {
try {
final URL srcURL = UrlUtils.resolveRelativeURL(_url, "./" + name);
@@ -106,10 +107,12 @@ public class URLResourceSource implements ResourceSource {
return _url;
}
+ @Override
public String getName() {
return _urlToString;
}
+ @Override
public String getType() {
return _type;
}
@@ -118,6 +121,7 @@ public class URLResourceSource implements ResourceSource {
_type = type;
}
+ @Override
public InputStream openStream() throws IOException {
return _url.openStream();
}
@@ -168,10 +172,12 @@ public class URLResourceSource implements ResourceSource {
return true;
}
+ @Override
public Class<?> getClassTag() {
return URLResourceSource.class;
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
final String protocol = capsule.readString("protocol", null);
final String host = capsule.readString("host", null);
@@ -194,6 +200,7 @@ public class URLResourceSource implements ResourceSource {
_type = capsule.readString("type", null);
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_url.getProtocol(), "protocol", null);
capsule.write(_url.getHost(), "host", null);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/scenegraph/DisplayListDelegate.java b/ardor3d-core/src/main/java/com/ardor3d/util/scenegraph/DisplayListDelegate.java
index b8f5680..0df947a 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/scenegraph/DisplayListDelegate.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/scenegraph/DisplayListDelegate.java
@@ -34,6 +34,7 @@ public class DisplayListDelegate implements RenderDelegate {
static {
ContextManager.addContextCleanListener(new ContextCleanListener() {
+ @Override
public void cleanForContext(final RenderContext renderContext) {
// TODO: Need a way to call back to the creator of the display list?
}
@@ -47,6 +48,7 @@ public class DisplayListDelegate implements RenderDelegate {
_identityCache.put(this, STATIC_REF);
}
+ @Override
public void render(final Spatial spatial, final Renderer renderer) {
// do transforms
final boolean transformed = renderer.doTransforms(spatial.getWorldTransform());
@@ -118,6 +120,7 @@ public class DisplayListDelegate implements RenderDelegate {
else {
GameTaskQueueManager.getManager(ContextManager.getContextForRef(glref)).render(
new RendererCallable<Void>() {
+ @Override
public Void call() throws Exception {
getRenderer().deleteDisplayLists(idMap.get(glref));
return null;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/scenegraph/SceneCompiler.java b/ardor3d-core/src/main/java/com/ardor3d/util/scenegraph/SceneCompiler.java
index 285806e..30cc6dd 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/scenegraph/SceneCompiler.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/scenegraph/SceneCompiler.java
@@ -75,6 +75,7 @@ public class SceneCompiler {
_renderer = renderer;
}
+ @Override
public void visit(final Spatial spatial) {
if (spatial instanceof Mesh) {
final Mesh mesh = (Mesh) spatial;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/shader/ShaderVariable.java b/ardor3d-core/src/main/java/com/ardor3d/util/shader/ShaderVariable.java
index a425753..6ea3c80 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/shader/ShaderVariable.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/shader/ShaderVariable.java
@@ -57,16 +57,19 @@ public class ShaderVariable implements Savable {
}
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(name, "name", "");
capsule.write(variableID, "variableID", -1);
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
name = capsule.readString("name", "");
variableID = capsule.readInt("variableID", -1);
}
+ @Override
public Class<? extends ShaderVariable> getClassTag() {
return this.getClass();
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/stat/StatType.java b/ardor3d-core/src/main/java/com/ardor3d/util/stat/StatType.java
index 2d4436f..42bfee6 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/stat/StatType.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/stat/StatType.java
@@ -60,6 +60,7 @@ public class StatType implements Comparable<StatType> {
return hash;
}
+ @Override
public int compareTo(final StatType obj) {
final StatType other = obj;
return _statName.compareTo(other._statName);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/DefColorFadeController.java b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/DefColorFadeController.java
index c69b02f..0fffc82 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/DefColorFadeController.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/DefColorFadeController.java
@@ -61,6 +61,7 @@ public class DefColorFadeController implements SpatialController<Spatial> {
_rate = rate;
}
+ @Override
public void update(final double time, final Spatial caller) {
if (_target == null) {
return;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/LineGrapher.java b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/LineGrapher.java
index 544b530..6e84991 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/LineGrapher.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/LineGrapher.java
@@ -72,6 +72,7 @@ public class LineGrapher extends AbstractStatGrapher implements TableLinkable {
_graphRoot.getSceneHints().setCullHint(CullHint.Never);
}
+ @Override
public void statsUpdated() {
if (!isEnabled() || !Constants.updateGraphs) {
return;
@@ -301,6 +302,7 @@ public class LineGrapher extends AbstractStatGrapher implements TableLinkable {
}
}
+ @Override
public Line updateLineKey(final StatType type, Line lineKey) {
if (lineKey == null) {
lineKey = new Line("lk", BufferUtils.createVector3Buffer(2), null, null, null);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TabledLabelGrapher.java b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TabledLabelGrapher.java
index bd32181..316a77e 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TabledLabelGrapher.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TabledLabelGrapher.java
@@ -69,6 +69,7 @@ public class TabledLabelGrapher extends AbstractStatGrapher {
_graphRoot.getSceneHints().setCullHint(CullHint.Never);
}
+ @Override
public void statsUpdated() {
if (!isEnabled() || !Constants.updateGraphs) {
return;
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TimedAreaGrapher.java b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TimedAreaGrapher.java
index bc336d5..9f650ea 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TimedAreaGrapher.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TimedAreaGrapher.java
@@ -72,6 +72,7 @@ public class TimedAreaGrapher extends AbstractStatGrapher implements TableLinkab
_graphRoot.getSceneHints().setCullHint(CullHint.Never);
}
+ @Override
public void statsUpdated() {
if (!isEnabled() || !Constants.updateGraphs) {
return;
@@ -282,6 +283,7 @@ public class TimedAreaGrapher extends AbstractStatGrapher implements TableLinkab
}
}
+ @Override
public Line updateLineKey(final StatType type, Line lineKey) {
if (lineKey == null) {
lineKey = new Line("lk", BufferUtils.createVector3Buffer(2), null, null, null);
diff --git a/ardor3d-core/src/test/java/com/ardor3d/renderer/queue/RenderBucketTypeTest.java b/ardor3d-core/src/test/java/com/ardor3d/renderer/queue/RenderBucketTypeTest.java
index 93e0786..8faf1c7 100644
--- a/ardor3d-core/src/test/java/com/ardor3d/renderer/queue/RenderBucketTypeTest.java
+++ b/ardor3d-core/src/test/java/com/ardor3d/renderer/queue/RenderBucketTypeTest.java
@@ -1,38 +1,39 @@
-package com.ardor3d.renderer.queue;
-import org.junit.Test;
+package com.ardor3d.renderer.queue;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;
+import org.junit.Test;
+
public class RenderBucketTypeTest {
- @Test
- public void getPrebucket() throws Exception {
- RenderBucketType preBucket = RenderBucketType.getRenderBucketType("PreBucket");
- assertNotNull(preBucket);
-
- RenderBucketType preBucket2 = RenderBucketType.getRenderBucketType("PreBucket");
- assertSame(preBucket, preBucket2);
- assertSame(RenderBucketType.PreBucket, preBucket);
- }
-
- @Test
- public void getUserDefined() throws Exception {
- RenderBucketType myBucket = RenderBucketType.getRenderBucketType("MyBucket");
- assertNotNull(myBucket);
-
- RenderBucketType myBucket2 = RenderBucketType.getRenderBucketType("MyBucket");
- assertSame(myBucket, myBucket2);
- }
-
- @Test
- public void getWithNull() throws Exception {
- try {
- RenderBucketType nullBucket = RenderBucketType.getRenderBucketType(null);
- fail();
- } catch (IllegalArgumentException e) {
- }
- }
+ @Test
+ public void getPrebucket() throws Exception {
+ final RenderBucketType preBucket = RenderBucketType.getRenderBucketType("PreBucket");
+ assertNotNull(preBucket);
+
+ final RenderBucketType preBucket2 = RenderBucketType.getRenderBucketType("PreBucket");
+ assertSame(preBucket, preBucket2);
+ assertSame(RenderBucketType.PreBucket, preBucket);
+ }
+
+ @Test
+ public void getUserDefined() throws Exception {
+ final RenderBucketType myBucket = RenderBucketType.getRenderBucketType("MyBucket");
+ assertNotNull(myBucket);
+
+ final RenderBucketType myBucket2 = RenderBucketType.getRenderBucketType("MyBucket");
+ assertSame(myBucket, myBucket2);
+ }
+
+ @Test
+ public void getWithNull() throws Exception {
+ try {
+ RenderBucketType.getRenderBucketType(null);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ }
+ }
}
diff --git a/ardor3d-core/src/test/java/com/ardor3d/util/TestLittleEndianDataInput.java b/ardor3d-core/src/test/java/com/ardor3d/util/TestLittleEndianDataInput.java
index b779190..0b433bb 100644
--- a/ardor3d-core/src/test/java/com/ardor3d/util/TestLittleEndianDataInput.java
+++ b/ardor3d-core/src/test/java/com/ardor3d/util/TestLittleEndianDataInput.java
@@ -20,17 +20,15 @@ import org.junit.Before;
import org.junit.Test;
/**
- * These tests are fairly brittle, since they rely on the implementation of BufferedInputStream.
- * It is necessary for the bytes available to always be larger than the buffer size of the buffered
- * input stream for the tests to work. This size is currently 8192, but if it changes, or if the
- * implementation changes, these tests can break.
+ * These tests are fairly brittle, since they rely on the implementation of BufferedInputStream. It is necessary for the
+ * bytes available to always be larger than the buffer size of the buffered input stream for the tests to work. This
+ * size is currently 8192, but if it changes, or if the implementation changes, these tests can break.
*/
public class TestLittleEndianDataInput {
MockInputStream in;
byte[] array;
LittleEndianDataInput littleEndien;
-
@Before
public void setup() throws Exception {
in = new MockInputStream();
@@ -40,7 +38,6 @@ public class TestLittleEndianDataInput {
littleEndien = new LittleEndianDataInput(in);
}
-
@Test
public void testReadFully1() throws Exception {
in.addBytesAvailable(11111);
@@ -53,7 +50,7 @@ public class TestLittleEndianDataInput {
@Test
public void testReadFully2() throws Exception {
in.addBytesAvailable(11240);
-
+
littleEndien.readFully(array, 0, 4);
// not caring about whether the bytes were actually copied successfully in this test
@@ -63,11 +60,12 @@ public class TestLittleEndianDataInput {
public void testReadFully3() throws Exception {
array = new byte[30003];
- Thread testThread = new Thread(new Runnable() {
+ final Thread testThread = new Thread(new Runnable() {
+ @Override
public void run() {
try {
littleEndien.readFully(array);
- } catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
fail("ioexception");
}
@@ -92,7 +90,7 @@ public class TestLittleEndianDataInput {
// not caring about whether the bytes were actually copied successfully in this test
}
- @Test (expected = EOFException.class)
+ @Test(expected = EOFException.class)
public void testReadFully4() throws Exception {
in.setEof(true);
diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/AnimationEntry.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/AnimationEntry.java
index 13d2554..f304962 100644
--- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/AnimationEntry.java
+++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/AnimationEntry.java
@@ -51,16 +51,19 @@ public class AnimationEntry implements Savable {
_rate = rate;
}
+ @Override
public Class<? extends AnimationEntry> getClassTag() {
return getClass();
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
_offset = capsule.readDouble("offsetMS", 0.05);
_rate = capsule.readDouble("rate", 0.2);
_frames = capsule.readIntArray("frames", null);
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_offset, "offsetMS", 0.05);
capsule.write(_rate, "rate", 0.2);
diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/Particle.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/Particle.java
index 7099bae..4414b42 100644
--- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/Particle.java
+++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/Particle.java
@@ -460,6 +460,7 @@ public class Particle implements Savable {
// Savable interface methods
// /////
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(startIndex, "startIndex", 0);
capsule.write(_position, "position", new Vector3(Vector3.ZERO));
@@ -471,6 +472,7 @@ public class Particle implements Savable {
capsule.write(type, "type", ParticleSystem.ParticleType.Quad);
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
startIndex = capsule.readInt("startIndex", 0);
_position.set((Vector3) capsule.readSavable("position", new Vector3(Vector3.ZERO)));
@@ -482,6 +484,7 @@ public class Particle implements Savable {
type = capsule.readEnum("type", ParticleSystem.ParticleType.class, ParticleSystem.ParticleType.Quad);
}
+ @Override
public Class<? extends Particle> getClassTag() {
return this.getClass();
}
diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/ParticleAppearanceRamp.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/ParticleAppearanceRamp.java
index c55f504..4d121cf 100644
--- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/ParticleAppearanceRamp.java
+++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/ParticleAppearanceRamp.java
@@ -154,10 +154,12 @@ public class ParticleAppearanceRamp implements Savable {
}
}
+ @Override
public Class<? extends ParticleAppearanceRamp> getClassTag() {
return getClass();
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
_entries = capsule.readSavableList("entries", null);
if (_entries == null) {
@@ -165,6 +167,7 @@ public class ParticleAppearanceRamp implements Savable {
}
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.writeSavableList(_entries, "entries", null);
}
diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/ParticleInfluence.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/ParticleInfluence.java
index 3cd6906..ce0842b 100644
--- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/ParticleInfluence.java
+++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/ParticleInfluence.java
@@ -69,14 +69,17 @@ public abstract class ParticleInfluence implements Savable {
*/
public abstract void apply(double dt, Particle particle, int index);
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_enabled, "enabled", true);
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
_enabled = capsule.readBoolean("enabled", true);
}
+ @Override
public Class<? extends ParticleInfluence> getClassTag() {
return this.getClass();
}
diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/RampEntry.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/RampEntry.java
index 690532a..3801ba8 100644
--- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/RampEntry.java
+++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/RampEntry.java
@@ -113,10 +113,12 @@ public class RampEntry implements Savable {
_offset = offset;
}
+ @Override
public Class<? extends RampEntry> getClassTag() {
return getClass();
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
_offset = capsule.readDouble("offsetMS", DEFAULT_OFFSET);
_size = capsule.readDouble("size", DEFAULT_SIZE);
@@ -125,6 +127,7 @@ public class RampEntry implements Savable {
_color = (ColorRGBA) capsule.readSavable("color", DEFAULT_COLOR);
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_offset, "offsetMS", DEFAULT_OFFSET);
capsule.write(_size, "size", DEFAULT_SIZE);
diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/TexAnimation.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/TexAnimation.java
index 3b73b03..bfcc10a 100644
--- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/TexAnimation.java
+++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/TexAnimation.java
@@ -73,10 +73,12 @@ public class TexAnimation implements Savable {
}
}
+ @Override
public Class<? extends TexAnimation> getClassTag() {
return getClass();
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
_entries = capsule.readSavableList("entries", null);
if (_entries == null) {
@@ -84,6 +86,7 @@ public class TexAnimation implements Savable {
}
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.writeSavableList(_entries, "entries", null);
}
diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/LineSegmentEmitter.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/LineSegmentEmitter.java
index 9e2a75c..8b91b29 100644
--- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/LineSegmentEmitter.java
+++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/LineSegmentEmitter.java
@@ -41,6 +41,7 @@ public class LineSegmentEmitter extends SavableParticleEmitter {
return _source;
}
+ @Override
public Vector3 randomEmissionPoint(final Vector3 store) {
Vector3 rVal = store;
if (rVal == null) {
@@ -55,10 +56,12 @@ public class LineSegmentEmitter extends SavableParticleEmitter {
// Methods for Savable
// /////////////////
+ @Override
public void read(final InputCapsule capsule) throws IOException {
_source = (LineSegment3) capsule.readSavable("source", null);
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_source, "source", null);
}
diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/MeshEmitter.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/MeshEmitter.java
index 48fb32d..2ef83dc 100644
--- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/MeshEmitter.java
+++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/MeshEmitter.java
@@ -52,6 +52,7 @@ public class MeshEmitter extends SavableParticleEmitter {
return _onlyVertices;
}
+ @Override
public Vector3 randomEmissionPoint(final Vector3 store) {
Vector3 rVal = store;
if (rVal == null) {
@@ -70,11 +71,13 @@ public class MeshEmitter extends SavableParticleEmitter {
// Methods for Savable
// /////////////////
+ @Override
public void read(final InputCapsule capsule) throws IOException {
_source = (Mesh) capsule.readSavable("source", null);
_onlyVertices = capsule.readBoolean("onlyVertices", false);
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_source, "source", null);
capsule.write(_onlyVertices, "onlyVertices", false);
diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/PointEmitter.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/PointEmitter.java
index 9e6b84d..2828532 100644
--- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/PointEmitter.java
+++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/PointEmitter.java
@@ -20,6 +20,7 @@ public class PointEmitter extends SavableParticleEmitter {
public PointEmitter() {}
+ @Override
public Vector3 randomEmissionPoint(final Vector3 store) {
Vector3 rVal = store;
if (rVal == null) {
@@ -34,7 +35,9 @@ public class PointEmitter extends SavableParticleEmitter {
// Methods for Savable
// /////////////////
+ @Override
public void read(final InputCapsule capsule) throws IOException {}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {}
}
diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/RectangleEmitter.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/RectangleEmitter.java
index 18264f4..20750f1 100644
--- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/RectangleEmitter.java
+++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/RectangleEmitter.java
@@ -41,6 +41,7 @@ public class RectangleEmitter extends SavableParticleEmitter {
return _source;
}
+ @Override
public Vector3 randomEmissionPoint(final Vector3 store) {
Vector3 rVal = store;
if (rVal == null) {
@@ -55,10 +56,12 @@ public class RectangleEmitter extends SavableParticleEmitter {
// Methods for Savable
// /////////////////
+ @Override
public void read(final InputCapsule capsule) throws IOException {
_source = (Rectangle3) capsule.readSavable("source", null);
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_source, "source", null);
}
diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/RingEmitter.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/RingEmitter.java
index 738bb60..338aa7f 100644
--- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/RingEmitter.java
+++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/RingEmitter.java
@@ -41,6 +41,7 @@ public class RingEmitter extends SavableParticleEmitter {
return _source;
}
+ @Override
public Vector3 randomEmissionPoint(final Vector3 store) {
Vector3 rVal = store;
if (rVal == null) {
@@ -55,10 +56,12 @@ public class RingEmitter extends SavableParticleEmitter {
// Methods for Savable
// /////////////////
+ @Override
public void read(final InputCapsule capsule) throws IOException {
_source = (Ring) capsule.readSavable("source", null);
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_source, "source", null);
}
diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/SavableParticleEmitter.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/SavableParticleEmitter.java
index a11413a..27caa54 100644
--- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/SavableParticleEmitter.java
+++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/emitter/SavableParticleEmitter.java
@@ -18,6 +18,7 @@ public abstract class SavableParticleEmitter implements Savable, ParticleEmitter
// Methods for Savable
// /////////////////
+ @Override
public Class<? extends SavableParticleEmitter> getClassTag() {
return this.getClass();
}
diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/ProjectedGrid.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/ProjectedGrid.java
index bfe48d5..98e9ba8 100644
--- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/ProjectedGrid.java
+++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/ProjectedGrid.java
@@ -315,6 +315,7 @@ public class ProjectedGrid extends Mesh {
final int from = sizeY * i / (nrUpdateThreads);
final int to = sizeY * (i + 1) / (nrUpdateThreads);
final Future<?> future = executorService.submit(new Runnable() {
+ @Override
public void run() {
updateGrid(from, to);
}
@@ -631,6 +632,7 @@ public class ProjectedGrid extends Mesh {
namePrefix = "ProjectedGrid Pool-" + poolNumber.getAndIncrement() + "-thread-";
}
+ @Override
public Thread newThread(final Runnable r) {
final Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0);
if (!t.isDaemon()) {
diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/WaterHeightGenerator.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/WaterHeightGenerator.java
index b7e86ef..2fe7839 100644
--- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/WaterHeightGenerator.java
+++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/WaterHeightGenerator.java
@@ -24,6 +24,7 @@ public class WaterHeightGenerator implements HeightGenerator {
private double speedbig = 0.5;
private int octaves = 2;
+ @Override
public double getHeight(final double x, final double z, final double time) {
final double zval = z * scaleybig * 4 + time * speedbig * 4;
double height = Math.sin(zval);
diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/shadow/map/ParallelSplitShadowMapPass.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/shadow/map/ParallelSplitShadowMapPass.java
index 96f452e..1c983fa 100644
--- a/ardor3d-effects/src/main/java/com/ardor3d/extension/shadow/map/ParallelSplitShadowMapPass.java
+++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/shadow/map/ParallelSplitShadowMapPass.java
@@ -763,6 +763,7 @@ public class ParallelSplitShadowMapPass extends Pass {
private Face cullFace;
private boolean isVisible;
+ @Override
public void apply(final Renderable renderable) {
if (renderable instanceof Mesh) {
final Mesh mesh = (Mesh) renderable;
@@ -782,6 +783,7 @@ public class ParallelSplitShadowMapPass extends Pass {
}
}
+ @Override
public void restore(final Renderable renderable) {
if (renderable instanceof Mesh) {
final Mesh mesh = (Mesh) renderable;
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleRunner.java b/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleRunner.java
index d3708be..4c51259 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleRunner.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleRunner.java
@@ -114,6 +114,7 @@ public class ExampleRunner extends JFrame {
"com/ardor3d/example/media/images/ardor3d_white_256.jpg") + "\"></p></body></html>";
private static Comparator<Class<?>> classComparator = new Comparator<Class<?>>() {
+ @Override
public int compare(final Class<?> o1, final Class<?> o2) {
return o1.getCanonicalName().compareTo(o2.getCanonicalName());
}
@@ -130,14 +131,17 @@ public class ExampleRunner extends JFrame {
tfPattern = new ErasableTextField(10);
tfPattern.getDocument().addDocumentListener(new DocumentListener() {
+ @Override
public void removeUpdate(final DocumentEvent e) {
search();
}
+ @Override
public void insertUpdate(final DocumentEvent e) {
search();
}
+ @Override
public void changedUpdate(final DocumentEvent e) {
search();
}
@@ -152,6 +156,7 @@ public class ExampleRunner extends JFrame {
putValue(Action.SHORT_DESCRIPTION, "Expand all branches");
}
+ @Override
public void actionPerformed(final ActionEvent e) {
if (((JToggleButton) e.getSource()).isSelected()) {
for (int row = 0; row < tree.getRowCount(); row++) {
@@ -192,6 +197,7 @@ public class ExampleRunner extends JFrame {
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control R"));
}
+ @Override
public void actionPerformed(final ActionEvent e) {
runSelected();
}
@@ -209,6 +215,7 @@ public class ExampleRunner extends JFrame {
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control B"));
}
+ @Override
public void actionPerformed(final ActionEvent e) {
browseSelected();
}
@@ -224,6 +231,7 @@ public class ExampleRunner extends JFrame {
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control P"));
}
+ @Override
public void actionPerformed(final ActionEvent e) {
navigateInMatches(-1);
}
@@ -239,6 +247,7 @@ public class ExampleRunner extends JFrame {
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control N"));
}
+ @Override
public void actionPerformed(final ActionEvent e) {
navigateInMatches(1);
}
@@ -254,6 +263,7 @@ public class ExampleRunner extends JFrame {
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control F"));
}
+ @Override
public void actionPerformed(final ActionEvent e) {
tree.setSelectionRow(0);
navigateInMatches(1);
@@ -306,6 +316,7 @@ public class ExampleRunner extends JFrame {
tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
+ @Override
public void valueChanged(final TreeSelectionEvent e) {
updateDescription();
updateActionStatus();
@@ -507,10 +518,12 @@ public class ExampleRunner extends JFrame {
private int size;
private int matchCount = 0;
+ @Override
public void addTreeModelListener(final TreeModelListener l) {
listeners.add(TreeModelListener.class, l);
}
+ @Override
public Object getChild(final Object parent, final int index) {
if (root.equals(parent)) {
final Vector<Package> vec = new Vector<Package>(classes.keySet());
@@ -520,6 +533,7 @@ public class ExampleRunner extends JFrame {
return cl == null ? null : cl.get(index);
}
+ @Override
public int getChildCount(final Object parent) {
if (root.equals(parent)) {
return classes.size();
@@ -528,6 +542,7 @@ public class ExampleRunner extends JFrame {
return cl == null ? 0 : cl.size();
}
+ @Override
public int getIndexOfChild(final Object parent, final Object child) {
if (root.equals(parent)) {
final Vector<Package> vec = new Vector<Package>(classes.keySet());
@@ -537,6 +552,7 @@ public class ExampleRunner extends JFrame {
return cl == null ? 0 : cl.indexOf(child);
}
+ @Override
public Object getRoot() {
return root;
}
@@ -558,6 +574,7 @@ public class ExampleRunner extends JFrame {
Collections.sort(cl, classComparator);
}
+ @Override
public int updateMatches(final String pattern) {
int numberMatches = 0;
final String lcPattern = pattern.toLowerCase();
@@ -610,6 +627,7 @@ public class ExampleRunner extends JFrame {
return numberMatches;
}
+ @Override
public boolean matches(final Object value) {
if (value instanceof Class<?>) {
return classMatches.get(value);
@@ -619,14 +637,17 @@ public class ExampleRunner extends JFrame {
return res == null ? false : res;
}
+ @Override
public boolean isLeaf(final Object node) {
return node instanceof Class<?>;
}
+ @Override
public void removeTreeModelListener(final TreeModelListener l) {
listeners.remove(TreeModelListener.class, l);
}
+ @Override
public void valueForPathChanged(final TreePath path, final Object newValue) {
fireTreeNodeChanged(path);
}
@@ -641,6 +662,7 @@ public class ExampleRunner extends JFrame {
/**
* @see FileFilter
*/
+ @Override
public boolean accept(final File pathname) {
return (pathname.isDirectory() && (pathname.getName().length() == 0 || pathname.getName()
.charAt(0) != '.'))
@@ -838,6 +860,7 @@ public class ExampleRunner extends JFrame {
this.searchFilter = searchFilter;
}
+ @Override
public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean selected,
final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) {
if (value == null) {
@@ -969,6 +992,7 @@ public class ExampleRunner extends JFrame {
putValue(Action.SMALL_ICON, getIcon("edit-clear-locationbar-rtl.png"));
}
+ @Override
public void actionPerformed(final ActionEvent e) {
textField.setText("");
}
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/PropertiesDialog.java b/ardor3d-examples/src/main/java/com/ardor3d/example/PropertiesDialog.java
index d18852f..d5baa45 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/PropertiesDialog.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/PropertiesDialog.java
@@ -273,6 +273,7 @@ public final class PropertiesDialog extends JDialog {
fullscreenBox = new JCheckBox("Fullscreen?");
fullscreenBox.setSelected(source.isFullscreen());
fullscreenBox.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent e) {
updateResolutionChoices();
}
@@ -295,6 +296,7 @@ public final class PropertiesDialog extends JDialog {
// Set the button action listeners. Cancel disposes without saving, OK
// saves.
ok.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent e) {
if (verifyAndSaveCurrentSelection()) {
dispose();
@@ -303,6 +305,7 @@ public final class PropertiesDialog extends JDialog {
});
cancel.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent e) {
cancelled = true;
dispose();
@@ -414,6 +417,7 @@ public final class PropertiesDialog extends JDialog {
resolutionBox.setSelectedItem(source.getWidth() + " x " + source.getHeight());
resolutionBox.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent e) {
updateDisplayChoices();
}
@@ -540,6 +544,7 @@ public final class PropertiesDialog extends JDialog {
*/
private static String[] getDepths(final String resolution, final DisplayMode[] modes) {
final Set<String> depths = new TreeSet<String>(new Comparator<String>() {
+ @Override
public int compare(final String o1, final String o2) {
// reverse order
return -o1.compareTo(o2);
@@ -590,6 +595,7 @@ public final class PropertiesDialog extends JDialog {
/**
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
+ @Override
public int compare(final DisplayMode a, final DisplayMode b) {
// Width
if (a.getWidth() != b.getWidth()) {
@@ -630,6 +636,7 @@ public final class PropertiesDialog extends JDialog {
this.renderer = renderer;
}
+ @Override
public void run() {
if (renderer.startsWith("JOGL")) {
// TODO: can we implement this?
@@ -655,6 +662,7 @@ public final class PropertiesDialog extends JDialog {
ModesRetriever() {}
+ @Override
public void run() {
try {
modes = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayModes();
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/applet/JoglBaseApplet.java b/ardor3d-examples/src/main/java/com/ardor3d/example/applet/JoglBaseApplet.java
index 92d7eaf..18f3f07 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/applet/JoglBaseApplet.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/applet/JoglBaseApplet.java
@@ -112,6 +112,7 @@ public abstract class JoglBaseApplet extends Applet implements Scene {
public void componentResized(final ComponentEvent e) {
GameTaskQueueManager.getManager(_glCanvas.getCanvasRenderer().getRenderContext()).update(
new Callable<Void>() {
+ @Override
public Void call() throws Exception {
final Camera cam = _glCanvas.getCanvasRenderer().getCamera();
cam.resize(getWidth(), getHeight());
@@ -221,6 +222,7 @@ public abstract class JoglBaseApplet extends Applet implements Scene {
_logicalLayer.registerTrigger(new InputTrigger(new KeyReleasedCondition(Key.F), new TriggerAction() {
+ @Override
public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState,
final double tpf) {
@@ -243,6 +245,7 @@ public abstract class JoglBaseApplet extends Applet implements Scene {
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyReleasedCondition(Key.V), new TriggerAction() {
+ @Override
public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState,
final double tpf) {
_glCanvas.setVSyncEnabled(true);
@@ -250,6 +253,7 @@ public abstract class JoglBaseApplet extends Applet implements Scene {
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyReleasedCondition(Key.B), new TriggerAction() {
+ @Override
public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState,
final double tpf) {
_glCanvas.setVSyncEnabled(false);
@@ -258,6 +262,7 @@ public abstract class JoglBaseApplet extends Applet implements Scene {
_logicalLayer.registerTrigger(new InputTrigger(new MouseButtonPressedCondition(MouseButton.LEFT),
new TriggerAction() {
+ @Override
public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState,
final double tpf) {
if (_mouseManager.isSetGrabbedSupported()) {
@@ -268,6 +273,7 @@ public abstract class JoglBaseApplet extends Applet implements Scene {
_logicalLayer.registerTrigger(new InputTrigger(new MouseButtonReleasedCondition(MouseButton.LEFT),
new TriggerAction() {
+ @Override
public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState,
final double tpf) {
if (_mouseManager.isSetGrabbedSupported()) {
@@ -297,11 +303,13 @@ public abstract class JoglBaseApplet extends Applet implements Scene {
_root.setRenderState(buf);
}
+ @Override
public PickResults doPick(final Ray3 pickRay) {
// ignore
return null;
}
+ @Override
public boolean renderUnto(final Renderer renderer) {
// Execute renderQueue item
GameTaskQueueManager.getManager(_glCanvas.getCanvasRenderer().getRenderContext())
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/basic/JoglBasicExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/basic/JoglBasicExample.java
index 4e6bd8b..03f4ae7 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/basic/JoglBasicExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/basic/JoglBasicExample.java
@@ -136,6 +136,7 @@ public class JoglBasicExample implements Scene {
private final Matrix3 _rotate = new Matrix3();
private double _angle = 0;
+ @Override
public void update(final double time, final Box caller) {
// update our rotation
_angle = _angle + (_timer.getTimePerFrame() * 25);
@@ -191,6 +192,7 @@ public class JoglBasicExample implements Scene {
// ------ Scene methods ------
+ @Override
public boolean renderUnto(final Renderer renderer) {
if (!_canvas.isClosing()) {
@@ -202,6 +204,7 @@ public class JoglBasicExample implements Scene {
return false;
}
+ @Override
public PickResults doPick(final Ray3 pickRay) {
// Ignore
return null;
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/basic/MouseManagerExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/basic/MouseManagerExample.java
index 6f29e91..1d7b52b 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/basic/MouseManagerExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/basic/MouseManagerExample.java
@@ -107,6 +107,7 @@ public class MouseManagerExample extends ExampleBase {
_cursor2 = createMouseCursor(awtImageLoader, "com/ardor3d/example/media/input/movedata.gif");
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.H), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
if (useCursorOne) {
_mouseManager.setCursor(_cursor1);
@@ -118,11 +119,13 @@ public class MouseManagerExample extends ExampleBase {
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.J), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
_mouseManager.setCursor(MouseCursor.SYSTEM_DEFAULT);
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.K), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
if (_mouseManager.isSetPositionSupported()) {
_mouseManager.setPosition(0, 0);
@@ -132,6 +135,7 @@ public class MouseManagerExample extends ExampleBase {
_logicalLayer.registerTrigger(new InputTrigger(new MouseButtonPressedCondition(MouseButton.LEFT),
new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
if (_mouseManager.isSetGrabbedSupported()) {
_mouseManager.setGrabbed(GrabbedState.GRABBED);
@@ -140,6 +144,7 @@ public class MouseManagerExample extends ExampleBase {
}));
_logicalLayer.registerTrigger(new InputTrigger(new MouseButtonReleasedCondition(MouseButton.LEFT),
new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
if (_mouseManager.isSetGrabbedSupported()) {
_mouseManager.setGrabbed(GrabbedState.NOT_GRABBED);
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/basic/ShapesExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/basic/ShapesExample.java
index d847eaf..9f03288 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/basic/ShapesExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/basic/ShapesExample.java
@@ -168,6 +168,7 @@ public class ShapesExample extends ExampleBase {
// Add mouse-over to show labels
_logicalLayer.registerTrigger(new InputTrigger(new MouseMovedCondition(), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
// Put together a pick ray
final Vector2 pos = Vector2.fetchTempInstance().set(inputStates.getCurrent().getMouseState().getX(),
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/basic/SwitchNodeExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/basic/SwitchNodeExample.java
index 6752d8b..58ccb81 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/basic/SwitchNodeExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/basic/SwitchNodeExample.java
@@ -77,6 +77,7 @@ public class SwitchNodeExample extends ExampleBase {
_root.getSceneHints().setCullHint(CullHint.Never);
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
switchNode.shiftVisibleRight();
}
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/benchmark/ball/BubbleMarkExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/benchmark/ball/BubbleMarkExample.java
index de5853a..aa1481d 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/benchmark/ball/BubbleMarkExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/benchmark/ball/BubbleMarkExample.java
@@ -276,6 +276,7 @@ public class BubbleMarkExample implements Scene {
// ------ Scene methods ------
+ @Override
public boolean renderUnto(final Renderer renderer) {
if (!canvas.isClosing()) {
@@ -287,6 +288,7 @@ public class BubbleMarkExample implements Scene {
return false;
}
+ @Override
public PickResults doPick(final Ray3 pickRay) {
// Ignore
return null;
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/benchmark/ball/BubbleMarkUIExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/benchmark/ball/BubbleMarkUIExample.java
index 8e8e2d4..7115471 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/benchmark/ball/BubbleMarkUIExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/benchmark/ball/BubbleMarkUIExample.java
@@ -117,6 +117,7 @@ public class BubbleMarkUIExample extends ExampleBase {
Alignment.TOP_LEFT, 5, -5));
vsync.setSelectable(true);
vsync.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
_canvas.setVSyncEnabled(vsync.isSelected());
}
@@ -128,6 +129,7 @@ public class BubbleMarkUIExample extends ExampleBase {
collide.setSelectable(true);
collide.setSelected(!skipBallCollide);
collide.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
skipBallCollide = !collide.isSelected();
}
@@ -145,6 +147,7 @@ public class BubbleMarkUIExample extends ExampleBase {
balls16.setSelectable(true);
balls16.setSelected(true);
balls16.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
resetBalls(16);
}
@@ -157,6 +160,7 @@ public class BubbleMarkUIExample extends ExampleBase {
balls32.setSelectable(true);
balls32.setSelected(true);
balls32.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
resetBalls(32);
}
@@ -169,6 +173,7 @@ public class BubbleMarkUIExample extends ExampleBase {
balls64.setSelectable(true);
balls64.setSelected(true);
balls64.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
resetBalls(64);
}
@@ -181,6 +186,7 @@ public class BubbleMarkUIExample extends ExampleBase {
balls128.setSelectable(true);
balls128.setSelected(true);
balls128.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
resetBalls(128);
}
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/RotatingCubeGame.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/RotatingCubeGame.java
index 395a411..d1653dc 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/RotatingCubeGame.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/RotatingCubeGame.java
@@ -64,6 +64,7 @@ public class RotatingCubeGame implements Updater {
this.toggleRotationKey = toggleRotationKey;
}
+ @Override
@MainThread
public void init() {
if (inited) {
@@ -119,34 +120,40 @@ public class RotatingCubeGame implements Updater {
control.setMoveSpeed(MOVE_SPEED);
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ESCAPE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
exit.exit();
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(toggleRotationKey), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
toggleRotation();
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyReleasedCondition(Key.U), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
toggleRotation();
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
resetCamera(source);
}
}));
logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
lookAtZero(source);
}
}));
logicalLayer.registerTrigger(new InputTrigger(new AnyKeyCondition(), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
final InputState current = inputStates.getCurrent();
@@ -172,6 +179,7 @@ public class RotatingCubeGame implements Updater {
rotationSign *= -1;
}
+ @Override
@MainThread
public void update(final ReadOnlyTimer timer) {
final double tpf = timer.getTimePerFrame();
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/collision/CollisionTreeExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/collision/CollisionTreeExample.java
index e2e8196..55b478d 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/collision/CollisionTreeExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/collision/CollisionTreeExample.java
@@ -81,6 +81,7 @@ public class CollisionTreeExample extends ExampleBase {
torus.addController(new SpatialController<PQTorus>() {
private double currentTime;
+ @Override
public void update(final double time, final PQTorus caller) {
currentTime += time * 0.2;
final ReadOnlyVector3 t = caller.getTranslation();
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/BloomExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/BloomExample.java
index 643dde5..d9c6a3d 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/BloomExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/BloomExample.java
@@ -92,6 +92,7 @@ public class BloomExample extends ExampleBase {
_canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(0, 0, 0), Vector3.UNIT_Y);
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
updateText();
}
@@ -147,72 +148,84 @@ public class BloomExample extends ExampleBase {
_passManager.add(renderPass);
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
bloomRenderPass.setEnabled(!bloomRenderPass.isEnabled());
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
bloomRenderPass.setBlurSize(bloomRenderPass.getBlurSize() - 0.001f);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
bloomRenderPass.setBlurSize(bloomRenderPass.getBlurSize() + 0.001f);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
bloomRenderPass.setExposurePow(bloomRenderPass.getExposurePow() - 1.0f);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
bloomRenderPass.setExposurePow(bloomRenderPass.getExposurePow() + 1.0f);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
bloomRenderPass.setExposureCutoff(bloomRenderPass.getExposureCutoff() - 0.1f);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SEVEN), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
bloomRenderPass.setExposureCutoff(bloomRenderPass.getExposureCutoff() + 0.1f);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.EIGHT), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
bloomRenderPass.setBlurIntensityMultiplier(bloomRenderPass.getBlurIntensityMultiplier() - 0.1f);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
bloomRenderPass.setBlurIntensityMultiplier(bloomRenderPass.getBlurIntensityMultiplier() + 0.1f);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
bloomRenderPass.resetParameters();
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.J), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
bloomRenderPass.setUseCurrentScene(!bloomRenderPass.useCurrentScene());
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
bloomRenderPass.setUseSeparateConvolution(!bloomRenderPass.isUseSeparateConvolution());
updateText();
@@ -250,6 +263,7 @@ public class BloomExample extends ExampleBase {
private double timer = 0;
private final Matrix3 rotation = new Matrix3();
+ @Override
public void update(final double time, final Torus caller) {
timer += time * 0.5;
caller.setTranslation(Math.sin(timer) * 40.0, Math.sin(timer) * 40.0, Math.cos(timer) * 40.0);
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/NewDynamicSmokerExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/NewDynamicSmokerExample.java
index 739beba..5f9a0a5 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/NewDynamicSmokerExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/NewDynamicSmokerExample.java
@@ -127,6 +127,7 @@ public class NewDynamicSmokerExample extends ExampleBase {
FirstPersonControl.removeTriggers(_logicalLayer, _controlHandle);
_logicalLayer.registerTrigger(new InputTrigger(new MouseMovedCondition(), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
final MouseState mouse = inputStates.getCurrent().getMouseState();
mouseLoc.set(mouse.getX(), mouse.getY());
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ParallelSplitShadowMapExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ParallelSplitShadowMapExample.java
index 5020f5c..cf65523 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ParallelSplitShadowMapExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ParallelSplitShadowMapExample.java
@@ -1 +1 @@
-/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.effect; import com.ardor3d.bounding.BoundingBox; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.shadow.map.ParallelSplitShadowMapPass; import com.ardor3d.framework.Canvas; import com.ardor3d.image.Texture; import com.ardor3d.image.Texture2D; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.light.DirectionalLight; import com.ardor3d.light.Light; import com.ardor3d.light.PointLight; import com.ardor3d.math.Matrix3; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.pass.BasicPassManager; import com.ardor3d.renderer.pass.RenderPass; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.BlendState; import com.ardor3d.renderer.state.BlendState.TestFunction; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.MaterialState; import com.ardor3d.renderer.state.MaterialState.ColorMaterial; import com.ardor3d.renderer.state.TextureState; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.Spatial; import com.ardor3d.scenegraph.controller.SpatialController; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.hint.TextureCombineMode; import com.ardor3d.scenegraph.shape.Box; import com.ardor3d.scenegraph.shape.Quad; import com.ardor3d.scenegraph.shape.Torus; import com.ardor3d.scenegraph.visitor.UpdateModelBoundVisitor; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.TextureManager; /** * Example showing the parallel split shadow mapping technique. Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.effect.ParallelSplitShadowMapExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/effect_ParallelSplitShadowMapExample.jpg", // maxHeapMemory = 64) public class ParallelSplitShadowMapExample extends ExampleBase { /** Pssm shadow map pass. */ private ParallelSplitShadowMapPass _pssmPass; /** Pass manager. */ private BasicPassManager _passManager; /** Quads used for debug showing shadowmaps. */ private Quad _orthoQuad[]; /** Flag for turning on/off light movement. */ private boolean _updateLight = false; /** Temp vec for updating light pos. */ private final Vector3 lightPosition = new Vector3(10000, 5000, 10000); /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[12]; /** Flag to make sure quads are updated on reinitialization of shadow renderer */ private boolean _quadsDirty = true; /** Console fps output */ private double counter = 0; private int frames = 0; /** * The main method. * * @param args * the arguments */ public static void main(final String[] args) { start(ParallelSplitShadowMapExample.class); } /** * Update the PassManager and light. * * @param timer * the application timer */ @Override protected void updateExample(final ReadOnlyTimer timer) { _passManager.updatePasses(timer.getTimePerFrame()); if (_updateLight) { final double time = timer.getTimeInSeconds() * 0.2; lightPosition.set(Math.sin(time) * 10000.0, 5000.0, Math.cos(time) * 10000.0); } counter += timer.getTimePerFrame(); frames++; if (counter > 1) { final double fps = (frames / counter); counter = 0; frames = 0; System.out.printf("%7.1f FPS\n", fps); } } /** * Initialize pssm if needed. Update light position. Render scene. * * @param renderer * the renderer */ @Override protected void renderExample(final Renderer renderer) { if (!_pssmPass.isInitialised()) { _pssmPass.init(renderer); } updateQuadTextures(renderer); // Update the shadowpass "light" position. Iow it's camera. final Light light = _lightState.get(0); if (light instanceof PointLight) { ((PointLight) light).setLocation(lightPosition); } else if (light instanceof DirectionalLight) { ((DirectionalLight) light).setDirection(lightPosition.normalize(null).negateLocal()); } _passManager.renderPasses(renderer); } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Parallel Split Shadow Maps - Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(250, 200, -250)); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 45.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / (float) _canvas.getCanvasRenderer().getCamera().getHeight(), 1.0, 10000); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(0, 0, 0), Vector3.UNIT_Y); _controlHandle.setMoveSpeed(200); // Setup some standard states for the scene. final CullState cullFrontFace = new CullState(); cullFrontFace.setEnabled(true); cullFrontFace.setCullFace(CullState.Face.Back); _root.setRenderState(cullFrontFace); final TextureState ts = new TextureState(); ts.setEnabled(true); ts.setTexture(TextureManager.load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.Trilinear, true)); _root.setRenderState(ts); final MaterialState ms = new MaterialState(); ms.setColorMaterial(ColorMaterial.Diffuse); _root.setRenderState(ms); _passManager = new BasicPassManager(); // setup some quads for debug viewing. final RenderPass renderPass = new RenderPass(); final int quadSize = _canvas.getCanvasRenderer().getCamera().getWidth() / 10; _orthoQuad = new Quad[ParallelSplitShadowMapPass._MAX_SPLITS]; for (int i = 0; i < ParallelSplitShadowMapPass._MAX_SPLITS; i++) { _orthoQuad[i] = new Quad("OrthoQuad", quadSize, quadSize); _orthoQuad[i].setTranslation(new Vector3((quadSize / 2 + 5) + (quadSize + 5) * i, (quadSize / 2 + 5), 1)); _orthoQuad[i].getSceneHints().setRenderBucketType(RenderBucketType.Ortho); _orthoQuad[i].getSceneHints().setLightCombineMode(LightCombineMode.Off); _orthoQuad[i].getSceneHints().setTextureCombineMode(TextureCombineMode.Replace); _orthoQuad[i].getSceneHints().setCullHint(CullHint.Never); renderPass.add(_orthoQuad[i]); } // Create scene objects. setupTerrain(); final RenderPass rootPass = new RenderPass(); rootPass.add(_root); _lightState.detachAll(); final DirectionalLight light = new DirectionalLight(); // final PointLight light = new PointLight(); light.setEnabled(true); _lightState.attach(light); // Create pssm pass _pssmPass = new ParallelSplitShadowMapPass(light, 1024, 3); _pssmPass.add(_root); _pssmPass.setUseSceneTexturing(true); _pssmPass.setUseObjectCullFace(true); final Node occluders = setupOccluders(); _pssmPass.addOccluder(occluders); // Populate passmanager with passes. _passManager.add(rootPass); _passManager.add(_pssmPass); _passManager.add(renderPass); // Setup textfields for presenting example info. final Node textNodes = new Node("Text"); renderPass.add(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight(); for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - (i + 1) * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); // Register keyboard triggers for manipulating example _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _pssmPass.setDrawShaderDebug(!_pssmPass.isDrawShaderDebug()); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _updateLight = !_updateLight; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _pssmPass.setUpdateMainCamera(!_pssmPass.isUpdateMainCamera()); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _pssmPass.setDrawDebug(!_pssmPass.isDrawDebug()); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (_pssmPass.getNumOfSplits() > ParallelSplitShadowMapPass._MIN_SPLITS) { _pssmPass.setNumOfSplits(_pssmPass.getNumOfSplits() - 1); updateText(); _quadsDirty = true; } } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (_pssmPass.getNumOfSplits() < ParallelSplitShadowMapPass._MAX_SPLITS) { _pssmPass.setNumOfSplits(_pssmPass.getNumOfSplits() + 1); updateText(); _quadsDirty = true; } } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (_pssmPass.getShadowMapSize() > 1) { _pssmPass.setShadowMapSize(_pssmPass.getShadowMapSize() / 2); updateText(); _quadsDirty = true; } } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SEVEN), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (_pssmPass.getShadowMapSize() < 2048) { _pssmPass.setShadowMapSize(_pssmPass.getShadowMapSize() * 2); updateText(); _quadsDirty = true; } } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.EIGHT), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final double maxShadowDistance = _pssmPass.getMaxShadowDistance(); if (maxShadowDistance > 200.0) { _pssmPass.setMaxShadowDistance(maxShadowDistance - 100.0); updateText(); } } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final double maxShadowDistance = _pssmPass.getMaxShadowDistance(); _pssmPass.setMaxShadowDistance(maxShadowDistance + 100.0); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _pssmPass.setNumOfSplits(1); _pssmPass.setShadowMapSize(1024); updateText(); _quadsDirty = true; } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.I), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _pssmPass.setNumOfSplits(3); _pssmPass.setShadowMapSize(512); updateText(); _quadsDirty = true; } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.J), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _pssmPass.setUseSceneTexturing(!_pssmPass.isUseSceneTexturing()); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.K), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _pssmPass.setUseObjectCullFace(!_pssmPass.isUseObjectCullFace()); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _pssmPass.setEnabled(!_pssmPass.isEnabled()); updateText(); _quadsDirty = true; } })); // Make sure all boundings are updated. _root.acceptVisitor(new UpdateModelBoundVisitor(), false); } /** * Setup debug quads to render pssm shadowmaps. */ private void updateQuadTextures(final Renderer r) { if (!_quadsDirty) { return; } _quadsDirty = false; _pssmPass.reinit(r); for (int i = 0; i < _pssmPass.getNumOfSplits(); i++) { final TextureState screen = new TextureState(); final Texture2D copy = new Texture2D(); copy.setTextureKey(_pssmPass.getShadowMapTexture(i).getTextureKey()); screen.setTexture(copy); _orthoQuad[i].setRenderState(screen); _orthoQuad[i].getSceneHints().setCullHint(CullHint.Never); _orthoQuad[i].updateGeometricState(0.0); } for (int i = _pssmPass.getNumOfSplits(); i < ParallelSplitShadowMapPass._MAX_SPLITS; i++) { _orthoQuad[i].getSceneHints().setCullHint(CullHint.Always); } } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[0] Debug shader draw: " + _pssmPass.isDrawShaderDebug()); _exampleInfo[1].setText("[1] Update light: " + _updateLight); _exampleInfo[2].setText("[2] Update main camera: " + _pssmPass.isUpdateMainCamera()); _exampleInfo[3].setText("[3] Debug draw: " + _pssmPass.isDrawDebug()); _exampleInfo[4].setText("[4/5] Number of splits: " + _pssmPass.getNumOfSplits()); _exampleInfo[5].setText("[6/7] Shadow map size: " + _pssmPass.getShadowMapSize()); _exampleInfo[6].setText("[8/9] Max shadow distance: " + _pssmPass.getMaxShadowDistance()); _exampleInfo[7].setText("[U] Setup 1 split of size 1024"); _exampleInfo[8].setText("[I] Setup 3 splits of size 512"); _exampleInfo[9].setText("[J] Use scene texturing: " + _pssmPass.isUseSceneTexturing()); _exampleInfo[10].setText("[K] Use object cull face: " + _pssmPass.isUseObjectCullFace()); _exampleInfo[11].setText("[SPACE] toggle PSSM pass: " + (_pssmPass.isEnabled() ? "enabled" : "disabled")); } /** * Setup terrain. */ private void setupTerrain() { final Box box = new Box("box", new Vector3(), 10000, 10, 10000); box.setModelBound(new BoundingBox()); box.addController(new SpatialController<Box>() { double timer = 0; public void update(final double time, final Box caller) { timer += time; caller.setTranslation(Math.sin(timer) * 20.0, 0, Math.cos(timer) * 20.0); } }); _root.attachChild(box); } /** * Setup occluders. */ private Node setupOccluders() { final Node occluders = new Node("occs"); _root.attachChild(occluders); for (int i = 0; i < 30; i++) { final double w = Math.random() * 40 + 10; final double y = Math.random() * 20 + 10; final Box b = new Box("box", new Vector3(), w, y, w); b.setModelBound(new BoundingBox()); final double x = Math.random() * 1000 - 500; final double z = Math.random() * 1000 - 500; b.setTranslation(new Vector3(x, y, z)); occluders.attachChild(b); } final Torus torusWithoutShadows = new Torus("torus", 32, 10, 15.0f, 20.0f); torusWithoutShadows.setModelBound(new BoundingBox()); torusWithoutShadows.getSceneHints().setCastsShadows(false); torusWithoutShadows.setTranslation(0, 50, -100); occluders.attachChild(torusWithoutShadows); final Torus torus = new Torus("torus", 64, 12, 10.0f, 15.0f); torus.setModelBound(new BoundingBox()); occluders.attachChild(torus); torus.addController(new SpatialController<Torus>() { double timer = 0; Matrix3 rotation = new Matrix3(); public void update(final double time, final Torus caller) { timer += time; caller.setTranslation(Math.sin(timer) * 40.0, Math.sin(timer) * 50.0 + 20.0, Math.cos(timer) * 40.0); rotation.fromAngles(timer * 0.4, timer * 0.4, timer * 0.4); caller.setRotation(rotation); } }); // Attach "billboard" with an alpha test. occluders.attachChild(makeBillBoard()); return occluders; } private Spatial makeBillBoard() { final Node billboard = new Node("bb"); billboard.getSceneHints().setRenderBucketType(RenderBucketType.Transparent); final Quad q1 = new Quad("font block", 150, 200); q1.setTranslation(0, 80, 0); q1.setModelBound(new BoundingBox()); final CullState cs = new CullState(); cs.setCullFace(CullState.Face.None); q1.setRenderState(cs); billboard.attachChild(q1); final TextureState ts = new TextureState(); ts.setEnabled(true); ts.setTexture(TextureManager.load("fonts/OkasaSansSerif-35-medium-regular_00.png", Texture.MinificationFilter.Trilinear, true)); billboard.setRenderState(ts); final BlendState bs = new BlendState(); bs.setEnabled(true); bs.setBlendEnabled(false); bs.setTestEnabled(true); bs.setTestFunction(TestFunction.GreaterThan); bs.setReference(0.7f); billboard.setRenderState(bs); return billboard; } } \ No newline at end of file
+/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.effect; import com.ardor3d.bounding.BoundingBox; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.shadow.map.ParallelSplitShadowMapPass; import com.ardor3d.framework.Canvas; import com.ardor3d.image.Texture; import com.ardor3d.image.Texture2D; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.light.DirectionalLight; import com.ardor3d.light.Light; import com.ardor3d.light.PointLight; import com.ardor3d.math.Matrix3; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.pass.BasicPassManager; import com.ardor3d.renderer.pass.RenderPass; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.BlendState; import com.ardor3d.renderer.state.BlendState.TestFunction; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.MaterialState; import com.ardor3d.renderer.state.MaterialState.ColorMaterial; import com.ardor3d.renderer.state.TextureState; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.Spatial; import com.ardor3d.scenegraph.controller.SpatialController; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.hint.TextureCombineMode; import com.ardor3d.scenegraph.shape.Box; import com.ardor3d.scenegraph.shape.Quad; import com.ardor3d.scenegraph.shape.Torus; import com.ardor3d.scenegraph.visitor.UpdateModelBoundVisitor; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.TextureManager; /** * Example showing the parallel split shadow mapping technique. Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.effect.ParallelSplitShadowMapExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/effect_ParallelSplitShadowMapExample.jpg", // maxHeapMemory = 64) public class ParallelSplitShadowMapExample extends ExampleBase { /** Pssm shadow map pass. */ private ParallelSplitShadowMapPass _pssmPass; /** Pass manager. */ private BasicPassManager _passManager; /** Quads used for debug showing shadowmaps. */ private Quad _orthoQuad[]; /** Flag for turning on/off light movement. */ private boolean _updateLight = false; /** Temp vec for updating light pos. */ private final Vector3 lightPosition = new Vector3(10000, 5000, 10000); /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[12]; /** Flag to make sure quads are updated on reinitialization of shadow renderer */ private boolean _quadsDirty = true; /** Console fps output */ private double counter = 0; private int frames = 0; /** * The main method. * * @param args * the arguments */ public static void main(final String[] args) { start(ParallelSplitShadowMapExample.class); } /** * Update the PassManager and light. * * @param timer * the application timer */ @Override protected void updateExample(final ReadOnlyTimer timer) { _passManager.updatePasses(timer.getTimePerFrame()); if (_updateLight) { final double time = timer.getTimeInSeconds() * 0.2; lightPosition.set(Math.sin(time) * 10000.0, 5000.0, Math.cos(time) * 10000.0); } counter += timer.getTimePerFrame(); frames++; if (counter > 1) { final double fps = (frames / counter); counter = 0; frames = 0; System.out.printf("%7.1f FPS\n", fps); } } /** * Initialize pssm if needed. Update light position. Render scene. * * @param renderer * the renderer */ @Override protected void renderExample(final Renderer renderer) { if (!_pssmPass.isInitialised()) { _pssmPass.init(renderer); } updateQuadTextures(renderer); // Update the shadowpass "light" position. Iow it's camera. final Light light = _lightState.get(0); if (light instanceof PointLight) { ((PointLight) light).setLocation(lightPosition); } else if (light instanceof DirectionalLight) { ((DirectionalLight) light).setDirection(lightPosition.normalize(null).negateLocal()); } _passManager.renderPasses(renderer); } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Parallel Split Shadow Maps - Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(250, 200, -250)); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 45.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / (float) _canvas.getCanvasRenderer().getCamera().getHeight(), 1.0, 10000); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(0, 0, 0), Vector3.UNIT_Y); _controlHandle.setMoveSpeed(200); // Setup some standard states for the scene. final CullState cullFrontFace = new CullState(); cullFrontFace.setEnabled(true); cullFrontFace.setCullFace(CullState.Face.Back); _root.setRenderState(cullFrontFace); final TextureState ts = new TextureState(); ts.setEnabled(true); ts.setTexture(TextureManager.load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.Trilinear, true)); _root.setRenderState(ts); final MaterialState ms = new MaterialState(); ms.setColorMaterial(ColorMaterial.Diffuse); _root.setRenderState(ms); _passManager = new BasicPassManager(); // setup some quads for debug viewing. final RenderPass renderPass = new RenderPass(); final int quadSize = _canvas.getCanvasRenderer().getCamera().getWidth() / 10; _orthoQuad = new Quad[ParallelSplitShadowMapPass._MAX_SPLITS]; for (int i = 0; i < ParallelSplitShadowMapPass._MAX_SPLITS; i++) { _orthoQuad[i] = new Quad("OrthoQuad", quadSize, quadSize); _orthoQuad[i].setTranslation(new Vector3((quadSize / 2 + 5) + (quadSize + 5) * i, (quadSize / 2 + 5), 1)); _orthoQuad[i].getSceneHints().setRenderBucketType(RenderBucketType.Ortho); _orthoQuad[i].getSceneHints().setLightCombineMode(LightCombineMode.Off); _orthoQuad[i].getSceneHints().setTextureCombineMode(TextureCombineMode.Replace); _orthoQuad[i].getSceneHints().setCullHint(CullHint.Never); renderPass.add(_orthoQuad[i]); } // Create scene objects. setupTerrain(); final RenderPass rootPass = new RenderPass(); rootPass.add(_root); _lightState.detachAll(); final DirectionalLight light = new DirectionalLight(); // final PointLight light = new PointLight(); light.setEnabled(true); _lightState.attach(light); // Create pssm pass _pssmPass = new ParallelSplitShadowMapPass(light, 1024, 3); _pssmPass.add(_root); _pssmPass.setUseSceneTexturing(true); _pssmPass.setUseObjectCullFace(true); final Node occluders = setupOccluders(); _pssmPass.addOccluder(occluders); // Populate passmanager with passes. _passManager.add(rootPass); _passManager.add(_pssmPass); _passManager.add(renderPass); // Setup textfields for presenting example info. final Node textNodes = new Node("Text"); renderPass.add(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight(); for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - (i + 1) * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); // Register keyboard triggers for manipulating example _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _pssmPass.setDrawShaderDebug(!_pssmPass.isDrawShaderDebug()); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _updateLight = !_updateLight; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _pssmPass.setUpdateMainCamera(!_pssmPass.isUpdateMainCamera()); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _pssmPass.setDrawDebug(!_pssmPass.isDrawDebug()); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (_pssmPass.getNumOfSplits() > ParallelSplitShadowMapPass._MIN_SPLITS) { _pssmPass.setNumOfSplits(_pssmPass.getNumOfSplits() - 1); updateText(); _quadsDirty = true; } } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (_pssmPass.getNumOfSplits() < ParallelSplitShadowMapPass._MAX_SPLITS) { _pssmPass.setNumOfSplits(_pssmPass.getNumOfSplits() + 1); updateText(); _quadsDirty = true; } } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (_pssmPass.getShadowMapSize() > 1) { _pssmPass.setShadowMapSize(_pssmPass.getShadowMapSize() / 2); updateText(); _quadsDirty = true; } } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SEVEN), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (_pssmPass.getShadowMapSize() < 2048) { _pssmPass.setShadowMapSize(_pssmPass.getShadowMapSize() * 2); updateText(); _quadsDirty = true; } } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.EIGHT), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final double maxShadowDistance = _pssmPass.getMaxShadowDistance(); if (maxShadowDistance > 200.0) { _pssmPass.setMaxShadowDistance(maxShadowDistance - 100.0); updateText(); } } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final double maxShadowDistance = _pssmPass.getMaxShadowDistance(); _pssmPass.setMaxShadowDistance(maxShadowDistance + 100.0); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _pssmPass.setNumOfSplits(1); _pssmPass.setShadowMapSize(1024); updateText(); _quadsDirty = true; } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.I), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _pssmPass.setNumOfSplits(3); _pssmPass.setShadowMapSize(512); updateText(); _quadsDirty = true; } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.J), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _pssmPass.setUseSceneTexturing(!_pssmPass.isUseSceneTexturing()); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.K), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _pssmPass.setUseObjectCullFace(!_pssmPass.isUseObjectCullFace()); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _pssmPass.setEnabled(!_pssmPass.isEnabled()); updateText(); _quadsDirty = true; } })); // Make sure all boundings are updated. _root.acceptVisitor(new UpdateModelBoundVisitor(), false); } /** * Setup debug quads to render pssm shadowmaps. */ private void updateQuadTextures(final Renderer r) { if (!_quadsDirty) { return; } _quadsDirty = false; _pssmPass.reinit(r); for (int i = 0; i < _pssmPass.getNumOfSplits(); i++) { final TextureState screen = new TextureState(); final Texture2D copy = new Texture2D(); copy.setTextureKey(_pssmPass.getShadowMapTexture(i).getTextureKey()); screen.setTexture(copy); _orthoQuad[i].setRenderState(screen); _orthoQuad[i].getSceneHints().setCullHint(CullHint.Never); _orthoQuad[i].updateGeometricState(0.0); } for (int i = _pssmPass.getNumOfSplits(); i < ParallelSplitShadowMapPass._MAX_SPLITS; i++) { _orthoQuad[i].getSceneHints().setCullHint(CullHint.Always); } } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[0] Debug shader draw: " + _pssmPass.isDrawShaderDebug()); _exampleInfo[1].setText("[1] Update light: " + _updateLight); _exampleInfo[2].setText("[2] Update main camera: " + _pssmPass.isUpdateMainCamera()); _exampleInfo[3].setText("[3] Debug draw: " + _pssmPass.isDrawDebug()); _exampleInfo[4].setText("[4/5] Number of splits: " + _pssmPass.getNumOfSplits()); _exampleInfo[5].setText("[6/7] Shadow map size: " + _pssmPass.getShadowMapSize()); _exampleInfo[6].setText("[8/9] Max shadow distance: " + _pssmPass.getMaxShadowDistance()); _exampleInfo[7].setText("[U] Setup 1 split of size 1024"); _exampleInfo[8].setText("[I] Setup 3 splits of size 512"); _exampleInfo[9].setText("[J] Use scene texturing: " + _pssmPass.isUseSceneTexturing()); _exampleInfo[10].setText("[K] Use object cull face: " + _pssmPass.isUseObjectCullFace()); _exampleInfo[11].setText("[SPACE] toggle PSSM pass: " + (_pssmPass.isEnabled() ? "enabled" : "disabled")); } /** * Setup terrain. */ private void setupTerrain() { final Box box = new Box("box", new Vector3(), 10000, 10, 10000); box.setModelBound(new BoundingBox()); box.addController(new SpatialController<Box>() { double timer = 0; @Override public void update(final double time, final Box caller) { timer += time; caller.setTranslation(Math.sin(timer) * 20.0, 0, Math.cos(timer) * 20.0); } }); _root.attachChild(box); } /** * Setup occluders. */ private Node setupOccluders() { final Node occluders = new Node("occs"); _root.attachChild(occluders); for (int i = 0; i < 30; i++) { final double w = Math.random() * 40 + 10; final double y = Math.random() * 20 + 10; final Box b = new Box("box", new Vector3(), w, y, w); b.setModelBound(new BoundingBox()); final double x = Math.random() * 1000 - 500; final double z = Math.random() * 1000 - 500; b.setTranslation(new Vector3(x, y, z)); occluders.attachChild(b); } final Torus torusWithoutShadows = new Torus("torus", 32, 10, 15.0f, 20.0f); torusWithoutShadows.setModelBound(new BoundingBox()); torusWithoutShadows.getSceneHints().setCastsShadows(false); torusWithoutShadows.setTranslation(0, 50, -100); occluders.attachChild(torusWithoutShadows); final Torus torus = new Torus("torus", 64, 12, 10.0f, 15.0f); torus.setModelBound(new BoundingBox()); occluders.attachChild(torus); torus.addController(new SpatialController<Torus>() { double timer = 0; Matrix3 rotation = new Matrix3(); @Override public void update(final double time, final Torus caller) { timer += time; caller.setTranslation(Math.sin(timer) * 40.0, Math.sin(timer) * 50.0 + 20.0, Math.cos(timer) * 40.0); rotation.fromAngles(timer * 0.4, timer * 0.4, timer * 0.4); caller.setRotation(rotation); } }); // Attach "billboard" with an alpha test. occluders.attachChild(makeBillBoard()); return occluders; } private Spatial makeBillBoard() { final Node billboard = new Node("bb"); billboard.getSceneHints().setRenderBucketType(RenderBucketType.Transparent); final Quad q1 = new Quad("font block", 150, 200); q1.setTranslation(0, 80, 0); q1.setModelBound(new BoundingBox()); final CullState cs = new CullState(); cs.setCullFace(CullState.Face.None); q1.setRenderState(cs); billboard.attachChild(q1); final TextureState ts = new TextureState(); ts.setEnabled(true); ts.setTexture(TextureManager.load("fonts/OkasaSansSerif-35-medium-regular_00.png", Texture.MinificationFilter.Trilinear, true)); billboard.setRenderState(ts); final BlendState bs = new BlendState(); bs.setEnabled(true); bs.setBlendEnabled(false); bs.setTestEnabled(true); bs.setTestFunction(TestFunction.GreaterThan); bs.setReference(0.7f); billboard.setRenderState(bs); return billboard; } } \ No newline at end of file
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ProjectedGridExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ProjectedGridExample.java
index 3ff01e1..d561228 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ProjectedGridExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ProjectedGridExample.java
@@ -96,30 +96,35 @@ public class ProjectedGridExample extends ExampleBase {
_root.attachChild(projectedGrid);
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
projectedGrid.setFreezeUpdate(!projectedGrid.isFreezeUpdate());
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
projectedGrid.setNrUpdateThreads(projectedGrid.getNrUpdateThreads() - 1);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
projectedGrid.setNrUpdateThreads(projectedGrid.getNrUpdateThreads() + 1);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
projectedGrid.setDrawDebug(!projectedGrid.isDrawDebug());
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
projectedGrid.setDrawDebug(true);
animateExternalCamera = !animateExternalCamera;
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ProjectedGridWaterExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ProjectedGridWaterExample.java
index 0bb3aa5..778d19a 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ProjectedGridWaterExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ProjectedGridWaterExample.java
@@ -1 +1 @@
-/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.effect; import com.ardor3d.bounding.BoundingBox; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.effect.water.ProjectedGrid; import com.ardor3d.extension.effect.water.WaterHeightGenerator; import com.ardor3d.extension.effect.water.WaterNode; import com.ardor3d.framework.Canvas; import com.ardor3d.image.Texture; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Matrix3; import com.ardor3d.math.Plane; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.MaterialState; import com.ardor3d.renderer.state.MaterialState.ColorMaterial; import com.ardor3d.renderer.state.TextureState; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.controller.SpatialController; import com.ardor3d.scenegraph.extension.Skybox; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Box; import com.ardor3d.scenegraph.shape.Quad; import com.ardor3d.scenegraph.shape.Torus; import com.ardor3d.scenegraph.visitor.UpdateModelBoundVisitor; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.TextureManager; /** * A demonstration of the WaterNode and ProjectedGrid classes; which handles rendering of water effects with a projected * grid. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.effect.ProjectedGridWaterExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/effect_ProjectedGridWaterExample.jpg", // maxHeapMemory = 64) public class ProjectedGridWaterExample extends ExampleBase { /** The water instance taking care of the water rendering. */ private WaterNode waterNode; /** The skybox. */ private Skybox skybox; /** The ProjectedGrid used as geometry for the water. */ private ProjectedGrid projectedGrid; /** The far plane. */ private final double farPlane = 10000.0; /** Node containing debug quads for showing waternode render textures. */ private Node debugQuadsNode; /** Flag for showing/hiding debug quads. */ private boolean showDebugQuads = true; /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[3]; /** * The main method. * * @param args * the args */ public static void main(final String[] args) { start(ProjectedGridWaterExample.class); } /** * Update skybox location and waterQuad position. * * @param timer * the timer */ @Override protected void updateExample(final ReadOnlyTimer timer) { final Camera cam = _canvas.getCanvasRenderer().getCamera(); skybox.setTranslation(cam.getLocation()); skybox.updateGeometricState(0.0f, true); waterNode.update(timer.getTimePerFrame()); } /** * Render example. * * @param renderer * the renderer */ @Override protected void renderExample(final Renderer renderer) { super.renderExample(renderer); if (debugQuadsNode == null) { createDebugQuads(); _root.attachChild(debugQuadsNode); } } /** * Initialize water node and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Projected Grid Water - Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(100, 50, 100)); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 45.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / (float) _canvas.getCanvasRenderer().getCamera().getHeight(), 1, farPlane); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(0, 0, 0), Vector3.UNIT_Y); // Setup some standard states for the scene. final CullState cullFrontFace = new CullState(); cullFrontFace.setEnabled(true); cullFrontFace.setCullFace(CullState.Face.Back); _root.setRenderState(cullFrontFace); final TextureState ts = new TextureState(); ts.setEnabled(true); ts.setTexture(TextureManager.load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.Trilinear, true)); _root.setRenderState(ts); final MaterialState ms = new MaterialState(); ms.setColorMaterial(ColorMaterial.Diffuse); _root.setRenderState(ms); // Need to setup fog cause the water use it for various calculations. setupFog(); // Collect everything we want reflected in the water under a node. final Node reflectedNode = new Node("reflectNode"); reflectedNode.attachChild(createObjects()); buildSkyBox(); reflectedNode.attachChild(skybox); _root.attachChild(reflectedNode); final Camera cam = _canvas.getCanvasRenderer().getCamera(); // Create a new WaterNode with refraction enabled. waterNode = new WaterNode(cam, 4, true, true); waterNode.setClipBias(0.5f); waterNode.setWaterMaxAmplitude(5.0f); // Setup textures to use for the water. waterNode.setNormalMapTextureString("images/water/normalmap3.dds"); waterNode.setDudvMapTextureString("images/water/dudvmap.png"); waterNode.setFallbackMapTextureString("images/water/water2.png"); waterNode.setFoamMapTextureString("images/water/oceanfoam.png"); // setting to default value just to show waterNode.setWaterPlane(new Plane(new Vector3(0.0, 1.0, 0.0), 0.0)); // Create a ProjectedGrid to use as geometry for the water. projectedGrid = new ProjectedGrid("ProjectedGrid", cam, 100, 70, 0.01f, new WaterHeightGenerator(), _timer); // or implement your own waves like this(or in a separate class)... // projectedGrid = new ProjectedGrid( "ProjectedGrid", cam, 50, 50, // 0.01f, new HeightGenerator() { // public float getHeight( float x, float z, float time ) { // return // FastMath.sin(x*0.05f+time*2.0f)+FastMath.cos(z*0.1f+time*4.0f)*2; // } // } ); projectedGrid.setNrUpdateThreads(Runtime.getRuntime().availableProcessors()); waterNode.attachChild(projectedGrid); waterNode.addReflectedScene(reflectedNode); waterNode.setSkybox(skybox); _root.attachChild(waterNode); // Setup textfields for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); // Register keyboard triggers for manipulating example _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { switchShowDebug(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.F), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { projectedGrid.setFreezeUpdate(!projectedGrid.isFreezeUpdate()); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { projectedGrid.setNrUpdateThreads(projectedGrid.getNrUpdateThreads() - 1); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { projectedGrid.setNrUpdateThreads(projectedGrid.getNrUpdateThreads() + 1); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { waterNode.reloadShader(); } })); // Make sure all boundings are updated. _root.acceptVisitor(new UpdateModelBoundVisitor(), false); } /** * Setup fog. */ private void setupFog() { final FogState fogState = new FogState(); fogState.setDensity(1.0f); fogState.setEnabled(true); fogState.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fogState.setEnd((float) farPlane); fogState.setStart((float) farPlane / 10.0f); fogState.setDensityFunction(FogState.DensityFunction.Linear); fogState.setQuality(FogState.Quality.PerVertex); _root.setRenderState(fogState); } /** * Builds the sky box. */ private void buildSkyBox() { skybox = new Skybox("skybox", 10, 10, 10); final String dir = "images/skybox/"; final Texture north = TextureManager .load(dir + "1.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture south = TextureManager .load(dir + "3.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture east = TextureManager.load(dir + "2.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture west = TextureManager.load(dir + "4.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture up = TextureManager.load(dir + "6.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture down = TextureManager.load(dir + "5.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); skybox.setTexture(Skybox.Face.North, north); skybox.setTexture(Skybox.Face.West, west); skybox.setTexture(Skybox.Face.South, south); skybox.setTexture(Skybox.Face.East, east); skybox.setTexture(Skybox.Face.Up, up); skybox.setTexture(Skybox.Face.Down, down); } /** * Creates the scene objects. * * @return the node containing the objects */ private Node createObjects() { final Node objects = new Node("objects"); final Torus torus = new Torus("Torus", 50, 50, 8, 17); torus.setTranslation(new Vector3(50, -5, 20)); TextureState ts = new TextureState(); torus.addController(new SpatialController<Torus>() { private double timer = 0; private final Matrix3 rotation = new Matrix3(); public void update(final double time, final Torus caller) { timer += time * 0.5; caller.setTranslation(Math.sin(timer) * 40.0, Math.sin(timer) * 40.0, Math.cos(timer) * 40.0); rotation.fromAngles(timer * 0.5, timer * 0.5, timer * 0.5); caller.setRotation(rotation); } }); Texture t0 = TextureManager.load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); ts.setTexture(t0, 0); ts.setEnabled(true); torus.setRenderState(ts); objects.attachChild(torus); ts = new TextureState(); t0 = TextureManager .load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); t0.setWrap(Texture.WrapMode.Repeat); ts.setTexture(t0); Box box = new Box("box1", new Vector3(-10, -10, -10), new Vector3(10, 10, 10)); box.setTranslation(new Vector3(0, -7, 0)); box.setRenderState(ts); objects.attachChild(box); box = new Box("box2", new Vector3(-5, -5, -5), new Vector3(5, 5, 5)); box.setTranslation(new Vector3(15, 10, 0)); box.setRenderState(ts); objects.attachChild(box); box = new Box("box3", new Vector3(-5, -5, -5), new Vector3(5, 5, 5)); box.setTranslation(new Vector3(0, -10, 15)); box.setRenderState(ts); objects.attachChild(box); box = new Box("box4", new Vector3(-5, -5, -5), new Vector3(5, 5, 5)); box.setTranslation(new Vector3(20, 0, 0)); box.setRenderState(ts); objects.attachChild(box); ts = new TextureState(); t0 = TextureManager .load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); t0.setWrap(Texture.WrapMode.Repeat); ts.setTexture(t0); box = new Box("box5", new Vector3(-50, -2, -50), new Vector3(50, 2, 50)); box.setTranslation(new Vector3(0, -15, 0)); box.setRenderState(ts); box.setModelBound(new BoundingBox()); objects.attachChild(box); return objects; } /** * Switch show debug. */ private void switchShowDebug() { showDebugQuads = !showDebugQuads; if (showDebugQuads) { debugQuadsNode.getSceneHints().setCullHint(CullHint.Never); } else { debugQuadsNode.getSceneHints().setCullHint(CullHint.Always); } } /** * Creates the debug quads. */ private void createDebugQuads() { debugQuadsNode = new Node("quadNode"); debugQuadsNode.getSceneHints().setCullHint(CullHint.Never); final double quadSize = _canvas.getCanvasRenderer().getCamera().getWidth() / 10; Quad debugQuad = new Quad("reflectionQuad", quadSize, quadSize); debugQuad.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); debugQuad.getSceneHints().setCullHint(CullHint.Never); debugQuad.getSceneHints().setLightCombineMode(LightCombineMode.Off); TextureState ts = new TextureState(); ts.setTexture(waterNode.getTextureReflect()); debugQuad.setRenderState(ts); debugQuad.setTranslation(quadSize * 0.6, quadSize * 1.0, 1.0); debugQuadsNode.attachChild(debugQuad); if (waterNode.getTextureRefract() != null) { debugQuad = new Quad("refractionQuad", quadSize, quadSize); debugQuad.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); debugQuad.getSceneHints().setCullHint(CullHint.Never); debugQuad.getSceneHints().setLightCombineMode(LightCombineMode.Off); ts = new TextureState(); ts.setTexture(waterNode.getTextureRefract()); debugQuad.setRenderState(ts); debugQuad.setTranslation(quadSize * 0.6, quadSize * 2.1, 1.0); debugQuadsNode.attachChild(debugQuad); } } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[SPACE] Show debug quads: " + showDebugQuads); _exampleInfo[1].setText("[1/2] Number of update threads: " + projectedGrid.getNrUpdateThreads()); _exampleInfo[2].setText("[F] Freeze update: " + projectedGrid.isFreezeUpdate()); } } \ No newline at end of file
+/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.effect; import com.ardor3d.bounding.BoundingBox; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.effect.water.ProjectedGrid; import com.ardor3d.extension.effect.water.WaterHeightGenerator; import com.ardor3d.extension.effect.water.WaterNode; import com.ardor3d.framework.Canvas; import com.ardor3d.image.Texture; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Matrix3; import com.ardor3d.math.Plane; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.MaterialState; import com.ardor3d.renderer.state.MaterialState.ColorMaterial; import com.ardor3d.renderer.state.TextureState; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.controller.SpatialController; import com.ardor3d.scenegraph.extension.Skybox; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Box; import com.ardor3d.scenegraph.shape.Quad; import com.ardor3d.scenegraph.shape.Torus; import com.ardor3d.scenegraph.visitor.UpdateModelBoundVisitor; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.TextureManager; /** * A demonstration of the WaterNode and ProjectedGrid classes; which handles rendering of water effects with a projected * grid. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.effect.ProjectedGridWaterExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/effect_ProjectedGridWaterExample.jpg", // maxHeapMemory = 64) public class ProjectedGridWaterExample extends ExampleBase { /** The water instance taking care of the water rendering. */ private WaterNode waterNode; /** The skybox. */ private Skybox skybox; /** The ProjectedGrid used as geometry for the water. */ private ProjectedGrid projectedGrid; /** The far plane. */ private final double farPlane = 10000.0; /** Node containing debug quads for showing waternode render textures. */ private Node debugQuadsNode; /** Flag for showing/hiding debug quads. */ private boolean showDebugQuads = true; /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[3]; /** * The main method. * * @param args * the args */ public static void main(final String[] args) { start(ProjectedGridWaterExample.class); } /** * Update skybox location and waterQuad position. * * @param timer * the timer */ @Override protected void updateExample(final ReadOnlyTimer timer) { final Camera cam = _canvas.getCanvasRenderer().getCamera(); skybox.setTranslation(cam.getLocation()); skybox.updateGeometricState(0.0f, true); waterNode.update(timer.getTimePerFrame()); } /** * Render example. * * @param renderer * the renderer */ @Override protected void renderExample(final Renderer renderer) { super.renderExample(renderer); if (debugQuadsNode == null) { createDebugQuads(); _root.attachChild(debugQuadsNode); } } /** * Initialize water node and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Projected Grid Water - Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(100, 50, 100)); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 45.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / (float) _canvas.getCanvasRenderer().getCamera().getHeight(), 1, farPlane); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(0, 0, 0), Vector3.UNIT_Y); // Setup some standard states for the scene. final CullState cullFrontFace = new CullState(); cullFrontFace.setEnabled(true); cullFrontFace.setCullFace(CullState.Face.Back); _root.setRenderState(cullFrontFace); final TextureState ts = new TextureState(); ts.setEnabled(true); ts.setTexture(TextureManager.load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.Trilinear, true)); _root.setRenderState(ts); final MaterialState ms = new MaterialState(); ms.setColorMaterial(ColorMaterial.Diffuse); _root.setRenderState(ms); // Need to setup fog cause the water use it for various calculations. setupFog(); // Collect everything we want reflected in the water under a node. final Node reflectedNode = new Node("reflectNode"); reflectedNode.attachChild(createObjects()); buildSkyBox(); reflectedNode.attachChild(skybox); _root.attachChild(reflectedNode); final Camera cam = _canvas.getCanvasRenderer().getCamera(); // Create a new WaterNode with refraction enabled. waterNode = new WaterNode(cam, 4, true, true); waterNode.setClipBias(0.5f); waterNode.setWaterMaxAmplitude(5.0f); // Setup textures to use for the water. waterNode.setNormalMapTextureString("images/water/normalmap3.dds"); waterNode.setDudvMapTextureString("images/water/dudvmap.png"); waterNode.setFallbackMapTextureString("images/water/water2.png"); waterNode.setFoamMapTextureString("images/water/oceanfoam.png"); // setting to default value just to show waterNode.setWaterPlane(new Plane(new Vector3(0.0, 1.0, 0.0), 0.0)); // Create a ProjectedGrid to use as geometry for the water. projectedGrid = new ProjectedGrid("ProjectedGrid", cam, 100, 70, 0.01f, new WaterHeightGenerator(), _timer); // or implement your own waves like this(or in a separate class)... // projectedGrid = new ProjectedGrid( "ProjectedGrid", cam, 50, 50, // 0.01f, new HeightGenerator() { // public float getHeight( float x, float z, float time ) { // return // FastMath.sin(x*0.05f+time*2.0f)+FastMath.cos(z*0.1f+time*4.0f)*2; // } // } ); projectedGrid.setNrUpdateThreads(Runtime.getRuntime().availableProcessors()); waterNode.attachChild(projectedGrid); waterNode.addReflectedScene(reflectedNode); waterNode.setSkybox(skybox); _root.attachChild(waterNode); // Setup textfields for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); // Register keyboard triggers for manipulating example _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { switchShowDebug(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.F), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { projectedGrid.setFreezeUpdate(!projectedGrid.isFreezeUpdate()); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { projectedGrid.setNrUpdateThreads(projectedGrid.getNrUpdateThreads() - 1); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { projectedGrid.setNrUpdateThreads(projectedGrid.getNrUpdateThreads() + 1); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { waterNode.reloadShader(); } })); // Make sure all boundings are updated. _root.acceptVisitor(new UpdateModelBoundVisitor(), false); } /** * Setup fog. */ private void setupFog() { final FogState fogState = new FogState(); fogState.setDensity(1.0f); fogState.setEnabled(true); fogState.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fogState.setEnd((float) farPlane); fogState.setStart((float) farPlane / 10.0f); fogState.setDensityFunction(FogState.DensityFunction.Linear); fogState.setQuality(FogState.Quality.PerVertex); _root.setRenderState(fogState); } /** * Builds the sky box. */ private void buildSkyBox() { skybox = new Skybox("skybox", 10, 10, 10); final String dir = "images/skybox/"; final Texture north = TextureManager .load(dir + "1.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture south = TextureManager .load(dir + "3.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture east = TextureManager.load(dir + "2.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture west = TextureManager.load(dir + "4.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture up = TextureManager.load(dir + "6.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture down = TextureManager.load(dir + "5.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); skybox.setTexture(Skybox.Face.North, north); skybox.setTexture(Skybox.Face.West, west); skybox.setTexture(Skybox.Face.South, south); skybox.setTexture(Skybox.Face.East, east); skybox.setTexture(Skybox.Face.Up, up); skybox.setTexture(Skybox.Face.Down, down); } /** * Creates the scene objects. * * @return the node containing the objects */ private Node createObjects() { final Node objects = new Node("objects"); final Torus torus = new Torus("Torus", 50, 50, 8, 17); torus.setTranslation(new Vector3(50, -5, 20)); TextureState ts = new TextureState(); torus.addController(new SpatialController<Torus>() { private double timer = 0; private final Matrix3 rotation = new Matrix3(); @Override public void update(final double time, final Torus caller) { timer += time * 0.5; caller.setTranslation(Math.sin(timer) * 40.0, Math.sin(timer) * 40.0, Math.cos(timer) * 40.0); rotation.fromAngles(timer * 0.5, timer * 0.5, timer * 0.5); caller.setRotation(rotation); } }); Texture t0 = TextureManager.load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); ts.setTexture(t0, 0); ts.setEnabled(true); torus.setRenderState(ts); objects.attachChild(torus); ts = new TextureState(); t0 = TextureManager .load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); t0.setWrap(Texture.WrapMode.Repeat); ts.setTexture(t0); Box box = new Box("box1", new Vector3(-10, -10, -10), new Vector3(10, 10, 10)); box.setTranslation(new Vector3(0, -7, 0)); box.setRenderState(ts); objects.attachChild(box); box = new Box("box2", new Vector3(-5, -5, -5), new Vector3(5, 5, 5)); box.setTranslation(new Vector3(15, 10, 0)); box.setRenderState(ts); objects.attachChild(box); box = new Box("box3", new Vector3(-5, -5, -5), new Vector3(5, 5, 5)); box.setTranslation(new Vector3(0, -10, 15)); box.setRenderState(ts); objects.attachChild(box); box = new Box("box4", new Vector3(-5, -5, -5), new Vector3(5, 5, 5)); box.setTranslation(new Vector3(20, 0, 0)); box.setRenderState(ts); objects.attachChild(box); ts = new TextureState(); t0 = TextureManager .load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); t0.setWrap(Texture.WrapMode.Repeat); ts.setTexture(t0); box = new Box("box5", new Vector3(-50, -2, -50), new Vector3(50, 2, 50)); box.setTranslation(new Vector3(0, -15, 0)); box.setRenderState(ts); box.setModelBound(new BoundingBox()); objects.attachChild(box); return objects; } /** * Switch show debug. */ private void switchShowDebug() { showDebugQuads = !showDebugQuads; if (showDebugQuads) { debugQuadsNode.getSceneHints().setCullHint(CullHint.Never); } else { debugQuadsNode.getSceneHints().setCullHint(CullHint.Always); } } /** * Creates the debug quads. */ private void createDebugQuads() { debugQuadsNode = new Node("quadNode"); debugQuadsNode.getSceneHints().setCullHint(CullHint.Never); final double quadSize = _canvas.getCanvasRenderer().getCamera().getWidth() / 10; Quad debugQuad = new Quad("reflectionQuad", quadSize, quadSize); debugQuad.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); debugQuad.getSceneHints().setCullHint(CullHint.Never); debugQuad.getSceneHints().setLightCombineMode(LightCombineMode.Off); TextureState ts = new TextureState(); ts.setTexture(waterNode.getTextureReflect()); debugQuad.setRenderState(ts); debugQuad.setTranslation(quadSize * 0.6, quadSize * 1.0, 1.0); debugQuadsNode.attachChild(debugQuad); if (waterNode.getTextureRefract() != null) { debugQuad = new Quad("refractionQuad", quadSize, quadSize); debugQuad.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); debugQuad.getSceneHints().setCullHint(CullHint.Never); debugQuad.getSceneHints().setLightCombineMode(LightCombineMode.Off); ts = new TextureState(); ts.setTexture(waterNode.getTextureRefract()); debugQuad.setRenderState(ts); debugQuad.setTranslation(quadSize * 0.6, quadSize * 2.1, 1.0); debugQuadsNode.attachChild(debugQuad); } } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[SPACE] Show debug quads: " + showDebugQuads); _exampleInfo[1].setText("[1/2] Number of update threads: " + projectedGrid.getNrUpdateThreads()); _exampleInfo[2].setText("[F] Freeze update: " + projectedGrid.isFreezeUpdate()); } } \ No newline at end of file
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/QuadImposterExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/QuadImposterExample.java
index f0b214c..e807d30 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/QuadImposterExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/QuadImposterExample.java
@@ -101,6 +101,7 @@ public class QuadImposterExample extends ExampleBase {
imposter2.attachChild(scene3);
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
showImposter = !showImposter;
if (showImposter) {
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/TrailExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/TrailExample.java
index bdcf643..de1b1cc 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/TrailExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/TrailExample.java
@@ -170,54 +170,63 @@ public class TrailExample extends ExampleBase {
updateText();
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
trailMesh.setFacingMode(TrailMesh.FacingMode.Tangent);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
trailMesh.setFacingMode(TrailMesh.FacingMode.Billboard);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
trailMesh.setUpdateMode(TrailMesh.UpdateMode.Step);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
trailMesh.setUpdateMode(TrailMesh.UpdateMode.Interpolate);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
trailMesh.setUpdateSpeed(trailMesh.getUpdateSpeed() * 2.0f);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
trailMesh.setUpdateSpeed(trailMesh.getUpdateSpeed() * 0.5f);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.F), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
updateTrail = !updateTrail;
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
variableWidth = !variableWidth;
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.E), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
trailMesh.resetPosition(sphere.getWorldTranslation());
updateText();
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/WaterExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/WaterExample.java
index 8c93caf..9ad238a 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/WaterExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/WaterExample.java
@@ -1 +1 @@
-/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.effect; import java.nio.FloatBuffer; import com.ardor3d.bounding.BoundingBox; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.effect.water.WaterNode; import com.ardor3d.framework.Canvas; import com.ardor3d.image.Texture; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Matrix3; import com.ardor3d.math.Plane; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.MaterialState; import com.ardor3d.renderer.state.MaterialState.ColorMaterial; import com.ardor3d.renderer.state.TextureState; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.controller.SpatialController; import com.ardor3d.scenegraph.extension.Skybox; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Box; import com.ardor3d.scenegraph.shape.Quad; import com.ardor3d.scenegraph.shape.Torus; import com.ardor3d.scenegraph.visitor.UpdateModelBoundVisitor; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.TextureManager; /** * A demonstration of the WaterNode class; which handles rendering of a water effect on all of it's children. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.effect.WaterExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/effect_WaterExample.jpg", // maxHeapMemory = 64) public class WaterExample extends ExampleBase { /** The water instance taking care of the water rendering. */ private WaterNode waterNode; /** The skybox. */ private Skybox skybox; /** The quad used as geometry for the water. */ private Quad waterQuad; /** The far plane. */ private final double farPlane = 10000.0; /** The texture scale to use for the water quad. */ private final double textureScale = 0.02; /** Node containing debug quads for showing waternode render textures. */ private Node debugQuadsNode; /** Flag for showing/hiding debug quads. */ private boolean showDebugQuads = true; /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[1]; /** * The main method. * * @param args * the args */ public static void main(final String[] args) { start(WaterExample.class); } /** * Update skybox location and waterQuad position. * * @param timer * the timer */ @Override protected void updateExample(final ReadOnlyTimer timer) { final Camera cam = _canvas.getCanvasRenderer().getCamera(); skybox.setTranslation(cam.getLocation()); skybox.updateGeometricState(0.0f, true); final Vector3 transVec = new Vector3(cam.getLocation().getX(), waterNode.getWaterHeight(), cam.getLocation() .getZ()); setTextureCoords(0, transVec.getX(), -transVec.getZ(), textureScale); // vertex coords setVertexCoords(transVec.getX(), transVec.getY(), transVec.getZ()); waterNode.update(timer.getTimePerFrame()); } /** * Render example. * * @param renderer * the renderer */ @Override protected void renderExample(final Renderer renderer) { super.renderExample(renderer); if (debugQuadsNode == null) { createDebugQuads(); _root.attachChild(debugQuadsNode); } } /** * Initialize water node and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Quad Water - Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(100, 50, 100)); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 45.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / (float) _canvas.getCanvasRenderer().getCamera().getHeight(), 1, farPlane); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(0, 0, 0), Vector3.UNIT_Y); // Setup some standard states for the scene. final CullState cullFrontFace = new CullState(); cullFrontFace.setEnabled(true); cullFrontFace.setCullFace(CullState.Face.Back); _root.setRenderState(cullFrontFace); final TextureState ts = new TextureState(); ts.setEnabled(true); ts.setTexture(TextureManager.load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.Trilinear, true)); _root.setRenderState(ts); final MaterialState ms = new MaterialState(); ms.setColorMaterial(ColorMaterial.Diffuse); _root.setRenderState(ms); // Need to setup fog cause the water use it for various calculations. setupFog(); // Collect everything we want reflected in the water under a node. final Node reflectedNode = new Node("reflectNode"); reflectedNode.attachChild(createObjects()); buildSkyBox(); reflectedNode.attachChild(skybox); _root.attachChild(reflectedNode); final Camera cam = _canvas.getCanvasRenderer().getCamera(); // Create a new WaterNode with refraction enabled. waterNode = new WaterNode(cam, 4, false, true); // Setup textures to use for the water. waterNode.setNormalMapTextureString("images/water/normalmap3.dds"); waterNode.setDudvMapTextureString("images/water/dudvmap.png"); waterNode.setFallbackMapTextureString("images/water/water2.png"); // setting to default value just to show waterNode.setWaterPlane(new Plane(new Vector3(0.0, 1.0, 0.0), 0.0)); // Create a quad to use as geometry for the water. waterQuad = new Quad("waterQuad", 1, 1); // Hack the quad normals to point up in the y-axis. Since we are manipulating the vertices as // we move this is more convenient than rotating the quad. final FloatBuffer normBuf = waterQuad.getMeshData().getNormalBuffer(); normBuf.clear(); normBuf.put(0).put(1).put(0); normBuf.put(0).put(1).put(0); normBuf.put(0).put(1).put(0); normBuf.put(0).put(1).put(0); waterNode.attachChild(waterQuad); waterNode.addReflectedScene(reflectedNode); waterNode.setSkybox(skybox); _root.attachChild(waterNode); // Setyp textfields for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); // Register keyboard triggers for manipulating example _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { switchShowDebug(); updateText(); } })); // Make sure all boundings are updated. _root.acceptVisitor(new UpdateModelBoundVisitor(), false); } /** * Sets the vertex coords of the quad. * * @param x * the x * @param y * the y * @param z * the z */ private void setVertexCoords(final double x, final double y, final double z) { final FloatBuffer vertBuf = waterQuad.getMeshData().getVertexBuffer(); vertBuf.clear(); vertBuf.put((float) (x - farPlane)).put((float) y).put((float) (z - farPlane)); vertBuf.put((float) (x - farPlane)).put((float) y).put((float) (z + farPlane)); vertBuf.put((float) (x + farPlane)).put((float) y).put((float) (z + farPlane)); vertBuf.put((float) (x + farPlane)).put((float) y).put((float) (z - farPlane)); } /** * Sets the texture coords of the quad. * * @param buffer * the buffer * @param x * the x * @param y * the y * @param textureScale * the texture scale */ private void setTextureCoords(final int buffer, double x, double y, double textureScale) { x *= textureScale * 0.5f; y *= textureScale * 0.5f; textureScale = farPlane * textureScale; FloatBuffer texBuf; texBuf = waterQuad.getMeshData().getTextureBuffer(buffer); texBuf.clear(); texBuf.put((float) x).put((float) (textureScale + y)); texBuf.put((float) x).put((float) y); texBuf.put((float) (textureScale + x)).put((float) y); texBuf.put((float) (textureScale + x)).put((float) (textureScale + y)); } /** * Setup fog. */ private void setupFog() { final FogState fogState = new FogState(); fogState.setDensity(1.0f); fogState.setEnabled(true); fogState.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fogState.setEnd((float) farPlane); fogState.setStart((float) farPlane / 10.0f); fogState.setDensityFunction(FogState.DensityFunction.Linear); fogState.setQuality(FogState.Quality.PerVertex); _root.setRenderState(fogState); } /** * Builds the sky box. */ private void buildSkyBox() { skybox = new Skybox("skybox", 10, 10, 10); final String dir = "images/skybox/"; final Texture north = TextureManager .load(dir + "1.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture south = TextureManager .load(dir + "3.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture east = TextureManager.load(dir + "2.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture west = TextureManager.load(dir + "4.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture up = TextureManager.load(dir + "6.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture down = TextureManager.load(dir + "5.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); skybox.setTexture(Skybox.Face.North, north); skybox.setTexture(Skybox.Face.West, west); skybox.setTexture(Skybox.Face.South, south); skybox.setTexture(Skybox.Face.East, east); skybox.setTexture(Skybox.Face.Up, up); skybox.setTexture(Skybox.Face.Down, down); } /** * Creates the scene objects. * * @return the node containing the objects */ private Node createObjects() { final Node objects = new Node("objects"); final Torus torus = new Torus("Torus", 50, 50, 8, 17); torus.setTranslation(new Vector3(50, -5, 20)); TextureState ts = new TextureState(); torus.addController(new SpatialController<Torus>() { private double timer = 0; private final Matrix3 rotation = new Matrix3(); public void update(final double time, final Torus caller) { timer += time * 0.5; caller.setTranslation(Math.sin(timer) * 40.0, Math.sin(timer) * 40.0, Math.cos(timer) * 40.0); rotation.fromAngles(timer * 0.5, timer * 0.5, timer * 0.5); caller.setRotation(rotation); } }); Texture t0 = TextureManager.load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); ts.setTexture(t0, 0); ts.setEnabled(true); torus.setRenderState(ts); objects.attachChild(torus); ts = new TextureState(); t0 = TextureManager .load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); t0.setWrap(Texture.WrapMode.Repeat); ts.setTexture(t0); Box box = new Box("box1", new Vector3(-10, -10, -10), new Vector3(10, 10, 10)); box.setTranslation(new Vector3(0, -7, 0)); box.setRenderState(ts); objects.attachChild(box); box = new Box("box2", new Vector3(-5, -5, -5), new Vector3(5, 5, 5)); box.setTranslation(new Vector3(15, 10, 0)); box.setRenderState(ts); objects.attachChild(box); box = new Box("box3", new Vector3(-5, -5, -5), new Vector3(5, 5, 5)); box.setTranslation(new Vector3(0, -10, 15)); box.setRenderState(ts); objects.attachChild(box); box = new Box("box4", new Vector3(-5, -5, -5), new Vector3(5, 5, 5)); box.setTranslation(new Vector3(20, 0, 0)); box.setRenderState(ts); objects.attachChild(box); ts = new TextureState(); t0 = TextureManager .load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); t0.setWrap(Texture.WrapMode.Repeat); ts.setTexture(t0); box = new Box("box5", new Vector3(-50, -2, -50), new Vector3(50, 2, 50)); box.setTranslation(new Vector3(0, -15, 0)); box.setRenderState(ts); box.setModelBound(new BoundingBox()); objects.attachChild(box); return objects; } /** * Switch show debug. */ private void switchShowDebug() { showDebugQuads = !showDebugQuads; if (showDebugQuads) { debugQuadsNode.getSceneHints().setCullHint(CullHint.Never); } else { debugQuadsNode.getSceneHints().setCullHint(CullHint.Always); } } /** * Creates the debug quads. */ private void createDebugQuads() { debugQuadsNode = new Node("quadNode"); debugQuadsNode.getSceneHints().setCullHint(CullHint.Never); final double quadSize = _canvas.getCanvasRenderer().getCamera().getWidth() / 10; Quad debugQuad = new Quad("reflectionQuad", quadSize, quadSize); debugQuad.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); debugQuad.getSceneHints().setCullHint(CullHint.Never); debugQuad.getSceneHints().setLightCombineMode(LightCombineMode.Off); TextureState ts = new TextureState(); ts.setTexture(waterNode.getTextureReflect()); debugQuad.setRenderState(ts); debugQuad.setTranslation(quadSize * 0.6, quadSize * 1.0, 1.0); debugQuadsNode.attachChild(debugQuad); if (waterNode.getTextureRefract() != null) { debugQuad = new Quad("refractionQuad", quadSize, quadSize); debugQuad.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); debugQuad.getSceneHints().setCullHint(CullHint.Never); debugQuad.getSceneHints().setLightCombineMode(LightCombineMode.Off); ts = new TextureState(); ts.setTexture(waterNode.getTextureRefract()); debugQuad.setRenderState(ts); debugQuad.setTranslation(quadSize * 0.6, quadSize * 2.1, 1.0); debugQuadsNode.attachChild(debugQuad); } } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[SPACE] Show debug quads: " + showDebugQuads); } } \ No newline at end of file
+/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.effect; import java.nio.FloatBuffer; import com.ardor3d.bounding.BoundingBox; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.effect.water.WaterNode; import com.ardor3d.framework.Canvas; import com.ardor3d.image.Texture; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Matrix3; import com.ardor3d.math.Plane; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.MaterialState; import com.ardor3d.renderer.state.MaterialState.ColorMaterial; import com.ardor3d.renderer.state.TextureState; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.controller.SpatialController; import com.ardor3d.scenegraph.extension.Skybox; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Box; import com.ardor3d.scenegraph.shape.Quad; import com.ardor3d.scenegraph.shape.Torus; import com.ardor3d.scenegraph.visitor.UpdateModelBoundVisitor; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.TextureManager; /** * A demonstration of the WaterNode class; which handles rendering of a water effect on all of it's children. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.effect.WaterExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/effect_WaterExample.jpg", // maxHeapMemory = 64) public class WaterExample extends ExampleBase { /** The water instance taking care of the water rendering. */ private WaterNode waterNode; /** The skybox. */ private Skybox skybox; /** The quad used as geometry for the water. */ private Quad waterQuad; /** The far plane. */ private final double farPlane = 10000.0; /** The texture scale to use for the water quad. */ private final double textureScale = 0.02; /** Node containing debug quads for showing waternode render textures. */ private Node debugQuadsNode; /** Flag for showing/hiding debug quads. */ private boolean showDebugQuads = true; /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[1]; /** * The main method. * * @param args * the args */ public static void main(final String[] args) { start(WaterExample.class); } /** * Update skybox location and waterQuad position. * * @param timer * the timer */ @Override protected void updateExample(final ReadOnlyTimer timer) { final Camera cam = _canvas.getCanvasRenderer().getCamera(); skybox.setTranslation(cam.getLocation()); skybox.updateGeometricState(0.0f, true); final Vector3 transVec = new Vector3(cam.getLocation().getX(), waterNode.getWaterHeight(), cam.getLocation() .getZ()); setTextureCoords(0, transVec.getX(), -transVec.getZ(), textureScale); // vertex coords setVertexCoords(transVec.getX(), transVec.getY(), transVec.getZ()); waterNode.update(timer.getTimePerFrame()); } /** * Render example. * * @param renderer * the renderer */ @Override protected void renderExample(final Renderer renderer) { super.renderExample(renderer); if (debugQuadsNode == null) { createDebugQuads(); _root.attachChild(debugQuadsNode); } } /** * Initialize water node and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Quad Water - Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(100, 50, 100)); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 45.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / (float) _canvas.getCanvasRenderer().getCamera().getHeight(), 1, farPlane); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(0, 0, 0), Vector3.UNIT_Y); // Setup some standard states for the scene. final CullState cullFrontFace = new CullState(); cullFrontFace.setEnabled(true); cullFrontFace.setCullFace(CullState.Face.Back); _root.setRenderState(cullFrontFace); final TextureState ts = new TextureState(); ts.setEnabled(true); ts.setTexture(TextureManager.load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.Trilinear, true)); _root.setRenderState(ts); final MaterialState ms = new MaterialState(); ms.setColorMaterial(ColorMaterial.Diffuse); _root.setRenderState(ms); // Need to setup fog cause the water use it for various calculations. setupFog(); // Collect everything we want reflected in the water under a node. final Node reflectedNode = new Node("reflectNode"); reflectedNode.attachChild(createObjects()); buildSkyBox(); reflectedNode.attachChild(skybox); _root.attachChild(reflectedNode); final Camera cam = _canvas.getCanvasRenderer().getCamera(); // Create a new WaterNode with refraction enabled. waterNode = new WaterNode(cam, 4, false, true); // Setup textures to use for the water. waterNode.setNormalMapTextureString("images/water/normalmap3.dds"); waterNode.setDudvMapTextureString("images/water/dudvmap.png"); waterNode.setFallbackMapTextureString("images/water/water2.png"); // setting to default value just to show waterNode.setWaterPlane(new Plane(new Vector3(0.0, 1.0, 0.0), 0.0)); // Create a quad to use as geometry for the water. waterQuad = new Quad("waterQuad", 1, 1); // Hack the quad normals to point up in the y-axis. Since we are manipulating the vertices as // we move this is more convenient than rotating the quad. final FloatBuffer normBuf = waterQuad.getMeshData().getNormalBuffer(); normBuf.clear(); normBuf.put(0).put(1).put(0); normBuf.put(0).put(1).put(0); normBuf.put(0).put(1).put(0); normBuf.put(0).put(1).put(0); waterNode.attachChild(waterQuad); waterNode.addReflectedScene(reflectedNode); waterNode.setSkybox(skybox); _root.attachChild(waterNode); // Setyp textfields for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); // Register keyboard triggers for manipulating example _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { switchShowDebug(); updateText(); } })); // Make sure all boundings are updated. _root.acceptVisitor(new UpdateModelBoundVisitor(), false); } /** * Sets the vertex coords of the quad. * * @param x * the x * @param y * the y * @param z * the z */ private void setVertexCoords(final double x, final double y, final double z) { final FloatBuffer vertBuf = waterQuad.getMeshData().getVertexBuffer(); vertBuf.clear(); vertBuf.put((float) (x - farPlane)).put((float) y).put((float) (z - farPlane)); vertBuf.put((float) (x - farPlane)).put((float) y).put((float) (z + farPlane)); vertBuf.put((float) (x + farPlane)).put((float) y).put((float) (z + farPlane)); vertBuf.put((float) (x + farPlane)).put((float) y).put((float) (z - farPlane)); } /** * Sets the texture coords of the quad. * * @param buffer * the buffer * @param x * the x * @param y * the y * @param textureScale * the texture scale */ private void setTextureCoords(final int buffer, double x, double y, double textureScale) { x *= textureScale * 0.5f; y *= textureScale * 0.5f; textureScale = farPlane * textureScale; FloatBuffer texBuf; texBuf = waterQuad.getMeshData().getTextureBuffer(buffer); texBuf.clear(); texBuf.put((float) x).put((float) (textureScale + y)); texBuf.put((float) x).put((float) y); texBuf.put((float) (textureScale + x)).put((float) y); texBuf.put((float) (textureScale + x)).put((float) (textureScale + y)); } /** * Setup fog. */ private void setupFog() { final FogState fogState = new FogState(); fogState.setDensity(1.0f); fogState.setEnabled(true); fogState.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fogState.setEnd((float) farPlane); fogState.setStart((float) farPlane / 10.0f); fogState.setDensityFunction(FogState.DensityFunction.Linear); fogState.setQuality(FogState.Quality.PerVertex); _root.setRenderState(fogState); } /** * Builds the sky box. */ private void buildSkyBox() { skybox = new Skybox("skybox", 10, 10, 10); final String dir = "images/skybox/"; final Texture north = TextureManager .load(dir + "1.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture south = TextureManager .load(dir + "3.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture east = TextureManager.load(dir + "2.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture west = TextureManager.load(dir + "4.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture up = TextureManager.load(dir + "6.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture down = TextureManager.load(dir + "5.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); skybox.setTexture(Skybox.Face.North, north); skybox.setTexture(Skybox.Face.West, west); skybox.setTexture(Skybox.Face.South, south); skybox.setTexture(Skybox.Face.East, east); skybox.setTexture(Skybox.Face.Up, up); skybox.setTexture(Skybox.Face.Down, down); } /** * Creates the scene objects. * * @return the node containing the objects */ private Node createObjects() { final Node objects = new Node("objects"); final Torus torus = new Torus("Torus", 50, 50, 8, 17); torus.setTranslation(new Vector3(50, -5, 20)); TextureState ts = new TextureState(); torus.addController(new SpatialController<Torus>() { private double timer = 0; private final Matrix3 rotation = new Matrix3(); @Override public void update(final double time, final Torus caller) { timer += time * 0.5; caller.setTranslation(Math.sin(timer) * 40.0, Math.sin(timer) * 40.0, Math.cos(timer) * 40.0); rotation.fromAngles(timer * 0.5, timer * 0.5, timer * 0.5); caller.setRotation(rotation); } }); Texture t0 = TextureManager.load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); ts.setTexture(t0, 0); ts.setEnabled(true); torus.setRenderState(ts); objects.attachChild(torus); ts = new TextureState(); t0 = TextureManager .load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); t0.setWrap(Texture.WrapMode.Repeat); ts.setTexture(t0); Box box = new Box("box1", new Vector3(-10, -10, -10), new Vector3(10, 10, 10)); box.setTranslation(new Vector3(0, -7, 0)); box.setRenderState(ts); objects.attachChild(box); box = new Box("box2", new Vector3(-5, -5, -5), new Vector3(5, 5, 5)); box.setTranslation(new Vector3(15, 10, 0)); box.setRenderState(ts); objects.attachChild(box); box = new Box("box3", new Vector3(-5, -5, -5), new Vector3(5, 5, 5)); box.setTranslation(new Vector3(0, -10, 15)); box.setRenderState(ts); objects.attachChild(box); box = new Box("box4", new Vector3(-5, -5, -5), new Vector3(5, 5, 5)); box.setTranslation(new Vector3(20, 0, 0)); box.setRenderState(ts); objects.attachChild(box); ts = new TextureState(); t0 = TextureManager .load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); t0.setWrap(Texture.WrapMode.Repeat); ts.setTexture(t0); box = new Box("box5", new Vector3(-50, -2, -50), new Vector3(50, 2, 50)); box.setTranslation(new Vector3(0, -15, 0)); box.setRenderState(ts); box.setModelBound(new BoundingBox()); objects.attachChild(box); return objects; } /** * Switch show debug. */ private void switchShowDebug() { showDebugQuads = !showDebugQuads; if (showDebugQuads) { debugQuadsNode.getSceneHints().setCullHint(CullHint.Never); } else { debugQuadsNode.getSceneHints().setCullHint(CullHint.Always); } } /** * Creates the debug quads. */ private void createDebugQuads() { debugQuadsNode = new Node("quadNode"); debugQuadsNode.getSceneHints().setCullHint(CullHint.Never); final double quadSize = _canvas.getCanvasRenderer().getCamera().getWidth() / 10; Quad debugQuad = new Quad("reflectionQuad", quadSize, quadSize); debugQuad.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); debugQuad.getSceneHints().setCullHint(CullHint.Never); debugQuad.getSceneHints().setLightCombineMode(LightCombineMode.Off); TextureState ts = new TextureState(); ts.setTexture(waterNode.getTextureReflect()); debugQuad.setRenderState(ts); debugQuad.setTranslation(quadSize * 0.6, quadSize * 1.0, 1.0); debugQuadsNode.attachChild(debugQuad); if (waterNode.getTextureRefract() != null) { debugQuad = new Quad("refractionQuad", quadSize, quadSize); debugQuad.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); debugQuad.getSceneHints().setCullHint(CullHint.Never); debugQuad.getSceneHints().setLightCombineMode(LightCombineMode.Off); ts = new TextureState(); ts.setTexture(waterNode.getTextureRefract()); debugQuad.setRenderState(ts); debugQuad.setTranslation(quadSize * 0.6, quadSize * 2.1, 1.0); debugQuadsNode.attachChild(debugQuad); } } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[SPACE] Show debug quads: " + showDebugQuads); } } \ No newline at end of file
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/interpolation/InterpolationControllerBase.java b/ardor3d-examples/src/main/java/com/ardor3d/example/interpolation/InterpolationControllerBase.java
index 78ea46e..b847833 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/interpolation/InterpolationControllerBase.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/interpolation/InterpolationControllerBase.java
@@ -77,6 +77,7 @@ public abstract class InterpolationControllerBase<C extends InterpolationControl
// Add a trigger to change the repeat type on the controller
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
switch (controller.getRepeatType()) {
case CLAMP:
@@ -95,6 +96,7 @@ public abstract class InterpolationControllerBase<C extends InterpolationControl
// Add a slow down command
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.LBRACKET), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
controller.setSpeed(getNewSpeed(false, controller));
speedText.setText(getSpeedText(controller));
@@ -103,6 +105,7 @@ public abstract class InterpolationControllerBase<C extends InterpolationControl
// Add a speed up command
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.RBRACKET), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
controller.setSpeed(getNewSpeed(true, controller));
speedText.setText(getSpeedText(controller));
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationBlinnPhongExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationBlinnPhongExample.java
index f6b1889..11401c7 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationBlinnPhongExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationBlinnPhongExample.java
@@ -131,6 +131,7 @@ public class AnimationBlinnPhongExample extends ExampleBase {
final BasicText t6 = createTextLabel("Text5", "[Y] Enable Light Motion.", 5);
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.F), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
useDiffuseMap = !useDiffuseMap;
gpuShader.setUniform("flags", useNormalMap, useDiffuseMap, useSpecularMap, false);
@@ -143,6 +144,7 @@ public class AnimationBlinnPhongExample extends ExampleBase {
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NUMPADADD), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (quantizationFactor > 1) {
quantizationFactor /= 2f;
@@ -153,6 +155,7 @@ public class AnimationBlinnPhongExample extends ExampleBase {
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NUMPADSUBTRACT),
new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (quantizationFactor < 512) {
quantizationFactor *= 2f;
@@ -163,6 +166,7 @@ public class AnimationBlinnPhongExample extends ExampleBase {
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.Y), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
updateLight = !updateLight;
if (updateLight) {
@@ -174,6 +178,7 @@ public class AnimationBlinnPhongExample extends ExampleBase {
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.P), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
useSpecularMap = !useSpecularMap;
gpuShader.setUniform("flags", useNormalMap, useDiffuseMap, useSpecularMap, false);
@@ -186,6 +191,7 @@ public class AnimationBlinnPhongExample extends ExampleBase {
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
useNormalMap = !useNormalMap;
gpuShader.setUniform("flags", useNormalMap, useDiffuseMap, useSpecularMap, false);
@@ -198,6 +204,7 @@ public class AnimationBlinnPhongExample extends ExampleBase {
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.K), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
showSkeleton = !showSkeleton;
if (showSkeleton) {
@@ -209,6 +216,7 @@ public class AnimationBlinnPhongExample extends ExampleBase {
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.M), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
showMesh = !showMesh;
colladaNode.getSceneHints().setCullHint(showMesh ? CullHint.Dynamic : CullHint.Always);
@@ -285,6 +293,7 @@ public class AnimationBlinnPhongExample extends ExampleBase {
gpuShader.setUniform("specularMap", 2);
colladaNode.acceptVisitor(new Visitor() {
+ @Override
public void visit(final Spatial spatial) {
if (spatial instanceof SkinnedMesh) {
final SkinnedMesh skinnedMesh = (SkinnedMesh) spatial;
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationCopyExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationCopyExample.java
index 6ff67d7..08259c1 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationCopyExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationCopyExample.java
@@ -166,6 +166,7 @@ public class AnimationCopyExample extends ExampleBase {
runWalkButton.addActionListener(new ActionListener() {
boolean walk = true;
+ @Override
public void actionPerformed(final ActionEvent event) {
if (!walk) {
if (manager.getBaseAnimationLayer().doTransition("walk")) {
@@ -186,6 +187,7 @@ public class AnimationCopyExample extends ExampleBase {
punchButton
.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, runWalkButton, Alignment.BOTTOM_LEFT, 0, -5));
punchButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
manager.findAnimationLayer("punch").setCurrentState("punch_right", true);
punchButton.setEnabled(false);
@@ -198,6 +200,7 @@ public class AnimationCopyExample extends ExampleBase {
headCheck.setSelected(true);
headCheck.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
manager.getValuesStore().put("head_blend", headCheck.isSelected() ? 1.0 : 0.0);
}
@@ -209,6 +212,7 @@ public class AnimationCopyExample extends ExampleBase {
.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, headCheck, Alignment.BOTTOM_LEFT, 0, -5));
gpuSkinningCheck.setSelected(false);
gpuSkinningCheck.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
_root.acceptVisitor(new Visitor() {
@Override
@@ -234,6 +238,7 @@ public class AnimationCopyExample extends ExampleBase {
vboCheck.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, gpuSkinningCheck, Alignment.BOTTOM_LEFT, 0, -5));
vboCheck.setSelected(false);
vboCheck.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
skNode.getSceneHints().setDataMode(vboCheck.isSelected() ? DataMode.VBO : DataMode.Arrays);
gpuShader.setUseAttributeVBO(vboCheck.isSelected());
@@ -247,6 +252,7 @@ public class AnimationCopyExample extends ExampleBase {
skeletonCheck.setSelected(showSkeleton);
skeletonCheck.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
showSkeleton = skeletonCheck.isSelected();
boneLabelCheck.setEnabled(showSkeleton);
@@ -260,6 +266,7 @@ public class AnimationCopyExample extends ExampleBase {
boneLabelCheck.setEnabled(showSkeleton);
boneLabelCheck.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
showJointLabels = boneLabelCheck.isSelected();
}
@@ -373,6 +380,7 @@ public class AnimationCopyExample extends ExampleBase {
// Add a call back to load clips.
final InputStore input = new InputStore();
input.getClips().setMissCallback(new MissingCallback<String, AnimationClip>() {
+ @Override
public AnimationClip getValue(final String key) {
try {
final ColladaStorage storage1 = colladaImporter.load("collada/skeleton/" + key + ".dae");
@@ -404,6 +412,7 @@ public class AnimationCopyExample extends ExampleBase {
_root.addController(new SpatialController<Node>() {
private final Quaternion headRotation = new Quaternion();
+ @Override
public void update(final double time, final Node caller) {
// update the head's position
if (headCheck != null && headCheck.isSelected()) {
@@ -425,6 +434,7 @@ public class AnimationCopyExample extends ExampleBase {
// add callback for our UI
manager.findClipInstance("skeleton.punch").addAnimationListener(new AnimationListener() {
+ @Override
public void animationFinished(final AnimationClipInstance source) {
punchButton.setEnabled(true);
}
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationDemoExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationDemoExample.java
index 746f0a1..73d7d03 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationDemoExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationDemoExample.java
@@ -209,6 +209,7 @@ public class AnimationDemoExample extends ExampleBase {
// Add a call back to load clips.
final InputStore input = new InputStore();
input.getClips().setMissCallback(new MissingCallback<String, AnimationClip>() {
+ @Override
public AnimationClip getValue(final String key) {
if (!animationStore.containsKey(key)) {
try {
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationStateExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationStateExample.java
index 44b3407..852ad63 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationStateExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/AnimationStateExample.java
@@ -161,6 +161,7 @@ public class AnimationStateExample extends ExampleBase {
runWalkButton.addActionListener(new ActionListener() {
boolean walk = true;
+ @Override
public void actionPerformed(final ActionEvent event) {
if (!walk) {
if (manager.getBaseAnimationLayer().doTransition("walk")) {
@@ -181,6 +182,7 @@ public class AnimationStateExample extends ExampleBase {
punchButton
.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, runWalkButton, Alignment.BOTTOM_LEFT, 0, -5));
punchButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
manager.findAnimationLayer("punch").setCurrentState("punch_right", true);
punchButton.setEnabled(false);
@@ -192,6 +194,7 @@ public class AnimationStateExample extends ExampleBase {
playPauseButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, punchButton, Alignment.BOTTOM_LEFT, 0,
-5));
playPauseButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
if (playPauseButton.getText().equals("Pause")) {
manager.pause();
@@ -208,6 +211,7 @@ public class AnimationStateExample extends ExampleBase {
stopButton
.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, playPauseButton, Alignment.BOTTOM_LEFT, 0, -5));
stopButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
manager.stop();
playPauseButton.setButtonText("Play");
@@ -220,6 +224,7 @@ public class AnimationStateExample extends ExampleBase {
.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, stopButton, Alignment.BOTTOM_LEFT, 0, -5));
resetAnimCheck.setSelected(false);
resetAnimCheck.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
manager.setResetClipsOnStop(resetAnimCheck.isSelected());
@@ -232,6 +237,7 @@ public class AnimationStateExample extends ExampleBase {
0, -5));
gpuSkinningCheck.setSelected(false);
gpuSkinningCheck.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
_root.acceptVisitor(new Visitor() {
@Override
@@ -257,6 +263,7 @@ public class AnimationStateExample extends ExampleBase {
vboCheck.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, gpuSkinningCheck, Alignment.BOTTOM_LEFT, 0, -5));
vboCheck.setSelected(false);
vboCheck.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
skNode.getSceneHints().setDataMode(vboCheck.isSelected() ? DataMode.VBO : DataMode.Arrays);
gpuShader.setUseAttributeVBO(vboCheck.isSelected());
@@ -270,6 +277,7 @@ public class AnimationStateExample extends ExampleBase {
skeletonCheck.setSelected(showSkeleton);
skeletonCheck.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
showSkeleton = skeletonCheck.isSelected();
boneLabelCheck.setEnabled(showSkeleton);
@@ -283,6 +291,7 @@ public class AnimationStateExample extends ExampleBase {
boneLabelCheck.setEnabled(showSkeleton);
boneLabelCheck.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
showJointLabels = boneLabelCheck.isSelected();
}
@@ -396,6 +405,7 @@ public class AnimationStateExample extends ExampleBase {
// Add a call back to load clips.
final InputStore input = new InputStore();
input.getClips().setMissCallback(new MissingCallback<String, AnimationClip>() {
+ @Override
public AnimationClip getValue(final String key) {
try {
final ColladaStorage storage1 = colladaImporter.load("collada/skeleton/" + key + ".dae");
@@ -421,6 +431,7 @@ public class AnimationStateExample extends ExampleBase {
// add callback for our UI
manager.findClipInstance("skeleton.punch").addAnimationListener(new AnimationListener() {
+ @Override
public void animationFinished(final AnimationClipInstance source) {
punchButton.setEnabled(true);
}
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ColladaExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ColladaExample.java
index f9c93d2..960e9a3 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ColladaExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ColladaExample.java
@@ -151,6 +151,7 @@ public class ColladaExample extends ExampleBase {
final UIButton loadSceneButton = new UIButton("Load next scene");
loadSceneButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, basePanel, Alignment.TOP_LEFT, 5, -5));
loadSceneButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
final File file = daeFiles.get(fileIndex);
try {
@@ -169,6 +170,7 @@ public class ColladaExample extends ExampleBase {
.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, loadSceneButton, Alignment.BOTTOM_LEFT, 0, -5));
skinCheck.setSelected(true);
skinCheck.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
colladaNode.getSceneHints().setCullHint(skinCheck.isSelected() ? CullHint.Dynamic : CullHint.Always);
}
@@ -180,6 +182,7 @@ public class ColladaExample extends ExampleBase {
skeletonCheck.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, skinCheck, Alignment.BOTTOM_LEFT, 0, -5));
skeletonCheck.setSelected(showSkeleton);
skeletonCheck.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
showSkeleton = skeletonCheck.isSelected();
boneLabelCheck.setEnabled(showSkeleton);
@@ -192,6 +195,7 @@ public class ColladaExample extends ExampleBase {
boneLabelCheck.setSelected(false);
boneLabelCheck.setEnabled(showSkeleton);
boneLabelCheck.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
showJointLabels = boneLabelCheck.isSelected();
}
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ColladaManualAnimationExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ColladaManualAnimationExample.java
index f5008ac..6a5f00c 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ColladaManualAnimationExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ColladaManualAnimationExample.java
@@ -232,6 +232,7 @@ public class ColladaManualAnimationExample extends ExampleBase {
_root.getSceneHints().setCullHint(CullHint.Never);
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.K), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
showSkeleton = !showSkeleton;
if (showSkeleton) {
@@ -243,6 +244,7 @@ public class ColladaManualAnimationExample extends ExampleBase {
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.M), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
showMesh = !showMesh;
colladaNode.getSceneHints().setCullHint(showMesh ? CullHint.Dynamic : CullHint.Always);
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/FireballTrigger.java b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/FireballTrigger.java
index 42d1411..c783518 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/FireballTrigger.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/FireballTrigger.java
@@ -33,6 +33,7 @@ public class FireballTrigger implements TriggerCallback {
example = AnimationDemoExample.instance;
}
+ @Override
public void doTrigger(final SkeletonPose applyToPose, final AnimationManager manager) {
GameTaskQueueManager.getManager(example.getCanvas().getCanvasRenderer().getRenderContext()).update(
new Callable<Void>() {
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/PrimitiveSkeletonExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/PrimitiveSkeletonExample.java
index d17d162..6b2d6fc 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/PrimitiveSkeletonExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/PrimitiveSkeletonExample.java
@@ -181,6 +181,7 @@ public class PrimitiveSkeletonExample extends ExampleBase {
_root.getSceneHints().setCullHint(CullHint.Never);
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.K), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
showSkeleton = !showSkeleton;
if (showSkeleton) {
@@ -192,6 +193,7 @@ public class PrimitiveSkeletonExample extends ExampleBase {
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
useGPU = !useGPU;
arm1.getGPUShader().setEnabled(useGPU);
@@ -207,6 +209,7 @@ public class PrimitiveSkeletonExample extends ExampleBase {
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
runAnimation = !runAnimation;
if (runAnimation) {
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ScenegraphTree.java b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ScenegraphTree.java
index 38612f2..9b46ea7 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ScenegraphTree.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ScenegraphTree.java
@@ -59,6 +59,7 @@ public class ScenegraphTree {
this.textArea = textArea;
}
+ @Override
public void valueChanged(final TreeSelectionEvent e) {
if (e.getNewLeadSelectionPath() == null || e.getNewLeadSelectionPath().getLastPathComponent() == null) {
return;
@@ -103,6 +104,7 @@ public class ScenegraphTree {
rootNode = node;
}
+ @Override
public Object getChild(final Object parent, final int index) {
if (parent instanceof Node) {
final Node parentNode = (Node) parent;
@@ -111,6 +113,7 @@ public class ScenegraphTree {
return null;
}
+ @Override
public int getChildCount(final Object parent) {
if (parent instanceof Node) {
final Node parentNode = (Node) parent;
@@ -119,6 +122,7 @@ public class ScenegraphTree {
return 0;
}
+ @Override
public int getIndexOfChild(final Object parent, final Object child) {
if (parent instanceof Node && child instanceof Spatial) {
final Node parentNode = (Node) parent;
@@ -127,18 +131,23 @@ public class ScenegraphTree {
return 0;
}
+ @Override
public Object getRoot() {
return rootNode;
}
+ @Override
public boolean isLeaf(final Object node) {
return !(node instanceof Node);
}
+ @Override
public void addTreeModelListener(final TreeModelListener l) {}
+ @Override
public void removeTreeModelListener(final TreeModelListener l) {}
+ @Override
public void valueForPathChanged(final TreePath path, final Object newValue) {}
}
}
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/BillboardNodeExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/BillboardNodeExample.java
index 5cff233..ab4ed82 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/BillboardNodeExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/BillboardNodeExample.java
@@ -67,6 +67,7 @@ public class BillboardNodeExample extends ExampleBase {
_root.attachChild(billboard);
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
int ordinal = billboard.getAlignment().ordinal() + 1;
if (ordinal > BillboardAlignment.values().length - 1) {
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DegenerateTrianglesExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DegenerateTrianglesExample.java
index c9a859d..ac89c60 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DegenerateTrianglesExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DegenerateTrianglesExample.java
@@ -105,6 +105,7 @@ public class DegenerateTrianglesExample extends ExampleBase {
degenerateStripMesh.getSceneHints().setCullHint(CullHint.Always);
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
showDegenerateMesh = !showDegenerateMesh;
if (showDegenerateMesh) {
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DisplayListDelegateExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DisplayListDelegateExample.java
index 2370a0f..60996ab 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DisplayListDelegateExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DisplayListDelegateExample.java
@@ -153,6 +153,7 @@ public class DisplayListDelegateExample extends ExampleBase {
updateText();
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
showingCompiled = !showingCompiled;
if (showingCompiled) {
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DisplayListExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DisplayListExample.java
index 14ee582..8e636f8 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DisplayListExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DisplayListExample.java
@@ -164,6 +164,7 @@ public class DisplayListExample extends ExampleBase {
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
private boolean useDL = true;
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
useDL = !useDL;
if (useDL) {
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/GeneratedTexturesExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/GeneratedTexturesExample.java
index 4fdc002..f74ef00 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/GeneratedTexturesExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/GeneratedTexturesExample.java
@@ -254,6 +254,7 @@ public class GeneratedTexturesExample extends ExampleBase {
float ratio = zoom ? 0 : 1;
float zSpeed = 1;
+ @Override
public void update(final double time, final UIPanel caller) {
// update ratio
ratio += (zoom ? 1 : -1) * zSpeed * time;
@@ -287,6 +288,7 @@ public class GeneratedTexturesExample extends ExampleBase {
super.registerInputTriggers();
_logicalLayer.registerTrigger(new InputTrigger(TriggerConditions.mouseMoved(), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (!allowClicks || !zoom) {
return;
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/GeometryInstancingExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/GeometryInstancingExample.java
index 52bac15..5c0b3e5 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/GeometryInstancingExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/GeometryInstancingExample.java
@@ -138,6 +138,7 @@ public class GeometryInstancingExample extends ExampleBase {
generateSpheres(unInstancedBase, false, nrOfObjects);
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.V), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
vboMode = (vboMode + 1) % 3;
if (vboMode == 0) {
@@ -146,6 +147,7 @@ public class GeometryInstancingExample extends ExampleBase {
// run this in the opengl thread
GameTaskQueueManager.getManager(_canvas.getCanvasRenderer().getRenderContext()).render(
new Callable<Void>() {
+ @Override
public Void call() throws Exception {
final DeleteVBOsVisitor viz = new DeleteVBOsVisitor(_canvas.getCanvasRenderer()
.getRenderer());
@@ -165,6 +167,7 @@ public class GeometryInstancingExample extends ExampleBase {
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.I), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
instancingEnabled = !instancingEnabled;
if (instancingEnabled) {
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/MandelbrotExplorerExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/MandelbrotExplorerExample.java
index d9d82c5..d7a747d 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/MandelbrotExplorerExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/MandelbrotExplorerExample.java
@@ -97,6 +97,7 @@ public class MandelbrotExplorerExample extends ExampleBase {
super.registerInputTriggers();
_logicalLayer.registerTrigger(new InputTrigger(new MouseButtonReleasedCondition(MouseButton.LEFT),
new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
// zoom in
final MouseState mouse = inputState.getCurrent().getMouseState();
@@ -112,6 +113,7 @@ public class MandelbrotExplorerExample extends ExampleBase {
}));
_logicalLayer.registerTrigger(new InputTrigger(new MouseButtonReleasedCondition(MouseButton.RIGHT),
new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
// zoom out
final MouseState mouse = inputState.getCurrent().getMouseState();
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/ManyLightsExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/ManyLightsExample.java
index b8d2a1c..5896d9e 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/ManyLightsExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/ManyLightsExample.java
@@ -81,6 +81,7 @@ public class ManyLightsExample extends ExampleBase {
double timeZ = rand.nextDouble() * Math.PI * 8;
double speed = MathUtils.nextRandomDouble();
+ @Override
public void update(final double tpf, final Spatial caller) {
timeX += tpf * speed;
timeY += tpf * speed;
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/PointCubeExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/PointCubeExample.java
index c73fa30..56d0ffc 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/PointCubeExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/PointCubeExample.java
@@ -226,21 +226,25 @@ public class PointCubeExample extends ExampleBase {
super.registerInputTriggers();
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() {
+ @Override
public void perform(final Canvas canvas, final TwoInputStates inputState, final double tpf) {
_rotationEnabled = !_rotationEnabled;
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() {
+ @Override
public void perform(final Canvas canvas, final TwoInputStates inputState, final double tpf) {
_waveEnabled = !_waveEnabled;
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() {
+ @Override
public void perform(final Canvas canvas, final TwoInputStates inputState, final double tpf) {
_blurEnabled = !_blurEnabled;
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() {
+ @Override
public void perform(final Canvas canvas, final TwoInputStates inputState, final double tpf) {
_scaleEnabled = !_scaleEnabled;
}
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/RenderEffectsExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/RenderEffectsExample.java
index b38dd01..67d2add 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/RenderEffectsExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/RenderEffectsExample.java
@@ -73,6 +73,7 @@ public class RenderEffectsExample extends ExampleBase {
private final Matrix3 _rotate = new Matrix3();
private double _angle = 0;
+ @Override
public void update(final double time, final Spatial caller) {
// update our rotation
_angle = _angle + (_timer.getTimePerFrame() * 25);
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/RenderQueueExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/RenderQueueExample.java
index 08483f8..efe5d6e 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/RenderQueueExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/RenderQueueExample.java
@@ -1 +1 @@
-/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.renderer; import com.ardor3d.bounding.BoundingBox; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.framework.Canvas; import com.ardor3d.image.Texture.MinificationFilter; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Vector2; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.BlendState; import com.ardor3d.renderer.state.BlendState.DestinationFunction; import com.ardor3d.renderer.state.BlendState.SourceFunction; import com.ardor3d.renderer.state.LightState; import com.ardor3d.renderer.state.MaterialState; import com.ardor3d.renderer.state.MaterialState.MaterialFace; import com.ardor3d.renderer.state.TextureState; import com.ardor3d.renderer.state.ZBufferState; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.hint.TransparencyType; import com.ardor3d.scenegraph.shape.Box; import com.ardor3d.scenegraph.shape.Quad; import com.ardor3d.scenegraph.shape.Torus; import com.ardor3d.util.TextureManager; /** * Illustrates the Render Queue, which controls how Nodes are drawn when overlapping occurs. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.renderer.RenderQueueExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/renderer_RenderQueueExample.jpg", // maxHeapMemory = 64) public class RenderQueueExample extends ExampleBase { private boolean useQueue = false; private boolean twoPass = false; protected Node opaques, transps, orthos; private boolean _updateTitle; public static void main(final String[] args) { start(RenderQueueExample.class); } @Override protected void renderExample(final Renderer renderer) { transps.getSceneHints().setTransparencyType(twoPass ? TransparencyType.TwoPass : TransparencyType.OnePass); if (_updateTitle) { _canvas.setTitle("Test Render Queue - " + useQueue + " - hit 'M' to toggle Queue mode - 'R' Two Pass: - " + twoPass); _updateTitle = false; } if (!useQueue) { renderer.setOrtho(); renderer.draw(orthos); renderer.unsetOrtho(); } else { renderer.draw(orthos); } transps.draw(renderer); opaques.draw(renderer); } @Override protected void initExample() { _canvas.setTitle("Test Render Queue - false - hit 'M' to toggle Queue mode - 'R' Two Pass: - false"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(10, 0, 50)); final Vector3 max = new Vector3(5, 5, 5); final Vector3 min = new Vector3(-5, -5, -5); opaques = new Node("Opaques"); transps = new Node("Transps"); orthos = new Node("Orthos"); transps.getSceneHints().setRenderBucketType(RenderBucketType.Skip); opaques.getSceneHints().setRenderBucketType(RenderBucketType.Skip); orthos.getSceneHints().setRenderBucketType(RenderBucketType.Skip); _root.attachChild(orthos); _root.attachChild(transps); _root.attachChild(opaques); final Box b1 = new Box("Box", min, max); b1.setModelBound(new BoundingBox()); b1.setTranslation(new Vector3(0, 0, -15)); opaques.attachChild(b1); final Box b2 = new Box("Box", min, max); b2.setModelBound(new BoundingBox()); b2.setTranslation(new Vector3(0, 0, -30)); opaques.attachChild(b2); final Box b3 = new Box("Box", min, max); b3.setModelBound(new BoundingBox()); b3.setTranslation(new Vector3(0, -15, -15)); opaques.attachChild(b3); final TextureState ts = new TextureState(); ts.setEnabled(true); ts.setTexture(TextureManager.load("images/ardor3d_white_256.jpg", MinificationFilter.Trilinear, true)); opaques.setRenderState(ts); final LightState ls = new LightState(); ls.setEnabled(true); final DirectionalLight dLight = new DirectionalLight(); dLight.setEnabled(true); dLight.setDiffuse(new ColorRGBA(1, 1, 1, 1)); dLight.setDirection(new Vector3(1, 1, 1)); ls.attach(dLight); final DirectionalLight dLight2 = new DirectionalLight(); dLight2.setEnabled(true); dLight2.setDiffuse(new ColorRGBA(1, 1, 1, 1)); dLight2.setDirection(new Vector3(-1, -1, -1)); ls.attach(dLight2); ls.setTwoSidedLighting(false); transps.setRenderState(ls); transps.getSceneHints().setLightCombineMode(LightCombineMode.Replace); final Box tb1 = new Box("TBox Blue", min, max); tb1.setModelBound(new BoundingBox()); tb1.setTranslation(new Vector3(0, 15, 15)); transps.attachChild(tb1); final MaterialState ms1 = new MaterialState(); ms1.setEnabled(true); ms1.setDiffuse(MaterialFace.FrontAndBack, new ColorRGBA(0, 0, 1, .75f)); ms1.setShininess(MaterialFace.FrontAndBack, 128); tb1.setRenderState(ms1); final Torus tb2 = new Torus("TBox Green", 20, 20, 3, 6); tb2.setModelBound(new BoundingBox()); tb2.setTranslation(new Vector3(0, 0, 30)); transps.attachChild(tb2); final MaterialState ms2 = new MaterialState(); ms2.setEnabled(true); ms2.setDiffuse(MaterialFace.FrontAndBack, new ColorRGBA(0, 1, 0, .5f)); ms2.setShininess(MaterialFace.FrontAndBack, 128); tb2.setRenderState(ms2); final Box tb3 = new Box("TBox Red", min, max); tb3.setModelBound(new BoundingBox()); tb3.setTranslation(new Vector3(0, 0, 15)); transps.attachChild(tb3); final MaterialState ms3 = new MaterialState(); ms3.setEnabled(true); ms3.setDiffuse(MaterialFace.FrontAndBack, new ColorRGBA(1, 0, 0, .5f)); ms3.setShininess(MaterialFace.FrontAndBack, 128); tb3.setRenderState(ms3); final BlendState as = new BlendState(); as.setEnabled(true); as.setBlendEnabled(true); as.setSourceFunction(SourceFunction.SourceAlpha); as.setDestinationFunction(DestinationFunction.OneMinusSourceAlpha); transps.setRenderState(as); final Vector2 center = new Vector2(_canvas.getCanvasRenderer().getCamera().getWidth() >> 1, _canvas .getCanvasRenderer().getCamera().getWidth() >> 1); final Quad q1 = new Quad("Ortho Q1", 40, 40); q1.setTranslation(new Vector3(100 + center.getX(), 100 + center.getY(), 0)); q1.getSceneHints().setOrthoOrder(1); q1.setDefaultColor(ColorRGBA.WHITE); q1.getSceneHints().setLightCombineMode(LightCombineMode.Off); orthos.attachChild(q1); final Quad q2 = new Quad("Ortho Q2", 100, 100); q2.setTranslation(new Vector3(60 + center.getX(), 60 + center.getY(), 0)); q2.getSceneHints().setOrthoOrder(5); q2.setDefaultColor(ColorRGBA.RED); q2.getSceneHints().setLightCombineMode(LightCombineMode.Off); orthos.attachChild(q2); final Quad q3 = new Quad("Ortho Q3", 120, 60); q3.setTranslation(new Vector3(-20 + center.getX(), -150 + center.getY(), 0)); q3.getSceneHints().setOrthoOrder(2); q3.setDefaultColor(ColorRGBA.BLUE); q3.getSceneHints().setLightCombineMode(LightCombineMode.Off); orthos.attachChild(q3); final ZBufferState zstate = new ZBufferState(); zstate.setWritable(false); zstate.setEnabled(false); orthos.setRenderState(zstate); orthos.setRenderState(new LightState()); _root.getSceneHints().setCullHint(CullHint.Always); opaques.getSceneHints().setCullHint(CullHint.Dynamic); transps.getSceneHints().setCullHint(CullHint.Dynamic); orthos.getSceneHints().setCullHint(CullHint.Never); } @Override protected void registerInputTriggers() { super.registerInputTriggers(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.M), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (useQueue) { transps.getSceneHints().setRenderBucketType(RenderBucketType.Skip); opaques.getSceneHints().setRenderBucketType(RenderBucketType.Skip); orthos.getSceneHints().setRenderBucketType(RenderBucketType.Skip); } else { transps.getSceneHints().setRenderBucketType(RenderBucketType.Transparent); opaques.getSceneHints().setRenderBucketType(RenderBucketType.Opaque); orthos.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); } useQueue = !useQueue; _updateTitle = true; } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { twoPass = !twoPass; _updateTitle = true; } })); } } \ No newline at end of file
+/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.renderer; import com.ardor3d.bounding.BoundingBox; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.framework.Canvas; import com.ardor3d.image.Texture.MinificationFilter; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Vector2; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.BlendState; import com.ardor3d.renderer.state.BlendState.DestinationFunction; import com.ardor3d.renderer.state.BlendState.SourceFunction; import com.ardor3d.renderer.state.LightState; import com.ardor3d.renderer.state.MaterialState; import com.ardor3d.renderer.state.MaterialState.MaterialFace; import com.ardor3d.renderer.state.TextureState; import com.ardor3d.renderer.state.ZBufferState; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.hint.TransparencyType; import com.ardor3d.scenegraph.shape.Box; import com.ardor3d.scenegraph.shape.Quad; import com.ardor3d.scenegraph.shape.Torus; import com.ardor3d.util.TextureManager; /** * Illustrates the Render Queue, which controls how Nodes are drawn when overlapping occurs. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.renderer.RenderQueueExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/renderer_RenderQueueExample.jpg", // maxHeapMemory = 64) public class RenderQueueExample extends ExampleBase { private boolean useQueue = false; private boolean twoPass = false; protected Node opaques, transps, orthos; private boolean _updateTitle; public static void main(final String[] args) { start(RenderQueueExample.class); } @Override protected void renderExample(final Renderer renderer) { transps.getSceneHints().setTransparencyType(twoPass ? TransparencyType.TwoPass : TransparencyType.OnePass); if (_updateTitle) { _canvas.setTitle("Test Render Queue - " + useQueue + " - hit 'M' to toggle Queue mode - 'R' Two Pass: - " + twoPass); _updateTitle = false; } if (!useQueue) { renderer.setOrtho(); renderer.draw(orthos); renderer.unsetOrtho(); } else { renderer.draw(orthos); } transps.draw(renderer); opaques.draw(renderer); } @Override protected void initExample() { _canvas.setTitle("Test Render Queue - false - hit 'M' to toggle Queue mode - 'R' Two Pass: - false"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(10, 0, 50)); final Vector3 max = new Vector3(5, 5, 5); final Vector3 min = new Vector3(-5, -5, -5); opaques = new Node("Opaques"); transps = new Node("Transps"); orthos = new Node("Orthos"); transps.getSceneHints().setRenderBucketType(RenderBucketType.Skip); opaques.getSceneHints().setRenderBucketType(RenderBucketType.Skip); orthos.getSceneHints().setRenderBucketType(RenderBucketType.Skip); _root.attachChild(orthos); _root.attachChild(transps); _root.attachChild(opaques); final Box b1 = new Box("Box", min, max); b1.setModelBound(new BoundingBox()); b1.setTranslation(new Vector3(0, 0, -15)); opaques.attachChild(b1); final Box b2 = new Box("Box", min, max); b2.setModelBound(new BoundingBox()); b2.setTranslation(new Vector3(0, 0, -30)); opaques.attachChild(b2); final Box b3 = new Box("Box", min, max); b3.setModelBound(new BoundingBox()); b3.setTranslation(new Vector3(0, -15, -15)); opaques.attachChild(b3); final TextureState ts = new TextureState(); ts.setEnabled(true); ts.setTexture(TextureManager.load("images/ardor3d_white_256.jpg", MinificationFilter.Trilinear, true)); opaques.setRenderState(ts); final LightState ls = new LightState(); ls.setEnabled(true); final DirectionalLight dLight = new DirectionalLight(); dLight.setEnabled(true); dLight.setDiffuse(new ColorRGBA(1, 1, 1, 1)); dLight.setDirection(new Vector3(1, 1, 1)); ls.attach(dLight); final DirectionalLight dLight2 = new DirectionalLight(); dLight2.setEnabled(true); dLight2.setDiffuse(new ColorRGBA(1, 1, 1, 1)); dLight2.setDirection(new Vector3(-1, -1, -1)); ls.attach(dLight2); ls.setTwoSidedLighting(false); transps.setRenderState(ls); transps.getSceneHints().setLightCombineMode(LightCombineMode.Replace); final Box tb1 = new Box("TBox Blue", min, max); tb1.setModelBound(new BoundingBox()); tb1.setTranslation(new Vector3(0, 15, 15)); transps.attachChild(tb1); final MaterialState ms1 = new MaterialState(); ms1.setEnabled(true); ms1.setDiffuse(MaterialFace.FrontAndBack, new ColorRGBA(0, 0, 1, .75f)); ms1.setShininess(MaterialFace.FrontAndBack, 128); tb1.setRenderState(ms1); final Torus tb2 = new Torus("TBox Green", 20, 20, 3, 6); tb2.setModelBound(new BoundingBox()); tb2.setTranslation(new Vector3(0, 0, 30)); transps.attachChild(tb2); final MaterialState ms2 = new MaterialState(); ms2.setEnabled(true); ms2.setDiffuse(MaterialFace.FrontAndBack, new ColorRGBA(0, 1, 0, .5f)); ms2.setShininess(MaterialFace.FrontAndBack, 128); tb2.setRenderState(ms2); final Box tb3 = new Box("TBox Red", min, max); tb3.setModelBound(new BoundingBox()); tb3.setTranslation(new Vector3(0, 0, 15)); transps.attachChild(tb3); final MaterialState ms3 = new MaterialState(); ms3.setEnabled(true); ms3.setDiffuse(MaterialFace.FrontAndBack, new ColorRGBA(1, 0, 0, .5f)); ms3.setShininess(MaterialFace.FrontAndBack, 128); tb3.setRenderState(ms3); final BlendState as = new BlendState(); as.setEnabled(true); as.setBlendEnabled(true); as.setSourceFunction(SourceFunction.SourceAlpha); as.setDestinationFunction(DestinationFunction.OneMinusSourceAlpha); transps.setRenderState(as); final Vector2 center = new Vector2(_canvas.getCanvasRenderer().getCamera().getWidth() >> 1, _canvas .getCanvasRenderer().getCamera().getWidth() >> 1); final Quad q1 = new Quad("Ortho Q1", 40, 40); q1.setTranslation(new Vector3(100 + center.getX(), 100 + center.getY(), 0)); q1.getSceneHints().setOrthoOrder(1); q1.setDefaultColor(ColorRGBA.WHITE); q1.getSceneHints().setLightCombineMode(LightCombineMode.Off); orthos.attachChild(q1); final Quad q2 = new Quad("Ortho Q2", 100, 100); q2.setTranslation(new Vector3(60 + center.getX(), 60 + center.getY(), 0)); q2.getSceneHints().setOrthoOrder(5); q2.setDefaultColor(ColorRGBA.RED); q2.getSceneHints().setLightCombineMode(LightCombineMode.Off); orthos.attachChild(q2); final Quad q3 = new Quad("Ortho Q3", 120, 60); q3.setTranslation(new Vector3(-20 + center.getX(), -150 + center.getY(), 0)); q3.getSceneHints().setOrthoOrder(2); q3.setDefaultColor(ColorRGBA.BLUE); q3.getSceneHints().setLightCombineMode(LightCombineMode.Off); orthos.attachChild(q3); final ZBufferState zstate = new ZBufferState(); zstate.setWritable(false); zstate.setEnabled(false); orthos.setRenderState(zstate); orthos.setRenderState(new LightState()); _root.getSceneHints().setCullHint(CullHint.Always); opaques.getSceneHints().setCullHint(CullHint.Dynamic); transps.getSceneHints().setCullHint(CullHint.Dynamic); orthos.getSceneHints().setCullHint(CullHint.Never); } @Override protected void registerInputTriggers() { super.registerInputTriggers(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.M), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (useQueue) { transps.getSceneHints().setRenderBucketType(RenderBucketType.Skip); opaques.getSceneHints().setRenderBucketType(RenderBucketType.Skip); orthos.getSceneHints().setRenderBucketType(RenderBucketType.Skip); } else { transps.getSceneHints().setRenderBucketType(RenderBucketType.Transparent); opaques.getSceneHints().setRenderBucketType(RenderBucketType.Opaque); orthos.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); } useQueue = !useQueue; _updateTitle = true; } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { twoPass = !twoPass; _updateTitle = true; } })); } } \ No newline at end of file
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/RenderTextureCubeMapExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/RenderTextureCubeMapExample.java
index d515ed9..7d62090 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/RenderTextureCubeMapExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/RenderTextureCubeMapExample.java
@@ -106,6 +106,7 @@ public class RenderTextureCubeMapExample extends ExampleBase {
final Pyramid b = new Pyramid("box", 2, 3);
b.setRotation(new Quaternion().fromAngleNormalAxis(MathUtils.PI, Vector3.UNIT_X));
b.addController(new SpatialController<Spatial>() {
+ @Override
public void update(final double time, final Spatial caller) {
b.setTranslation(-3, 6 * MathUtils.sin(_timer.getTimeInSeconds()), 0);
};
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/StereoExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/StereoExample.java
index 7c5905d..9545330 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/StereoExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/StereoExample.java
@@ -115,6 +115,7 @@ public class StereoExample extends ExampleBase {
_root.setTranslation(0, -1, 0);
}
+ @SuppressWarnings("unused")
@Override
protected void renderExample(final Renderer renderer) {
@@ -168,6 +169,6 @@ public class StereoExample extends ExampleBase {
@Override
protected void renderDebug(final Renderer renderer) {
- // ignore. We'll call super on the individual left/right renderings.
+ // ignore. We'll call super on the individual left/right renderings.
}
}
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/Texture3DExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/Texture3DExample.java
index 9884266..b9d862f 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/Texture3DExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/Texture3DExample.java
@@ -59,6 +59,7 @@ public class Texture3DExample extends ExampleBase {
_root.attachChild(sp);
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
final Texture tex = createTexture();
tex.setEnvironmentalMapMode(EnvironmentalMapMode.ObjectLinear);
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/UpdateTextureExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/UpdateTextureExample.java
index c4b5ae3..a6f4ccd 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/UpdateTextureExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/UpdateTextureExample.java
@@ -147,6 +147,7 @@ public class UpdateTextureExample extends ExampleBase {
_root.attachChild(keyText);
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
mode++;
mode %= 3;
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/VBOSpeedExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/VBOSpeedExample.java
index c82a548..dea2858 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/VBOSpeedExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/VBOSpeedExample.java
@@ -115,6 +115,7 @@ public class VBOSpeedExample extends ExampleBase {
}
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
vboMode = (vboMode + 1) % 3;
if (vboMode == 0) {
@@ -123,6 +124,7 @@ public class VBOSpeedExample extends ExampleBase {
// run this in the opengl thread
GameTaskQueueManager.getManager(_canvas.getCanvasRenderer().getRenderContext()).render(
new Callable<Void>() {
+ @Override
public Void call() throws Exception {
final DeleteVBOsVisitor viz = new DeleteVBOsVisitor(_canvas.getCanvasRenderer()
.getRenderer());
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/ViewportExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/ViewportExample.java
index 1d827da..bb9a1c2 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/ViewportExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/ViewportExample.java
@@ -120,6 +120,7 @@ public class ViewportExample extends ExampleBase {
super.registerInputTriggers();
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.V), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
fullViewport = !fullViewport;
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExample.java
index ce1c13e..1b74add 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExample.java
@@ -111,6 +111,7 @@ public class AtlasExample extends ExampleBase {
// Pack textures into atlas
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.F), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
packIntoAtlas(boxNode);
}
@@ -118,6 +119,7 @@ public class AtlasExample extends ExampleBase {
// Combine into one mesh
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
final Mesh merged = MeshCombiner.combine(boxNode);
boxNode.detachAllChildren();
@@ -127,6 +129,7 @@ public class AtlasExample extends ExampleBase {
// Combine into one mesh
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
resetBoxes();
}
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExampleMultiTextured.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExampleMultiTextured.java
index e8e4921..356238a 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExampleMultiTextured.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/utils/atlas/AtlasExampleMultiTextured.java
@@ -112,6 +112,7 @@ public class AtlasExampleMultiTextured extends ExampleBase {
// Pack textures into atlas
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.F), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
packIntoAtlas(boxNode);
}
@@ -119,6 +120,7 @@ public class AtlasExampleMultiTextured extends ExampleBase {
// Combine into one mesh
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
final Mesh merged = MeshCombiner.combine(boxNode);
boxNode.detachAllChildren();
@@ -128,6 +130,7 @@ public class AtlasExampleMultiTextured extends ExampleBase {
// Combine into one mesh
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
resetBoxes();
}
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ArrayTerrainExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ArrayTerrainExample.java
index bdebb18..03db913 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ArrayTerrainExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ArrayTerrainExample.java
@@ -1 +1 @@
-/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.terrain; import java.util.concurrent.Callable; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.terrain.client.Terrain; import com.ardor3d.extension.terrain.client.TerrainBuilder; import com.ardor3d.extension.terrain.client.TerrainDataProvider; import com.ardor3d.extension.terrain.heightmap.MidPointHeightMapGenerator; import com.ardor3d.extension.terrain.providers.array.ArrayTerrainDataProvider; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.intersection.PickingUtil; import com.ardor3d.intersection.PrimitivePickResults; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Matrix3; import com.ardor3d.math.Ray3; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.scenegraph.Mesh; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Box; import com.ardor3d.scenegraph.shape.Sphere; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.GameTaskQueue; import com.ardor3d.util.GameTaskQueueManager; import com.ardor3d.util.ReadOnlyTimer; /** * Example showing the Geometry Clipmap Terrain system with 'MegaTextures' where the terrain data is provided from a * float array. Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.ArrayTerrainExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_ArrayTerrainExample.jpg", // maxHeapMemory = 128) public class ArrayTerrainExample extends ExampleBase { private boolean updateTerrain = true; private final float farPlane = 8000.0f; private Terrain terrain; private final Sphere sphere = new Sphere("sp", 16, 16, 1); private final Mesh arrow = new Box("normal", new Vector3(-0.2, -0.2, 0), new Vector3(0.2, 0.2, 4)); private final Ray3 pickRay = new Ray3(); private boolean groundCamera = false; private Camera terrainCamera; /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[5]; private double counter = 0; private int frames = 0; public static void main(final String[] args) { ExampleBase.start(ArrayTerrainExample.class); } @Override protected void updateExample(final ReadOnlyTimer timer) { counter += timer.getTimePerFrame(); frames++; if (counter > 1) { final double fps = frames / counter; counter = 0; frames = 0; System.out.printf("%7.1f FPS\n", fps); } final Camera camera = _canvas.getCanvasRenderer().getCamera(); // Make sure camera is above terrain final double height = terrain.getHeightAt(camera.getLocation().getX(), camera.getLocation().getZ()); if (height > -Float.MAX_VALUE && (groundCamera || camera.getLocation().getY() < height + 3)) { camera.setLocation(new Vector3(camera.getLocation().getX(), height + 3, camera.getLocation().getZ())); } if (updateTerrain) { terrainCamera.set(camera); } // if we're picking... if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { // Set up our pick ray pickRay.setOrigin(camera.getLocation()); pickRay.setDirection(camera.getDirection()); // do pick and move the sphere final PrimitivePickResults pickResults = new PrimitivePickResults(); pickResults.setCheckDistance(true); PickingUtil.findPick(_root, pickRay, pickResults); if (pickResults.getNumber() != 0) { final Vector3 intersectionPoint = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionPoint(0); sphere.setTranslation(intersectionPoint); final Vector3 intersectionNormal = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionNormal(0); final Matrix3 rotation = new Matrix3(); rotation.lookAt(intersectionNormal, Vector3.UNIT_Z); arrow.setRotation(rotation); arrow.setTranslation(intersectionPoint); } } } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Terrain Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(0, 300, 0)); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(1, 300, 1), Vector3.UNIT_Y); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 70.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / _canvas.getCanvasRenderer().getCamera().getHeight(), 1.0f, farPlane); final CanvasRenderer canvasRenderer = _canvas.getCanvasRenderer(); final RenderContext renderContext = canvasRenderer.getRenderContext(); final Renderer renderer = canvasRenderer.getRenderer(); GameTaskQueueManager.getManager(renderContext).getQueue(GameTaskQueue.RENDER).enqueue(new Callable<Void>() { @Override public Void call() throws Exception { renderer.setBackgroundColor(ColorRGBA.GRAY); return null; } }); _controlHandle.setMoveSpeed(200); setupDefaultStates(); sphere.getSceneHints().setAllPickingHints(false); sphere.getSceneHints().setCullHint(CullHint.Always); _root.attachChild(sphere); arrow.getSceneHints().setAllPickingHints(false); arrow.getSceneHints().setCullHint(CullHint.Always); _root.attachChild(arrow); try { // Keep a separate camera to be able to freeze terrain update final Camera camera = _canvas.getCanvasRenderer().getCamera(); terrainCamera = new Camera(camera); final int SIZE = 2048; final MidPointHeightMapGenerator raw = new MidPointHeightMapGenerator(SIZE, 0.6f); raw.setHeightRange(0.2f); final float[] heightMap = raw.getHeightData(); final TerrainDataProvider terrainDataProvider = new ArrayTerrainDataProvider(heightMap, SIZE, new Vector3( 1, 300, 1)); terrain = new TerrainBuilder(terrainDataProvider, terrainCamera).setShowDebugPanels(true).build(); _root.attachChild(terrain); } catch (final Exception ex1) { System.out.println("Problem setting up terrain..."); ex1.printStackTrace(); } // Setup labels for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { updateTerrain = !updateTerrain; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(5); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(50); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(400); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(1000); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { groundCamera = !groundCamera; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.P), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { sphere.getSceneHints().setCullHint(CullHint.Always); arrow.getSceneHints().setCullHint(CullHint.Always); } else if (sphere.getSceneHints().getCullHint() == CullHint.Always) { sphere.getSceneHints().setCullHint(CullHint.Dynamic); arrow.getSceneHints().setCullHint(CullHint.Dynamic); } updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setShowDebug(!terrain.getTextureClipmap().isShowDebug()); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.reloadShader(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() / 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() * 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SEVEN), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX() + 500.0, camera.getLocation().getY(), camera .getLocation().getZ()); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.EIGHT), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX() - 500.0, camera.getLocation().getY(), camera .getLocation().getZ()); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() + 1500.0); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() - 1500.0); } })); } private void setupDefaultStates() { _lightState.detachAll(); final DirectionalLight dLight = new DirectionalLight(); dLight.setEnabled(true); dLight.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); dLight.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); dLight.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); dLight.setDirection(new Vector3(-1, -1, -1).normalizeLocal()); _lightState.attach(dLight); _lightState.setEnabled(true); final CullState cs = new CullState(); cs.setEnabled(true); cs.setCullFace(CullState.Face.Back); _root.setRenderState(cs); final FogState fs = new FogState(); fs.setStart(farPlane / 2.0f); fs.setEnd(farPlane); fs.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fs.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fs); } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[1/2/3] Moving speed: " + _controlHandle.getMoveSpeed() * 3.6 + " km/h"); _exampleInfo[1].setText("[P] Do picking: " + (sphere.getSceneHints().getCullHint() == CullHint.Dynamic)); _exampleInfo[2].setText("[SPACE] Toggle fly/walk: " + (groundCamera ? "walk" : "fly")); _exampleInfo[3].setText("[J] Regenerate heightmap/texture"); _exampleInfo[4].setText("[U] Freeze terrain(debug): " + !updateTerrain); } } \ No newline at end of file
+/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.terrain; import java.util.concurrent.Callable; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.terrain.client.Terrain; import com.ardor3d.extension.terrain.client.TerrainBuilder; import com.ardor3d.extension.terrain.client.TerrainDataProvider; import com.ardor3d.extension.terrain.heightmap.MidPointHeightMapGenerator; import com.ardor3d.extension.terrain.providers.array.ArrayTerrainDataProvider; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.intersection.PickingUtil; import com.ardor3d.intersection.PrimitivePickResults; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Matrix3; import com.ardor3d.math.Ray3; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.scenegraph.Mesh; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Box; import com.ardor3d.scenegraph.shape.Sphere; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.GameTaskQueue; import com.ardor3d.util.GameTaskQueueManager; import com.ardor3d.util.ReadOnlyTimer; /** * Example showing the Geometry Clipmap Terrain system with 'MegaTextures' where the terrain data is provided from a * float array. Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.ArrayTerrainExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_ArrayTerrainExample.jpg", // maxHeapMemory = 128) public class ArrayTerrainExample extends ExampleBase { private boolean updateTerrain = true; private final float farPlane = 8000.0f; private Terrain terrain; private final Sphere sphere = new Sphere("sp", 16, 16, 1); private final Mesh arrow = new Box("normal", new Vector3(-0.2, -0.2, 0), new Vector3(0.2, 0.2, 4)); private final Ray3 pickRay = new Ray3(); private boolean groundCamera = false; private Camera terrainCamera; /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[5]; private double counter = 0; private int frames = 0; public static void main(final String[] args) { ExampleBase.start(ArrayTerrainExample.class); } @Override protected void updateExample(final ReadOnlyTimer timer) { counter += timer.getTimePerFrame(); frames++; if (counter > 1) { final double fps = frames / counter; counter = 0; frames = 0; System.out.printf("%7.1f FPS\n", fps); } final Camera camera = _canvas.getCanvasRenderer().getCamera(); // Make sure camera is above terrain final double height = terrain.getHeightAt(camera.getLocation().getX(), camera.getLocation().getZ()); if (height > -Float.MAX_VALUE && (groundCamera || camera.getLocation().getY() < height + 3)) { camera.setLocation(new Vector3(camera.getLocation().getX(), height + 3, camera.getLocation().getZ())); } if (updateTerrain) { terrainCamera.set(camera); } // if we're picking... if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { // Set up our pick ray pickRay.setOrigin(camera.getLocation()); pickRay.setDirection(camera.getDirection()); // do pick and move the sphere final PrimitivePickResults pickResults = new PrimitivePickResults(); pickResults.setCheckDistance(true); PickingUtil.findPick(_root, pickRay, pickResults); if (pickResults.getNumber() != 0) { final Vector3 intersectionPoint = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionPoint(0); sphere.setTranslation(intersectionPoint); final Vector3 intersectionNormal = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionNormal(0); final Matrix3 rotation = new Matrix3(); rotation.lookAt(intersectionNormal, Vector3.UNIT_Z); arrow.setRotation(rotation); arrow.setTranslation(intersectionPoint); } } } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Terrain Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(0, 300, 0)); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(1, 300, 1), Vector3.UNIT_Y); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 70.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / _canvas.getCanvasRenderer().getCamera().getHeight(), 1.0f, farPlane); final CanvasRenderer canvasRenderer = _canvas.getCanvasRenderer(); final RenderContext renderContext = canvasRenderer.getRenderContext(); final Renderer renderer = canvasRenderer.getRenderer(); GameTaskQueueManager.getManager(renderContext).getQueue(GameTaskQueue.RENDER).enqueue(new Callable<Void>() { @Override public Void call() throws Exception { renderer.setBackgroundColor(ColorRGBA.GRAY); return null; } }); _controlHandle.setMoveSpeed(200); setupDefaultStates(); sphere.getSceneHints().setAllPickingHints(false); sphere.getSceneHints().setCullHint(CullHint.Always); _root.attachChild(sphere); arrow.getSceneHints().setAllPickingHints(false); arrow.getSceneHints().setCullHint(CullHint.Always); _root.attachChild(arrow); try { // Keep a separate camera to be able to freeze terrain update final Camera camera = _canvas.getCanvasRenderer().getCamera(); terrainCamera = new Camera(camera); final int SIZE = 2048; final MidPointHeightMapGenerator raw = new MidPointHeightMapGenerator(SIZE, 0.6f); raw.setHeightRange(0.2f); final float[] heightMap = raw.getHeightData(); final TerrainDataProvider terrainDataProvider = new ArrayTerrainDataProvider(heightMap, SIZE, new Vector3( 1, 300, 1)); terrain = new TerrainBuilder(terrainDataProvider, terrainCamera).setShowDebugPanels(true).build(); _root.attachChild(terrain); } catch (final Exception ex1) { System.out.println("Problem setting up terrain..."); ex1.printStackTrace(); } // Setup labels for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { updateTerrain = !updateTerrain; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(5); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(50); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(400); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(1000); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { groundCamera = !groundCamera; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.P), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { sphere.getSceneHints().setCullHint(CullHint.Always); arrow.getSceneHints().setCullHint(CullHint.Always); } else if (sphere.getSceneHints().getCullHint() == CullHint.Always) { sphere.getSceneHints().setCullHint(CullHint.Dynamic); arrow.getSceneHints().setCullHint(CullHint.Dynamic); } updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setShowDebug(!terrain.getTextureClipmap().isShowDebug()); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.reloadShader(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() / 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() * 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SEVEN), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX() + 500.0, camera.getLocation().getY(), camera .getLocation().getZ()); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.EIGHT), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX() - 500.0, camera.getLocation().getY(), camera .getLocation().getZ()); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() + 1500.0); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() - 1500.0); } })); } private void setupDefaultStates() { _lightState.detachAll(); final DirectionalLight dLight = new DirectionalLight(); dLight.setEnabled(true); dLight.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); dLight.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); dLight.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); dLight.setDirection(new Vector3(-1, -1, -1).normalizeLocal()); _lightState.attach(dLight); _lightState.setEnabled(true); final CullState cs = new CullState(); cs.setEnabled(true); cs.setCullFace(CullState.Face.Back); _root.setRenderState(cs); final FogState fs = new FogState(); fs.setStart(farPlane / 2.0f); fs.setEnd(farPlane); fs.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fs.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fs); } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[1/2/3] Moving speed: " + _controlHandle.getMoveSpeed() * 3.6 + " km/h"); _exampleInfo[1].setText("[P] Do picking: " + (sphere.getSceneHints().getCullHint() == CullHint.Dynamic)); _exampleInfo[2].setText("[SPACE] Toggle fly/walk: " + (groundCamera ? "walk" : "fly")); _exampleInfo[3].setText("[J] Regenerate heightmap/texture"); _exampleInfo[4].setText("[U] Freeze terrain(debug): " + !updateTerrain); } } \ No newline at end of file
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ImageMapTerrainExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ImageMapTerrainExample.java
index 02a004e..bd00f89 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ImageMapTerrainExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ImageMapTerrainExample.java
@@ -1 +1 @@
-/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.terrain; import java.awt.image.BufferedImage; import java.util.concurrent.Callable; import javax.imageio.ImageIO; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.terrain.client.Terrain; import com.ardor3d.extension.terrain.client.TerrainBuilder; import com.ardor3d.extension.terrain.client.TerrainDataProvider; import com.ardor3d.extension.terrain.heightmap.ImageHeightMap; import com.ardor3d.extension.terrain.providers.array.ArrayTerrainDataProvider; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.image.Image; import com.ardor3d.image.util.awt.AWTImageLoader; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.intersection.PickingUtil; import com.ardor3d.intersection.PrimitivePickResults; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Matrix3; import com.ardor3d.math.Ray3; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.scenegraph.Mesh; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Box; import com.ardor3d.scenegraph.shape.Sphere; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.GameTaskQueue; import com.ardor3d.util.GameTaskQueueManager; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.resource.ResourceLocatorTool; /** * Example showing the Geometry Clipmap Terrain system with 'MegaTextures' where the terrain data is provided from a * float array populated from a heightmap generated from an Image. Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.ImageMapTerrainExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_ImageMapTerrainExample.jpg", // maxHeapMemory = 128) public class ImageMapTerrainExample extends ExampleBase { private boolean updateTerrain = true; private final float farPlane = 8000.0f; private Terrain terrain; private final Sphere sphere = new Sphere("sp", 16, 16, 1); private final Mesh arrow = new Box("normal", new Vector3(-0.2, -0.2, 0), new Vector3(0.2, 0.2, 4)); private final Ray3 pickRay = new Ray3(); private boolean groundCamera = false; private Camera terrainCamera; /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[5]; private double counter = 0; private int frames = 0; public static void main(final String[] args) { ExampleBase.start(ImageMapTerrainExample.class); } @Override protected void updateExample(final ReadOnlyTimer timer) { counter += timer.getTimePerFrame(); frames++; if (counter > 1) { final double fps = frames / counter; counter = 0; frames = 0; System.out.printf("%7.1f FPS\n", fps); } final Camera camera = _canvas.getCanvasRenderer().getCamera(); // Make sure camera is above terrain final double height = terrain.getHeightAt(camera.getLocation().getX(), camera.getLocation().getZ()); if (height > -Float.MAX_VALUE && (groundCamera || camera.getLocation().getY() < height + 3)) { camera.setLocation(new Vector3(camera.getLocation().getX(), height + 3, camera.getLocation().getZ())); } if (updateTerrain) { terrainCamera.set(camera); } // if we're picking... if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { // Set up our pick ray pickRay.setOrigin(camera.getLocation()); pickRay.setDirection(camera.getDirection()); // do pick and move the sphere final PrimitivePickResults pickResults = new PrimitivePickResults(); pickResults.setCheckDistance(true); PickingUtil.findPick(_root, pickRay, pickResults); if (pickResults.getNumber() != 0) { final Vector3 intersectionPoint = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionPoint(0); sphere.setTranslation(intersectionPoint); final Vector3 intersectionNormal = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionNormal(0); final Matrix3 rotation = new Matrix3(); rotation.lookAt(intersectionNormal, Vector3.UNIT_Z); arrow.setRotation(rotation); arrow.setTranslation(intersectionPoint); } } } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Terrain Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(0, 300, 0)); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(1, 300, 1), Vector3.UNIT_Y); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 70.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / _canvas.getCanvasRenderer().getCamera().getHeight(), 1.0f, farPlane); final CanvasRenderer canvasRenderer = _canvas.getCanvasRenderer(); final RenderContext renderContext = canvasRenderer.getRenderContext(); final Renderer renderer = canvasRenderer.getRenderer(); GameTaskQueueManager.getManager(renderContext).getQueue(GameTaskQueue.RENDER).enqueue(new Callable<Void>() { @Override public Void call() throws Exception { renderer.setBackgroundColor(ColorRGBA.GRAY); return null; } }); _controlHandle.setMoveSpeed(200); setupDefaultStates(); sphere.getSceneHints().setAllPickingHints(false); sphere.getSceneHints().setCullHint(CullHint.Always); _root.attachChild(sphere); arrow.getSceneHints().setAllPickingHints(false); arrow.getSceneHints().setCullHint(CullHint.Always); _root.attachChild(arrow); try { // Keep a separate camera to be able to freeze terrain update final Camera camera = _canvas.getCanvasRenderer().getCamera(); terrainCamera = new Camera(camera); // IMAGE LOADING AND CONVERSION TO HEIGHTMAP DONE HERE final BufferedImage logo = ImageIO.read(ResourceLocatorTool.getClassPathResource( ImageMapTerrainExample.class, "com/ardor3d/example/media/images/water/dudvmap.png")); final Image ardorImage = AWTImageLoader.makeArdor3dImage(logo, false); final float[] heightMap = ImageHeightMap.generateHeightMap(ardorImage, 0.1f, .3f); // END OF IMAGE CONVERSION final int SIZE = ardorImage.getWidth(); final TerrainDataProvider terrainDataProvider = new ArrayTerrainDataProvider(heightMap, SIZE, new Vector3( 3, 50, 3)); terrain = new TerrainBuilder(terrainDataProvider, terrainCamera).setShowDebugPanels(true).build(); _root.attachChild(terrain); } catch (final Exception ex1) { System.out.println("Problem setting up terrain..."); ex1.printStackTrace(); } // Setup labels for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { updateTerrain = !updateTerrain; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(5); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(50); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(400); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(1000); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { groundCamera = !groundCamera; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.P), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { sphere.getSceneHints().setCullHint(CullHint.Always); arrow.getSceneHints().setCullHint(CullHint.Always); } else if (sphere.getSceneHints().getCullHint() == CullHint.Always) { sphere.getSceneHints().setCullHint(CullHint.Dynamic); arrow.getSceneHints().setCullHint(CullHint.Dynamic); } updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setShowDebug(!terrain.getTextureClipmap().isShowDebug()); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.reloadShader(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() / 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() * 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SEVEN), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX() + 500.0, camera.getLocation().getY(), camera .getLocation().getZ()); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.EIGHT), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX() - 500.0, camera.getLocation().getY(), camera .getLocation().getZ()); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() + 1500.0); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() - 1500.0); } })); } private void setupDefaultStates() { _lightState.detachAll(); final DirectionalLight dLight = new DirectionalLight(); dLight.setEnabled(true); dLight.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); dLight.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); dLight.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); dLight.setDirection(new Vector3(-1, -1, -1).normalizeLocal()); _lightState.attach(dLight); _lightState.setEnabled(true); final CullState cs = new CullState(); cs.setEnabled(true); cs.setCullFace(CullState.Face.Back); _root.setRenderState(cs); final FogState fs = new FogState(); fs.setStart(farPlane / 2.0f); fs.setEnd(farPlane); fs.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fs.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fs); } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[1/2/3] Moving speed: " + _controlHandle.getMoveSpeed() * 3.6 + " km/h"); _exampleInfo[1].setText("[P] Do picking: " + (sphere.getSceneHints().getCullHint() == CullHint.Dynamic)); _exampleInfo[2].setText("[SPACE] Toggle fly/walk: " + (groundCamera ? "walk" : "fly")); _exampleInfo[3].setText("[J] Regenerate heightmap/texture"); _exampleInfo[4].setText("[U] Freeze terrain(debug): " + !updateTerrain); } } \ No newline at end of file
+/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.terrain; import java.awt.image.BufferedImage; import java.util.concurrent.Callable; import javax.imageio.ImageIO; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.terrain.client.Terrain; import com.ardor3d.extension.terrain.client.TerrainBuilder; import com.ardor3d.extension.terrain.client.TerrainDataProvider; import com.ardor3d.extension.terrain.heightmap.ImageHeightMap; import com.ardor3d.extension.terrain.providers.array.ArrayTerrainDataProvider; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.image.Image; import com.ardor3d.image.util.awt.AWTImageLoader; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.intersection.PickingUtil; import com.ardor3d.intersection.PrimitivePickResults; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Matrix3; import com.ardor3d.math.Ray3; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.scenegraph.Mesh; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Box; import com.ardor3d.scenegraph.shape.Sphere; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.GameTaskQueue; import com.ardor3d.util.GameTaskQueueManager; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.resource.ResourceLocatorTool; /** * Example showing the Geometry Clipmap Terrain system with 'MegaTextures' where the terrain data is provided from a * float array populated from a heightmap generated from an Image. Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.ImageMapTerrainExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_ImageMapTerrainExample.jpg", // maxHeapMemory = 128) public class ImageMapTerrainExample extends ExampleBase { private boolean updateTerrain = true; private final float farPlane = 8000.0f; private Terrain terrain; private final Sphere sphere = new Sphere("sp", 16, 16, 1); private final Mesh arrow = new Box("normal", new Vector3(-0.2, -0.2, 0), new Vector3(0.2, 0.2, 4)); private final Ray3 pickRay = new Ray3(); private boolean groundCamera = false; private Camera terrainCamera; /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[5]; private double counter = 0; private int frames = 0; public static void main(final String[] args) { ExampleBase.start(ImageMapTerrainExample.class); } @Override protected void updateExample(final ReadOnlyTimer timer) { counter += timer.getTimePerFrame(); frames++; if (counter > 1) { final double fps = frames / counter; counter = 0; frames = 0; System.out.printf("%7.1f FPS\n", fps); } final Camera camera = _canvas.getCanvasRenderer().getCamera(); // Make sure camera is above terrain final double height = terrain.getHeightAt(camera.getLocation().getX(), camera.getLocation().getZ()); if (height > -Float.MAX_VALUE && (groundCamera || camera.getLocation().getY() < height + 3)) { camera.setLocation(new Vector3(camera.getLocation().getX(), height + 3, camera.getLocation().getZ())); } if (updateTerrain) { terrainCamera.set(camera); } // if we're picking... if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { // Set up our pick ray pickRay.setOrigin(camera.getLocation()); pickRay.setDirection(camera.getDirection()); // do pick and move the sphere final PrimitivePickResults pickResults = new PrimitivePickResults(); pickResults.setCheckDistance(true); PickingUtil.findPick(_root, pickRay, pickResults); if (pickResults.getNumber() != 0) { final Vector3 intersectionPoint = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionPoint(0); sphere.setTranslation(intersectionPoint); final Vector3 intersectionNormal = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionNormal(0); final Matrix3 rotation = new Matrix3(); rotation.lookAt(intersectionNormal, Vector3.UNIT_Z); arrow.setRotation(rotation); arrow.setTranslation(intersectionPoint); } } } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Terrain Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(0, 300, 0)); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(1, 300, 1), Vector3.UNIT_Y); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 70.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / _canvas.getCanvasRenderer().getCamera().getHeight(), 1.0f, farPlane); final CanvasRenderer canvasRenderer = _canvas.getCanvasRenderer(); final RenderContext renderContext = canvasRenderer.getRenderContext(); final Renderer renderer = canvasRenderer.getRenderer(); GameTaskQueueManager.getManager(renderContext).getQueue(GameTaskQueue.RENDER).enqueue(new Callable<Void>() { @Override public Void call() throws Exception { renderer.setBackgroundColor(ColorRGBA.GRAY); return null; } }); _controlHandle.setMoveSpeed(200); setupDefaultStates(); sphere.getSceneHints().setAllPickingHints(false); sphere.getSceneHints().setCullHint(CullHint.Always); _root.attachChild(sphere); arrow.getSceneHints().setAllPickingHints(false); arrow.getSceneHints().setCullHint(CullHint.Always); _root.attachChild(arrow); try { // Keep a separate camera to be able to freeze terrain update final Camera camera = _canvas.getCanvasRenderer().getCamera(); terrainCamera = new Camera(camera); // IMAGE LOADING AND CONVERSION TO HEIGHTMAP DONE HERE final BufferedImage logo = ImageIO.read(ResourceLocatorTool.getClassPathResource( ImageMapTerrainExample.class, "com/ardor3d/example/media/images/water/dudvmap.png")); final Image ardorImage = AWTImageLoader.makeArdor3dImage(logo, false); final float[] heightMap = ImageHeightMap.generateHeightMap(ardorImage, 0.1f, .3f); // END OF IMAGE CONVERSION final int SIZE = ardorImage.getWidth(); final TerrainDataProvider terrainDataProvider = new ArrayTerrainDataProvider(heightMap, SIZE, new Vector3( 3, 50, 3)); terrain = new TerrainBuilder(terrainDataProvider, terrainCamera).setShowDebugPanels(true).build(); _root.attachChild(terrain); } catch (final Exception ex1) { System.out.println("Problem setting up terrain..."); ex1.printStackTrace(); } // Setup labels for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { updateTerrain = !updateTerrain; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(5); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(50); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(400); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(1000); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { groundCamera = !groundCamera; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.P), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { sphere.getSceneHints().setCullHint(CullHint.Always); arrow.getSceneHints().setCullHint(CullHint.Always); } else if (sphere.getSceneHints().getCullHint() == CullHint.Always) { sphere.getSceneHints().setCullHint(CullHint.Dynamic); arrow.getSceneHints().setCullHint(CullHint.Dynamic); } updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setShowDebug(!terrain.getTextureClipmap().isShowDebug()); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.reloadShader(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() / 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() * 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SEVEN), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX() + 500.0, camera.getLocation().getY(), camera .getLocation().getZ()); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.EIGHT), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX() - 500.0, camera.getLocation().getY(), camera .getLocation().getZ()); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() + 1500.0); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() - 1500.0); } })); } private void setupDefaultStates() { _lightState.detachAll(); final DirectionalLight dLight = new DirectionalLight(); dLight.setEnabled(true); dLight.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); dLight.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); dLight.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); dLight.setDirection(new Vector3(-1, -1, -1).normalizeLocal()); _lightState.attach(dLight); _lightState.setEnabled(true); final CullState cs = new CullState(); cs.setEnabled(true); cs.setCullFace(CullState.Face.Back); _root.setRenderState(cs); final FogState fs = new FogState(); fs.setStart(farPlane / 2.0f); fs.setEnd(farPlane); fs.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fs.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fs); } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[1/2/3] Moving speed: " + _controlHandle.getMoveSpeed() * 3.6 + " km/h"); _exampleInfo[1].setText("[P] Do picking: " + (sphere.getSceneHints().getCullHint() == CullHint.Dynamic)); _exampleInfo[2].setText("[SPACE] Toggle fly/walk: " + (groundCamera ? "walk" : "fly")); _exampleInfo[3].setText("[J] Regenerate heightmap/texture"); _exampleInfo[4].setText("[U] Freeze terrain(debug): " + !updateTerrain); } } \ No newline at end of file
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/InMemoryTerrainExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/InMemoryTerrainExample.java
index 531ffd4..442df7e 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/InMemoryTerrainExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/InMemoryTerrainExample.java
@@ -1 +1 @@
-/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.terrain; import java.util.concurrent.Callable; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.terrain.client.Terrain; import com.ardor3d.extension.terrain.client.TerrainBuilder; import com.ardor3d.extension.terrain.client.TerrainDataProvider; import com.ardor3d.extension.terrain.providers.inmemory.InMemoryTerrainDataProvider; import com.ardor3d.extension.terrain.providers.inmemory.data.InMemoryTerrainData; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.image.Texture; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.intersection.PickingUtil; import com.ardor3d.intersection.PrimitivePickResults; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Ray3; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.extension.Skybox; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Sphere; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.GameTaskQueue; import com.ardor3d.util.GameTaskQueueManager; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.TextureManager; /** * Example showing the Geometry Clipmap Terrain system with 'MegaTextures' streaming from an in-memory data source. * Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.InMemoryTerrainExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_InMemoryTerrainExample.jpg", // maxHeapMemory = 128) public class InMemoryTerrainExample extends ExampleBase { private boolean updateTerrain = true; private final float farPlane = 8000.0f; private Terrain terrain; private final Sphere sphere = new Sphere("sp", 16, 16, 1); private final Ray3 pickRay = new Ray3(); private boolean groundCamera = false; private Camera terrainCamera; private Skybox skybox; private InMemoryTerrainData inMemoryTerrainData; /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[6]; public static void main(final String[] args) { ExampleBase.start(InMemoryTerrainExample.class); } @Override protected void updateExample(final ReadOnlyTimer timer) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); // Make sure camera is above terrain final double height = terrain.getHeightAt(camera.getLocation().getX(), camera.getLocation().getZ()); if (height > -Float.MAX_VALUE && (groundCamera || camera.getLocation().getY() < height + 3)) { camera.setLocation(new Vector3(camera.getLocation().getX(), height + 3, camera.getLocation().getZ())); } if (updateTerrain) { terrainCamera.set(camera); } skybox.setTranslation(camera.getLocation()); // if we're picking... if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { // Set up our pick ray pickRay.setOrigin(camera.getLocation()); pickRay.setDirection(camera.getDirection()); // do pick and move the sphere final PrimitivePickResults pickResults = new PrimitivePickResults(); pickResults.setCheckDistance(true); PickingUtil.findPick(_root, pickRay, pickResults); if (pickResults.getNumber() != 0) { final Vector3 intersectionPoint = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionPoint(0); sphere.setTranslation(intersectionPoint); // XXX: maybe change the color of the ball for valid vs. invalid? } } } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Terrain Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(0, 300, 0)); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(1, 300, 1), Vector3.UNIT_Y); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 70.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / _canvas.getCanvasRenderer().getCamera().getHeight(), 1.0f, farPlane); final CanvasRenderer canvasRenderer = _canvas.getCanvasRenderer(); final RenderContext renderContext = canvasRenderer.getRenderContext(); final Renderer renderer = canvasRenderer.getRenderer(); GameTaskQueueManager.getManager(renderContext).getQueue(GameTaskQueue.RENDER).enqueue(new Callable<Void>() { @Override public Void call() throws Exception { renderer.setBackgroundColor(ColorRGBA.GRAY); return null; } }); _controlHandle.setMoveSpeed(200); setupDefaultStates(); sphere.getSceneHints().setAllPickingHints(false); sphere.getSceneHints().setCullHint(CullHint.Always); _root.attachChild(sphere); try { // Keep a separate camera to be able to freeze terrain update final Camera camera = _canvas.getCanvasRenderer().getCamera(); terrainCamera = new Camera(camera); inMemoryTerrainData = new InMemoryTerrainData(2048, 9, 128, new Vector3(1, 200, 1)); final TerrainDataProvider terrainDataProvider = new InMemoryTerrainDataProvider(inMemoryTerrainData, true); terrain = new TerrainBuilder(terrainDataProvider, terrainCamera).setShowDebugPanels(true).build(); _root.attachChild(terrain); } catch (final Exception ex1) { System.out.println("Problem setting up terrain..."); ex1.printStackTrace(); } skybox = buildSkyBox(); skybox.getSceneHints().setAllPickingHints(false); _root.attachChild(skybox); // Setup labels for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.V), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (!inMemoryTerrainData.isRunning()) { inMemoryTerrainData.startUpdates(); } else { inMemoryTerrainData.stopUpdates(); } updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { updateTerrain = !updateTerrain; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(5); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(50); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(400); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(1000); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { groundCamera = !groundCamera; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.P), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { sphere.getSceneHints().setCullHint(CullHint.Always); } else if (sphere.getSceneHints().getCullHint() == CullHint.Always) { sphere.getSceneHints().setCullHint(CullHint.Dynamic); } updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setShowDebug(!terrain.getTextureClipmap().isShowDebug()); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.reloadShader(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() / 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() * 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SEVEN), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX() + 500.0, camera.getLocation().getY(), camera .getLocation().getZ()); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.EIGHT), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX() - 500.0, camera.getLocation().getY(), camera .getLocation().getZ()); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() + 1500.0); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() - 1500.0); } })); } private void setupDefaultStates() { _lightState.detachAll(); final DirectionalLight dLight = new DirectionalLight(); dLight.setEnabled(true); dLight.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); dLight.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); dLight.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); dLight.setDirection(new Vector3(-1, -1, -1).normalizeLocal()); _lightState.attach(dLight); _lightState.setEnabled(true); final CullState cs = new CullState(); cs.setEnabled(true); cs.setCullFace(CullState.Face.Back); _root.setRenderState(cs); final FogState fs = new FogState(); fs.setStart(farPlane / 2.0f); fs.setEnd(farPlane); fs.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fs.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fs); } /** * Builds the sky box. */ private Skybox buildSkyBox() { final Skybox skybox = new Skybox("skybox", 10, 10, 10); final String dir = "images/skybox/"; final Texture north = TextureManager .load(dir + "1.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture south = TextureManager .load(dir + "3.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture east = TextureManager.load(dir + "2.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture west = TextureManager.load(dir + "4.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture up = TextureManager.load(dir + "6.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture down = TextureManager.load(dir + "5.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); skybox.setTexture(Skybox.Face.North, north); skybox.setTexture(Skybox.Face.West, west); skybox.setTexture(Skybox.Face.South, south); skybox.setTexture(Skybox.Face.East, east); skybox.setTexture(Skybox.Face.Up, up); skybox.setTexture(Skybox.Face.Down, down); return skybox; } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[1/2/3] Moving speed: " + _controlHandle.getMoveSpeed() * 3.6 + " km/h"); _exampleInfo[1].setText("[P] Do picking: " + (sphere.getSceneHints().getCullHint() == CullHint.Dynamic)); _exampleInfo[2].setText("[SPACE] Toggle fly/walk: " + (groundCamera ? "walk" : "fly")); _exampleInfo[3].setText("[J] Regenerate heightmap/texture"); _exampleInfo[4].setText("[U] Freeze terrain(debug): " + !updateTerrain); _exampleInfo[5].setText("[V] Updating terrain data: " + inMemoryTerrainData.isRunning()); } } \ No newline at end of file
+/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.terrain; import java.util.concurrent.Callable; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.terrain.client.Terrain; import com.ardor3d.extension.terrain.client.TerrainBuilder; import com.ardor3d.extension.terrain.client.TerrainDataProvider; import com.ardor3d.extension.terrain.providers.inmemory.InMemoryTerrainDataProvider; import com.ardor3d.extension.terrain.providers.inmemory.data.InMemoryTerrainData; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.image.Texture; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.intersection.PickingUtil; import com.ardor3d.intersection.PrimitivePickResults; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Ray3; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.extension.Skybox; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Sphere; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.GameTaskQueue; import com.ardor3d.util.GameTaskQueueManager; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.TextureManager; /** * Example showing the Geometry Clipmap Terrain system with 'MegaTextures' streaming from an in-memory data source. * Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.InMemoryTerrainExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_InMemoryTerrainExample.jpg", // maxHeapMemory = 128) public class InMemoryTerrainExample extends ExampleBase { private boolean updateTerrain = true; private final float farPlane = 8000.0f; private Terrain terrain; private final Sphere sphere = new Sphere("sp", 16, 16, 1); private final Ray3 pickRay = new Ray3(); private boolean groundCamera = false; private Camera terrainCamera; private Skybox skybox; private InMemoryTerrainData inMemoryTerrainData; /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[6]; public static void main(final String[] args) { ExampleBase.start(InMemoryTerrainExample.class); } @Override protected void updateExample(final ReadOnlyTimer timer) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); // Make sure camera is above terrain final double height = terrain.getHeightAt(camera.getLocation().getX(), camera.getLocation().getZ()); if (height > -Float.MAX_VALUE && (groundCamera || camera.getLocation().getY() < height + 3)) { camera.setLocation(new Vector3(camera.getLocation().getX(), height + 3, camera.getLocation().getZ())); } if (updateTerrain) { terrainCamera.set(camera); } skybox.setTranslation(camera.getLocation()); // if we're picking... if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { // Set up our pick ray pickRay.setOrigin(camera.getLocation()); pickRay.setDirection(camera.getDirection()); // do pick and move the sphere final PrimitivePickResults pickResults = new PrimitivePickResults(); pickResults.setCheckDistance(true); PickingUtil.findPick(_root, pickRay, pickResults); if (pickResults.getNumber() != 0) { final Vector3 intersectionPoint = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionPoint(0); sphere.setTranslation(intersectionPoint); // XXX: maybe change the color of the ball for valid vs. invalid? } } } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Terrain Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(0, 300, 0)); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(1, 300, 1), Vector3.UNIT_Y); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 70.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / _canvas.getCanvasRenderer().getCamera().getHeight(), 1.0f, farPlane); final CanvasRenderer canvasRenderer = _canvas.getCanvasRenderer(); final RenderContext renderContext = canvasRenderer.getRenderContext(); final Renderer renderer = canvasRenderer.getRenderer(); GameTaskQueueManager.getManager(renderContext).getQueue(GameTaskQueue.RENDER).enqueue(new Callable<Void>() { @Override public Void call() throws Exception { renderer.setBackgroundColor(ColorRGBA.GRAY); return null; } }); _controlHandle.setMoveSpeed(200); setupDefaultStates(); sphere.getSceneHints().setAllPickingHints(false); sphere.getSceneHints().setCullHint(CullHint.Always); _root.attachChild(sphere); try { // Keep a separate camera to be able to freeze terrain update final Camera camera = _canvas.getCanvasRenderer().getCamera(); terrainCamera = new Camera(camera); inMemoryTerrainData = new InMemoryTerrainData(2048, 9, 128, new Vector3(1, 200, 1)); final TerrainDataProvider terrainDataProvider = new InMemoryTerrainDataProvider(inMemoryTerrainData, true); terrain = new TerrainBuilder(terrainDataProvider, terrainCamera).setShowDebugPanels(true).build(); _root.attachChild(terrain); } catch (final Exception ex1) { System.out.println("Problem setting up terrain..."); ex1.printStackTrace(); } skybox = buildSkyBox(); skybox.getSceneHints().setAllPickingHints(false); _root.attachChild(skybox); // Setup labels for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.V), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (!inMemoryTerrainData.isRunning()) { inMemoryTerrainData.startUpdates(); } else { inMemoryTerrainData.stopUpdates(); } updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { updateTerrain = !updateTerrain; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(5); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(50); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(400); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(1000); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { groundCamera = !groundCamera; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.P), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { sphere.getSceneHints().setCullHint(CullHint.Always); } else if (sphere.getSceneHints().getCullHint() == CullHint.Always) { sphere.getSceneHints().setCullHint(CullHint.Dynamic); } updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setShowDebug(!terrain.getTextureClipmap().isShowDebug()); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.reloadShader(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() / 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() * 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SEVEN), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX() + 500.0, camera.getLocation().getY(), camera .getLocation().getZ()); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.EIGHT), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX() - 500.0, camera.getLocation().getY(), camera .getLocation().getZ()); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() + 1500.0); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() - 1500.0); } })); } private void setupDefaultStates() { _lightState.detachAll(); final DirectionalLight dLight = new DirectionalLight(); dLight.setEnabled(true); dLight.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); dLight.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); dLight.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); dLight.setDirection(new Vector3(-1, -1, -1).normalizeLocal()); _lightState.attach(dLight); _lightState.setEnabled(true); final CullState cs = new CullState(); cs.setEnabled(true); cs.setCullFace(CullState.Face.Back); _root.setRenderState(cs); final FogState fs = new FogState(); fs.setStart(farPlane / 2.0f); fs.setEnd(farPlane); fs.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fs.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fs); } /** * Builds the sky box. */ private Skybox buildSkyBox() { final Skybox skybox = new Skybox("skybox", 10, 10, 10); final String dir = "images/skybox/"; final Texture north = TextureManager .load(dir + "1.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture south = TextureManager .load(dir + "3.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture east = TextureManager.load(dir + "2.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture west = TextureManager.load(dir + "4.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture up = TextureManager.load(dir + "6.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture down = TextureManager.load(dir + "5.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); skybox.setTexture(Skybox.Face.North, north); skybox.setTexture(Skybox.Face.West, west); skybox.setTexture(Skybox.Face.South, south); skybox.setTexture(Skybox.Face.East, east); skybox.setTexture(Skybox.Face.Up, up); skybox.setTexture(Skybox.Face.Down, down); return skybox; } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[1/2/3] Moving speed: " + _controlHandle.getMoveSpeed() * 3.6 + " km/h"); _exampleInfo[1].setText("[P] Do picking: " + (sphere.getSceneHints().getCullHint() == CullHint.Dynamic)); _exampleInfo[2].setText("[SPACE] Toggle fly/walk: " + (groundCamera ? "walk" : "fly")); _exampleInfo[3].setText("[J] Regenerate heightmap/texture"); _exampleInfo[4].setText("[U] Freeze terrain(debug): " + !updateTerrain); _exampleInfo[5].setText("[V] Updating terrain data: " + inMemoryTerrainData.isRunning()); } } \ No newline at end of file
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ProceduralTerrainExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ProceduralTerrainExample.java
index 0483945..8585f14 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ProceduralTerrainExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ProceduralTerrainExample.java
@@ -1 +1 @@
-/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.terrain; import java.util.concurrent.Callable; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.terrain.client.Terrain; import com.ardor3d.extension.terrain.client.TerrainBuilder; import com.ardor3d.extension.terrain.client.TerrainDataProvider; import com.ardor3d.extension.terrain.providers.procedural.ProceduralTerrainDataProvider; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.image.Texture; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.intersection.PickingUtil; import com.ardor3d.intersection.PrimitivePickResults; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Ray3; import com.ardor3d.math.Vector3; import com.ardor3d.math.functions.FbmFunction3D; import com.ardor3d.math.functions.Function3D; import com.ardor3d.math.functions.Functions; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.extension.Skybox; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Sphere; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.GameTaskQueue; import com.ardor3d.util.GameTaskQueueManager; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.TextureManager; /** * Example showing the Geometry Clipmap Terrain system with 'MegaTextures' using content procedurally generated * on-the-fly. Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.ProceduralTerrainExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_ProceduralTerrainExample.jpg", // maxHeapMemory = 64) public class ProceduralTerrainExample extends ExampleBase { private boolean updateTerrain = true; private final float farPlane = 8000.0f; private Terrain terrain; private final Sphere sphere = new Sphere("sp", 16, 16, 1); private final Ray3 pickRay = new Ray3(); private boolean groundCamera = false; private Camera terrainCamera; private Skybox skybox; /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[5]; public static void main(final String[] args) { ExampleBase.start(ProceduralTerrainExample.class); } @Override protected void updateExample(final ReadOnlyTimer timer) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); // Make sure camera is above terrain final double height = terrain.getHeightAt(camera.getLocation().getX(), camera.getLocation().getZ()); if (height > -Float.MAX_VALUE && (groundCamera || camera.getLocation().getY() < height + 3)) { camera.setLocation(new Vector3(camera.getLocation().getX(), height + 3, camera.getLocation().getZ())); } if (updateTerrain) { terrainCamera.set(camera); } skybox.setTranslation(camera.getLocation()); // if we're picking... if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { // Set up our pick ray pickRay.setOrigin(camera.getLocation()); pickRay.setDirection(camera.getDirection()); // do pick and move the sphere final PrimitivePickResults pickResults = new PrimitivePickResults(); pickResults.setCheckDistance(true); PickingUtil.findPick(_root, pickRay, pickResults); if (pickResults.getNumber() != 0) { final Vector3 intersectionPoint = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionPoint(0); sphere.setTranslation(intersectionPoint); // XXX: maybe change the color of the ball for valid vs. invalid? } } } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Procedural Terrain Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(0, 300, 0)); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(1, 300, 1), Vector3.UNIT_Y); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 70.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / _canvas.getCanvasRenderer().getCamera().getHeight(), 1.0f, farPlane); final CanvasRenderer canvasRenderer = _canvas.getCanvasRenderer(); final RenderContext renderContext = canvasRenderer.getRenderContext(); final Renderer renderer = canvasRenderer.getRenderer(); GameTaskQueueManager.getManager(renderContext).getQueue(GameTaskQueue.RENDER).enqueue(new Callable<Void>() { @Override public Void call() throws Exception { renderer.setBackgroundColor(ColorRGBA.BLUE); return null; } }); _controlHandle.setMoveSpeed(50); setupDefaultStates(); sphere.getSceneHints().setAllPickingHints(false); sphere.getSceneHints().setCullHint(CullHint.Always); _root.attachChild(sphere); try { // Keep a separate camera to be able to freeze terrain update final Camera camera = _canvas.getCanvasRenderer().getCamera(); terrainCamera = new Camera(camera); final double scale = 1.0 / 4000.0; Function3D functionTmp = new FbmFunction3D(Functions.simplexNoise(), 9, 0.5, 0.5, 3.14); functionTmp = Functions.clamp(functionTmp, -1.2, 1.2); final Function3D function = Functions.scaleInput(functionTmp, scale, scale, 1); final TerrainDataProvider terrainDataProvider = new ProceduralTerrainDataProvider(function, new Vector3(1, 200, 1), -1.2f, 1.2f); terrain = new TerrainBuilder(terrainDataProvider, terrainCamera).setShowDebugPanels(true).build(); _root.attachChild(terrain); } catch (final Exception ex1) { System.out.println("Problem setting up terrain..."); ex1.printStackTrace(); } skybox = buildSkyBox(); skybox.getSceneHints().setAllPickingHints(false); _root.attachChild(skybox); // Setup labels for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { updateTerrain = !updateTerrain; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(5); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(50); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(200); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(500); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { groundCamera = !groundCamera; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.P), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { sphere.getSceneHints().setCullHint(CullHint.Always); } else if (sphere.getSceneHints().getCullHint() == CullHint.Always) { sphere.getSceneHints().setCullHint(CullHint.Dynamic); } updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setShowDebug(!terrain.getTextureClipmap().isShowDebug()); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.reloadShader(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() / 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() * 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SEVEN), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(-5000, 500, -5000); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.EIGHT), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(5000, 500, 5000); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() + 1500.0); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() - 1500.0); } })); } private void setupDefaultStates() { _lightState.detachAll(); final DirectionalLight dLight = new DirectionalLight(); dLight.setEnabled(true); dLight.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); dLight.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); dLight.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); dLight.setDirection(new Vector3(-1, -1, -1).normalizeLocal()); _lightState.attach(dLight); _lightState.setEnabled(true); final CullState cs = new CullState(); cs.setEnabled(true); cs.setCullFace(CullState.Face.Back); _root.setRenderState(cs); final FogState fs = new FogState(); fs.setStart(farPlane / 2.0f); fs.setEnd(farPlane); fs.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fs.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fs); } /** * Builds the sky box. */ private Skybox buildSkyBox() { final Skybox skybox = new Skybox("skybox", 10, 10, 10); final String dir = "images/skybox/"; final Texture north = TextureManager .load(dir + "1.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture south = TextureManager .load(dir + "3.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture east = TextureManager.load(dir + "2.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture west = TextureManager.load(dir + "4.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture up = TextureManager.load(dir + "6.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture down = TextureManager.load(dir + "5.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); skybox.setTexture(Skybox.Face.North, north); skybox.setTexture(Skybox.Face.West, west); skybox.setTexture(Skybox.Face.South, south); skybox.setTexture(Skybox.Face.East, east); skybox.setTexture(Skybox.Face.Up, up); skybox.setTexture(Skybox.Face.Down, down); return skybox; } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[1/2/3/4] Moving speed: " + _controlHandle.getMoveSpeed() * 3.6 + " km/h"); _exampleInfo[1].setText("[P] Do picking: " + (sphere.getSceneHints().getCullHint() == CullHint.Dynamic)); _exampleInfo[2].setText("[SPACE] Toggle fly/walk: " + (groundCamera ? "walk" : "fly")); _exampleInfo[3].setText("[J] Regenerate heightmap/texture"); _exampleInfo[4].setText("[U] Freeze terrain(debug): " + !updateTerrain); } } \ No newline at end of file
+/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.terrain; import java.util.concurrent.Callable; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.terrain.client.Terrain; import com.ardor3d.extension.terrain.client.TerrainBuilder; import com.ardor3d.extension.terrain.client.TerrainDataProvider; import com.ardor3d.extension.terrain.providers.procedural.ProceduralTerrainDataProvider; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.image.Texture; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.intersection.PickingUtil; import com.ardor3d.intersection.PrimitivePickResults; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Ray3; import com.ardor3d.math.Vector3; import com.ardor3d.math.functions.FbmFunction3D; import com.ardor3d.math.functions.Function3D; import com.ardor3d.math.functions.Functions; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.extension.Skybox; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Sphere; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.GameTaskQueue; import com.ardor3d.util.GameTaskQueueManager; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.TextureManager; /** * Example showing the Geometry Clipmap Terrain system with 'MegaTextures' using content procedurally generated * on-the-fly. Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.ProceduralTerrainExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_ProceduralTerrainExample.jpg", // maxHeapMemory = 64) public class ProceduralTerrainExample extends ExampleBase { private boolean updateTerrain = true; private final float farPlane = 8000.0f; private Terrain terrain; private final Sphere sphere = new Sphere("sp", 16, 16, 1); private final Ray3 pickRay = new Ray3(); private boolean groundCamera = false; private Camera terrainCamera; private Skybox skybox; /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[5]; public static void main(final String[] args) { ExampleBase.start(ProceduralTerrainExample.class); } @Override protected void updateExample(final ReadOnlyTimer timer) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); // Make sure camera is above terrain final double height = terrain.getHeightAt(camera.getLocation().getX(), camera.getLocation().getZ()); if (height > -Float.MAX_VALUE && (groundCamera || camera.getLocation().getY() < height + 3)) { camera.setLocation(new Vector3(camera.getLocation().getX(), height + 3, camera.getLocation().getZ())); } if (updateTerrain) { terrainCamera.set(camera); } skybox.setTranslation(camera.getLocation()); // if we're picking... if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { // Set up our pick ray pickRay.setOrigin(camera.getLocation()); pickRay.setDirection(camera.getDirection()); // do pick and move the sphere final PrimitivePickResults pickResults = new PrimitivePickResults(); pickResults.setCheckDistance(true); PickingUtil.findPick(_root, pickRay, pickResults); if (pickResults.getNumber() != 0) { final Vector3 intersectionPoint = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionPoint(0); sphere.setTranslation(intersectionPoint); // XXX: maybe change the color of the ball for valid vs. invalid? } } } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Procedural Terrain Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(0, 300, 0)); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(1, 300, 1), Vector3.UNIT_Y); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 70.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / _canvas.getCanvasRenderer().getCamera().getHeight(), 1.0f, farPlane); final CanvasRenderer canvasRenderer = _canvas.getCanvasRenderer(); final RenderContext renderContext = canvasRenderer.getRenderContext(); final Renderer renderer = canvasRenderer.getRenderer(); GameTaskQueueManager.getManager(renderContext).getQueue(GameTaskQueue.RENDER).enqueue(new Callable<Void>() { @Override public Void call() throws Exception { renderer.setBackgroundColor(ColorRGBA.BLUE); return null; } }); _controlHandle.setMoveSpeed(50); setupDefaultStates(); sphere.getSceneHints().setAllPickingHints(false); sphere.getSceneHints().setCullHint(CullHint.Always); _root.attachChild(sphere); try { // Keep a separate camera to be able to freeze terrain update final Camera camera = _canvas.getCanvasRenderer().getCamera(); terrainCamera = new Camera(camera); final double scale = 1.0 / 4000.0; Function3D functionTmp = new FbmFunction3D(Functions.simplexNoise(), 9, 0.5, 0.5, 3.14); functionTmp = Functions.clamp(functionTmp, -1.2, 1.2); final Function3D function = Functions.scaleInput(functionTmp, scale, scale, 1); final TerrainDataProvider terrainDataProvider = new ProceduralTerrainDataProvider(function, new Vector3(1, 200, 1), -1.2f, 1.2f); terrain = new TerrainBuilder(terrainDataProvider, terrainCamera).setShowDebugPanels(true).build(); _root.attachChild(terrain); } catch (final Exception ex1) { System.out.println("Problem setting up terrain..."); ex1.printStackTrace(); } skybox = buildSkyBox(); skybox.getSceneHints().setAllPickingHints(false); _root.attachChild(skybox); // Setup labels for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { updateTerrain = !updateTerrain; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(5); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(50); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(200); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(500); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { groundCamera = !groundCamera; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.P), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { sphere.getSceneHints().setCullHint(CullHint.Always); } else if (sphere.getSceneHints().getCullHint() == CullHint.Always) { sphere.getSceneHints().setCullHint(CullHint.Dynamic); } updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setShowDebug(!terrain.getTextureClipmap().isShowDebug()); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.reloadShader(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() / 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() * 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SEVEN), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(-5000, 500, -5000); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.EIGHT), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(5000, 500, 5000); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() + 1500.0); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() - 1500.0); } })); } private void setupDefaultStates() { _lightState.detachAll(); final DirectionalLight dLight = new DirectionalLight(); dLight.setEnabled(true); dLight.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); dLight.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); dLight.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); dLight.setDirection(new Vector3(-1, -1, -1).normalizeLocal()); _lightState.attach(dLight); _lightState.setEnabled(true); final CullState cs = new CullState(); cs.setEnabled(true); cs.setCullFace(CullState.Face.Back); _root.setRenderState(cs); final FogState fs = new FogState(); fs.setStart(farPlane / 2.0f); fs.setEnd(farPlane); fs.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fs.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fs); } /** * Builds the sky box. */ private Skybox buildSkyBox() { final Skybox skybox = new Skybox("skybox", 10, 10, 10); final String dir = "images/skybox/"; final Texture north = TextureManager .load(dir + "1.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture south = TextureManager .load(dir + "3.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture east = TextureManager.load(dir + "2.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture west = TextureManager.load(dir + "4.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture up = TextureManager.load(dir + "6.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture down = TextureManager.load(dir + "5.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); skybox.setTexture(Skybox.Face.North, north); skybox.setTexture(Skybox.Face.West, west); skybox.setTexture(Skybox.Face.South, south); skybox.setTexture(Skybox.Face.East, east); skybox.setTexture(Skybox.Face.Up, up); skybox.setTexture(Skybox.Face.Down, down); return skybox; } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[1/2/3/4] Moving speed: " + _controlHandle.getMoveSpeed() * 3.6 + " km/h"); _exampleInfo[1].setText("[P] Do picking: " + (sphere.getSceneHints().getCullHint() == CullHint.Dynamic)); _exampleInfo[2].setText("[SPACE] Toggle fly/walk: " + (groundCamera ? "walk" : "fly")); _exampleInfo[3].setText("[J] Regenerate heightmap/texture"); _exampleInfo[4].setText("[U] Freeze terrain(debug): " + !updateTerrain); } } \ No newline at end of file
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ShadowedTerrainExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ShadowedTerrainExample.java
index 2a028be..3f339fc 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ShadowedTerrainExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ShadowedTerrainExample.java
@@ -1 +1 @@
-/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.terrain; import java.util.Random; import java.util.concurrent.Callable; import java.util.logging.Level; import java.util.logging.Logger; import com.ardor3d.bounding.BoundingBox; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.shadow.map.ParallelSplitShadowMapPass; import com.ardor3d.extension.shadow.map.ParallelSplitShadowMapPass.Filter; import com.ardor3d.extension.terrain.client.Terrain; import com.ardor3d.extension.terrain.client.TerrainBuilder; import com.ardor3d.extension.terrain.client.TerrainDataProvider; import com.ardor3d.extension.terrain.client.UrlInputSupplier; import com.ardor3d.extension.terrain.heightmap.MidPointHeightMapGenerator; import com.ardor3d.extension.terrain.providers.array.ArrayTerrainDataProvider; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.intersection.PickingUtil; import com.ardor3d.intersection.PrimitivePickResults; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Ray3; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.scenegraph.Mesh; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Box; import com.ardor3d.scenegraph.shape.Sphere; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.GameTaskQueue; import com.ardor3d.util.GameTaskQueueManager; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.resource.ResourceLocatorTool; /** * Example showing the Geometry Clipmap Terrain system combined with PSSM. (a bit experimental) Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.ShadowedTerrainExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_ShadowedTerrainExample.jpg", // maxHeapMemory = 128) public class ShadowedTerrainExample extends ExampleBase { /** The Constant logger. */ private static final Logger logger = Logger.getLogger(ShadowedTerrainExample.class.getName()); private boolean updateTerrain = true; private final float farPlane = 2500.0f; private Terrain terrain; private final Sphere sphere = new Sphere("sp", 16, 16, 1); private final Ray3 pickRay = new Ray3(); private boolean groundCamera = false; private Camera terrainCamera; /** Pssm shadow map pass. */ private ParallelSplitShadowMapPass _pssmPass; private DirectionalLight light; /** Temp vec for updating light pos. */ private final Vector3 lightPosition = new Vector3(10000, 10000, 10000); /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[5]; public static void main(final String[] args) { ExampleBase.start(ShadowedTerrainExample.class); } @Override protected void updateExample(final ReadOnlyTimer timer) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); // Make sure camera is above terrain final double height = terrain.getHeightAt(camera.getLocation().getX(), camera.getLocation().getZ()); if (height > -Float.MAX_VALUE && (groundCamera || camera.getLocation().getY() < height + 3)) { camera.setLocation(new Vector3(camera.getLocation().getX(), height + 3, camera.getLocation().getZ())); } if (updateTerrain) { terrainCamera.set(camera); } // if we're picking... if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { // Set up our pick ray pickRay.setOrigin(camera.getLocation()); pickRay.setDirection(camera.getDirection()); // do pick and move the sphere final PrimitivePickResults pickResults = new PrimitivePickResults(); pickResults.setCheckDistance(true); PickingUtil.findPick(_root, pickRay, pickResults); if (pickResults.getNumber() != 0) { final Vector3 intersectionPoint = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionPoint(0); sphere.setTranslation(intersectionPoint); // XXX: maybe change the color of the ball for valid vs. invalid? } } } @Override protected void renderExample(final Renderer renderer) { // Lazy init since it needs the renderer... if (!_pssmPass.isInitialised()) { _pssmPass.init(renderer); _pssmPass.setPssmShader(terrain.getGeometryClipmapShader()); for (int i = 0; i < _pssmPass.getNumOfSplits(); i++) { terrain.getClipTextureState().setTexture(_pssmPass.getShadowMapTexture(i), i + 1); } for (int i = 0; i < ParallelSplitShadowMapPass._MAX_SPLITS; i++) { terrain.getGeometryClipmapShader().setUniform("shadowMap" + i, i + 1); } } // Update shadowmaps _pssmPass.updateShadowMaps(renderer); // Render scene and terrain with shadows super.renderExample(renderer); renderer.renderBuckets(); // Render overlay shadows for all objects except the terrain _pssmPass.renderShadowedScene(renderer); // TODO: this results in text etc also being shadowed, since they are drawn in the main render... } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { _canvas.setTitle("Terrain Example"); final Camera cam = _canvas.getCanvasRenderer().getCamera(); cam.setLocation(new Vector3(440, 215, 275)); cam.lookAt(new Vector3(450, 140, 360), Vector3.UNIT_Y); cam.setFrustumPerspective(70.0, (float) cam.getWidth() / cam.getHeight(), 1.0f, farPlane); final CanvasRenderer canvasRenderer = _canvas.getCanvasRenderer(); final RenderContext renderContext = canvasRenderer.getRenderContext(); final Renderer renderer = canvasRenderer.getRenderer(); GameTaskQueueManager.getManager(renderContext).getQueue(GameTaskQueue.RENDER).enqueue(new Callable<Void>() { @Override public Void call() throws Exception { renderer.setBackgroundColor(ColorRGBA.GRAY); return null; } }); _controlHandle.setMoveSpeed(200); setupDefaultStates(); sphere.getSceneHints().setAllPickingHints(false); sphere.getSceneHints().setCullHint(CullHint.Always); _root.attachChild(sphere); try { // Keep a separate camera to be able to freeze terrain update terrainCamera = new Camera(cam); final int SIZE = 2048; final MidPointHeightMapGenerator raw = new MidPointHeightMapGenerator(SIZE, 0.6f); raw.setHeightRange(0.2f); final float[] heightMap = raw.getHeightData(); final TerrainDataProvider terrainDataProvider = new ArrayTerrainDataProvider(heightMap, SIZE, new Vector3( 1, 300, 1)); terrain = new TerrainBuilder(terrainDataProvider, terrainCamera).setShowDebugPanels(true).build(); terrain.setPixelShader(new UrlInputSupplier(ResourceLocatorTool .getClassPathResource(ShadowedTerrainExample.class, "com/ardor3d/extension/terrain/shadowedGeometryClipmapShaderPCF.frag"))); terrain.reloadShader(); _root.attachChild(terrain); } catch (final Exception e) { logger.log(Level.SEVERE, "Problem setting up terrain...", e); System.exit(1); } // Initialize PSSM shadows _pssmPass = new ParallelSplitShadowMapPass(light, 1024, 4); _pssmPass.setFiltering(Filter.Pcf); _pssmPass.setRenderShadowedScene(false); _pssmPass.setKeepMainShader(true); _pssmPass.setMaxShadowDistance(750); // XXX: Tune this // _pssmPass.setMinimumLightDistance(500); // XXX: Tune this _pssmPass.setUseSceneTexturing(false); _pssmPass.setUseObjectCullFace(false); // _pssmPass.setDrawDebug(true); final Node occluders = setupOccluders(); _root.attachChild(occluders); // TODO: could we use the shadow variable in scenehints here?? // Add objects that will get shadowed through overlay render _pssmPass.add(occluders); // Add terrain in as bounds receiver as well, since it's not in the overlay list _pssmPass.addBoundsReceiver(terrain); // Add our occluders that will produce shadows _pssmPass.addOccluder(occluders); // Setup labels for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { updateTerrain = !updateTerrain; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(5); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(50); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(400); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(1000); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { groundCamera = !groundCamera; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.P), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { sphere.getSceneHints().setCullHint(CullHint.Always); } else if (sphere.getSceneHints().getCullHint() == CullHint.Always) { sphere.getSceneHints().setCullHint(CullHint.Dynamic); } updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setShowDebug(!terrain.getTextureClipmap().isShowDebug()); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.reloadShader(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() / 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() * 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.C), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _pssmPass.setUpdateMainCamera(!_pssmPass.isUpdateMainCamera()); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera cam = _canvas.getCanvasRenderer().getCamera(); System.out.println("camera location: " + cam.getLocation()); System.out.println("camera direction: " + cam.getDirection()); } })); } private Node setupOccluders() { final Node occluders = new Node("Occluders"); final Box box = new Box("Box", new Vector3(), 1, 40, 1); box.setModelBound(new BoundingBox()); box.setRandomColors(); final Random rand = new Random(1337); for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { final Mesh sm = box.makeCopy(true); sm.setTranslation(500 + rand.nextDouble() * 300 - 150, 20 + rand.nextDouble() * 5.0, 500 + rand.nextDouble() * 300 - 150); occluders.attachChild(sm); } } return occluders; } private void setupDefaultStates() { _lightState.detachAll(); light = new DirectionalLight(); light.setEnabled(true); light.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); light.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); light.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); light.setDirection(lightPosition.normalize(null).negateLocal()); _lightState.attach(light); _lightState.setEnabled(true); final CullState cs = new CullState(); cs.setEnabled(true); cs.setCullFace(CullState.Face.Back); _root.setRenderState(cs); final FogState fs = new FogState(); fs.setStart(farPlane / 2.0f); fs.setEnd(farPlane); fs.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fs.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fs); } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[1/2/3] Moving speed: " + _controlHandle.getMoveSpeed() * 3.6 + " km/h"); _exampleInfo[1].setText("[P] Do picking: " + (sphere.getSceneHints().getCullHint() == CullHint.Dynamic)); _exampleInfo[2].setText("[SPACE] Toggle fly/walk: " + (groundCamera ? "walk" : "fly")); _exampleInfo[3].setText("[J] Regenerate heightmap/texture"); _exampleInfo[4].setText("[U] Freeze terrain(debug): " + !updateTerrain); } } \ No newline at end of file
+/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.terrain; import java.util.Random; import java.util.concurrent.Callable; import java.util.logging.Level; import java.util.logging.Logger; import com.ardor3d.bounding.BoundingBox; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.shadow.map.ParallelSplitShadowMapPass; import com.ardor3d.extension.shadow.map.ParallelSplitShadowMapPass.Filter; import com.ardor3d.extension.terrain.client.Terrain; import com.ardor3d.extension.terrain.client.TerrainBuilder; import com.ardor3d.extension.terrain.client.TerrainDataProvider; import com.ardor3d.extension.terrain.client.UrlInputSupplier; import com.ardor3d.extension.terrain.heightmap.MidPointHeightMapGenerator; import com.ardor3d.extension.terrain.providers.array.ArrayTerrainDataProvider; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.intersection.PickingUtil; import com.ardor3d.intersection.PrimitivePickResults; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Ray3; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.scenegraph.Mesh; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Box; import com.ardor3d.scenegraph.shape.Sphere; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.GameTaskQueue; import com.ardor3d.util.GameTaskQueueManager; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.resource.ResourceLocatorTool; /** * Example showing the Geometry Clipmap Terrain system combined with PSSM. (a bit experimental) Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.ShadowedTerrainExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_ShadowedTerrainExample.jpg", // maxHeapMemory = 128) public class ShadowedTerrainExample extends ExampleBase { /** The Constant logger. */ private static final Logger logger = Logger.getLogger(ShadowedTerrainExample.class.getName()); private boolean updateTerrain = true; private final float farPlane = 2500.0f; private Terrain terrain; private final Sphere sphere = new Sphere("sp", 16, 16, 1); private final Ray3 pickRay = new Ray3(); private boolean groundCamera = false; private Camera terrainCamera; /** Pssm shadow map pass. */ private ParallelSplitShadowMapPass _pssmPass; private DirectionalLight light; /** Temp vec for updating light pos. */ private final Vector3 lightPosition = new Vector3(10000, 10000, 10000); /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[5]; public static void main(final String[] args) { ExampleBase.start(ShadowedTerrainExample.class); } @Override protected void updateExample(final ReadOnlyTimer timer) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); // Make sure camera is above terrain final double height = terrain.getHeightAt(camera.getLocation().getX(), camera.getLocation().getZ()); if (height > -Float.MAX_VALUE && (groundCamera || camera.getLocation().getY() < height + 3)) { camera.setLocation(new Vector3(camera.getLocation().getX(), height + 3, camera.getLocation().getZ())); } if (updateTerrain) { terrainCamera.set(camera); } // if we're picking... if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { // Set up our pick ray pickRay.setOrigin(camera.getLocation()); pickRay.setDirection(camera.getDirection()); // do pick and move the sphere final PrimitivePickResults pickResults = new PrimitivePickResults(); pickResults.setCheckDistance(true); PickingUtil.findPick(_root, pickRay, pickResults); if (pickResults.getNumber() != 0) { final Vector3 intersectionPoint = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionPoint(0); sphere.setTranslation(intersectionPoint); // XXX: maybe change the color of the ball for valid vs. invalid? } } } @Override protected void renderExample(final Renderer renderer) { // Lazy init since it needs the renderer... if (!_pssmPass.isInitialised()) { _pssmPass.init(renderer); _pssmPass.setPssmShader(terrain.getGeometryClipmapShader()); for (int i = 0; i < _pssmPass.getNumOfSplits(); i++) { terrain.getClipTextureState().setTexture(_pssmPass.getShadowMapTexture(i), i + 1); } for (int i = 0; i < ParallelSplitShadowMapPass._MAX_SPLITS; i++) { terrain.getGeometryClipmapShader().setUniform("shadowMap" + i, i + 1); } } // Update shadowmaps _pssmPass.updateShadowMaps(renderer); // Render scene and terrain with shadows super.renderExample(renderer); renderer.renderBuckets(); // Render overlay shadows for all objects except the terrain _pssmPass.renderShadowedScene(renderer); // TODO: this results in text etc also being shadowed, since they are drawn in the main render... } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { _canvas.setTitle("Terrain Example"); final Camera cam = _canvas.getCanvasRenderer().getCamera(); cam.setLocation(new Vector3(440, 215, 275)); cam.lookAt(new Vector3(450, 140, 360), Vector3.UNIT_Y); cam.setFrustumPerspective(70.0, (float) cam.getWidth() / cam.getHeight(), 1.0f, farPlane); final CanvasRenderer canvasRenderer = _canvas.getCanvasRenderer(); final RenderContext renderContext = canvasRenderer.getRenderContext(); final Renderer renderer = canvasRenderer.getRenderer(); GameTaskQueueManager.getManager(renderContext).getQueue(GameTaskQueue.RENDER).enqueue(new Callable<Void>() { @Override public Void call() throws Exception { renderer.setBackgroundColor(ColorRGBA.GRAY); return null; } }); _controlHandle.setMoveSpeed(200); setupDefaultStates(); sphere.getSceneHints().setAllPickingHints(false); sphere.getSceneHints().setCullHint(CullHint.Always); _root.attachChild(sphere); try { // Keep a separate camera to be able to freeze terrain update terrainCamera = new Camera(cam); final int SIZE = 2048; final MidPointHeightMapGenerator raw = new MidPointHeightMapGenerator(SIZE, 0.6f); raw.setHeightRange(0.2f); final float[] heightMap = raw.getHeightData(); final TerrainDataProvider terrainDataProvider = new ArrayTerrainDataProvider(heightMap, SIZE, new Vector3( 1, 300, 1)); terrain = new TerrainBuilder(terrainDataProvider, terrainCamera).setShowDebugPanels(true).build(); terrain.setPixelShader(new UrlInputSupplier(ResourceLocatorTool .getClassPathResource(ShadowedTerrainExample.class, "com/ardor3d/extension/terrain/shadowedGeometryClipmapShaderPCF.frag"))); terrain.reloadShader(); _root.attachChild(terrain); } catch (final Exception e) { logger.log(Level.SEVERE, "Problem setting up terrain...", e); System.exit(1); } // Initialize PSSM shadows _pssmPass = new ParallelSplitShadowMapPass(light, 1024, 4); _pssmPass.setFiltering(Filter.Pcf); _pssmPass.setRenderShadowedScene(false); _pssmPass.setKeepMainShader(true); _pssmPass.setMaxShadowDistance(750); // XXX: Tune this // _pssmPass.setMinimumLightDistance(500); // XXX: Tune this _pssmPass.setUseSceneTexturing(false); _pssmPass.setUseObjectCullFace(false); // _pssmPass.setDrawDebug(true); final Node occluders = setupOccluders(); _root.attachChild(occluders); // TODO: could we use the shadow variable in scenehints here?? // Add objects that will get shadowed through overlay render _pssmPass.add(occluders); // Add terrain in as bounds receiver as well, since it's not in the overlay list _pssmPass.addBoundsReceiver(terrain); // Add our occluders that will produce shadows _pssmPass.addOccluder(occluders); // Setup labels for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { updateTerrain = !updateTerrain; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(5); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(50); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(400); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(1000); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { groundCamera = !groundCamera; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.P), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { sphere.getSceneHints().setCullHint(CullHint.Always); } else if (sphere.getSceneHints().getCullHint() == CullHint.Always) { sphere.getSceneHints().setCullHint(CullHint.Dynamic); } updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setShowDebug(!terrain.getTextureClipmap().isShowDebug()); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.reloadShader(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() / 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() * 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.C), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _pssmPass.setUpdateMainCamera(!_pssmPass.isUpdateMainCamera()); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera cam = _canvas.getCanvasRenderer().getCamera(); System.out.println("camera location: " + cam.getLocation()); System.out.println("camera direction: " + cam.getDirection()); } })); } private Node setupOccluders() { final Node occluders = new Node("Occluders"); final Box box = new Box("Box", new Vector3(), 1, 40, 1); box.setModelBound(new BoundingBox()); box.setRandomColors(); final Random rand = new Random(1337); for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { final Mesh sm = box.makeCopy(true); sm.setTranslation(500 + rand.nextDouble() * 300 - 150, 20 + rand.nextDouble() * 5.0, 500 + rand.nextDouble() * 300 - 150); occluders.attachChild(sm); } } return occluders; } private void setupDefaultStates() { _lightState.detachAll(); light = new DirectionalLight(); light.setEnabled(true); light.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); light.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); light.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); light.setDirection(lightPosition.normalize(null).negateLocal()); _lightState.attach(light); _lightState.setEnabled(true); final CullState cs = new CullState(); cs.setEnabled(true); cs.setCullFace(CullState.Face.Back); _root.setRenderState(cs); final FogState fs = new FogState(); fs.setStart(farPlane / 2.0f); fs.setEnd(farPlane); fs.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fs.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fs); } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[1/2/3] Moving speed: " + _controlHandle.getMoveSpeed() * 3.6 + " km/h"); _exampleInfo[1].setText("[P] Do picking: " + (sphere.getSceneHints().getCullHint() == CullHint.Dynamic)); _exampleInfo[2].setText("[SPACE] Toggle fly/walk: " + (groundCamera ? "walk" : "fly")); _exampleInfo[3].setText("[J] Regenerate heightmap/texture"); _exampleInfo[4].setText("[U] Freeze terrain(debug): " + !updateTerrain); } } \ No newline at end of file
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ShapesPlusProceduralTerrainExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ShapesPlusProceduralTerrainExample.java
index ac2a1c1..7438448 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ShapesPlusProceduralTerrainExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ShapesPlusProceduralTerrainExample.java
@@ -1 +1 @@
-/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.terrain; import java.awt.Color; import java.awt.Rectangle; import java.awt.geom.Ellipse2D; import java.io.IOException; import java.util.concurrent.Callable; import javax.imageio.ImageIO; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.terrain.client.Terrain; import com.ardor3d.extension.terrain.client.TerrainBuilder; import com.ardor3d.extension.terrain.client.TerrainDataProvider; import com.ardor3d.extension.terrain.client.TextureClipmap; import com.ardor3d.extension.terrain.providers.awt.AbstractAwtElement; import com.ardor3d.extension.terrain.providers.awt.AwtImageElement; import com.ardor3d.extension.terrain.providers.awt.AwtShapeElement; import com.ardor3d.extension.terrain.providers.awt.AwtTextureSource; import com.ardor3d.extension.terrain.providers.procedural.ProceduralTerrainDataProvider; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.image.TextureStoreFormat; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.MathUtils; import com.ardor3d.math.Matrix3; import com.ardor3d.math.Transform; import com.ardor3d.math.Vector3; import com.ardor3d.math.functions.FbmFunction3D; import com.ardor3d.math.functions.Function3D; import com.ardor3d.math.functions.Functions; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Box; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.GameTaskQueue; import com.ardor3d.util.GameTaskQueueManager; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.resource.ResourceLocatorTool; /** * Example showing the Geometry Clipmap Terrain system with 'MegaTextures'. We merge AWT drawing with the terrain * texture in real time. Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.ShapesPlusProceduralTerrainExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_ShapesPlusProceduralTerrainExample.jpg", // maxHeapMemory = 128) public class ShapesPlusProceduralTerrainExample extends ExampleBase { private boolean updateTerrain = true; private final float farPlane = 8000.0f; private final float heightScale = 200; private Terrain terrain; private boolean groundCamera = false; private Camera terrainCamera; Transform ovalTrans = new Transform(); /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[5]; public static void main(final String[] args) { ExampleBase.start(ShapesPlusProceduralTerrainExample.class); } private double counter = 0; private int frames = 0; private final double awtUpdate = 1.0 / 15.0; // 15 fps private double awtCounter = 0; @Override protected void updateExample(final ReadOnlyTimer timer) { counter += timer.getTimePerFrame(); frames++; if (counter > 1) { final double fps = frames / counter; counter = 0; frames = 0; System.out.printf("%7.1f FPS\n", fps); } final Camera camera = _canvas.getCanvasRenderer().getCamera(); awtCounter += timer.getTimePerFrame(); if (awtCounter > awtUpdate) { final double tis = timer.getTimeInSeconds() * 0.75; ovalTrans.setTranslation(250 * MathUtils.sin(-tis), 150 * MathUtils.cos(tis), 0); oval.setTransform(ovalTrans); awtCounter -= awtUpdate; } // Make sure camera is above terrain final double height = terrain.getHeightAt(camera.getLocation().getX(), camera.getLocation().getZ()); if (height > -Float.MAX_VALUE && (groundCamera || camera.getLocation().getY() < height + 3)) { camera.setLocation(new Vector3(camera.getLocation().getX(), height + 3, camera.getLocation().getZ())); } if (updateTerrain) { terrainCamera.set(camera); } } private AwtTextureSource awtTextureSource; private AwtShapeElement rectangle; private AwtShapeElement oval; private AwtImageElement bubble; /** * Initialize pssm pass and scene. */ @Override protected void initExample() { for (int i = 0; i < 9; i++) { final double x = (i % 3 - 1) * 128.0; final double z = (i / 3 - 1) * 128.0; final Box b = new Box("" + i, new Vector3(x, 0, z), 5, 150, 5); _root.attachChild(b); } // Setup main camera. _canvas.setTitle("Shapes + Procedural Terrain Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(0, 300, 0)); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(1, 300, 1), Vector3.UNIT_Y); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 70.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / _canvas.getCanvasRenderer().getCamera().getHeight(), 1.0f, farPlane); final CanvasRenderer canvasRenderer = _canvas.getCanvasRenderer(); final RenderContext renderContext = canvasRenderer.getRenderContext(); final Renderer renderer = canvasRenderer.getRenderer(); GameTaskQueueManager.getManager(renderContext).getQueue(GameTaskQueue.RENDER).enqueue(new Callable<Void>() { @Override public Void call() throws Exception { renderer.setBackgroundColor(ColorRGBA.GRAY); return null; } }); _controlHandle.setMoveSpeed(50); setupDefaultStates(); try { // Keep a separate camera to be able to freeze terrain update final Camera camera = _canvas.getCanvasRenderer().getCamera(); terrainCamera = new Camera(camera); awtTextureSource = new AwtTextureSource(8, TextureStoreFormat.RGBA8); // Same as procedural one final double scale = 1.0 / 4000.0; Function3D functionTmp = new FbmFunction3D(Functions.simplexNoise(), 9, 0.5, 0.5, 3.14); functionTmp = Functions.clamp(functionTmp, -1.2, 1.2); final Function3D function = Functions.scaleInput(functionTmp, scale, scale, 1); final TerrainDataProvider baseTerrainDataProvider = new ProceduralTerrainDataProvider(function, new Vector3(1, heightScale, 1), -1.2f, 1.2f); final TerrainBuilder terrainBuilder = new TerrainBuilder(baseTerrainDataProvider, terrainCamera); terrainBuilder.addTextureConnection(awtTextureSource); terrain = terrainBuilder.setShowDebugPanels(true).build(); _root.attachChild(terrain); } catch (final Exception ex1) { System.out.println("Problem setting up terrain..."); ex1.printStackTrace(); } // add some shapes rectangle = new AwtShapeElement(new Rectangle(400, 50)); Transform t = new Transform(); t.setRotation(new Matrix3().fromAngles(0, 0, 45 * MathUtils.DEG_TO_RAD)); rectangle.setTransform(t); awtTextureSource.getProvider().addElement(rectangle); oval = new AwtShapeElement(new Ellipse2D.Float(0, 0, 250, 150)); oval.setFillColor(Color.red); // set transparency oval.setCompositeOverride(AbstractAwtElement.makeAlphaComposite(.75f)); awtTextureSource.getProvider().addElement(oval); // add an image element to test. t = new Transform(); t.setScale(2.0); t.translate(-250, 150, 0); addBubble(t); // Setup labels for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { updateTerrain = !updateTerrain; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(5); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(50); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(200); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(1000); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { groundCamera = !groundCamera; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setShowDebug(!terrain.getTextureClipmap().isShowDebug()); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.reloadShader(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { for (final TextureClipmap clipmap : terrain.getTextureClipmaps()) { clipmap.setScale(terrain.getTextureClipmap().getScale() / 2); } terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { for (final TextureClipmap clipmap : terrain.getTextureClipmaps()) { clipmap.setScale(terrain.getTextureClipmap().getScale() * 2); } terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SEVEN), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(-5000, 500, -5000); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.EIGHT), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(5000, 500, 5000); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() + 1500.0); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.V), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Transform t = new Transform(); t.setScale(MathUtils.nextRandomDouble() * 4.9 + 0.1); t.translate(MathUtils.nextRandomDouble() * 500 - 250, MathUtils.nextRandomDouble() * 500 - 250, 0); addBubble(t); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() - 1500.0); } })); } protected void addBubble(final Transform t) { java.awt.Image bubbleImg = null; try { bubbleImg = ImageIO.read(ResourceLocatorTool.getClassPathResourceAsStream( ShapesPlusProceduralTerrainExample.class, "com/ardor3d/example/media/images/ball.png")); } catch (final IOException e) { e.printStackTrace(); System.exit(-1); } bubble = new AwtImageElement(bubbleImg); bubble.setTransform(t); awtTextureSource.getProvider().addElement(bubble); } private void setupDefaultStates() { _lightState.detachAll(); final DirectionalLight dLight = new DirectionalLight(); dLight.setEnabled(true); dLight.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); dLight.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); dLight.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); dLight.setDirection(new Vector3(-1, -1, -1).normalizeLocal()); _lightState.attach(dLight); _lightState.setEnabled(true); final CullState cs = new CullState(); cs.setEnabled(true); cs.setCullFace(CullState.Face.Back); _root.setRenderState(cs); final FogState fs = new FogState(); fs.setStart(farPlane / 2.0f); fs.setEnd(farPlane); fs.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fs.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fs); } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[1/2/3] Moving speed: " + _controlHandle.getMoveSpeed() * 3.6 + " km/h"); _exampleInfo[1].setText("[R] Draw texture debug: " + terrain.getTextureClipmap().isShowDebug()); _exampleInfo[2].setText("[SPACE] Toggle fly/walk: " + (groundCamera ? "walk" : "fly")); _exampleInfo[3].setText("[J] Regenerate heightmap/texture"); _exampleInfo[4].setText("[U] Freeze terrain(debug): " + !updateTerrain); } } \ No newline at end of file
+/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.terrain; import java.awt.Color; import java.awt.Rectangle; import java.awt.geom.Ellipse2D; import java.io.IOException; import java.util.concurrent.Callable; import javax.imageio.ImageIO; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.terrain.client.Terrain; import com.ardor3d.extension.terrain.client.TerrainBuilder; import com.ardor3d.extension.terrain.client.TerrainDataProvider; import com.ardor3d.extension.terrain.client.TextureClipmap; import com.ardor3d.extension.terrain.providers.awt.AbstractAwtElement; import com.ardor3d.extension.terrain.providers.awt.AwtImageElement; import com.ardor3d.extension.terrain.providers.awt.AwtShapeElement; import com.ardor3d.extension.terrain.providers.awt.AwtTextureSource; import com.ardor3d.extension.terrain.providers.procedural.ProceduralTerrainDataProvider; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.image.TextureStoreFormat; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.MathUtils; import com.ardor3d.math.Matrix3; import com.ardor3d.math.Transform; import com.ardor3d.math.Vector3; import com.ardor3d.math.functions.FbmFunction3D; import com.ardor3d.math.functions.Function3D; import com.ardor3d.math.functions.Functions; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Box; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.GameTaskQueue; import com.ardor3d.util.GameTaskQueueManager; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.resource.ResourceLocatorTool; /** * Example showing the Geometry Clipmap Terrain system with 'MegaTextures'. We merge AWT drawing with the terrain * texture in real time. Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.ShapesPlusProceduralTerrainExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_ShapesPlusProceduralTerrainExample.jpg", // maxHeapMemory = 128) public class ShapesPlusProceduralTerrainExample extends ExampleBase { private boolean updateTerrain = true; private final float farPlane = 8000.0f; private final float heightScale = 200; private Terrain terrain; private boolean groundCamera = false; private Camera terrainCamera; Transform ovalTrans = new Transform(); /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[5]; public static void main(final String[] args) { ExampleBase.start(ShapesPlusProceduralTerrainExample.class); } private double counter = 0; private int frames = 0; private final double awtUpdate = 1.0 / 15.0; // 15 fps private double awtCounter = 0; @Override protected void updateExample(final ReadOnlyTimer timer) { counter += timer.getTimePerFrame(); frames++; if (counter > 1) { final double fps = frames / counter; counter = 0; frames = 0; System.out.printf("%7.1f FPS\n", fps); } final Camera camera = _canvas.getCanvasRenderer().getCamera(); awtCounter += timer.getTimePerFrame(); if (awtCounter > awtUpdate) { final double tis = timer.getTimeInSeconds() * 0.75; ovalTrans.setTranslation(250 * MathUtils.sin(-tis), 150 * MathUtils.cos(tis), 0); oval.setTransform(ovalTrans); awtCounter -= awtUpdate; } // Make sure camera is above terrain final double height = terrain.getHeightAt(camera.getLocation().getX(), camera.getLocation().getZ()); if (height > -Float.MAX_VALUE && (groundCamera || camera.getLocation().getY() < height + 3)) { camera.setLocation(new Vector3(camera.getLocation().getX(), height + 3, camera.getLocation().getZ())); } if (updateTerrain) { terrainCamera.set(camera); } } private AwtTextureSource awtTextureSource; private AwtShapeElement rectangle; private AwtShapeElement oval; private AwtImageElement bubble; /** * Initialize pssm pass and scene. */ @Override protected void initExample() { for (int i = 0; i < 9; i++) { final double x = (i % 3 - 1) * 128.0; final double z = (i / 3 - 1) * 128.0; final Box b = new Box("" + i, new Vector3(x, 0, z), 5, 150, 5); _root.attachChild(b); } // Setup main camera. _canvas.setTitle("Shapes + Procedural Terrain Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(0, 300, 0)); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(1, 300, 1), Vector3.UNIT_Y); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 70.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / _canvas.getCanvasRenderer().getCamera().getHeight(), 1.0f, farPlane); final CanvasRenderer canvasRenderer = _canvas.getCanvasRenderer(); final RenderContext renderContext = canvasRenderer.getRenderContext(); final Renderer renderer = canvasRenderer.getRenderer(); GameTaskQueueManager.getManager(renderContext).getQueue(GameTaskQueue.RENDER).enqueue(new Callable<Void>() { @Override public Void call() throws Exception { renderer.setBackgroundColor(ColorRGBA.GRAY); return null; } }); _controlHandle.setMoveSpeed(50); setupDefaultStates(); try { // Keep a separate camera to be able to freeze terrain update final Camera camera = _canvas.getCanvasRenderer().getCamera(); terrainCamera = new Camera(camera); awtTextureSource = new AwtTextureSource(8, TextureStoreFormat.RGBA8); // Same as procedural one final double scale = 1.0 / 4000.0; Function3D functionTmp = new FbmFunction3D(Functions.simplexNoise(), 9, 0.5, 0.5, 3.14); functionTmp = Functions.clamp(functionTmp, -1.2, 1.2); final Function3D function = Functions.scaleInput(functionTmp, scale, scale, 1); final TerrainDataProvider baseTerrainDataProvider = new ProceduralTerrainDataProvider(function, new Vector3(1, heightScale, 1), -1.2f, 1.2f); final TerrainBuilder terrainBuilder = new TerrainBuilder(baseTerrainDataProvider, terrainCamera); terrainBuilder.addTextureConnection(awtTextureSource); terrain = terrainBuilder.setShowDebugPanels(true).build(); _root.attachChild(terrain); } catch (final Exception ex1) { System.out.println("Problem setting up terrain..."); ex1.printStackTrace(); } // add some shapes rectangle = new AwtShapeElement(new Rectangle(400, 50)); Transform t = new Transform(); t.setRotation(new Matrix3().fromAngles(0, 0, 45 * MathUtils.DEG_TO_RAD)); rectangle.setTransform(t); awtTextureSource.getProvider().addElement(rectangle); oval = new AwtShapeElement(new Ellipse2D.Float(0, 0, 250, 150)); oval.setFillColor(Color.red); // set transparency oval.setCompositeOverride(AbstractAwtElement.makeAlphaComposite(.75f)); awtTextureSource.getProvider().addElement(oval); // add an image element to test. t = new Transform(); t.setScale(2.0); t.translate(-250, 150, 0); addBubble(t); // Setup labels for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { updateTerrain = !updateTerrain; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(5); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(50); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(200); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(1000); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { groundCamera = !groundCamera; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setShowDebug(!terrain.getTextureClipmap().isShowDebug()); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.reloadShader(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { for (final TextureClipmap clipmap : terrain.getTextureClipmaps()) { clipmap.setScale(terrain.getTextureClipmap().getScale() / 2); } terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { for (final TextureClipmap clipmap : terrain.getTextureClipmaps()) { clipmap.setScale(terrain.getTextureClipmap().getScale() * 2); } terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SEVEN), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(-5000, 500, -5000); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.EIGHT), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(5000, 500, 5000); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() + 1500.0); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.V), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Transform t = new Transform(); t.setScale(MathUtils.nextRandomDouble() * 4.9 + 0.1); t.translate(MathUtils.nextRandomDouble() * 500 - 250, MathUtils.nextRandomDouble() * 500 - 250, 0); addBubble(t); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() - 1500.0); } })); } protected void addBubble(final Transform t) { java.awt.Image bubbleImg = null; try { bubbleImg = ImageIO.read(ResourceLocatorTool.getClassPathResourceAsStream( ShapesPlusProceduralTerrainExample.class, "com/ardor3d/example/media/images/ball.png")); } catch (final IOException e) { e.printStackTrace(); System.exit(-1); } bubble = new AwtImageElement(bubbleImg); bubble.setTransform(t); awtTextureSource.getProvider().addElement(bubble); } private void setupDefaultStates() { _lightState.detachAll(); final DirectionalLight dLight = new DirectionalLight(); dLight.setEnabled(true); dLight.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); dLight.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); dLight.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); dLight.setDirection(new Vector3(-1, -1, -1).normalizeLocal()); _lightState.attach(dLight); _lightState.setEnabled(true); final CullState cs = new CullState(); cs.setEnabled(true); cs.setCullFace(CullState.Face.Back); _root.setRenderState(cs); final FogState fs = new FogState(); fs.setStart(farPlane / 2.0f); fs.setEnd(farPlane); fs.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fs.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fs); } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[1/2/3] Moving speed: " + _controlHandle.getMoveSpeed() * 3.6 + " km/h"); _exampleInfo[1].setText("[R] Draw texture debug: " + terrain.getTextureClipmap().isShowDebug()); _exampleInfo[2].setText("[SPACE] Toggle fly/walk: " + (groundCamera ? "walk" : "fly")); _exampleInfo[3].setText("[J] Regenerate heightmap/texture"); _exampleInfo[4].setText("[U] Freeze terrain(debug): " + !updateTerrain); } } \ No newline at end of file
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/TerrainWaterExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/TerrainWaterExample.java
index 2958130..f436f77 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/TerrainWaterExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/TerrainWaterExample.java
@@ -1 +1 @@
-/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.terrain; import java.nio.FloatBuffer; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.effect.water.WaterNode; import com.ardor3d.extension.terrain.client.Terrain; import com.ardor3d.extension.terrain.client.TerrainBuilder; import com.ardor3d.extension.terrain.client.TerrainDataProvider; import com.ardor3d.extension.terrain.providers.procedural.ProceduralTerrainDataProvider; import com.ardor3d.framework.Canvas; import com.ardor3d.image.Texture; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.intersection.PickingUtil; import com.ardor3d.intersection.PrimitivePickResults; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Plane; import com.ardor3d.math.Ray3; import com.ardor3d.math.Vector3; import com.ardor3d.math.functions.FbmFunction3D; import com.ardor3d.math.functions.Function3D; import com.ardor3d.math.functions.Functions; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.renderer.state.TextureState; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.extension.Skybox; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Quad; import com.ardor3d.scenegraph.shape.Sphere; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.TextureManager; /** * Example showing how to combine the terrain and water systems. Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.TerrainWaterExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_TerrainWaterExample.jpg", // maxHeapMemory = 128) public class TerrainWaterExample extends ExampleBase { private final int SIZE = 2048; private Terrain terrain; private boolean updateTerrain = true; private final float farPlane = 3500.0f; private final float heightOffset = 3.0f; /** The water instance taking care of the water rendering. */ private WaterNode waterNode; private boolean aboveWater = true; /** Node containing debug quads for showing waternode render textures. */ private Node debugQuadsNode; /** The quad used as geometry for the water. */ private Quad waterQuad; private boolean groundCamera = false; private Camera terrainCamera; private Skybox skybox; private final Sphere sphere = new Sphere("sp", 16, 16, 1); private final double textureScale = 0.05; private FogState fogState; private boolean showUI = true; private final Ray3 pickRay = new Ray3(); /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[8]; /** * The main method. * * @param args * the arguments */ public static void main(final String[] args) { start(TerrainWaterExample.class); } private double counter = 0; private int frames = 0; /** * Update the PassManager, skybox, camera position, etc. * * @param timer * the application timer */ @Override protected void updateExample(final ReadOnlyTimer timer) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); final double height = terrain.getHeightAt(camera.getLocation().getX(), camera.getLocation().getZ()) + heightOffset; if (groundCamera || camera.getLocation().getY() < height) { camera.setLocation(new Vector3(camera.getLocation().getX(), height, camera.getLocation().getZ())); } if (aboveWater && camera.getLocation().getY() < waterNode.getWaterHeight()) { fogState.setStart(-1000f); fogState.setEnd(farPlane / 10f); fogState.setColor(new ColorRGBA(0.0f, 0.0f, 0.1f, 1.0f)); aboveWater = false; } else if (!aboveWater && camera.getLocation().getY() >= waterNode.getWaterHeight()) { fogState.setStart(farPlane / 2.0f); fogState.setEnd(farPlane); fogState.setColor(new ColorRGBA(0.96f, 0.97f, 1.0f, 1.0f)); aboveWater = true; } if (updateTerrain) { terrainCamera.set(camera); } skybox.setTranslation(camera.getLocation()); counter += timer.getTimePerFrame(); frames++; if (counter > 1) { final double fps = (frames / counter); counter = 0; frames = 0; System.out.printf("%7.1f FPS\n", fps); } // if we're picking... if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { // Set up our pick ray pickRay.setOrigin(camera.getLocation()); pickRay.setDirection(camera.getDirection()); // do pick and move the sphere final PrimitivePickResults pickResults = new PrimitivePickResults(); pickResults.setCheckDistance(true); PickingUtil.findPick(_root, pickRay, pickResults); if (pickResults.getNumber() != 0) { final Vector3 intersectionPoint = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionPoint(0); sphere.setTranslation(intersectionPoint); // XXX: maybe change the color of the ball for valid vs. invalid? } } final Vector3 transVec = new Vector3(camera.getLocation().getX(), waterNode.getWaterHeight(), camera .getLocation().getZ()); setTextureCoords(0, transVec.getX(), -transVec.getZ(), textureScale); // vertex coords setVertexCoords(transVec.getX(), transVec.getY(), transVec.getZ()); waterNode.update(timer.getTimePerFrame()); } /** * Render example. * * @param renderer * the renderer */ @Override protected void renderExample(final Renderer renderer) { super.renderExample(renderer); if (debugQuadsNode == null) { createDebugQuads(); _root.attachChild(debugQuadsNode); } } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Terrain + Water - Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(0, 100, 0)); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(0, 100, 1), Vector3.UNIT_Y); _canvas.getCanvasRenderer().getCamera().setFrustumPerspective( 65.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / _canvas.getCanvasRenderer().getCamera().getHeight(), 1.0f, farPlane); _controlHandle.setMoveSpeed(50); _lightState.detachAll(); final DirectionalLight dLight = new DirectionalLight(); dLight.setEnabled(true); dLight.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); dLight.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); dLight.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); dLight.setDirection(new Vector3(-1, -1, -1).normalizeLocal()); _lightState.attach(dLight); _lightState.setEnabled(true); final CullState cs = new CullState(); cs.setEnabled(true); cs.setCullFace(CullState.Face.Back); _root.setRenderState(cs); fogState = new FogState(); fogState.setStart(farPlane / 2.0f); fogState.setEnd(farPlane); fogState.setColor(new ColorRGBA(0.96f, 0.97f, 1.0f, 1.0f)); fogState.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fogState); // add our sphere, but have it off for now. sphere.getSceneHints().setCullHint(CullHint.Always); sphere.getSceneHints().setAllPickingHints(false); _root.attachChild(sphere); try { // Keep a separate camera to be able to freeze terrain update final Camera camera = _canvas.getCanvasRenderer().getCamera(); terrainCamera = new Camera(camera); final double scale = 1.0 / 4000.0; Function3D functionTmp = new FbmFunction3D(Functions.simplexNoise(), 9, 0.5, 0.5, 3.14); functionTmp = Functions.clamp(functionTmp, -1.2, 1.2); final Function3D function = Functions.scaleInput(functionTmp, scale, scale, 1); final TerrainDataProvider terrainDataProvider = new ProceduralTerrainDataProvider(function, new Vector3(1, 200, 1), -1.2f, 1.2f); terrain = new TerrainBuilder(terrainDataProvider, terrainCamera).setShowDebugPanels(true).build(); } catch (final Exception ex1) { ex1.printStackTrace(); } final Node reflectedNode = new Node("reflectNode"); reflectedNode.attachChild(terrain); skybox = buildSkyBox(); skybox.getSceneHints().setAllPickingHints(false); reflectedNode.attachChild(skybox); final Camera cam = _canvas.getCanvasRenderer().getCamera(); // Create a new WaterNode with refraction enabled. waterNode = new WaterNode(cam, 2, false, true); // Setup textures to use for the water. waterNode.setNormalMapTextureString("images/water/normalmap3.dds"); waterNode.setDudvMapTextureString("images/water/dudvmap.png"); waterNode.setFallbackMapTextureString("images/water/water2.png"); waterNode.useFadeToFogColor(true); waterNode.setSpeedReflection(0.02); waterNode.setSpeedReflection(-0.01); // setting to default value just to show waterNode.setWaterPlane(new Plane(new Vector3(0.0, 1.0, 0.0), 40.0)); // Create a quad to use as geometry for the water. waterQuad = new Quad("waterQuad", 1, 1); // Hack the quad normals to point up in the y-axis. Since we are manipulating the vertices as // we move this is more convenient than rotating the quad. final FloatBuffer normBuf = waterQuad.getMeshData().getNormalBuffer(); normBuf.clear(); normBuf.put(0).put(1).put(0); normBuf.put(0).put(1).put(0); normBuf.put(0).put(1).put(0); normBuf.put(0).put(1).put(0); waterNode.attachChild(waterQuad); waterNode.addReflectedScene(reflectedNode); waterNode.setSkybox(skybox); _root.attachChild(reflectedNode); _root.attachChild(waterNode); // Setup cam above water and terrain final Camera camera = _canvas.getCanvasRenderer().getCamera(); final double height = Math.max(terrain.getHeightAt(camera.getLocation().getX(), camera.getLocation().getZ()), waterNode.getWaterHeight()) + heightOffset; if (camera.getLocation().getY() < height) { camera.setLocation(new Vector3(camera.getLocation().getX(), height, camera.getLocation().getZ())); } // Setup labels for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() - 20; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { updateTerrain = !updateTerrain; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(5); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(50); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(400); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { groundCamera = !groundCamera; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.P), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { sphere.getSceneHints().setCullHint( sphere.getSceneHints().getCullHint() == CullHint.Always ? CullHint.Dynamic : CullHint.Always); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.V), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { showUI = !showUI; if (showUI) { textNodes.getSceneHints().setCullHint(CullHint.Never); debugQuadsNode.getSceneHints().setCullHint(CullHint.Never); } else { textNodes.getSceneHints().setCullHint(CullHint.Always); debugQuadsNode.getSceneHints().setCullHint(CullHint.Always); } updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.B), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { waterNode.setDoBlurReflection(!waterNode.isDoBlurReflection()); waterNode.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.F), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(new Vector3(camera.getLocation().getX() + 5000, camera.getLocation().getY(), camera .getLocation().getZ())); updateText(); } })); } /** * Sets the vertex coords of the quad. * * @param x * the x * @param y * the y * @param z * the z */ private void setVertexCoords(final double x, final double y, final double z) { final FloatBuffer vertBuf = waterQuad.getMeshData().getVertexBuffer(); vertBuf.clear(); vertBuf.put((float) (x - farPlane)).put((float) y).put((float) (z - farPlane)); vertBuf.put((float) (x - farPlane)).put((float) y).put((float) (z + farPlane)); vertBuf.put((float) (x + farPlane)).put((float) y).put((float) (z + farPlane)); vertBuf.put((float) (x + farPlane)).put((float) y).put((float) (z - farPlane)); } /** * Sets the texture coords of the quad. * * @param buffer * the buffer * @param x * the x * @param y * the y * @param textureScale * the texture scale */ private void setTextureCoords(final int buffer, double x, double y, double textureScale) { x *= textureScale * 0.5f; y *= textureScale * 0.5f; textureScale = farPlane * textureScale; FloatBuffer texBuf; texBuf = waterQuad.getMeshData().getTextureBuffer(buffer); texBuf.clear(); texBuf.put((float) x).put((float) (textureScale + y)); texBuf.put((float) x).put((float) y); texBuf.put((float) (textureScale + x)).put((float) y); texBuf.put((float) (textureScale + x)).put((float) (textureScale + y)); } /** * Builds the sky box. */ private Skybox buildSkyBox() { final Skybox skybox = new Skybox("skybox", 10, 10, 10); final String dir = "images/skybox/"; final Texture north = TextureManager .load(dir + "1.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture south = TextureManager .load(dir + "3.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture east = TextureManager.load(dir + "2.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture west = TextureManager.load(dir + "4.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture up = TextureManager.load(dir + "6.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture down = TextureManager.load(dir + "5.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); skybox.setTexture(Skybox.Face.North, north); skybox.setTexture(Skybox.Face.West, west); skybox.setTexture(Skybox.Face.South, south); skybox.setTexture(Skybox.Face.East, east); skybox.setTexture(Skybox.Face.Up, up); skybox.setTexture(Skybox.Face.Down, down); return skybox; } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("Heightmap size: " + SIZE + "x" + SIZE); _exampleInfo[1].setText("Spec: One meter per heightmap value"); _exampleInfo[2].setText("[1/2/3] Moving speed: " + _controlHandle.getMoveSpeed() + " m/s"); _exampleInfo[3].setText("[U] Update terrain: " + updateTerrain); _exampleInfo[4].setText("[SPACE] Toggle fly/walk: " + (groundCamera ? "walk" : "fly")); _exampleInfo[5].setText("[P] Toggle showing a sphere that follows the ground using picking: " + (sphere.getSceneHints().getCullHint() != CullHint.Always)); _exampleInfo[6].setText("[B] Blur reflection: " + waterNode.isDoBlurReflection()); _exampleInfo[7].setText("[V] Show/Hide UI"); } /** * Creates the debug quads. */ private void createDebugQuads() { debugQuadsNode = new Node("quadNode"); debugQuadsNode.getSceneHints().setCullHint(CullHint.Never); final double quadSize = _canvas.getCanvasRenderer().getCamera().getWidth() / 10; Quad debugQuad = new Quad("reflectionQuad", quadSize, quadSize); debugQuad.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); debugQuad.getSceneHints().setCullHint(CullHint.Never); debugQuad.getSceneHints().setLightCombineMode(LightCombineMode.Off); TextureState ts = new TextureState(); ts.setTexture(waterNode.getTextureReflect()); debugQuad.setRenderState(ts); debugQuad.setTranslation(quadSize * 0.6, quadSize * 1.0, 1.0); debugQuadsNode.attachChild(debugQuad); if (waterNode.getTextureRefract() != null) { debugQuad = new Quad("refractionQuad", quadSize, quadSize); debugQuad.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); debugQuad.getSceneHints().setCullHint(CullHint.Never); debugQuad.getSceneHints().setLightCombineMode(LightCombineMode.Off); ts = new TextureState(); ts.setTexture(waterNode.getTextureRefract()); debugQuad.setRenderState(ts); debugQuad.setTranslation(quadSize * 0.6, quadSize * 2.1, 1.0); debugQuadsNode.attachChild(debugQuad); } } } \ No newline at end of file
+/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.terrain; import java.nio.FloatBuffer; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.effect.water.WaterNode; import com.ardor3d.extension.terrain.client.Terrain; import com.ardor3d.extension.terrain.client.TerrainBuilder; import com.ardor3d.extension.terrain.client.TerrainDataProvider; import com.ardor3d.extension.terrain.providers.procedural.ProceduralTerrainDataProvider; import com.ardor3d.framework.Canvas; import com.ardor3d.image.Texture; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.intersection.PickingUtil; import com.ardor3d.intersection.PrimitivePickResults; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Plane; import com.ardor3d.math.Ray3; import com.ardor3d.math.Vector3; import com.ardor3d.math.functions.FbmFunction3D; import com.ardor3d.math.functions.Function3D; import com.ardor3d.math.functions.Functions; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.renderer.state.TextureState; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.extension.Skybox; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Quad; import com.ardor3d.scenegraph.shape.Sphere; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.TextureManager; /** * Example showing how to combine the terrain and water systems. Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.TerrainWaterExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_TerrainWaterExample.jpg", // maxHeapMemory = 128) public class TerrainWaterExample extends ExampleBase { private final int SIZE = 2048; private Terrain terrain; private boolean updateTerrain = true; private final float farPlane = 3500.0f; private final float heightOffset = 3.0f; /** The water instance taking care of the water rendering. */ private WaterNode waterNode; private boolean aboveWater = true; /** Node containing debug quads for showing waternode render textures. */ private Node debugQuadsNode; /** The quad used as geometry for the water. */ private Quad waterQuad; private boolean groundCamera = false; private Camera terrainCamera; private Skybox skybox; private final Sphere sphere = new Sphere("sp", 16, 16, 1); private final double textureScale = 0.05; private FogState fogState; private boolean showUI = true; private final Ray3 pickRay = new Ray3(); /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[8]; /** * The main method. * * @param args * the arguments */ public static void main(final String[] args) { start(TerrainWaterExample.class); } private double counter = 0; private int frames = 0; /** * Update the PassManager, skybox, camera position, etc. * * @param timer * the application timer */ @Override protected void updateExample(final ReadOnlyTimer timer) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); final double height = terrain.getHeightAt(camera.getLocation().getX(), camera.getLocation().getZ()) + heightOffset; if (groundCamera || camera.getLocation().getY() < height) { camera.setLocation(new Vector3(camera.getLocation().getX(), height, camera.getLocation().getZ())); } if (aboveWater && camera.getLocation().getY() < waterNode.getWaterHeight()) { fogState.setStart(-1000f); fogState.setEnd(farPlane / 10f); fogState.setColor(new ColorRGBA(0.0f, 0.0f, 0.1f, 1.0f)); aboveWater = false; } else if (!aboveWater && camera.getLocation().getY() >= waterNode.getWaterHeight()) { fogState.setStart(farPlane / 2.0f); fogState.setEnd(farPlane); fogState.setColor(new ColorRGBA(0.96f, 0.97f, 1.0f, 1.0f)); aboveWater = true; } if (updateTerrain) { terrainCamera.set(camera); } skybox.setTranslation(camera.getLocation()); counter += timer.getTimePerFrame(); frames++; if (counter > 1) { final double fps = (frames / counter); counter = 0; frames = 0; System.out.printf("%7.1f FPS\n", fps); } // if we're picking... if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { // Set up our pick ray pickRay.setOrigin(camera.getLocation()); pickRay.setDirection(camera.getDirection()); // do pick and move the sphere final PrimitivePickResults pickResults = new PrimitivePickResults(); pickResults.setCheckDistance(true); PickingUtil.findPick(_root, pickRay, pickResults); if (pickResults.getNumber() != 0) { final Vector3 intersectionPoint = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionPoint(0); sphere.setTranslation(intersectionPoint); // XXX: maybe change the color of the ball for valid vs. invalid? } } final Vector3 transVec = new Vector3(camera.getLocation().getX(), waterNode.getWaterHeight(), camera .getLocation().getZ()); setTextureCoords(0, transVec.getX(), -transVec.getZ(), textureScale); // vertex coords setVertexCoords(transVec.getX(), transVec.getY(), transVec.getZ()); waterNode.update(timer.getTimePerFrame()); } /** * Render example. * * @param renderer * the renderer */ @Override protected void renderExample(final Renderer renderer) { super.renderExample(renderer); if (debugQuadsNode == null) { createDebugQuads(); _root.attachChild(debugQuadsNode); } } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Terrain + Water - Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(0, 100, 0)); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(0, 100, 1), Vector3.UNIT_Y); _canvas.getCanvasRenderer().getCamera().setFrustumPerspective( 65.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / _canvas.getCanvasRenderer().getCamera().getHeight(), 1.0f, farPlane); _controlHandle.setMoveSpeed(50); _lightState.detachAll(); final DirectionalLight dLight = new DirectionalLight(); dLight.setEnabled(true); dLight.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); dLight.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); dLight.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); dLight.setDirection(new Vector3(-1, -1, -1).normalizeLocal()); _lightState.attach(dLight); _lightState.setEnabled(true); final CullState cs = new CullState(); cs.setEnabled(true); cs.setCullFace(CullState.Face.Back); _root.setRenderState(cs); fogState = new FogState(); fogState.setStart(farPlane / 2.0f); fogState.setEnd(farPlane); fogState.setColor(new ColorRGBA(0.96f, 0.97f, 1.0f, 1.0f)); fogState.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fogState); // add our sphere, but have it off for now. sphere.getSceneHints().setCullHint(CullHint.Always); sphere.getSceneHints().setAllPickingHints(false); _root.attachChild(sphere); try { // Keep a separate camera to be able to freeze terrain update final Camera camera = _canvas.getCanvasRenderer().getCamera(); terrainCamera = new Camera(camera); final double scale = 1.0 / 4000.0; Function3D functionTmp = new FbmFunction3D(Functions.simplexNoise(), 9, 0.5, 0.5, 3.14); functionTmp = Functions.clamp(functionTmp, -1.2, 1.2); final Function3D function = Functions.scaleInput(functionTmp, scale, scale, 1); final TerrainDataProvider terrainDataProvider = new ProceduralTerrainDataProvider(function, new Vector3(1, 200, 1), -1.2f, 1.2f); terrain = new TerrainBuilder(terrainDataProvider, terrainCamera).setShowDebugPanels(true).build(); } catch (final Exception ex1) { ex1.printStackTrace(); } final Node reflectedNode = new Node("reflectNode"); reflectedNode.attachChild(terrain); skybox = buildSkyBox(); skybox.getSceneHints().setAllPickingHints(false); reflectedNode.attachChild(skybox); final Camera cam = _canvas.getCanvasRenderer().getCamera(); // Create a new WaterNode with refraction enabled. waterNode = new WaterNode(cam, 2, false, true); // Setup textures to use for the water. waterNode.setNormalMapTextureString("images/water/normalmap3.dds"); waterNode.setDudvMapTextureString("images/water/dudvmap.png"); waterNode.setFallbackMapTextureString("images/water/water2.png"); waterNode.useFadeToFogColor(true); waterNode.setSpeedReflection(0.02); waterNode.setSpeedReflection(-0.01); // setting to default value just to show waterNode.setWaterPlane(new Plane(new Vector3(0.0, 1.0, 0.0), 40.0)); // Create a quad to use as geometry for the water. waterQuad = new Quad("waterQuad", 1, 1); // Hack the quad normals to point up in the y-axis. Since we are manipulating the vertices as // we move this is more convenient than rotating the quad. final FloatBuffer normBuf = waterQuad.getMeshData().getNormalBuffer(); normBuf.clear(); normBuf.put(0).put(1).put(0); normBuf.put(0).put(1).put(0); normBuf.put(0).put(1).put(0); normBuf.put(0).put(1).put(0); waterNode.attachChild(waterQuad); waterNode.addReflectedScene(reflectedNode); waterNode.setSkybox(skybox); _root.attachChild(reflectedNode); _root.attachChild(waterNode); // Setup cam above water and terrain final Camera camera = _canvas.getCanvasRenderer().getCamera(); final double height = Math.max(terrain.getHeightAt(camera.getLocation().getX(), camera.getLocation().getZ()), waterNode.getWaterHeight()) + heightOffset; if (camera.getLocation().getY() < height) { camera.setLocation(new Vector3(camera.getLocation().getX(), height, camera.getLocation().getZ())); } // Setup labels for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() - 20; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { updateTerrain = !updateTerrain; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(5); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(50); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(400); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { groundCamera = !groundCamera; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.P), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { sphere.getSceneHints().setCullHint( sphere.getSceneHints().getCullHint() == CullHint.Always ? CullHint.Dynamic : CullHint.Always); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.V), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { showUI = !showUI; if (showUI) { textNodes.getSceneHints().setCullHint(CullHint.Never); debugQuadsNode.getSceneHints().setCullHint(CullHint.Never); } else { textNodes.getSceneHints().setCullHint(CullHint.Always); debugQuadsNode.getSceneHints().setCullHint(CullHint.Always); } updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.B), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { waterNode.setDoBlurReflection(!waterNode.isDoBlurReflection()); waterNode.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.F), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(new Vector3(camera.getLocation().getX() + 5000, camera.getLocation().getY(), camera .getLocation().getZ())); updateText(); } })); } /** * Sets the vertex coords of the quad. * * @param x * the x * @param y * the y * @param z * the z */ private void setVertexCoords(final double x, final double y, final double z) { final FloatBuffer vertBuf = waterQuad.getMeshData().getVertexBuffer(); vertBuf.clear(); vertBuf.put((float) (x - farPlane)).put((float) y).put((float) (z - farPlane)); vertBuf.put((float) (x - farPlane)).put((float) y).put((float) (z + farPlane)); vertBuf.put((float) (x + farPlane)).put((float) y).put((float) (z + farPlane)); vertBuf.put((float) (x + farPlane)).put((float) y).put((float) (z - farPlane)); } /** * Sets the texture coords of the quad. * * @param buffer * the buffer * @param x * the x * @param y * the y * @param textureScale * the texture scale */ private void setTextureCoords(final int buffer, double x, double y, double textureScale) { x *= textureScale * 0.5f; y *= textureScale * 0.5f; textureScale = farPlane * textureScale; FloatBuffer texBuf; texBuf = waterQuad.getMeshData().getTextureBuffer(buffer); texBuf.clear(); texBuf.put((float) x).put((float) (textureScale + y)); texBuf.put((float) x).put((float) y); texBuf.put((float) (textureScale + x)).put((float) y); texBuf.put((float) (textureScale + x)).put((float) (textureScale + y)); } /** * Builds the sky box. */ private Skybox buildSkyBox() { final Skybox skybox = new Skybox("skybox", 10, 10, 10); final String dir = "images/skybox/"; final Texture north = TextureManager .load(dir + "1.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture south = TextureManager .load(dir + "3.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture east = TextureManager.load(dir + "2.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture west = TextureManager.load(dir + "4.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture up = TextureManager.load(dir + "6.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture down = TextureManager.load(dir + "5.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); skybox.setTexture(Skybox.Face.North, north); skybox.setTexture(Skybox.Face.West, west); skybox.setTexture(Skybox.Face.South, south); skybox.setTexture(Skybox.Face.East, east); skybox.setTexture(Skybox.Face.Up, up); skybox.setTexture(Skybox.Face.Down, down); return skybox; } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("Heightmap size: " + SIZE + "x" + SIZE); _exampleInfo[1].setText("Spec: One meter per heightmap value"); _exampleInfo[2].setText("[1/2/3] Moving speed: " + _controlHandle.getMoveSpeed() + " m/s"); _exampleInfo[3].setText("[U] Update terrain: " + updateTerrain); _exampleInfo[4].setText("[SPACE] Toggle fly/walk: " + (groundCamera ? "walk" : "fly")); _exampleInfo[5].setText("[P] Toggle showing a sphere that follows the ground using picking: " + (sphere.getSceneHints().getCullHint() != CullHint.Always)); _exampleInfo[6].setText("[B] Blur reflection: " + waterNode.isDoBlurReflection()); _exampleInfo[7].setText("[V] Show/Hide UI"); } /** * Creates the debug quads. */ private void createDebugQuads() { debugQuadsNode = new Node("quadNode"); debugQuadsNode.getSceneHints().setCullHint(CullHint.Never); final double quadSize = _canvas.getCanvasRenderer().getCamera().getWidth() / 10; Quad debugQuad = new Quad("reflectionQuad", quadSize, quadSize); debugQuad.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); debugQuad.getSceneHints().setCullHint(CullHint.Never); debugQuad.getSceneHints().setLightCombineMode(LightCombineMode.Off); TextureState ts = new TextureState(); ts.setTexture(waterNode.getTextureReflect()); debugQuad.setRenderState(ts); debugQuad.setTranslation(quadSize * 0.6, quadSize * 1.0, 1.0); debugQuadsNode.attachChild(debugQuad); if (waterNode.getTextureRefract() != null) { debugQuad = new Quad("refractionQuad", quadSize, quadSize); debugQuad.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); debugQuad.getSceneHints().setCullHint(CullHint.Never); debugQuad.getSceneHints().setLightCombineMode(LightCombineMode.Off); ts = new TextureState(); ts.setTexture(waterNode.getTextureRefract()); debugQuad.setRenderState(ts); debugQuad.setTranslation(quadSize * 0.6, quadSize * 2.1, 1.0); debugQuadsNode.attachChild(debugQuad); } } } \ No newline at end of file
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ZupTerrainExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ZupTerrainExample.java
index 29ff14a..53a5c43 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ZupTerrainExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/terrain/ZupTerrainExample.java
@@ -1 +1 @@
-/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.terrain; import java.util.concurrent.Callable; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.terrain.client.Terrain; import com.ardor3d.extension.terrain.client.TerrainBuilder; import com.ardor3d.extension.terrain.client.TerrainDataProvider; import com.ardor3d.extension.terrain.heightmap.MidPointHeightMapGenerator; import com.ardor3d.extension.terrain.providers.array.ArrayTerrainDataProvider; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.image.Texture; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.intersection.PickingUtil; import com.ardor3d.intersection.PrimitivePickResults; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.MathUtils; import com.ardor3d.math.Quaternion; import com.ardor3d.math.Ray3; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.extension.Skybox; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Sphere; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.GameTaskQueue; import com.ardor3d.util.GameTaskQueueManager; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.TextureManager; /** * Example showing the Geometry Clipmap Terrain system with 'MegaTextures' using Z-Up. This is done by flipping the * terrain system from y-up to z-up and inverting interactions with it back to the y-up terrain coordinate space. * Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.ZupTerrainExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_ZupTerrainExample.jpg", // maxHeapMemory = 128) public class ZupTerrainExample extends ExampleBase { private boolean updateTerrain = true; private final float farPlane = 10000.0f; private Terrain terrain; private final Sphere sphere = new Sphere("sp", 16, 16, 1); private final Ray3 pickRay = new Ray3(); private boolean groundCamera = false; private Camera terrainCamera; private Skybox skybox; /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[5]; public static void main(final String[] args) { ExampleBase.start(ZupTerrainExample.class); } @Override protected void updateExample(final ReadOnlyTimer timer) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); // Make sure camera is above terrain pickRay.setOrigin(camera.getLocation()); pickRay.setDirection(Vector3.NEG_UNIT_Z); final PrimitivePickResults pickResultsCam = new PrimitivePickResults(); pickResultsCam.setCheckDistance(true); PickingUtil.findPick(terrain, pickRay, pickResultsCam); if (pickResultsCam.getNumber() != 0) { final Vector3 intersectionPoint = pickResultsCam.getPickData(0).getIntersectionRecord() .getIntersectionPoint(0); final double height = intersectionPoint.getZ(); if (height > -Float.MAX_VALUE && (groundCamera || camera.getLocation().getZ() < height + 5)) { camera.setLocation(new Vector3(camera.getLocation().getX(), camera.getLocation().getY(), height + 5)); } } if (updateTerrain) { terrainCamera.set(camera); } skybox.setTranslation(camera.getLocation()); // if we're picking... if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { // Set up our pick ray pickRay.setOrigin(camera.getLocation()); pickRay.setDirection(camera.getDirection()); // do pick and move the sphere final PrimitivePickResults pickResults = new PrimitivePickResults(); pickResults.setCheckDistance(true); PickingUtil.findPick(_root, pickRay, pickResults); if (pickResults.getNumber() != 0) { final Vector3 intersectionPoint = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionPoint(0); sphere.setTranslation(intersectionPoint); // XXX: maybe change the color of the ball for valid vs. invalid? } } } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Z-up Terrain Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(0, 0, 300)); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(1, -1, 300), Vector3.UNIT_Z); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 70.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / _canvas.getCanvasRenderer().getCamera().getHeight(), 1.0f, farPlane); final CanvasRenderer canvasRenderer = _canvas.getCanvasRenderer(); final RenderContext renderContext = canvasRenderer.getRenderContext(); final Renderer renderer = canvasRenderer.getRenderer(); GameTaskQueueManager.getManager(renderContext).getQueue(GameTaskQueue.RENDER).enqueue(new Callable<Void>() { @Override public Void call() throws Exception { renderer.setBackgroundColor(ColorRGBA.GRAY); return null; } }); _controlHandle.setUpAxis(Vector3.UNIT_Z); _controlHandle.setMoveSpeed(200); setupDefaultStates(); sphere.getSceneHints().setAllPickingHints(false); sphere.getSceneHints().setCullHint(CullHint.Always); _root.attachChild(sphere); try { // Keep a separate camera to be able to freeze terrain update final Camera camera = _canvas.getCanvasRenderer().getCamera(); terrainCamera = new Camera(camera); final int SIZE = 2048; final MidPointHeightMapGenerator raw = new MidPointHeightMapGenerator(SIZE, 0.5f); raw.setHeightRange(0.2f); final float[] heightMap = raw.getHeightData(); final TerrainDataProvider terrainDataProvider = new ArrayTerrainDataProvider(heightMap, SIZE, new Vector3( 1, 300, 1)); terrain = new TerrainBuilder(terrainDataProvider, terrainCamera).setShowDebugPanels(true).build(); terrain.setRotation(new Quaternion().fromAngleAxis(MathUtils.HALF_PI, Vector3.UNIT_X)); _root.attachChild(terrain); } catch (final Exception ex1) { System.out.println("Problem setting up terrain..."); ex1.printStackTrace(); } skybox = buildSkyBox(); skybox.getSceneHints().setAllPickingHints(false); _root.attachChild(skybox); // Setup labels for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { updateTerrain = !updateTerrain; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(5); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(50); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(400); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(1000); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { groundCamera = !groundCamera; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.P), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { sphere.getSceneHints().setCullHint(CullHint.Always); } else if (sphere.getSceneHints().getCullHint() == CullHint.Always) { sphere.getSceneHints().setCullHint(CullHint.Dynamic); } updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setShowDebug(!terrain.getTextureClipmap().isShowDebug()); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.reloadShader(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() / 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() * 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SEVEN), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX() + 500.0, camera.getLocation().getY(), camera .getLocation().getZ()); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.EIGHT), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX() - 500.0, camera.getLocation().getY(), camera .getLocation().getZ()); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() + 500.0); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() - 500.0); } })); } private void setupDefaultStates() { _lightState.detachAll(); final DirectionalLight dLight = new DirectionalLight(); dLight.setEnabled(true); dLight.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); dLight.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); dLight.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); dLight.setDirection(new Vector3(-1, -1, -1).normalizeLocal()); _lightState.attach(dLight); _lightState.setEnabled(true); final CullState cs = new CullState(); cs.setEnabled(true); cs.setCullFace(CullState.Face.Back); _root.setRenderState(cs); final FogState fs = new FogState(); fs.setStart(farPlane / 2.0f); fs.setEnd(farPlane); fs.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fs.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fs); } /** * Builds the sky box. */ private Skybox buildSkyBox() { final Skybox skybox = new Skybox("skybox", 10, 10, 10); final String dir = "images/skybox/"; final Texture north = TextureManager .load(dir + "1.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture south = TextureManager .load(dir + "3.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture east = TextureManager.load(dir + "2.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture west = TextureManager.load(dir + "4.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture up = TextureManager.load(dir + "6.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture down = TextureManager.load(dir + "5.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); skybox.setTexture(Skybox.Face.North, north); skybox.setTexture(Skybox.Face.West, west); skybox.setTexture(Skybox.Face.South, south); skybox.setTexture(Skybox.Face.East, east); skybox.setTexture(Skybox.Face.Up, up); skybox.setTexture(Skybox.Face.Down, down); skybox.setRotation(new Quaternion().fromAngleAxis(MathUtils.HALF_PI, Vector3.UNIT_X)); return skybox; } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[1/2/3] Moving speed: " + _controlHandle.getMoveSpeed() * 3.6 + " km/h"); _exampleInfo[1].setText("[P] Do picking: " + (sphere.getSceneHints().getCullHint() == CullHint.Dynamic)); _exampleInfo[2].setText("[SPACE] Toggle fly/walk: " + (groundCamera ? "walk" : "fly")); _exampleInfo[3].setText("[J] Regenerate heightmap/texture"); _exampleInfo[4].setText("[U] Freeze terrain(debug): " + !updateTerrain); } } \ No newline at end of file
+/** * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.terrain; import java.util.concurrent.Callable; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; import com.ardor3d.extension.terrain.client.Terrain; import com.ardor3d.extension.terrain.client.TerrainBuilder; import com.ardor3d.extension.terrain.client.TerrainDataProvider; import com.ardor3d.extension.terrain.heightmap.MidPointHeightMapGenerator; import com.ardor3d.extension.terrain.providers.array.ArrayTerrainDataProvider; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.image.Texture; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.intersection.PickingUtil; import com.ardor3d.intersection.PrimitivePickResults; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.MathUtils; import com.ardor3d.math.Quaternion; import com.ardor3d.math.Ray3; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.extension.Skybox; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Sphere; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.GameTaskQueue; import com.ardor3d.util.GameTaskQueueManager; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.TextureManager; /** * Example showing the Geometry Clipmap Terrain system with 'MegaTextures' using Z-Up. This is done by flipping the * terrain system from y-up to z-up and inverting interactions with it back to the y-up terrain coordinate space. * Requires GLSL support. */ @Purpose(htmlDescriptionKey = "com.ardor3d.example.terrain.ZupTerrainExample", // thumbnailPath = "com/ardor3d/example/media/thumbnails/terrain_ZupTerrainExample.jpg", // maxHeapMemory = 128) public class ZupTerrainExample extends ExampleBase { private boolean updateTerrain = true; private final float farPlane = 10000.0f; private Terrain terrain; private final Sphere sphere = new Sphere("sp", 16, 16, 1); private final Ray3 pickRay = new Ray3(); private boolean groundCamera = false; private Camera terrainCamera; private Skybox skybox; /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[5]; public static void main(final String[] args) { ExampleBase.start(ZupTerrainExample.class); } @Override protected void updateExample(final ReadOnlyTimer timer) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); // Make sure camera is above terrain pickRay.setOrigin(camera.getLocation()); pickRay.setDirection(Vector3.NEG_UNIT_Z); final PrimitivePickResults pickResultsCam = new PrimitivePickResults(); pickResultsCam.setCheckDistance(true); PickingUtil.findPick(terrain, pickRay, pickResultsCam); if (pickResultsCam.getNumber() != 0) { final Vector3 intersectionPoint = pickResultsCam.getPickData(0).getIntersectionRecord() .getIntersectionPoint(0); final double height = intersectionPoint.getZ(); if (height > -Float.MAX_VALUE && (groundCamera || camera.getLocation().getZ() < height + 5)) { camera.setLocation(new Vector3(camera.getLocation().getX(), camera.getLocation().getY(), height + 5)); } } if (updateTerrain) { terrainCamera.set(camera); } skybox.setTranslation(camera.getLocation()); // if we're picking... if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { // Set up our pick ray pickRay.setOrigin(camera.getLocation()); pickRay.setDirection(camera.getDirection()); // do pick and move the sphere final PrimitivePickResults pickResults = new PrimitivePickResults(); pickResults.setCheckDistance(true); PickingUtil.findPick(_root, pickRay, pickResults); if (pickResults.getNumber() != 0) { final Vector3 intersectionPoint = pickResults.getPickData(0).getIntersectionRecord() .getIntersectionPoint(0); sphere.setTranslation(intersectionPoint); // XXX: maybe change the color of the ball for valid vs. invalid? } } } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Z-up Terrain Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(0, 0, 300)); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(1, -1, 300), Vector3.UNIT_Z); _canvas.getCanvasRenderer() .getCamera() .setFrustumPerspective( 70.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / _canvas.getCanvasRenderer().getCamera().getHeight(), 1.0f, farPlane); final CanvasRenderer canvasRenderer = _canvas.getCanvasRenderer(); final RenderContext renderContext = canvasRenderer.getRenderContext(); final Renderer renderer = canvasRenderer.getRenderer(); GameTaskQueueManager.getManager(renderContext).getQueue(GameTaskQueue.RENDER).enqueue(new Callable<Void>() { @Override public Void call() throws Exception { renderer.setBackgroundColor(ColorRGBA.GRAY); return null; } }); _controlHandle.setUpAxis(Vector3.UNIT_Z); _controlHandle.setMoveSpeed(200); setupDefaultStates(); sphere.getSceneHints().setAllPickingHints(false); sphere.getSceneHints().setCullHint(CullHint.Always); _root.attachChild(sphere); try { // Keep a separate camera to be able to freeze terrain update final Camera camera = _canvas.getCanvasRenderer().getCamera(); terrainCamera = new Camera(camera); final int SIZE = 2048; final MidPointHeightMapGenerator raw = new MidPointHeightMapGenerator(SIZE, 0.5f); raw.setHeightRange(0.2f); final float[] heightMap = raw.getHeightData(); final TerrainDataProvider terrainDataProvider = new ArrayTerrainDataProvider(heightMap, SIZE, new Vector3( 1, 300, 1)); terrain = new TerrainBuilder(terrainDataProvider, terrainCamera).setShowDebugPanels(true).build(); terrain.setRotation(new Quaternion().fromAngleAxis(MathUtils.HALF_PI, Vector3.UNIT_X)); _root.attachChild(terrain); } catch (final Exception ex1) { System.out.println("Problem setting up terrain..."); ex1.printStackTrace(); } skybox = buildSkyBox(); skybox.getSceneHints().setAllPickingHints(false); _root.attachChild(skybox); // Setup labels for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { updateTerrain = !updateTerrain; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(5); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(50); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(400); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(1000); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { groundCamera = !groundCamera; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.P), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { sphere.getSceneHints().setCullHint(CullHint.Always); } else if (sphere.getSceneHints().getCullHint() == CullHint.Always) { sphere.getSceneHints().setCullHint(CullHint.Dynamic); } updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setShowDebug(!terrain.getTextureClipmap().isShowDebug()); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.reloadShader(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() / 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { terrain.getTextureClipmap().setScale(terrain.getTextureClipmap().getScale() * 2); terrain.reloadShader(); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SEVEN), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX() + 500.0, camera.getLocation().getY(), camera .getLocation().getZ()); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.EIGHT), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX() - 500.0, camera.getLocation().getY(), camera .getLocation().getZ()); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() + 500.0); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() { @Override public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation() .getZ() - 500.0); } })); } private void setupDefaultStates() { _lightState.detachAll(); final DirectionalLight dLight = new DirectionalLight(); dLight.setEnabled(true); dLight.setAmbient(new ColorRGBA(0.4f, 0.4f, 0.5f, 1)); dLight.setDiffuse(new ColorRGBA(0.6f, 0.6f, 0.5f, 1)); dLight.setSpecular(new ColorRGBA(0.3f, 0.3f, 0.2f, 1)); dLight.setDirection(new Vector3(-1, -1, -1).normalizeLocal()); _lightState.attach(dLight); _lightState.setEnabled(true); final CullState cs = new CullState(); cs.setEnabled(true); cs.setCullFace(CullState.Face.Back); _root.setRenderState(cs); final FogState fs = new FogState(); fs.setStart(farPlane / 2.0f); fs.setEnd(farPlane); fs.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fs.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fs); } /** * Builds the sky box. */ private Skybox buildSkyBox() { final Skybox skybox = new Skybox("skybox", 10, 10, 10); final String dir = "images/skybox/"; final Texture north = TextureManager .load(dir + "1.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture south = TextureManager .load(dir + "3.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture east = TextureManager.load(dir + "2.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture west = TextureManager.load(dir + "4.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture up = TextureManager.load(dir + "6.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); final Texture down = TextureManager.load(dir + "5.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true); skybox.setTexture(Skybox.Face.North, north); skybox.setTexture(Skybox.Face.West, west); skybox.setTexture(Skybox.Face.South, south); skybox.setTexture(Skybox.Face.East, east); skybox.setTexture(Skybox.Face.Up, up); skybox.setTexture(Skybox.Face.Down, down); skybox.setRotation(new Quaternion().fromAngleAxis(MathUtils.HALF_PI, Vector3.UNIT_X)); return skybox; } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("[1/2/3] Moving speed: " + _controlHandle.getMoveSpeed() * 3.6 + " km/h"); _exampleInfo[1].setText("[P] Do picking: " + (sphere.getSceneHints().getCullHint() == CullHint.Dynamic)); _exampleInfo[2].setText("[SPACE] Toggle fly/walk: " + (groundCamera ? "walk" : "fly")); _exampleInfo[3].setText("[J] Regenerate heightmap/texture"); _exampleInfo[4].setText("[U] Freeze terrain(debug): " + !updateTerrain); } } \ No newline at end of file
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/ui/BMTextExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/ui/BMTextExample.java
index dc2b588..ae60475 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/ui/BMTextExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/ui/BMTextExample.java
@@ -184,6 +184,7 @@ public class BMTextExample extends ExampleBase {
final int changeInterval = 20000;
final List<BMFont> fonts = BMFontLoader.allFonts();
+ @Override
public void update(final double time, final BMText text) {
final int t = (int) (System.currentTimeMillis() / changeInterval);
final int index = t % fonts.size();
@@ -216,6 +217,7 @@ public class BMTextExample extends ExampleBase {
final SpatialController<Node> nodeMover = new SpatialController<Node>() {
Matrix3 rot = new Matrix3();
+ @Override
public void update(final double time, final Node caller) {
final long t = System.currentTimeMillis();
final double s = Math.cos(t * Math.PI / 10000.0);
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/ui/RotatingUIExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/ui/RotatingUIExample.java
index b66b7a2..35f2615 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/ui/RotatingUIExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/ui/RotatingUIExample.java
@@ -94,6 +94,7 @@ public class RotatingUIExample extends ExampleBase {
rotatingLabel.addController(new SpatialController<UICheckBox>() {
double angle = 0;
+ @Override
public void update(final double time, final UICheckBox caller) {
angle += time * 10;
angle %= 360;
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/ui/SimpleUIExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/ui/SimpleUIExample.java
index 8c756e5..17f387f 100644
--- a/ardor3d-examples/src/main/java/com/ardor3d/example/ui/SimpleUIExample.java
+++ b/ardor3d-examples/src/main/java/com/ardor3d/example/ui/SimpleUIExample.java
@@ -90,6 +90,7 @@ public class SimpleUIExample extends ExampleBase {
private double angle = 0;
private final Vector3 axis = new Vector3(1, 1, 0.5f).normalizeLocal();
+ @Override
public void update(final double time, final Box caller) {
angle += time * 50;
angle %= 360;
@@ -171,6 +172,7 @@ public class SimpleUIExample extends ExampleBase {
tfPassword.setLayoutData(GridLayoutData.WrapAndGrow);
final UIButton btLogin = new UIButton("login");
btLogin.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
System.out.println("login as user: " + tfName.getText() + " password: " + tfPassword.getText());
}
@@ -202,6 +204,7 @@ public class SimpleUIExample extends ExampleBase {
chatButton.setLayoutData(BorderLayoutData.EAST);
final ActionListener actionListener = new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
applyChat(historyArea, chatField);
}
@@ -271,6 +274,7 @@ public class SimpleUIExample extends ExampleBase {
final UILabel lSliderValue = new UILabel("0");
lSliderValue.setLayoutData(GridLayoutData.SpanAndWrap(2));
slider.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
lSliderValue.setText(String.valueOf(slider.getValue()));
}
@@ -333,6 +337,7 @@ public class SimpleUIExample extends ExampleBase {
multiImgBD.addImage(minute);
clockPanel.addController(new SpatialController<Spatial>() {
+ @Override
public void update(final double time, final Spatial caller) {
final double angle1 = _timer.getTimeInSeconds() % MathUtils.TWO_PI;
final double angle2 = (_timer.getTimeInSeconds() / 12.) % MathUtils.TWO_PI;
diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java
index e49ad25..bfb1f63 100644
--- a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java
+++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java
@@ -123,11 +123,13 @@ public class InteractManager {
*/
private void setupLogicalLayer() {
_logicalLayer.registerTrigger(new InputTrigger(new Predicate<TwoInputStates>() {
+ @Override
public boolean apply(final TwoInputStates arg0) {
// always trigger this.
return true;
}
}, new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (_spatialTarget != null) {
_state.getTransform().set(_spatialTarget.getTransform());
diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Line3.java b/ardor3d-math/src/main/java/com/ardor3d/math/Line3.java
index 453f48a..ca8d6cc 100644
--- a/ardor3d-math/src/main/java/com/ardor3d/math/Line3.java
+++ b/ardor3d-math/src/main/java/com/ardor3d/math/Line3.java
@@ -69,6 +69,7 @@ public class Line3 extends Line3Base implements ReadOnlyLine3, Poolable {
* @throws NullPointerException
* if the point is null.
*/
+ @Override
public double distanceSquared(final ReadOnlyVector3 point, final Vector3 store) {
final Vector3 vectorA = Vector3.fetchTempInstance();
vectorA.set(point).subtractLocal(_origin);
diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Line3Base.java b/ardor3d-math/src/main/java/com/ardor3d/math/Line3Base.java
index 6b6e5f7..409268a 100644
--- a/ardor3d-math/src/main/java/com/ardor3d/math/Line3Base.java
+++ b/ardor3d-math/src/main/java/com/ardor3d/math/Line3Base.java
@@ -84,15 +84,18 @@ public abstract class Line3Base implements Savable, Externalizable {
// Methods for Savable
// /////////////////
+ @Override
public Class<? extends Line3Base> getClassTag() {
return this.getClass();
}
+ @Override
public void write(final OutputCapsule capsule) throws IOException {
capsule.write(_origin, "origin", new Vector3(Vector3.ZERO));
capsule.write(_direction, "direction", new Vector3(Vector3.UNIT_Z));
}
+ @Override
public void read(final InputCapsule capsule) throws IOException {
_origin.set((Vector3) capsule.readSavable("origin", new Vector3(Vector3.ZERO)));
_direction.set((Vector3) capsule.readSavable("direction", new Vector3(Vector3.UNIT_Z)));
@@ -110,6 +113,7 @@ public abstract class Line3Base implements Savable, Externalizable {
* @throws IOException
* @throws ClassNotFoundException
*/
+ @Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
setOrigin((Vector3) in.readObject());
setDirection((Vector3) in.readObject());
@@ -122,6 +126,7 @@ public abstract class Line3Base implements Savable, Externalizable {
* ObjectOutput
* @throws IOException
*/
+ @Override
public void writeExternal(final ObjectOutput out) throws IOException {
out.writeObject(_origin);
out.writeObject(_direction);
diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/functions/ArchimedeanSpiralFunction3D.java b/ardor3d-math/src/main/java/com/ardor3d/math/functions/ArchimedeanSpiralFunction3D.java
index c2952c5..23b3fe6 100644
--- a/ardor3d-math/src/main/java/com/ardor3d/math/functions/ArchimedeanSpiralFunction3D.java
+++ b/ardor3d-math/src/main/java/com/ardor3d/math/functions/ArchimedeanSpiralFunction3D.java
@@ -57,6 +57,7 @@ public class ArchimedeanSpiralFunction3D implements Function3D {
*
* @return A result which is generally, but not always, in the -1 to 1 range.
*/
+ @Override
public double eval(final double x, final double y, final double z) {
final double radius = Math.sqrt(x * x + y * y);
diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/functions/CheckerFunction3D.java b/ardor3d-math/src/main/java/com/ardor3d/math/functions/CheckerFunction3D.java
index b782051..6ba1916 100644
--- a/ardor3d-math/src/main/java/com/ardor3d/math/functions/CheckerFunction3D.java
+++ b/ardor3d-math/src/main/java/com/ardor3d/math/functions/CheckerFunction3D.java
@@ -17,6 +17,7 @@ import com.ardor3d.math.MathUtils;
*/
public class CheckerFunction3D implements Function3D {
+ @Override
public double eval(final double x, final double y, final double z) {
if ((MathUtils.floor(x) + MathUtils.floor(y) + MathUtils.floor(z)) % 2 == 0) {
return -1;
diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/functions/CylinderFunction3D.java b/ardor3d-math/src/main/java/com/ardor3d/math/functions/CylinderFunction3D.java
index 6ec23b0..0fbfa60 100644
--- a/ardor3d-math/src/main/java/com/ardor3d/math/functions/CylinderFunction3D.java
+++ b/ardor3d-math/src/main/java/com/ardor3d/math/functions/CylinderFunction3D.java
@@ -30,6 +30,7 @@ public class CylinderFunction3D implements Function3D {
setFrequency(frequency);
}
+ @Override
public double eval(final double x, final double y, final double z) {
final double dx = x * _frequency;
final double dz = z * _frequency;
diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/functions/FbmFunction3D.java b/ardor3d-math/src/main/java/com/ardor3d/math/functions/FbmFunction3D.java
index 7aa48b4..3fbd641 100644
--- a/ardor3d-math/src/main/java/com/ardor3d/math/functions/FbmFunction3D.java
+++ b/ardor3d-math/src/main/java/com/ardor3d/math/functions/FbmFunction3D.java
@@ -54,6 +54,7 @@ public class FbmFunction3D implements Function3D {
_lacunarity = lacunarity;
}
+ @Override
public double eval(final double x, final double y, final double z) {
double sum = 0;
double dx = x * _frequency, dy = y * _frequency, dz = z * _frequency;
diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/functions/Functions.java b/ardor3d-math/src/main/java/com/ardor3d/math/functions/Functions.java
index b0ba25d..86e11a7 100644
--- a/ardor3d-math/src/main/java/com/ardor3d/math/functions/Functions.java
+++ b/ardor3d-math/src/main/java/com/ardor3d/math/functions/Functions.java
@@ -25,6 +25,7 @@ public class Functions {
*/
public static Function3D constant(final double constant) {
return new Function3D() {
+ @Override
public double eval(final double x, final double y, final double z) {
return constant;
}
@@ -39,6 +40,7 @@ public class Functions {
*/
public static Function3D scaleBias(final Function3D source, final double scale, final double bias) {
return new Function3D() {
+ @Override
public double eval(final double x, final double y, final double z) {
return source.eval(x, y, z) * scale + bias;
}
@@ -51,6 +53,7 @@ public class Functions {
*/
public static Function3D abs(final Function3D source) {
return new Function3D() {
+ @Override
public double eval(final double x, final double y, final double z) {
return Math.abs(source.eval(x, y, z));
}
@@ -65,6 +68,7 @@ public class Functions {
*/
public static Function3D clamp(final Function3D source, final double min, final double max) {
return new Function3D() {
+ @Override
public double eval(final double x, final double y, final double z) {
return MathUtils.clamp(source.eval(x, y, z), min, max);
}
@@ -77,6 +81,7 @@ public class Functions {
*/
public static Function3D invert(final Function3D source) {
return new Function3D() {
+ @Override
public double eval(final double x, final double y, final double z) {
return -source.eval(x, y, z);
}
@@ -90,6 +95,7 @@ public class Functions {
*/
public static Function3D add(final Function3D sourceA, final Function3D sourceB) {
return new Function3D() {
+ @Override
public double eval(final double x, final double y, final double z) {
return sourceA.eval(x, y, z) + sourceB.eval(x, y, z);
}
@@ -103,6 +109,7 @@ public class Functions {
*/
public static Function3D multiply(final Function3D sourceA, final Function3D sourceB) {
return new Function3D() {
+ @Override
public double eval(final double x, final double y, final double z) {
return sourceA.eval(x, y, z) * sourceB.eval(x, y, z);
}
@@ -116,6 +123,7 @@ public class Functions {
*/
public static Function3D min(final Function3D sourceA, final Function3D sourceB) {
return new Function3D() {
+ @Override
public double eval(final double x, final double y, final double z) {
return Math.min(sourceA.eval(x, y, z), sourceB.eval(x, y, z));
}
@@ -129,6 +137,7 @@ public class Functions {
*/
public static Function3D max(final Function3D sourceA, final Function3D sourceB) {
return new Function3D() {
+ @Override
public double eval(final double x, final double y, final double z) {
return Math.max(sourceA.eval(x, y, z), sourceB.eval(x, y, z));
}
@@ -145,6 +154,7 @@ public class Functions {
*/
public static Function3D lerp(final Function3D sourceA, final Function3D sourceB, final double amount) {
return new Function3D() {
+ @Override
public double eval(final double x, final double y, final double z) {
return MathUtils.lerp(amount, sourceA.eval(x, y, z), sourceB.eval(x, y, z));
}
@@ -159,6 +169,7 @@ public class Functions {
*/
public static Function3D rotateInput(final Function3D source, final ReadOnlyMatrix3 rotation) {
return new Function3D() {
+ @Override
public double eval(final double x, final double y, final double z) {
final Vector3 temp = Vector3.fetchTempInstance();
temp.set(x, y, z);
@@ -180,6 +191,7 @@ public class Functions {
public static Function3D scaleInput(final Function3D source, final double scaleX, final double scaleY,
final double scaleZ) {
return new Function3D() {
+ @Override
public double eval(final double x, final double y, final double z) {
return source.eval(x * scaleX, y * scaleY, z * scaleZ);
}
@@ -196,6 +208,7 @@ public class Functions {
public static Function3D translateInput(final Function3D source, final double transX, final double transY,
final double transZ) {
return new Function3D() {
+ @Override
public double eval(final double x, final double y, final double z) {
return source.eval(x + transX, y + transY, z + transZ);
}
@@ -213,6 +226,7 @@ public class Functions {
public static Function3D remap(final Function3D source, final double oldLow, final double oldHigh,
final double newLow, final double newHigh) {
return new Function3D() {
+ @Override
public double eval(final double x, final double y, final double z) {
double val = source.eval(x, y, z);
// Zero out old domain
@@ -233,6 +247,7 @@ public class Functions {
return new Function3D() {
SimplexNoise noiseGenerator = new SimplexNoise();
+ @Override
public double eval(final double x, final double y, final double z) {
return noiseGenerator.noise(x, y, z);
}
diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/functions/GridPatternFunction3D.java b/ardor3d-math/src/main/java/com/ardor3d/math/functions/GridPatternFunction3D.java
index 1d74d00..8cbf487 100644
--- a/ardor3d-math/src/main/java/com/ardor3d/math/functions/GridPatternFunction3D.java
+++ b/ardor3d-math/src/main/java/com/ardor3d/math/functions/GridPatternFunction3D.java
@@ -51,6 +51,7 @@ public class GridPatternFunction3D implements Function3D {
*
* @return
*/
+ @Override
public double eval(double x, double y, final double z) {
x = Math.abs(x);
y = Math.abs(y);
diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/functions/MandelbrotFunction3D.java b/ardor3d-math/src/main/java/com/ardor3d/math/functions/MandelbrotFunction3D.java
index d81c105..9881511 100644
--- a/ardor3d-math/src/main/java/com/ardor3d/math/functions/MandelbrotFunction3D.java
+++ b/ardor3d-math/src/main/java/com/ardor3d/math/functions/MandelbrotFunction3D.java
@@ -23,6 +23,7 @@ public class MandelbrotFunction3D implements Function3D {
setIterations(iterations);
}
+ @Override
public double eval(final double x, final double y, final double z) {
double dx = 0;
double dy = 0;
diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/functions/MapperFunction3D.java b/ardor3d-math/src/main/java/com/ardor3d/math/functions/MapperFunction3D.java
index 5502f7f..1a64086 100644
--- a/ardor3d-math/src/main/java/com/ardor3d/math/functions/MapperFunction3D.java
+++ b/ardor3d-math/src/main/java/com/ardor3d/math/functions/MapperFunction3D.java
@@ -38,6 +38,7 @@ public class MapperFunction3D implements Function3D {
_domainEnd = domainEnd;
}
+ @Override
public double eval(final double x, final double y, final double z) {
// grab a value from our map function.
final double mappingValue = MathUtils.clamp(_mapFunction.eval(x, y, z), _domainStart, _domainEnd);
diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/functions/MeshFunction3D.java b/ardor3d-math/src/main/java/com/ardor3d/math/functions/MeshFunction3D.java
index e399d95..aa34bcc 100644
--- a/ardor3d-math/src/main/java/com/ardor3d/math/functions/MeshFunction3D.java
+++ b/ardor3d-math/src/main/java/com/ardor3d/math/functions/MeshFunction3D.java
@@ -38,6 +38,7 @@ public class MeshFunction3D implements Function3D {
/**
* Evaluate the function.
*/
+ @Override
public double eval(final double x, final double y, final double z) {
final double value = (Math.sin(x) + Math.sin(y) + Math.sin(z)) / _lineSize;
return ((value * value) * 2.0) - 1.0;
diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/functions/RidgeFunction3D.java b/ardor3d-math/src/main/java/com/ardor3d/math/functions/RidgeFunction3D.java
index 669c09b..9c2b071 100644
--- a/ardor3d-math/src/main/java/com/ardor3d/math/functions/RidgeFunction3D.java
+++ b/ardor3d-math/src/main/java/com/ardor3d/math/functions/RidgeFunction3D.java
@@ -44,6 +44,7 @@ public class RidgeFunction3D implements Function3D {
updateWeights();
}
+ @Override
public double eval(final double x, final double y, final double z) {
double value = 0, signal = 0, weight = 1;
double dx = x * _frequency, dy = y * _frequency, dz = z * _frequency;
diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/functions/TurbulenceFunction3D.java b/ardor3d-math/src/main/java/com/ardor3d/math/functions/TurbulenceFunction3D.java
index be32008..d249304 100644
--- a/ardor3d-math/src/main/java/com/ardor3d/math/functions/TurbulenceFunction3D.java
+++ b/ardor3d-math/src/main/java/com/ardor3d/math/functions/TurbulenceFunction3D.java
@@ -40,6 +40,7 @@ public class TurbulenceFunction3D implements Function3D {
_distortModule = new FbmFunction3D(Functions.simplexNoise(), roughness, frequency, 0.5, 2.0);
}
+ @Override
public double eval(final double x, final double y, final double z) {
// tweak the incoming x, y, and z with some magic numbers to prevent singularities as integer boundaries.
final double x0 = x + .1985;
diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/functions/VoroniFunction3D.java b/ardor3d-math/src/main/java/com/ardor3d/math/functions/VoroniFunction3D.java
index f17ba34..149db66 100644
--- a/ardor3d-math/src/main/java/com/ardor3d/math/functions/VoroniFunction3D.java
+++ b/ardor3d-math/src/main/java/com/ardor3d/math/functions/VoroniFunction3D.java
@@ -58,6 +58,7 @@ public class VoroniFunction3D implements Function3D {
_seed = seed;
}
+ @Override
public double eval(final double x, final double y, final double z) {
final double dx = x * _frequency, dy = y * _frequency, dz = z * _frequency;
diff --git a/ardor3d-swt/src/main/java/com/ardor3d/framework/swt/SwtCanvas.java b/ardor3d-swt/src/main/java/com/ardor3d/framework/swt/SwtCanvas.java
index 97aebf3..4207794 100644
--- a/ardor3d-swt/src/main/java/com/ardor3d/framework/swt/SwtCanvas.java
+++ b/ardor3d-swt/src/main/java/com/ardor3d/framework/swt/SwtCanvas.java
@@ -75,11 +75,13 @@ public class SwtCanvas extends GLCanvas implements Canvas {
_inited = true;
}
+ @Override
@MainThread
public void init() {
privateInit();
}
+ @Override
@MainThread
public void draw(final CountDownLatch latch) {
if (!_inited) {
@@ -98,6 +100,7 @@ public class SwtCanvas extends GLCanvas implements Canvas {
latch.countDown();
}
+ @Override
public CanvasRenderer getCanvasRenderer() {
return _canvasRenderer;
}
diff --git a/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtFocusWrapper.java b/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtFocusWrapper.java
index 930c43a..c4180c7 100644
--- a/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtFocusWrapper.java
+++ b/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtFocusWrapper.java
@@ -30,14 +30,17 @@ public class SwtFocusWrapper implements FocusWrapper, FocusListener {
_control = checkNotNull(control, "control");
}
+ @Override
public void focusGained(final FocusEvent focusEvent) {
// nothing to do
}
+ @Override
public void focusLost(final FocusEvent focusEvent) {
_focusLost = true;
}
+ @Override
public boolean getAndClearFocusLost() {
final boolean result = _focusLost;
@@ -46,6 +49,7 @@ public class SwtFocusWrapper implements FocusWrapper, FocusListener {
return result;
}
+ @Override
public void init() {
_control.addFocusListener(this);
}
diff --git a/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtKeyboardWrapper.java b/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtKeyboardWrapper.java
index 7a7535b..7996aa4 100644
--- a/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtKeyboardWrapper.java
+++ b/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtKeyboardWrapper.java
@@ -46,10 +46,12 @@ public class SwtKeyboardWrapper implements KeyboardWrapper, KeyListener {
_control = checkNotNull(control, "control");
}
+ @Override
public void init() {
_control.addKeyListener(this);
}
+ @Override
public synchronized PeekingIterator<KeyEvent> getEvents() {
if (_currentIterator == null || !_currentIterator.hasNext()) {
_currentIterator = new SwtKeyboardIterator();
@@ -58,6 +60,7 @@ public class SwtKeyboardWrapper implements KeyboardWrapper, KeyListener {
return _currentIterator;
}
+ @Override
public synchronized void keyPressed(final org.eclipse.swt.events.KeyEvent event) {
final Key key = fromKeyEventToKey(event);
if (key == _lastKeyPressed) {
@@ -81,6 +84,7 @@ public class SwtKeyboardWrapper implements KeyboardWrapper, KeyListener {
_upcomingEvents.add(new KeyEvent(key, KeyState.DOWN, keyChar));
}
+ @Override
public synchronized void keyReleased(final org.eclipse.swt.events.KeyEvent event) {
_upcomingEvents.add(new KeyEvent(fromKeyEventToKey(event), KeyState.UP, event.character));
_lastKeyPressed = null;
diff --git a/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtMouseManager.java b/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtMouseManager.java
index 8918263..92ac4e6 100644
--- a/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtMouseManager.java
+++ b/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtMouseManager.java
@@ -48,6 +48,7 @@ public class SwtMouseManager implements MouseManager {
_control = control;
}
+ @Override
public void setCursor(final MouseCursor cursor) {
if (cursor == MouseCursor.SYSTEM_DEFAULT) {
_control.setCursor(null);
@@ -62,11 +63,13 @@ public class SwtMouseManager implements MouseManager {
_control.setCursor(swtCursor);
}
+ @Override
public void setPosition(final int x, final int y) {
final Point p = new Point(x, _control.getSize().y - y);
_control.getDisplay().setCursorLocation(_control.toDisplay(p));
}
+ @Override
public void setGrabbed(final GrabbedState grabbedState) {
if (!isSetGrabbedSupported()) {
throw new UnsupportedOperationException();
@@ -105,14 +108,17 @@ public class SwtMouseManager implements MouseManager {
return _transparentCursor;
}
+ @Override
public boolean isSetPositionSupported() {
return true;
}
+ @Override
public boolean isSetGrabbedSupported() {
return true;
}
+ @Override
public GrabbedState getGrabbed() {
return _grabbedState;
}
diff --git a/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtMouseWrapper.java b/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtMouseWrapper.java
index 46266d7..4067060 100644
--- a/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtMouseWrapper.java
+++ b/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtMouseWrapper.java
@@ -61,12 +61,14 @@ public class SwtMouseWrapper implements MouseWrapper, MouseListener, MouseMoveLi
}
}
+ @Override
public void init() {
_control.addMouseListener(this);
_control.addMouseMoveListener(this);
_control.addMouseWheelListener(this);
}
+ @Override
public synchronized PeekingIterator<MouseState> getEvents() {
expireClickEvents();
@@ -87,10 +89,12 @@ public class SwtMouseWrapper implements MouseWrapper, MouseListener, MouseMoveLi
}
}
+ @Override
public synchronized void mouseDoubleClick(final MouseEvent mouseEvent) {
// ignoring this. We'll handle (multi)click in a uniform way
}
+ @Override
public synchronized void mouseDown(final MouseEvent e) {
final MouseButton b = getButtonForEvent(e);
if (_clickArmed.contains(b)) {
@@ -108,6 +112,7 @@ public class SwtMouseWrapper implements MouseWrapper, MouseListener, MouseMoveLi
addNewState(e, 0, buttons, null);
}
+ @Override
public synchronized void mouseUp(final MouseEvent e) {
initState(e);
@@ -170,6 +175,7 @@ public class SwtMouseWrapper implements MouseWrapper, MouseListener, MouseMoveLi
return button;
}
+ @Override
public synchronized void mouseMove(final MouseEvent mouseEvent) {
_clickArmed.clear();
_clicks.clear();
@@ -180,6 +186,7 @@ public class SwtMouseWrapper implements MouseWrapper, MouseListener, MouseMoveLi
addNewState(mouseEvent, 0, _lastState.getButtonStates(), null);
}
+ @Override
public synchronized void mouseScrolled(final MouseEvent mouseEvent) {
initState(mouseEvent);
diff --git a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/Terrain.java b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/Terrain.java
index cad6281..48df204 100644
--- a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/Terrain.java
+++ b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/Terrain.java
@@ -445,6 +445,7 @@ public class Terrain extends Node implements Pickable {
}
_geometryClipmapShader.setShaderDataLogic(new GLSLShaderDataLogic() {
+ @Override
public void applyData(final GLSLShaderObjectsState shader, final Mesh mesh, final Renderer renderer) {
if (mesh instanceof ClipmapLevel) {
shader.setUniform("vertexDistance", (float) ((ClipmapLevel) mesh).getVertexDistance());
diff --git a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/TerrainGridCache.java b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/TerrainGridCache.java
index 8c03bdd..680a3dc 100644
--- a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/TerrainGridCache.java
+++ b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/TerrainGridCache.java
@@ -160,6 +160,7 @@ public class TerrainGridCache implements TerrainCache, Runnable {
return updateTiles;
}
+ @Override
public void setCurrentPosition(final int x, final int y) {
final int tileX = MathUtils.floor((float) x / tileSize);
final int tileY = MathUtils.floor((float) y / tileSize);
@@ -623,6 +624,7 @@ public class TerrainGridCache implements TerrainCache, Runnable {
}
}
+ @Override
public boolean isValid() {
int nrValid = 0;
for (final TileLoadingData data : currentTiles) {
@@ -633,10 +635,12 @@ public class TerrainGridCache implements TerrainCache, Runnable {
return nrValid != 0;
}
+ @Override
public void setMailBox(final DoubleBufferedList<Region> mailBox) {
this.mailBox = mailBox;
}
+ @Override
public void shutdown() {
exit = true;
started = false;
diff --git a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/TextureGridCache.java b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/TextureGridCache.java
index 27df40d..ee8612b 100644
--- a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/TextureGridCache.java
+++ b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/TextureGridCache.java
@@ -167,6 +167,7 @@ public class TextureGridCache implements TextureCache, Runnable {
return updateTiles;
}
+ @Override
public void setCurrentPosition(final int x, final int y) {
final int tileX = MathUtils.floor((float) x / tileSize);
final int tileY = MathUtils.floor((float) y / tileSize);
@@ -577,6 +578,7 @@ public class TextureGridCache implements TextureCache, Runnable {
}
}
+ @Override
public boolean isValid() {
int nrValid = 0;
for (final TileLoadingData data : currentTiles) {
@@ -587,6 +589,7 @@ public class TextureGridCache implements TextureCache, Runnable {
return nrValid != 0;
}
+ @Override
public void setMailBox(final DoubleBufferedList<Region> mailBox) {
this.mailBox = mailBox;
}
@@ -599,6 +602,7 @@ public class TextureGridCache implements TextureCache, Runnable {
this.function = function;
}
+ @Override
public void shutdown() {
exit = true;
started = false;
diff --git a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/Luminance12ToRGBFunction.java b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/Luminance12ToRGBFunction.java
index a2d5102..fc47c63 100644
--- a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/Luminance12ToRGBFunction.java
+++ b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/Luminance12ToRGBFunction.java
@@ -24,6 +24,7 @@ public class Luminance12ToRGBFunction implements SourceCacheFunction {
return INSTANCE;
}
+ @Override
public void doConversion(final ByteBuffer sourceData, final byte[] store, final int destX, final int destY,
final int dataSize, final int tileSize) {
final int offset = (destY * tileSize * dataSize + destX * tileSize) * 3;
diff --git a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/Luminance8ToRGBFunction.java b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/Luminance8ToRGBFunction.java
index 983851a..781f5db 100644
--- a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/Luminance8ToRGBFunction.java
+++ b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/Luminance8ToRGBFunction.java
@@ -23,6 +23,7 @@ public class Luminance8ToRGBFunction implements SourceCacheFunction {
return INSTANCE;
}
+ @Override
public void doConversion(final ByteBuffer sourceData, final byte[] store, final int destX, final int destY,
final int dataSize, final int tileSize) {
final int offset = (destY * tileSize * dataSize + destX * tileSize) * 3;
diff --git a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGB8ToRGBAFunction.java b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGB8ToRGBAFunction.java
index 836ae39..d03552b 100644
--- a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGB8ToRGBAFunction.java
+++ b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGB8ToRGBAFunction.java
@@ -23,6 +23,7 @@ public class RGB8ToRGBAFunction implements SourceCacheFunction {
return INSTANCE;
}
+ @Override
public void doConversion(final ByteBuffer sourceData, final byte[] store, final int destX, final int destY,
final int dataSize, final int tileSize) {
try {
diff --git a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGB8ToRGBFunction.java b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGB8ToRGBFunction.java
index 6a161f6..653411e 100644
--- a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGB8ToRGBFunction.java
+++ b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGB8ToRGBFunction.java
@@ -23,6 +23,7 @@ public class RGB8ToRGBFunction implements SourceCacheFunction {
return INSTANCE;
}
+ @Override
public void doConversion(final ByteBuffer sourceData, final byte[] store, final int destX, final int destY,
final int dataSize, final int tileSize) {
try {
diff --git a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGBA8ToRGBAFunction.java b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGBA8ToRGBAFunction.java
index 88ca47a..ec234f9 100644
--- a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGBA8ToRGBAFunction.java
+++ b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGBA8ToRGBAFunction.java
@@ -23,6 +23,7 @@ public class RGBA8ToRGBAFunction implements SourceCacheFunction {
return INSTANCE;
}
+ @Override
public void doConversion(final ByteBuffer sourceData, final byte[] store, final int destX, final int destY,
final int dataSize, final int tileSize) {
try {
diff --git a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGBA8ToRGBFunction.java b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGBA8ToRGBFunction.java
index 8c0c4df..7f613f4 100644
--- a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGBA8ToRGBFunction.java
+++ b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/functions/RGBA8ToRGBFunction.java
@@ -23,6 +23,7 @@ public class RGBA8ToRGBFunction implements SourceCacheFunction {
return INSTANCE;
}
+ @Override
public void doConversion(final ByteBuffer sourceData, final byte[] store, final int destX, final int destY,
final int dataSize, final int tileSize) {
try {
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/AbstractLabelUIComponent.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/AbstractLabelUIComponent.java
index 6d87247..49235d7 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/AbstractLabelUIComponent.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/AbstractLabelUIComponent.java
@@ -77,6 +77,7 @@ public abstract class AbstractLabelUIComponent extends StateBasedUIComponent imp
/**
* @return the currently set text value of this label.
*/
+ @Override
public String getText() {
return _uiText != null ? _uiText.getText() : null;
}
@@ -87,6 +88,7 @@ public abstract class AbstractLabelUIComponent extends StateBasedUIComponent imp
* @param text
* the new text
*/
+ @Override
public void setText(String text) {
if (text != null && text.length() == 0) {
text = null;
@@ -101,10 +103,12 @@ public abstract class AbstractLabelUIComponent extends StateBasedUIComponent imp
updateMinimumSizeFromContents();
}
+ @Override
public boolean isStyledText() {
return _styled;
}
+ @Override
public void setStyledText(final boolean value) {
_styled = value;
fireStyleChanged();
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/AbstractUITextEntryComponent.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/AbstractUITextEntryComponent.java
index 8b6f0ff..1b41627 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/AbstractUITextEntryComponent.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/AbstractUITextEntryComponent.java
@@ -77,6 +77,7 @@ public abstract class AbstractUITextEntryComponent extends StateBasedUIComponent
/**
* @return the text value of this text entry widget
*/
+ @Override
public String getText() {
return _uiText != null ? _uiText.getText() : "";
}
@@ -87,6 +88,7 @@ public abstract class AbstractUITextEntryComponent extends StateBasedUIComponent
* @param text
* the new text
*/
+ @Override
public void setText(String text) {
if (text != null && text.length() == 0) {
text = null;
@@ -111,10 +113,12 @@ public abstract class AbstractUITextEntryComponent extends StateBasedUIComponent
updateMinimumSizeFromContents();
}
+ @Override
public boolean isStyledText() {
return _styled;
}
+ @Override
public void setStyledText(final boolean value) {
_styled = value;
}
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIComponent.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIComponent.java
index 9cbab74..eb74c10 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIComponent.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIComponent.java
@@ -1335,6 +1335,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
final UIHud hud = getHud();
if (hud != null && getTooltipText() != null) {
final Callable<Void> show = new Callable<Void>() {
+ @Override
public Void call() throws Exception {
while (true) {
@@ -1526,6 +1527,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
* current tracked state of the input system.
* @return true if we want to consider the event "consumed" by the UI system.
*/
+ @Override
public boolean keyPressed(final Key key, final InputState state) {
if (!_consumeKeyEvents && getParent() instanceof UIComponent) {
return ((UIComponent) getParent()).keyPressed(key, state);
@@ -1543,6 +1545,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
* current tracked state of the input system.
* @return true if we want to consider the event "consumed" by the UI system.
*/
+ @Override
public boolean keyHeld(final Key key, final InputState state) {
if (!_consumeKeyEvents && getParent() instanceof UIComponent) {
return ((UIComponent) getParent()).keyHeld(key, state);
@@ -1560,6 +1563,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
* current tracked state of the input system.
* @return true if we want to consider the event "consumed" by the UI system.
*/
+ @Override
public boolean keyReleased(final Key key, final InputState state) {
if (!_consumeKeyEvents && getParent() instanceof UIComponent) {
return ((UIComponent) getParent()).keyReleased(key, state);
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIFrame.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIFrame.java
index 5bbf7b6..c4e873c 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIFrame.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIFrame.java
@@ -378,6 +378,7 @@ public class UIFrame extends UIContainer {
*/
public static void resetTextureRenderer(final Object queueKey) {
final Callable<Void> exe = new Callable<Void>() {
+ @Override
public Void call() {
if (UIContainer._textureRenderer != null) {
UIContainer._textureRenderer.cleanup();
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIFrameBar.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIFrameBar.java
index 9b43b22..df80f5a 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIFrameBar.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIFrameBar.java
@@ -47,6 +47,7 @@ public class UIFrameBar extends UIPanel {
if (buttons.contains(FrameButtons.HELP)) {
_helpButton = createFrameButton("?");
_helpButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
// TODO: Implement
}
@@ -59,6 +60,7 @@ public class UIFrameBar extends UIPanel {
if (buttons.contains(FrameButtons.MINIMIZE)) {
_minimizeButton = createFrameButton("_");
_minimizeButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
// TODO: Implement
}
@@ -71,6 +73,7 @@ public class UIFrameBar extends UIPanel {
if (buttons.contains(FrameButtons.MAXIMIZE)) {
_maximizeButton = createFrameButton("^");
_maximizeButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
// XXX: Should this also update the button img?
final UIFrame frame = (UIFrame) getParent();
@@ -89,6 +92,7 @@ public class UIFrameBar extends UIPanel {
if (buttons.contains(FrameButtons.CLOSE)) {
_closeButton = createFrameButton("x");
_closeButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
((UIFrame) getParent()).close();
}
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIHud.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIHud.java
index 1eae2d2..796bcf9 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIHud.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIHud.java
@@ -532,11 +532,13 @@ public class UIHud extends Node {
*/
private void setupLogicalLayer() {
_logicalLayer.registerTrigger(new InputTrigger(new Predicate<TwoInputStates>() {
+ @Override
public boolean apply(final TwoInputStates arg0) {
// always trigger this.
return true;
}
}, new TriggerAction() {
+ @Override
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_mouseInputConsumed = offerMouseInputToUI(inputStates);
_keyInputConsumed = offerKeyInputToUI(inputStates);
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIMenuItem.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIMenuItem.java
index 05c16e0..0410ab5 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIMenuItem.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIMenuItem.java
@@ -27,6 +27,7 @@ public class UIMenuItem extends UIButton {
// Close menus when a menu item is clicked
addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
final UIHud hud = getHud();
if (hud != null) {
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIScrollBar.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIScrollBar.java
index d077a7b..267daeb 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIScrollBar.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIScrollBar.java
@@ -55,6 +55,7 @@ public class UIScrollBar extends UIPanel {
layout();
final ActionListener al = new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
int direction;
if (event.getSource() == btTopLeft) {
@@ -81,6 +82,7 @@ public class UIScrollBar extends UIPanel {
btTopLeft.addActionListener(al);
btBottomRight.addActionListener(al);
slider.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
fireChangeEvent();
}
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIScrollPanel.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIScrollPanel.java
index e7c74cb..a4cf35c 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIScrollPanel.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIScrollPanel.java
@@ -50,6 +50,7 @@ public class UIScrollPanel extends UIPanel {
add(verticalScrollBar);
setDoClip(true);
horizontalScrollBar.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
offsetX = horizontalScrollBar.getValue();
fireComponentDirty();
@@ -57,6 +58,7 @@ public class UIScrollPanel extends UIPanel {
}
});
verticalScrollBar.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
offsetY = verticalScrollBar.getValue();
fireComponentDirty();
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UISliderKnob.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UISliderKnob.java
index 8790618..44b641a 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UISliderKnob.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UISliderKnob.java
@@ -180,6 +180,7 @@ public class UISliderKnob extends UIContainer {
private int _initialHudLoc;
private int _delta;
+ @Override
public void startDrag(final int x, final int y) {
// skip out if not enabled.
if (!isEnabled()) {
@@ -201,6 +202,7 @@ public class UISliderKnob extends UIContainer {
}
}
+ @Override
public void drag(final int x, final int y) {
if (!isEnabled()) {
return;
@@ -228,11 +230,13 @@ public class UISliderKnob extends UIContainer {
_parentSlider);
}
+ @Override
public void endDrag(final UIComponent dropOn, final int x, final int y) {
// call back to our parent slider, allowing for snapping
_parentSlider.knobReleased();
}
+ @Override
public boolean isDragHandle(final UIComponent w, final int x, final int y) {
// if not enabled, we don't slide
if (!isEnabled()) {
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UITabbedPane.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UITabbedPane.java
index eaf9ea5..37e2855 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UITabbedPane.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UITabbedPane.java
@@ -301,6 +301,7 @@ public class UITabbedPane extends UIPanel {
private UITab makeTab(final String label, final SubTex icon) {
final UITab button = new UITab(label, icon, _placement);
button.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(final ActionEvent event) {
setCurrentTab(button);
}
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/event/FrameDragListener.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/event/FrameDragListener.java
index 66d639a..d891104 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/event/FrameDragListener.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/event/FrameDragListener.java
@@ -26,11 +26,13 @@ public class FrameDragListener implements DragListener {
this.uiFrame = uiFrame;
}
+ @Override
public void startDrag(final int mouseX, final int mouseY) {
oldX = mouseX;
oldY = mouseY;
}
+ @Override
public void drag(final int mouseX, final int mouseY) {
if (!uiFrame.isDraggable()) {
return;
@@ -63,11 +65,13 @@ public class FrameDragListener implements DragListener {
/**
* Do nothing.
*/
+ @Override
public void endDrag(final UIComponent component, final int mouseX, final int mouseY) {}
/**
* Check if we are dragging's the frames title bar label.
*/
+ @Override
public boolean isDragHandle(final UIComponent component, final int mouseX, final int mouseY) {
return component == uiFrame.getTitleBar().getTitleLabel();
}
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/event/FrameResizeListener.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/event/FrameResizeListener.java
index 47a5d5c..d770a8c 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/event/FrameResizeListener.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/event/FrameResizeListener.java
@@ -28,6 +28,7 @@ public final class FrameResizeListener implements DragListener {
_uiFrameStatusBar = uiFrameStatusBar;
}
+ @Override
public void startDrag(final int mouseX, final int mouseY) {
final Vector3 vec = Vector3.fetchTempInstance();
vec.set(mouseX, mouseY, 0);
@@ -44,10 +45,12 @@ public final class FrameResizeListener implements DragListener {
_initFrameTransform.set(frame.getWorldTransform());
}
+ @Override
public void drag(final int mouseX, final int mouseY) {
resizeFrameByPosition(mouseX, mouseY);
}
+ @Override
public void endDrag(final UIComponent component, final int mouseX, final int mouseY) {
resizeFrameByPosition(mouseX, mouseY);
}
@@ -104,6 +107,7 @@ public final class FrameResizeListener implements DragListener {
frame.layout();
}
+ @Override
public boolean isDragHandle(final UIComponent component, final int mouseX, final int mouseY) {
return component == _uiFrameStatusBar.getResizeButton();
}
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/model/DefaultSliderModel.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/model/DefaultSliderModel.java
index 8a5b7ab..2daa8c9 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/model/DefaultSliderModel.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/model/DefaultSliderModel.java
@@ -40,14 +40,17 @@ public class DefaultSliderModel implements SliderModel {
setMaxValue(maxValue);
}
+ @Override
public int getCurrentValue() {
return _currentValue;
}
+ @Override
public void setCurrentValue(final int currentValue) {
setCurrentValue(currentValue, null);
}
+ @Override
public void setCurrentValue(final int currentValue, final UISlider slider) {
if (_currentValue == currentValue) {
return;
@@ -58,18 +61,22 @@ public class DefaultSliderModel implements SliderModel {
}
}
+ @Override
public int getMaxValue() {
return _maxValue;
}
+ @Override
public void setMaxValue(final int maxValue) {
_maxValue = maxValue;
}
+ @Override
public int getMinValue() {
return _minValue;
}
+ @Override
public void setMinValue(final int minValue) {
_minValue = minValue;
}
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/parser/ForumLikeMarkupParser.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/parser/ForumLikeMarkupParser.java
index 6afa78f..eb08795 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/parser/ForumLikeMarkupParser.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/parser/ForumLikeMarkupParser.java
@@ -26,6 +26,7 @@ import com.google.common.collect.Lists;
public class ForumLikeMarkupParser implements StyleParser {
Comparator<StyleSpan> endSorter = new Comparator<StyleSpan>() {
+ @Override
public int compare(final StyleSpan o1, final StyleSpan o2) {
return o1.getSpanStart() + o1.getSpanLength() - (o2.getSpanStart() + o2.getSpanLength());
}
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/util/TransformedSubTex.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/util/TransformedSubTex.java
index dc3140d..5c43613 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/util/TransformedSubTex.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/util/TransformedSubTex.java
@@ -66,6 +66,7 @@ public class TransformedSubTex extends SubTex implements Comparable<TransformedS
return _priority;
}
+ @Override
public int compareTo(final TransformedSubTex other) {
return _priority - other._priority;
}